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

ParameterTypeDescriptionDefault
optionsFindInstancesOptionsOptional The options options filter criteria to search by, or null to fetch all Instances.
options.ownerstringOptional 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.statusstringOptional Find Instances with a specific status (running, completed, or cancelled )
options.workflowIDstringOptional Find Instances of a specific Workflow
options.querystringOptional A query string to search by. Applies to the name and description properties of Instances
options.pageSizenumberOptional The number of Instances to fetch in a single InstancesPage response25
options.pageTokenstringOptional The nextPageToken of a previous find request, used to fetch the next set of results
callback(err?: Error, instancesPage: InstancesPage) => anyOptional The callback
returnsInstancesPageThe 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);
});