new TDXApi(config)
- Source:
Create a TDXApi instance
Example
import TDXApi from "nqm-api-tdx";
const api = new TDXApi({tdxServer: "https://tdx.acme.com"});
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object | the TDX configuration for the remote TDX Properties
|
Methods
abortDatabotInstance(instanceId)
- Source:
Aborts a running databot instance.
Parameters:
Name | Type | Description |
---|---|---|
instanceId |
string | The id of the instance to abort. |
addAccount(options, waitopt) → {CommandResult}
- Source:
Adds an account to the TDX. An account can be an e-mail based user account, a share key (token) account, a databot host, an application, or an account-set (user group).
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | new account options Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
wait |
boolean |
<optional> |
false
|
flag indicating this method will wait for the account to be fully created before returning. |
Returns:
- Type
- CommandResult
addAccountApplicationConnection(accountId, applicationId, waitopt)
- Source:
Adds the application/user connection resource. The authenticated token must belong to the application.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
accountId |
string | the account id |
||
applicationId |
string | the application id |
||
wait |
boolean |
<optional> |
true
|
whether or not to wait for the projection to catch up. |
addData(datasetId, data, doNotThrowopt)
- Source:
Add data to a dataset resource.
Examples
// Assumes the dataset primary key is 'lsoa'
tdxApi.addData(myDatasetId, {lsoa: "E0000001", count: 398});
tdxApi.addData(myDatasetId, [
{lsoa: "E0000001", count: 398},
{lsoa: "E0000002", count: 1775},
{lsoa: "E0000005", count: 4533},
]);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
datasetId |
string | The id of the dataset-based resource to add data to. |
||
data |
object | array | The data to add. Must conform to the schema defined by the resource metadata. |
||
doNotThrow |
boolean |
<optional> |
false
|
set to override default error handling. See TDXApi. Supports creating an individual document or many documents. |
addResource(options, waitopt)
- Source:
Adds a resource to the TDX.
Example
// Creates a dataset resource in the authenticated users' scratch folder. The dataset stores key/value pairs
// where the `key` property is the primary key and the `value` property can take any JSON value.
tdxApi.addResource({
name: "resource #1",
schema: {
dataSchema: {
key: "string",
value: {}
},
uniqueIndex: {key: 1}
}
})
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | details of the resource to be added. Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
wait |
boolean | string |
<optional> |
false
|
indicates if the call should wait for the index to be built before it returns. You can pass a string here to indicate the status you want to wait for, default is 'built'. |
addResourceAccess(resourceId, accountId, sourceId, access)
- Source:
Adds read and/or write permission for an account to access a resource. Permission is required equivalent to that which is being added, e.g. adding write permission requires existing write access. Note access as a result of group membership is not included in determining permissions, in this case add the account to the group instead.
Example
tdxApi.addResourceAccess(myResourceId, "bob@acme.com/tdx.acme.com", myResourceId, ["r"]);
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The resource id |
accountId |
string | The account id to assign permission to |
sourceId |
string | The id of the resource acting as the source of the access. This
is usually the same as the target |
access |
Array.<string> | The access, one or more of [ |
addTrustedExchange(options)
- Source:
Adds a data exchange to the list of trusted exchanges known to the current TDX.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
addZoneConnection(options)
- Source:
Adds a zone connection to a remote TDX. The details for the connection should be retrieved by a call to the certificate endpoint for the TDX, e.g. https://tdx.nqminds.com/certficate.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | The zone connection details Properties
|
approveAccount(username, approved)
- Source:
Set account approved status. Reserved for system use.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | the full TDX identity of the account. |
approved |
boolean | account approved status |
authenticate(id, secret, ttlopt) → {string}
- Source:
Authenticates with the TDX, acquiring an authorisation token.
Examples
tdxApi.authenticate("DKJG8dfg", "letmein");
tdxApi.authenticate("DKJG8dfg", "letmein", 7200);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id |
string | the account id, or a pre-formed credentials string, e.g. "DKJG8dfg:letmein" |
||
secret |
string | the account secret |
||
ttl |
number |
<optional> |
3600
|
the Time-To-Live of the token in seconds, default is 1 hour. Will default to config.accessTokenTTL if not given here. |
Throws:
Will throw if credentials are invalid or there is a network error contacting the TDX.
Returns:
The access token.
- Type
- string
createTDXToken(username, ipopt, ttlopt) → {object}
- Source:
Creates a client user token (e.g. bound to the browser IP) for an application-user token bound to the given IP or the currently authenticated token IP. The currently authenticated token must be an application token, whereby the application has been authorised by the user and the user has permission to access the application. The returned token will be bound to the given IP or the IP of the currently authenticated token (i.e the application server IP).
Examples
tdxApi.createTDXToken("bob@bob.com/acme.tdx.com");
tdxApi.createTDXToken("bob@bob.com/acme.tdx.com", newClientIP);
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
username |
string | The users' TDX id. |
|
ip |
string |
<optional> |
The optional IP address to bind the user token to. |
ttl |
number |
<optional> |
The ttl in seconds. |
Returns:
- The new application-user token, bound to the given IP.
- Type
- object
deleteAccount(username)
- Source:
Delete an account
Parameters:
Name | Type | Description |
---|---|---|
username |
string | the full TDX identity of the account to delete. |
deleteData(datasetId, data, doNotThrowopt)
- Source:
Deletes data from a dataset-based resource.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
datasetId |
string | The id of the dataset-based resource to delete data from. |
||
data |
object | array | The primary key data to delete. |
||
doNotThrow |
boolean |
<optional> |
false
|
set to override default error handling. See TDXApi. |
deleteDatabotHost(payload)
- Source:
Deletes one or more hosts, depending on the given parameters. E.g. if just a hostId
is given, all hosts
will be deleted with that id. If an ip address is also given, all hosts with the id on that ip address will
be deleted and so on. Note that hosts can only be deleted if they are in the offline
status.
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
payload |
object | The definition of the host(s) to delete. Can be an array of objects or a single object Properties
|
deleteDatabotInstance(instanceId)
- Source:
Deletes a databot instance and all output/debug data associated with it.
Parameters:
Name | Type | Description |
---|---|---|
instanceId |
Array.<string> | The id(s) of the instances to delete. Can be an array of instance ids or an individual string id |
deleteDataByQuery(datasetId, query, doNotThrowopt)
- Source:
Deletes data from a dataset-based resource using a query to specify the documents to be deleted.
Example
// Delete all documents with English lsoa.
tdxApi.deleteDataByQuery(myDatasetId, {lsoa: {$regex: "E*"}});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
datasetId |
string | The id of the dataset-based resource to delete data from. |
||
query |
object | The query that specifies the data to delete. All documents matching the query will be deleted. |
||
doNotThrow |
boolean |
<optional> |
false
|
set to override default error handling. See TDXApi. |
deleteManyResources(resourceList) → {CommandResult}
- Source:
Permanently deletes a list of resources. Will fail all deletes if any of the permission checks fail.
Parameters:
Name | Type | Description |
---|---|---|
resourceList |
Array.<Resource> | The list of resources to delete. Note only the |
Returns:
- Type
- CommandResult
deleteResource(resourceId)
- Source:
Permanently deletes a resource.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | the id of the resource to delete. Requires write permission to the resource. |
deleteZoneConnection(id)
- Source:
Deletes a zone connection. The authenticated account must own the zone connection.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | The id of the zone connection to delete. |
downloadResource(resourceId) → {object}
- Source:
Streams the contents of a resource. For dataset-based resources this will stream the dataset contents in newline delimited JSON (NDJSON). For raw file resources this will stream the raw file contents (zip, raw JSON etc).
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The id of the resource to be downloaded. |
Returns:
- Response object, where the response body is a stream object.
- Type
- object
exchangeTDXToken(token, validateIPopt, exchangeIPopt, ttlopt) → {object}
- Source:
Exchanges a client user token (e.g. bound to the browser IP) for an application-user token bound to the given IP or the currently authenticated token IP. The currently authenticated token must be an application token, whereby the application has been authorised by the user and the user has permission to access the application. The returned token will be bound to the given IP or the IP of the currently authenticated token (i.e the application server IP).
Examples
tdxApi.exchangeTDXToken(clientToken);
tdxApi.exchangeTDXToken(clientToken, newClientIP);
tdxApi.exchangeTDXToken(clientToken, null, serverIP);
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
token |
string | The users' TDX auth server token to validate. |
|
validateIP |
string |
<optional> |
The optional IP address to validate the user token against. |
exchangeIP |
string |
<optional> |
The optional IP address to bind the new token to. |
ttl |
number |
<optional> |
The ttl in seconds. |
Returns:
- The new token application-user token, bound to the server IP.
- Type
- object
fileUpload(resourceId, file, streamopt, compressedopt, base64Encodedopt)
- Source:
Upload a file to a resource.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resourceId |
string | The id of the destination resource. |
||
file |
object | The file to upload, obtained from an |
||
stream |
boolean |
<optional> |
false
|
Flag indicating whether the call should return a stream allowing callees to monitor progress. |
compressed |
boolean |
<optional> |
false
|
Flag indicating the file should be decompressed after upload. ZIP format only. |
base64Encoded |
boolean |
<optional> |
false
|
= Flag indicating the file should be decoded from base64 after upload. |
getAccount(accountId) → {Zone}
- Source:
Gets the details for a given account id.
Parameters:
Name | Type | Description |
---|---|---|
accountId |
string | the id of the account to be retrieved. |
Returns:
zone
- Type
- Zone
getAccounts(filter) → {Array.<Zone>}
- Source:
Gets the details for all peer accounts.
Example
api.getAccounts({accountType: "host", own: "bob@nqminds.com"})
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
filter |
object | query filter. Properties
|
Returns:
zone
- Type
- Array.<Zone>
getAggregateData(datasetId, pipeline, ndJSONopt) → {DatasetData}
- Source:
Performs an aggregate query on the given dataset resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource to perform the aggregate query on. |
|
pipeline |
object | string | The aggregate pipeline, as defined in the mongodb docs. Can be given as a JSON object or as a stringified JSON object. |
|
ndJSON |
boolean |
<optional> |
If set, the data is sent in newline delimited json format. |
Returns:
- Type
- DatasetData
getAggregateDataStream(datasetId, pipeline, ndJSONopt) → {object}
- Source:
Performs an aggregate query on the given dataset resource, returning a response object with stream in the body
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource to perform the aggregate query on. |
|
pipeline |
object | string | The aggregate pipeline, as defined in the mongodb docs. Can be given as a JSON object or as a stringified JSON object. |
|
ndJSON |
boolean |
<optional> |
If set, the data is sent in newline delimited json format. |
Returns:
- Response object, where the response body is a stream object.
- Type
- object
getAuthenticatedAccount() → {object}
- Source:
Gets details of the currently authenticated account.
Returns:
- Details of the authenticated account.
- Type
- object
getData(datasetId, filteropt, projectionopt, optionsopt, ndJSONopt) → {DatasetData}
- Source:
For structured resources, e.g. datasets, this function gets all data from the given dataset resource that matches the filter provided.
For non-structured resources such as text-content or raw files etc only the datasetId
argument is relevant
and this method is equivalent to downloadResource
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource. |
|
filter |
object |
<optional> |
A mongodb filter object. If omitted, all data will be retrieved. |
projection |
object |
<optional> |
A mongodb projection object. Should be used to restrict the payload to the minimum properties needed if a lot of data is being retrieved. |
options |
GetDataOptions |
<optional> |
A mongodb options object. Can be used to limit, skip, sort etc. Note a default
|
ndJSON |
boolean |
<optional> |
If set, the data is sent in newline delimited json format. |
Returns:
- Type
- DatasetData
getDatabotInstance(instanceId)
- Source:
Gets databot instance data for the given instance id.
Parameters:
Name | Type | Description |
---|---|---|
instanceId |
string | The id of the instance to retrieve. |
getDatabotInstanceOutput(instanceId, processIdopt)
- Source:
Get databot instance output.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
instanceId |
string | The instance id to retrieve output for. |
|
processId |
string |
<optional> |
Optional process id. If omitted, output for all instance processes will be returned. |
getDatabotInstanceStatus(instanceId)
- Source:
Get databot instance status.
Parameters:
Name | Type | Description |
---|---|---|
instanceId |
string | The id of the databot instance for which status is retrieved. |
getDataCount(datasetId, filteropt)
- Source:
Gets a count of the data in a dataset-based resource, after applying the given filter.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource. |
|
filter |
object |
<optional> |
An optional mongodb filter to apply before counting the data. |
getDatasetData(datasetId, filteropt, projectionopt, optionsopt, ndJSONopt) → {DatasetData}
- Source:
- Deprecated:
- use TDXApi#getData Gets all data from the given dataset resource that matches the filter provided.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource. |
|
filter |
object |
<optional> |
A mongodb filter object. If omitted, all data will be retrieved. |
projection |
object |
<optional> |
A mongodb projection object. Should be used to restrict the payload to the minimum properties needed if a lot of data is being retrieved. |
options |
GetDataOptions |
<optional> |
A mongodb options object. Can be used to limit, skip, sort etc. Note a default
|
ndJSON |
boolean |
<optional> |
If set, the data is sent in newline delimited json format. |
Returns:
- Type
- DatasetData
getDatasetDataCount(datasetId, filteropt)
- Source:
- Deprecated:
- use TDXApi#getDataCount Gets a count of the data in a dataset-based resource, after applying the given filter.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource. |
|
filter |
object |
<optional> |
An optional mongodb filter to apply before counting the data. |
getDatasetDataStream(datasetId, filteropt, projectionopt, optionsopt, ndJSONopt) → {object}
- Source:
- Deprecated:
- use TDXApi#getDataStream Gets all data from the given dataset resource that matches the filter provided and returns a response object with stream in the body.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource. |
|
filter |
object |
<optional> |
A mongodb filter object. If omitted, all data will be retrieved. |
projection |
object |
<optional> |
A mongodb projection object. Should be used to restrict the payload to the minimum properties needed if a lot of data is being retrieved. |
options |
GetDataOptions |
<optional> |
A mongodb options object. Can be used to limit, skip, sort etc. Note a default
|
ndJSON |
boolean |
<optional> |
If set, the data is sent in newline delimited json format. |
Returns:
- Response object, where the response body is a stream object.
- Type
- object
getDataStream(datasetId, filteropt, projectionopt, optionsopt, ndJSONopt) → {object}
- Source:
Gets all data from the given dataset resource that matches the filter provided and returns a response object with stream in the body.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource. |
|
filter |
object |
<optional> |
A mongodb filter object. If omitted, all data will be retrieved. |
projection |
object |
<optional> |
A mongodb projection object. Should be used to restrict the payload to the minimum properties needed if a lot of data is being retrieved. |
options |
GetDataOptions |
<optional> |
A mongodb options object. Can be used to limit, skip, sort etc. Note a default
|
ndJSON |
boolean |
<optional> |
If set, the data is sent in newline delimited json format. |
Returns:
- Response object, where the response body is a stream object.
- Type
- object
getDistinct(datasetId, key, filteropt) → {Array.<object>}
- Source:
Gets a list of distinct values for a given property in a dataset-based resource.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
datasetId |
string | The id of the dataset-based resource. |
|
key |
string | The name of the property to use. Can be a property path, e.g. |
|
filter |
object |
<optional> |
An optional mongodb filter to apply. |
Returns:
- The distinct values.
- Type
- Array.<object>
getNDData()
- Source:
Sugar for newline delimited data. See getData
for details.
getResource(resourceId, noThrowopt) → {Resource}
- Source:
Gets the details for a given resource id.
Example
api.getResource(myResourceId)
.then((resource) => {
console.log(resource.name);
});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
resourceId |
string | The id of the resource to retrieve. |
||
noThrow |
boolean |
<optional> |
false
|
If set, the call won't reject or throw if the resource doesn't exist. |
Throws:
Will throw if the resource is not found (see noThrow
flag) or permission is denied.
Returns:
- Type
- Resource
getResourceAccess(resourceId) → {Array.<ResourceAccess>}
- Source:
Gets all access the authenticated account has to the given resource id.
Example
api.getResourceAccess(myResourceId)
.then((resourceAccess) => {
console.log("length of access list: ", resourceAccess.length);
});
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The id of the resource whose access is to be retrieved. |
Returns:
- Array of ResourceAccess objects.
- Type
- Array.<ResourceAccess>
getResourceAncestors(resourceId) → {Array.<Resource>}
- Source:
Gets all resources that are ancestors of the given resource.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The id of the resource whose parents are to be retrieved. |
Returns:
- Type
- Array.<Resource>
getResources(filteropt, projectionopt, optionsopt) → {Array.<Resource>}
- Source:
Gets the details of all resources that match the given filter.
Examples
tdxApi.getResources({"id": "rygq8DNEPw"});
tdxApi.getResources({"id": {"$in": ["rygq8DNEPw", "xmm1z-D8d"]}});
tdxApi.getResources({"name": {"$regex": "test"}});
tdxApi.getResources({"name": {"$regex": "test"}}, {"id": 1, "name": 1});
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filter |
object |
<optional> |
A mongodb filter definition. Note, filtering on |
projection |
object |
<optional> |
A mongodb projection definition, can be used to restrict which properties are returned thereby limiting the payload. |
options |
object |
<optional> |
A mongodb options definition, can be used for limit, skip, sorting etc. |
Returns:
- Type
- Array.<Resource>
getResourcesWithSchema(schemaId) → {Array.<Resource>}
- Source:
Retrieves all resources that have an immediate ancestor of the given schema id.
Parameters:
Name | Type | Description |
---|---|---|
schemaId |
string | The id of the schema to match, e.g. |
Returns:
- Type
- Array.<Resource>
getTDXToken(tdx) → {string}
- Source:
Retrieves an authorisation token for the given TDX instance
Parameters:
Name | Type | Description |
---|---|---|
tdx |
string | The TDX instance name, e.g. |
Returns:
- Type
- string
getZone(accountId) → {Zone}
- Source:
Gets the details for a given zone (account) id.
Parameters:
Name | Type | Description |
---|---|---|
accountId |
string | the id of the zone to be retrieved. |
Returns:
zone
- Type
- Zone
isInGroup(accountId, groupId) → {boolean}
- Source:
Determines if the given account is a member of the given group. Note that accurate visibility of group members requires one or more of the following to be true:
- the authenticated account added
accountId
to the group - the authenticated account owns the group
Parameters:
Name | Type | Description |
---|---|---|
accountId |
string | the id of the account |
groupId |
* | the id of the group |
Returns:
true
ifaccountId
is a member of the group and visible to the authenticated account.
- Type
- boolean
moveResource(id, fromParentId, toParentId)
- Source:
Move resource from one folder to another. Requires write permission on the resource, the source parent and the target parent resources.
Parameters:
Name | Type | Description |
---|---|---|
id |
string | the id of the resource to move. |
fromParentId |
string | the current parent resource to move from. |
toParentId |
string | the target folder resource to move to. |
patchData(datasetId, data, doNotThrowopt)
- Source:
Patches data in a dataset resource. Uses the JSON patch format, which involves defining the primary key data followed by a flexible update specification.
Examples
tdxApi.patchData(myDatasetId, {lsoa: "E000001", __update: [{path: "/count", op: "replace", value: 948}]});
tdxApi.patchData(myDatasetId, {lsoa: "E000001", __update: [
{path: "/count", op: "replace", value: 948}
{path: "/modified", op: "add", value: Date.now()}
]});
Parameters:
Name | Type | Attributes | Default | Description | ||||||
---|---|---|---|---|---|---|---|---|---|---|
datasetId |
string | The id of the dataset-based resource to update. |
||||||||
data |
object | The patch definition. Properties
|
||||||||
doNotThrow |
boolean |
<optional> |
false
|
set to override default error handling. See TDXApi. |
rebuildResourceIndex(resourceId)
- Source:
Resets the resource index. This involves deleting existing indexes and rebuilding them. May take a while depending on the size of any associated dataset and the number and complexity of indexes.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | the id of the resource, requires write permission. |
registerDatabotHost(payload)
- Source:
Registers a databot host with the TDX. Once registered, a host is eligible to receive commands from the TDX.
Example
tdxApi.registerDatabotHost({version: "0.3.11", port: 2312, hostStatus: "idle"});
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
payload |
object | The databot host identifier payload. Properties
|
removeResourceAccess(resourceId, accountId, addedBy, sourceId, access)
- Source:
Removes access for an account to a resource. Permission is required equivalent to that which is being added, e.g. adding write permission requires existing write access.
Example
// Removes read access for account "john.trulove@nqminds.com/tdx.nqm-1.com" added by
// Toby via "ezh.ubiapps@gmail.com/tdx.nqm-1.com,toby.ealden@gmail.com/tdx.nqm-1.com".
tdxApi.removeResourceAccess(
"rJg9ldNEwD",
"john.trulove@nqminds.com/tdx.nqm-1.com",
"ezh.ubiapps@gmail.com/tdx.nqm-1.com,toby.ealden@gmail.com/tdx.nqm-1.com",
"rJg9ldNEwD",
["r"]
);
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The resource id. |
accountId |
string | The account id to remove access from. |
addedBy |
string | The full |
sourceId |
string | The source of the access, usually the resource itself. |
access |
Array.<string> | The access, one or more of [ |
resetAccount(username, key)
- Source:
Change account secret.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | the full TDX identity of the account. |
key |
string | the new secret |
rollbackCommand()
- Source:
AUDIT COMMANDS
sendDatabotHostCommand(command, hostId, hostIpopt, hostPortopt, payloadopt)
- Source:
Sends a command to a databot host. Reserved for system use.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
command |
string | The command to send. Must be one of ["stopHost", "updateHost", "runInstance", "stopInstance", "clearInstance"] |
|
hostId |
string | The id of the host. |
|
hostIp |
string |
<optional> |
The ip address of the host. If omitted, the command will be sent to all host ip addresses. |
hostPort |
number |
<optional> |
The port number of the host. If omitted, the command will be sent to all host ports. |
payload |
object |
<optional> |
The command payload. |
setResourceImporting(resourceId, importing) → {CommandResult}
- Source:
Set the resource import flag.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The id of the dataset-based resource. |
importing |
boolean | Indicates the state of the import flag. |
Returns:
- Type
- CommandResult
setResourcePermissiveShare(resourceId, allowPermissive)
- Source:
Sets the permissive share mode of the resource. Permissive share allows anybody with acces to the resource to share it with others. If a resource is not in permissive share mode, only the resource owner can share it with others.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The resource id. |
allowPermissive |
boolean | The required permissive share mode. |
setResourceSchema(resourceId, schema) → {CommandResult}
- Source:
Set the resource schema.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The id of the dataset-based resource. |
schema |
object | The new schema definition. TODO - document |
Returns:
- Type
- CommandResult
setResourceShareMode(resourceId, shareMode)
- Source:
Set the share mode for a resource.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The resource id. |
shareMode |
string | The share mode to set, one or [ |
setResourceStore(resourceId, store, storeSizeopt)
- Source:
Sets the dataset store of the resource. Reserved for system use.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
resourceId |
string | The resource id. |
|
store |
string | The name of the store. |
|
storeSize |
number |
<optional> |
The size in bytes of the store. |
setResourceTextContent(resourceId, textContent)
- Source:
Set the text for a text-content based resource.
Example
// Sets the text content for a text-html resource.
tdxApi.setResourceTextContent(
"HyeqJgVdJ7",
"<html><body><p>Hello World</p></body></html>"
);
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The resource id. |
textContent |
string | The text content to set. |
startDatabotInstance(databotId, payload)
- Source:
Starts a databot instance.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
databotId |
string | The id of the databot definition to start. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
payload |
object | The instance input and parameters. Properties
|
stopDatabotInstance(instanceId, mode)
- Source:
Terminates or pauses a running databot instance.
Parameters:
Name | Type | Description |
---|---|---|
instanceId |
string | The id of the instance to terminate or pause. |
mode |
string | One of [ |
suspendResourceIndex(resourceId)
- Source:
Suspends the resource index. This involves deleting any existing indexes. Requires write permission. When
a resource index is in suspended
status, it is not possible to run any queries or updates against
the resource.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | the id of the resource. Requires write permission. |
truncateResource(resourceId)
- Source:
Removes all data from the resource. Applicable to dataset-based resources only. This can not be undone.
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
string | The resource id to truncate. |
updateAccount(username, options)
- Source:
Updates account details. All update properties are optional. See createAccount for full details of each option.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
username |
string | the full TDX identity of the account to update. |
||||||||||||||||||||||||
options |
object | the update options Properties
|
updateData(datasetId, data, upsertopt, doNotThrowopt, optsopt) → {CommandResult}
- Source:
Updates data in a dataset resource.
Examples
tdxApi.updateData(myDatasetId, {lsoa: "E000001", count: 488});
// Will create a document if no data exists matching key 'lsoa': "E000004"
tdxApi.updateData(myDatasetId, {lsoa: "E000004", count: 288}, true);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
datasetId |
string | The id of the dataset-based resource to update. |
||
data |
object | array | The data to update. Must conform to the schema defined by the resource metadata. Supports updating individual or multiple documents. |
||
upsert |
boolean |
<optional> |
false
|
Indicates the data should be created if no document is found matching the primary key. |
doNotThrow |
boolean |
<optional> |
false
|
set to override default error handling. See TDXApi. |
opts |
object |
<optional> |
reserved for system use. |
Returns:
- Use the result property to check for errors.
- Type
- CommandResult
updateDatabotHostStatus(payload)
- Source:
Updates a databot host status.
n.b. the response to this request will contain any commands from the TDX that the host should action ( see commands).
Example
tdxApi.updateDatabotHostStatus({port: 2312, hostStatus: "idle"});
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
payload |
object | The databot host status payload. Properties
|
updateDataByQuery(datasetId, query, doNotThrowopt)
- Source:
Updates data in a dataset-based resource using a query to specify the documents to be updated.
Example
// Update all documents with English lsoa, setting `count` to 1000.
tdxApi.updateDataByQuery(myDatasetId, {lsoa: {$regex: "E*"}}, {count: 1000});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
datasetId |
string | The id of the dataset-based resource to update data in. |
||
query |
object | The query that specifies the data to update. All documents matching the |
||
doNotThrow |
boolean |
<optional> |
false
|
set to override default error handling. See TDXApi. query will be updated. |
updateResource(resourceId, update)
- Source:
Modify one or more of the meta data associated with the resource.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
resourceId |
string | id of the resource to update |
||||||||||||||||||||||||||||||||||||||||
update |
object | object containing the properties to update. Can be one or more of those listed below. See the TDXApi#addResource method for semantics and syntax of each property. Properties
|
validateTDXToken(token, ipopt) → {object}
- Source:
Validates the given token was signed by this TDX, and returns the decoded token data.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
token |
string | The TDX auth server token to validate. |
|
ip |
string |
<optional> |
The optional IP address to validate against. |
Returns:
- The decoded token data.
- Type
- object
verifyAccount(username, approved)
- Source:
Set account verified status. Reserved for system use.
Parameters:
Name | Type | Description |
---|---|---|
username |
string | the full TDX identity of the account. |
approved |
boolean | account verified status |
writeDatabotHostInstanceOutput(output)
- Source:
Stores databot instance output on the TDX.
Parameters:
Name | Type | Description |
---|---|---|
output |
object | The output payload for the databot instance. |