Find Instances
Finds Instances matching your criteria.
Permissions Required
Matching Instances will only be included in the results if you have Find permissions to that Instance. Instances that you do not have permissions to will be excluded from the results.
Method Signature
find(): Promise<InstancesPage>;
find(options: FindInstancesOptions): Promise<InstancesPage>;
find(callback: ClientMethodCallback<InstancesPage>): void;
find(options: FindInstancesOptions, callback: ClientMethodCallback<InstancesPage>): void;
Parameters
Parameter | Type | Description | Default |
---|---|---|---|
options | FindInstancesOptions | Optional The options options filter criteria to search by, or null to fetch all Instances. | |
options.owner | string | Optional Search for Instances owned by a specific team member. The email address of the owner of the Instance must match exactly, apart from casing. | |
options.status | string | Optional Find Instances with a specific status (running , completed , or cancelled ) | |
options.workflowID | string | Optional Find Instances of a specific Workflow | |
options.query | string | Optional A query string to search by. Applies to the name and description properties of Instances | |
options.pageSize | number | Optional The number of Instances to fetch in a single InstancesPage response | 25 |
options.pageToken | string | Optional The nextPageToken of a previous find request, used to fetch the next set of results | |
callback | (err?: Error, instancesPage: InstancesPage) => any | Optional The callback | |
returns | InstancesPage | The requested page of Instances |
Example
/*
* This example demonstrates finding all Instances of a specific
* Workflow owned by a particular user that are still running.
* This also demonstrates paging through results to collect all
* matches into a single list.
*/
const { CatalyticClient } = require('@catalytic/sdk');
const catalytic = new CatalyticClient();
const instances = [];
const options = {
pageSize: 25,
workflowID: 'c9f2beec-10c0-4f2f-b4e0-1d884c7e053c',
owner: '[email protected]',
status: 'running'
};
let hasNextPage = true;
while (hasNextPage) {
const instancesPage = await catalytic.instances.find(options);
instances.push(...instancesPage.instances);
if (instancesPage.nextPageToken) {
options.pageToken = instancesPage.nextPageToken;
} else {
hasNextPage = false;
}
}
instances.forEach(instance => {
console.log(instance.name);
});
Updated about 3 years ago