Constructor
new APTrustClient(remoteRepository)
Parameters:
Name | Type | Description |
---|---|---|
remoteRepository |
RemoteRepository |
The repository to connect to. |
- Source:
Methods
(static) description() → {PluginDefinition}
Returns a PluginDefinition object describing this plugin.
- Source:
_doRequest(url, function) → {Promise}
This creates an HTTP(S) request and returns a promise.
Parameters:
Name | Type | Description |
---|---|---|
url |
string |
The URL to fetch. For this module, all requests will be GET requests. |
function |
formatter |
The function to format the data, if it is successfully retrieved. The formatter function should take a single paramater, an object, which is constructed from the parsed JSON data in the response body fetched from url. |
- Source:
_getHeaders() → {object}
Returns the HTTP request headers our client will need to send when connecting to Pharos.
- Source:
_request(url, onSuccess, onError)
This sends a GET request to url, calling the onSuccess callback if it gets a 200 response, and the onError callback for all other responses.
Other repository plugins may need to support PUT, POST, and HEAD requests, and may need more robust handling for different response status codes.
For APTrust, we're hitting only two endpoints, using only GET, and we know that any non-200 response means something is wrong.
Because we're using the request library from https://github.com/request/request, the onSuccess and onError functions take params (error, response, body), which are an Error object, a Response object, and the body of the HTTP response (which should be JSON).
Parameters:
Name | Type | Description |
---|---|---|
url |
string |
The URL to get. |
onSuccess |
function |
A function to handle successful responses. Takes params (error, response, body). |
onError |
function |
A function to handle errors. Takes params (error, response, body). |
- Source:
hasRequiredConnectionInfo() → {boolean}
This returns true if the RemoteRepository object has enough info to attempt a connection. For APTrust, we require url, userId, and apiToken. Other repositories may require different data in their RemoteRepository object.
- Source:
provides()
This returns a list of objects describing what reports this module provides. The DART dashboard queries this list to see what method calls this plugin makes available. Each object in the list this function returns has three properties.
title - This is the title of the report. The dashboard will display this title as is at the top of the report.
description - A description of the report.
method - A function to call to get the contents of the report. The function takes no parameters and should a promis that ultimately returns HTML. The dashboard will display the HTML when the promise is resolved.
- Source:
recentIngests() → {Promise}
This fetches a list of recently ingested objects from Pharos, which is APTrust's REST API. After retrieving the data, this function formats the list into an HTML table.
This function returns a promise. The promise resolves to the HTML, which DART will display in its Dashboard.
- Source:
recentWorkItems() → {Promise}
This returns a list of Pharos Work Items, which describe pending ingest requests and other tasks. Items uploaded for ingest that have not yet been processed will be in this list.
This function returns a promise. The promise resolves to the HTML, which DART will display in its Dashboard.
- Source: