@coveo/platform-client
Version:
The main goal of this package is to provide an easy to configure and straightforward way of querying Coveo Cloud APIs using JavaScript.
77 lines • 3.12 kB
JavaScript
import Resource from '../../Resource.js';
export default class Condition extends Resource {
static baseUrl = `/rest/search/v1/admin/pipelines/statements`;
/**
* Returns a paginated list of condition models.
* @param options
*/
list(options = {}) {
return this.api.get(this.buildPath(Condition.baseUrl, { feature: 'when', organizationId: this.api.organizationId, ...options }));
}
/**
* Creates and returns a new condition model.
* @param conditionModel
*/
create(conditionModel) {
return this.api.post(this.buildPath(Condition.baseUrl, { organizationId: this.api.organizationId }), conditionModel);
}
/**
* Delete a condition model.
* @param conditionId The unique identifier of the condition to be deleted.
*/
delete(conditionId) {
return this.api.delete(this.buildPath(`${Condition.baseUrl}/${conditionId}`, { organizationId: this.api.organizationId }));
}
/**
* Returns a condition model.
* @param conditionId The unique identifier of the condition to be fetched.
*/
get(conditionId) {
return this.api.get(this.buildPath(`${Condition.baseUrl}/${conditionId}`, { organizationId: this.api.organizationId }));
}
/**
* Update a condition model with the model sent and returns the updated condition model.
* @param conditionId The unique identifier of the condition to be updated.
* @param conditionModel
*/
update(conditionId, conditionModel) {
return this.api.put(this.buildPath(`${Condition.baseUrl}/${conditionId}`, { organizationId: this.api.organizationId }), conditionModel);
}
/**
* Bulk get a list of conditions corresponding of the ids sent.
* @param {string[]} conditionIds The list of condition's ids to be fetched. Limit of 1000 incoming ids.
* @param {ListConditionsOptions} params
*/
bulkGet(conditionIds, params = {}) {
return this.api.post(this.buildPath(`${Condition.baseUrl}/bulkGet`, {
organizationId: this.api.organizationId,
...params,
}), {
ids: conditionIds,
});
}
/**
* Bulk delete of condition statements
* @param conditionIds A list of resource identifiers to delete. A maximum of 100 can be sent.
*/
bulkDelete(conditionIds) {
return this.api.post(this.buildPath(`${Condition.baseUrl}/bulkDelete`, {
organizationId: this.api.organizationId,
}), {
ids: conditionIds,
});
}
/**
* Gets the list of all objects associated with a condition.
* @param conditionId The unique identifier of the condition to be fetched.
* @param params
*/
listAssociations(conditionId, params) {
return this.api.get(this.buildPath(`${Condition.baseUrl}/${conditionId}/associations`, {
...params,
...(params?.associationTypes ? { associationTypes: JSON.stringify(params.associationTypes) } : {}),
organizationId: this.api.organizationId,
}));
}
}
//# sourceMappingURL=Condition.js.map