acquia-dam-sdk
Version:
Interact with the Acquia DAM API
1,562 lines (1,549 loc) • 57.3 kB
JavaScript
'use strict';
var client_index = require('../client/index.cjs');
class AnalyticsApi {
/**
* Create an instance of the AnalyticsApi class.
*
* The Analytics endpoints provide information about asset usage from the Insights application. The API will return download, view, and share details for a single asset.
* Events may take up to 24 hours before appearing in analytics API results.
* Note: Three years of analytics data is available, starting from January 1, 2021 onward. The default `date_range` filter is from this date until today.
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Analytics}
*/
constructor(client) {
this._client = client;
}
/**
* Retrieve a list of Asset Download events
* @param params Information about the request
* @returns Promise containing the Download Asset events that meet the request criteria
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Analytics/operation/listAssetDownloads}
*/
listAssetDownloads(params) {
return this._client.sendRequest({
apiVersion: '2',
body: params,
method: 'POST',
path: 'analytics/assets/downloads'
});
}
/**
* Retrieve a list of Asset Share events
* @param params Information about the request
* @returns Promise containing the Share Asset events that meet the request criteria
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Analytics/operation/listAssetShares}
*/
listAssetShares(params) {
return this._client.sendRequest({
apiVersion: '2',
body: params,
method: 'POST',
path: 'analytics/assets/shares'
});
}
/**
* Retrieve a list of View Asset events
* @param params Information about the request
* @returns Promise containing the View Asset events that meet the request criteria
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Analytics/operation/listAssetViews}
*/
listAssetViews(params) {
return this._client.sendRequest({
apiVersion: '2',
body: params,
method: 'POST',
path: 'analytics/assets/views'
});
}
}
class CategoriesApi {
/**
* Create an instance of the CategoriesApi class
*
* Provides information about Categories and the Assets contained in them
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Categories}
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Categories}
*/
constructor(client) {
this._client = client;
}
/**
* Add or remove multiple assets from multiple categories
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Categories/operation/updateCategoryAssets}
*/
addOrRemoveAsets(params) {
const {
assets_to_add = [],
assets_to_remove = [],
categories
} = params;
const body = {
categories: {
uuids: categories
},
add: {
uuids: assets_to_add
},
remove: {
uuids: assets_to_remove
}
};
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path: 'category/assets',
body
});
}
/**
* Create a new category
* @param params Information about the request
* @returns Promise containing information about the new category
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Categories/operation/createCategory}
*/
createCategory(params) {
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path: 'category',
body: params
});
}
/**
* Update a category's information
* @param params Information about the request
* @returns Promise containing information about the modified category
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Categories/operation/editCategory}
*/
editCategory(params) {
const {
uuid,
...body
} = params;
const path = `category/uuid/${uuid}`;
return this._client.sendRequest({
apiVersion: '1',
method: 'PUT',
body,
path
});
}
/**
* Gets the category tree sctructure for the entire site
* @param includeEmpty `true` if the response should include categories with no assets.
* @returns Promise containing the category tree structure
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Categories/operation/getCategoryTree}
*/
getCategoryTree(includeEmpty) {
const queryStringParams = {
includeEmpty
};
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path: 'category/categoryTree',
queryStringParams
});
}
/**
* Retrieve a list of child categories.
* @param categoryPath Optional parent category path. Slashes in category names must be escaped with a backslash. If omitted, the top-level categories will be returned.
* @returns Promise containing a list of asset categories
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Categories/operation/listAssetCategories}
*/
listCategories(categoryPath) {
let path = 'categories';
if (categoryPath) {
path += `/${this.encodeCategoryPath(categoryPath)}`;
}
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* URL-encodes symbols in the path. Escaped slashes are treated as part of the category's name.
* @param path The category path
*/
encodeCategoryPath(path) {
return path.split(/(?<!\\)\//).map(part => encodeURIComponent(part)).join('/');
}
}
class CollectionsApi {
/**
* Create an instance of the CollectionsApi class
*
* Provides information about global, shared, and private Collections
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Collections}
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Collections}
*/
constructor(client) {
this._client = client;
}
/**
* Add or remove multiple assets from multiple collections
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Collections/operation/addOrRemoveAssetsFromCollections}
*/
addOrRemoveAssets(params) {
const {
assets_to_add = [],
assets_to_remove = [],
collections
} = params;
const body = {
collections: {
uuids: collections
},
add: {
uuids: assets_to_add
},
remove: {
uuids: assets_to_remove
}
};
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path: 'collection/assets',
body
});
}
/**
* Create a local (private) collection
* @param params Information about the request
* @returns Promise containing information about the created collection
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Collections/operation/createCollection}
*/
createCollection(params) {
const {
assets,
description,
title
} = params;
const body = {
assets: {
uuids: assets
},
description,
title
};
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path: 'collection',
body
});
}
/**
* Retrieve a list of collections.
* @param params Information about the request
* @returns Promise containing a list of collections
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Collections/operation/listCollections}
*/
listCollections(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'collections',
queryStringParams: params
});
}
}
class AssetsApi {
/**
* Create an instance of the AssetsApi class.
*
* Asset objects represent stored files in the DAM system. The API allows you to create, update, and delete Assets. You can search for assets, matching specific search criteria or load an individual asset by unique ID.
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets}
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Assets}
*/
constructor(client) {
this._client = client;
}
/**
* Add an asset to one or more categories.
* For bulk handling of assets, use the CategoriesApi.
* @param params Information about the request
* @returns Promise containing no data
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Categories/operation/updateCategoryAssets}
*/
async addAssetToCategories(params) {
const {
categories
} = params;
const id = await this.findAssetId(params);
return new CategoriesApi(this._client).addOrRemoveAsets({
assets_to_add: [id],
categories
});
}
/**
* Add an asset to one or more collections.
* For bulk handling of assets, use the CollectionsApi.
* @param params Information about the request
* @returns Promise containing no data
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Collections/operation/addOrRemoveAssetsFromCollections}
*/
async addAssetToCollections(params) {
const {
collections
} = params;
const id = await this.findAssetId(params);
return new CollectionsApi(this._client).addOrRemoveAssets({
assets_to_add: [id],
collections
});
}
/**
* Call this after all file chunks have uploaded to signal the completion of a chunked upload session.
* After calling this endpoint, provide the `file_id` to the `create` function to create a new asset.
* @param params Information about the request
* @returns Promise containing the `file_id`
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/uploadChunk3}
*/
completeChunkedUpload(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'uploads/chunks/complete',
body: params
});
}
/**
* Create a new asset using a URL, file data, or a `file_id` provided by a chunked upload.
* For larger files, use a chunked upload.
* @param params Information about the request
* @returns Promise containing the asset's `id`
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/uploadAsset}
*/
async createAsset(params) {
const body = new FormData();
body.append('profile', params.profile);
body.append('filename', params.filename);
if (params.metadata) {
body.append('metadata', JSON.stringify({
fields: params.metadata
}));
}
if (params.file) {
body.append('file', params.file);
} else if (params.file_id) {
body.append('file_id', params.file_id);
} else if (params.url) {
body.append('url', params.url);
} else {
throw new client_index.AcquiaDAMError('SDK Error', undefined, 'One of file, file_id, url must be defined');
}
const result = await this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'uploads',
body
});
const id = result._links.self.split('/').pop() || null;
return {
...result,
id
};
}
/**
* Remove an alternate preview from an asset.
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/alternatePreviewDelete}
*/
async deleteAlternatePreview(params) {
const id = await this.findAssetId(params);
const path = `assets/${id}/alternatepreview`;
return this._client.sendRequest({
apiVersion: '2',
method: 'DELETE',
path
});
}
/**
* Send an asset to the Pending Delete queue.
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetDelete}
*/
async deleteAsset(params) {
const id = await this.findAssetId(params);
const path = `assets/${id}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'DELETE',
path
});
}
/**
* Find an asset's UUID by searching via filename or embed ID (external ID).
* @param params Information about the request
* @returns Promise containing the asset's `id`
*/
async findAssetId(params) {
let query = '';
if (params.id) {
return params.id;
} else if (params.external_id) {
query = `embedid: ${params.external_id}`;
} else if (params.filename) {
query = `filename: {${params.filename}}`;
} else {
throw new client_index.AcquiaDAMError('SDK Error', undefined, 'One of id, external_id, filename must be defined');
}
const result = await this.searchAssets({
limit: 1,
query
});
if (!result.items[0]) {
throw new client_index.AcquiaDAMError('SDK Error', undefined, `Unable to find asset using query ${query}`);
}
return result.items[0].id;
}
/**
* Retrieve information about an individual asset.
* @param params Information about the request
* @returns Promise containing the asset data
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetRetrieveById}
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetRetrieveByIdAndVersion}
*/
async getAsset(params) {
const {
external_id: _1,
filename: _2,
id: _3,
version_id,
...queryStringParams
} = params;
const id = await this.findAssetId(params);
let path = `assets/${id}`;
if (version_id) {
path += `/versions/${version_id}`;
}
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
queryStringParams,
path
});
}
/**
* Metadata subresource simply returns the `metadata` property of the asset.
* The object structure returned by search endpoint and this method are identical.
* All assigned fields for the asset will be included. Empty fields are repesented with an empty array.
* @param params Information about the request
* @returns Promise containing the asset's metadata only
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetMetadataRetrieve}
*/
async getMetadata(params) {
const id = await this.findAssetId(params);
const path = `assets/${id}/metadata`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* Security subresource simply returns the `security` property of the asset.
* The object structure returned by search endpoint and this method are identical.
* @param params Information about the request
* @returns Promise containing the asset's security only
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetRetrieveSecurity}
*/
async getSecurity(params) {
const id = await this.findAssetId(params);
const path = `assets/${id}/security`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* Get a list of Asset Groups that the calling User has permission to view.
* @returns Promise containing a list of security groups
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetGroupsGet}
*/
listAssetGroups() {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'assets/assetgroups'
});
}
/**
* Retrieve a list of child categories.
* @param categoryPath Optional parent category name. If omitted, the top-level categories will be returned.
* @returns Promise containing a list of asset categories
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Categories/operation/listAssetCategories}
*/
listCategories(categoryPath) {
return new CategoriesApi(this._client).listCategories(categoryPath);
}
/**
* Retrieve a list of collections.
* @param params Information about the request
* @returns Promise containing a list of collections
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Collections/operation/listCollections}
*/
listCollections(params) {
return new CollectionsApi(this._client).listCollections(params);
}
/**
* Retrieve a list of integration links
* @returns a Promise containing a list of integration links
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Integration-Links/operation/getIntegrationLinks}
*/
listIntegrationLinks() {
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path: 'integrationlink'
});
}
/**
* Retrieve a list of upload profiles.
* @returns a Promise containing a list of Upload Profiles
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/uploadAssetProfilesList}
*/
listUploadProfiles() {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'uploads/profiles'
});
}
/**
* Retrieve a list of recognized file formats.
* @returns a Promise containing a list of file formats
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/File-Formats/operation/getFileFormats}
*/
listFileFormats() {
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path: 'fileformats'
});
}
/**
* Retrieve a list of asset versions.
* @param params Information about the request
* @returns Promise containing a list of asset versions
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Assets/operation/getAssetVersions}
*/
async listVersions(params) {
const id = await this.findAssetId(params);
const path = `asset/uuid/${id}/assetversions`;
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path
});
}
/**
* Remove an asset from one or more categories.
* For bulk handling of assets, use the CategoriesApi.
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Categories/operation/updateCategoryAssets}
*/
async removeAssetFromCatgories(params) {
const {
categories
} = params;
const id = await this.findAssetId(params);
return new CategoriesApi(this._client).addOrRemoveAsets({
assets_to_remove: [id],
categories
});
}
/**
* Remove an asset from one or more collections.
* For bulk handling of assets, use the CollectionsApi.
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Collections/operation/addOrRemoveAssetsFromCollections}
*/
async removeAssetFromCollections(params) {
const {
collections
} = params;
const id = await this.findAssetId(params);
return new CollectionsApi(this._client).addOrRemoveAssets({
assets_to_remove: [id],
collections
});
}
/**
* Remove an integration link.
* @param uuid The Integration Link UUID
* @returns a Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Integration-Links/operation/removeLink}
*/
removeIntegrationLink(uuid) {
return this._client.sendRequest({
apiVersion: '1',
method: 'DELETE',
path: `integrationlink/${uuid}`
});
}
/**
* Register a new Integration Link.
* @param params Information about the request
* @returns a Promise containing information about the created Integration Link
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Integration-Links/operation/createLink}
*/
async registerIntegrationLink(params) {
const {
description,
url
} = params;
const assetUuid = await this.findAssetId(params);
const body = {
assetUuid,
description,
url
};
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path: 'integrationlink',
body
});
}
/**
* Change an asset's `filename`
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetRename}
*/
async renameAsset(params) {
const {
new_filename
} = params;
const id = await this.findAssetId(params);
const path = `assets/${id}/filename`;
const body = {
filename: new_filename
};
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
body,
path
});
}
/**
* Search for a list of assets via a query
* @param params Information about the request
* @returns Promise containing a list of assets that meet the search criteria
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetListBySearchQuery}
*/
searchAssets(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'assets/search',
queryStringParams: params
});
}
/**
* Begins a chunked uploading session. The `session_id` in the response must be used for subsequent upload chunk and complete chunk calls. This `session_id` is good for 7 days.
* @returns Promise containing the `session_id`
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/uploadChunk0}
*/
startChunkedUpload() {
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'uploads/chunks/start'
});
}
/**
* Update an asset's `metadata` fields
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetMetadataUpdate}
*/
async updateMetadata(params) {
const {
external_id: _1,
filename: _2,
id: _3,
patch,
...body
} = params;
const id = await this.findAssetId(params);
const path = `assets/${id}/metadata`;
const queryStringParams = {
patch: patch ?? Object.keys(body.fields).join(',')
};
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
body,
path,
queryStringParams
});
}
/**
* Change an asset's metadata type
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Assets/operation/updateMetadataType}
*/
async updateMetadataType(params) {
const {
metadata_type_uuid
} = params;
const id = await this.findAssetId(params);
const path = `asset/changemetadatatype/asset/${id}/type/${metadata_type_uuid}`;
return this._client.sendRequest({
apiVersion: '1',
method: 'PUT',
path
});
}
/**
* Update an asset's `security` fields
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/assetUpdateSecurity}
*/
async updateSecurity(params) {
const {
external_id: _1,
filename: _2,
id: _3,
patch,
...body
} = params;
const id = await this.findAssetId(params);
const path = `assets/${id}/security`;
const queryStringParams = {
patch: patch ?? Object.keys(body)
};
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
body,
path,
queryStringParams
});
}
/**
* Upload a new file as an alternate preview to an Asset
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/alternatePreviewUpload}
*/
async uploadAlternatePreview(params) {
const {
file
} = params;
const id = await this.findAssetId(params);
const path = `assets/${id}/alternatepreview`;
const body = new FormData();
body.append('file', file);
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path,
body
});
}
/**
* Upload each piece of the file. The `tag` in each Upload Chunk response must be used in the Complete Chunked Upload call
* @param params Information about the request
* @returns Promise containing the tag for the chunk
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Assets/operation/uploadChunk1}
*/
uploadChunk(params) {
const body = new FormData();
for (const [k, v] of Object.entries(params)) {
body.append(k, v);
}
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'uploads/chunks/upload',
body
});
}
}
class AttributesApi {
/**
* Create an instance of the AttributesApi class.
*
* The Attributes API lists all product attributes that have been configured in Entries, and all controlled vocabulary values for any single-select or multi-select attribute
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Attributes}
*/
constructor(client) {
this._client = client;
}
/**
* Retrieve a list of attributes
* @param params Information about the request
* @returns Promise containing a list of attributes
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Attributes/operation/listAttributes}
*/
listAttributes(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'attributes',
queryStringParams: params
});
}
/**
* List the vocabulary for a single-select or multi-select attribute
* @param id Attribute ID
* @returns Promise containing the vocabulary for the provided attribute field
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Attributes/operation/listVocabulary}
*/
listAttributeVocabulary(id) {
const path = `attributes/${id}/vocabulary`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
}
class MetadataApi {
/**
* Create an instance of the MetadataApi class.
*
* These endpoints allow you to retrieve or modify information about existing metadata fields. If you want to retrieve or modify metadata applied to a specific asset, use the AssetsApi
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Metadata}
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Metadata}
*/
constructor(client) {
this._client = client;
}
/**
* Add a value to a controlled metadata field's vocabulary
* @param params Information about the request
* @returns Promise containing no data
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Metadata/operation/addControlledVocabularyValue}
*/
addValue(params) {
const {
displayKey,
...body
} = params;
const path = `metadata/${displayKey}/vocabulary`;
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path,
body
});
}
/**
* Remove a value from a controlled metadata field's vocabulary
* @param displayKey Display key of the controlled vocabulary metadata field
* @param value The controlled vocabulary value you wish to remove
* @returns Promise containing no data
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Metadata/operation/deleteControlledVocabularyValue}
*/
deleteValue(displayKey, value) {
const path = `metadata/${displayKey}/vocabulary/${value}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'DELETE',
path
});
}
/**
* Retrieve a list of controlled vocabulary metadata values
* @param displayKey Display key of the controlled vocabulary metadata field
* @returns Promise containing the vocabulary for the given field
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Metadata/operation/listControlledVocabularyValues}
*/
listFieldValues(displayKey) {
const path = `metadata/${displayKey}/vocabulary`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* Get details for a single controlled vocabulary value
* @param displayKey Display key of the controlled vocabulary metadata field
* @param value The controlled vocabulary value
* @returns Promise containing information for the metadata field value
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Metadata/operation/getControlledVocabularyValue}
*/
getValue(displayKey, value) {
const path = `metadata/${displayKey}/vocabulary/${value}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* Retrieves the list of all MetadataTypes in the system. In addition to the Type's name and use, a listing of all that Type's MetadataFields is provided. For MetadataFields with a controlled list of options, each value is also provided.
* @returns Promise containing a list of metadata types
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Metadata/operation/getMetadataTypes}
*/
listMetadataTypes() {
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path: 'metadata/types'
});
}
/**
* Query for a list of metadata fields that you have permission to see
* @param params Information about the request
* @returns Promise containing information for the desired metadata fields
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Metadata/operation/listMetadataFields}
*/
listViewableFields(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'metadata/fields/viewable',
queryStringParams: params
});
}
/**
* Update the display value or the index (or both) of a controlled metadata field value
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Metadata/operation/updateControlledVocabularyValue}
*/
updateValue(params) {
const {
displayKey,
existingValue,
...body
} = params;
const path = `metadata/${displayKey}/vocabulary/${existingValue}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
body,
path
});
}
}
class OrdersApi {
/**
* Create an instance of the OrdersApi class
*
* Provides information about Orders and Conversions
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders}
*/
constructor(client) {
this._client = client;
}
/**
* This can be called before attempting to create an order to determine which items will be removed from the order. Situations include an asset that has been deleted or an asset the user does not have permission to order. Any items returned in the removedItems list, will be removed automatically when the order is submitted.
* @param assets Array of asset UUIDs
* @returns Promise containing the assets that will not be ordered
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/cleanOrderItems}
*/
cleanAssets(assets) {
const body = {
uuids: assets
};
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path: 'order/items/removals',
body
});
}
/**
* Create an asset order.
* @param params Information about the request
* @returns Promise containing information about the created order
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/createOrder}
*/
createOrder(params) {
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path: 'order',
body: params
});
}
/**
* Used to submit a request to begin the creation of a zip archive for a specific order
* @param uuid The order UUID
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/createZipForOrder}
*/
createZipArchive(uuid) {
const path = `order/uuid/${uuid}/zip`;
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
path
});
}
/**
* Gets order information by uuid or sequence number and, if the order conversion status is 'Completed', up to 100 assets and associated conversions and pickup urls for that order. If the order conversion status is not 'Completed', only order details (uuid, conversion status, assets in order, and sequence number) will appear in the response.
* @param params Information about the request
* @returns Promise containing information about the order
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/getOrderDetailByUUID}
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/getOrderDetailBySequenceNum}
*/
getOrderDetails(params) {
const {
id,
seqNum,
...queryStringParams
} = params;
let field, value;
if (id) {
field = 'uuid';
value = id;
} else if (seqNum) {
field = 'seqNum';
value = seqNum;
} else {
throw new client_index.AcquiaDAMError('SDK Error', undefined, 'One of id, seqNum must be defined');
}
const path = `order/${field}/${value}`;
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path,
queryStringParams
});
}
/**
* Used to check the status of an archive operation that has previously been submitted. If the archive operation is complete, this call returns a download link for the zip archive.
* @param uuid The order UUID
* @returns Promise containing information about the status of the Zip archive
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/getZipStatusOrDownloadLink}
*/
getZipStatus(uuid) {
const path = `order/uuid/${uuid}/zip`;
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path
});
}
/**
* Retrieves the list of conversions available for a specific order profile and set of assets.
* @param params Information about the request
* @returns Promise containing the list of available conversions
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/getApplicableConversions}
*/
listConversionsForOrder(params) {
const {
assetIds,
profileId
} = params;
const path = `conversion/order/profile/uuid/${profileId}`;
const body = {
uuids: assetIds
};
return this._client.sendRequest({
apiVersion: '1',
method: 'POST',
body,
path
});
}
/**
* Gets the Order Profiles available for sending orders via the internet
* @returns Promise containing the list of available order profiles
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Orders/operation/getDirectorInternetProfiles}
*/
listOrderProfiles() {
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path: 'order/profile/internet'
});
}
}
class ProductsApi {
/**
* Create an instance of the ProductsApi class.
*
* The Products API provides access to product information stored in Acquia Entries. The API allows you to create, retrieve, delete, and update products.
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products}
*/
constructor(client) {
this._client = client;
}
/**
* Create a new product
* @param params Information about the request
* @returns Promise containing the new Product ID
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/createProduct}
*/
createProduct(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'products',
body: params
});
}
/**
* Delete a product
* @param id Product ID
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/deleteProduct}
*/
deleteProduct(id) {
const path = `products/${id}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'DELETE',
path
});
}
/**
* Retrieve information about a product
* @param id Product ID
* @returns Promise containing information about a product
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/retrieveProductById}
*/
getProduct(id) {
const path = `products/${id}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* Retrieve a list of channels
* @param params Information about the request
* @returns Promise containing a list of channels
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Channels/operation/listChannels}
*/
listChannels(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'channels',
queryStringParams: params
});
}
/**
* The Channel Products endpoint returns a list of products associated with a given channel in Entries. Only the products and attributes that are configured for the channel will be included in the response
* @param params Information about the request
* @returns Promise containing a list of products in the channel
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/listProductsForChannel}
*/
listProductsByChannel(params) {
const {
channel_id,
...queryStringParams
} = params;
const path = `products/channels/${channel_id}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path,
queryStringParams
});
}
/**
* Retrieve a list of product categories
* @param params Information about the request
* @returns Promise containing a list of product categories
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Categories/operation/listProductCategories}
*/
listProductCategories(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'product-categories',
queryStringParams: params
});
}
/**
* Retrieve a list of product types
* @param params Information about the request
* @returns Promise containing a list of product types
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Product-Types/operation/listProductTypes}
*/
listProductTypes(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'product-types',
queryStringParams: params
});
}
/**
* Change a product's name
* @param id Product ID
* @param name New product name
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/renameProduct}
*/
renameProduct(id, name) {
const path = `products/${id}/rename`;
const body = {
new_name: name
};
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
path,
body
});
}
/**
* Search for products
* @param params Information about the request
* @returns Promise containing a list of products
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/listProductsBySearchQuery}
*/
searchProducts(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'products/search',
body: params
});
}
/**
* Update a product's attribute values
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/updateAttributeValues}
*/
updateAttributes(params) {
const {
id,
...body
} = params;
const path = `products/${id}/attributes`;
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
path,
body
});
}
/**
* Update a product's categories
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/updateProductCategory}
*/
updateProductCategory(params) {
const {
id,
...body
} = params;
const path = `products/${id}/product-category`;
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
path,
body
});
}
/**
* Update a product's featured image
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/updateFeaturedImage}
*/
updateFeaturedImage(params) {
const {
id,
...body
} = params;
const path = `products/${id}/featured-image`;
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
path,
body
});
}
/**
* Update a product's parent product
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/updateParentProduct}
*/
updateParentProduct(params) {
const {
id,
...body
} = params;
const path = `products/${id}/parent-product`;
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
path,
body
});
}
/**
* Update a product's type
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Products/operation/updateProductType}
*/
updateProductType(params) {
const {
id,
...body
} = params;
const path = `products/${id}/product-type`;
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
path,
body
});
}
}
class SearchConnectorApi {
/**
* Create an instance of the SearchConnectorApi class.
*
* The Instant Search Connector allows external applications access to Acquia DAM Asset search, without having to implement a native search UI
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Search-Connector}
*/
constructor(client) {
this._client = client;
}
/**
* Retrieve a url to the Search Connector UI. This UI intended to be displayed in an iframe within the parent application. The returned url is valid for 24 hours and is signed via a one-way hash to prevent modification of its parameters
* @param params Information about the request
* @returns Promise containing the URL to the search connector UI.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Search-Connector/operation/getSearchConnectorUrl}
*/
getSearchConnectorUrl(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'integrations/url',
queryStringParams: params
});
}
}
class UsageApi {
/**
* Create an instance of the UsageApi class.
*
* Retrieve information about the monthly usage of the API
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Usage}
*/
constructor(client) {
this._client = client;
}
/**
* Reveals the total number of API requests made within the current month. Note: Usage data is aggregated periodically and a delay of up to 24 hours may occur
* @returns Promise containing the monthly request count
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Usage/operation/getApiUsageSummary}
*/
getApiUsage() {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: 'usage/api'
});
}
}
class UsersApi {
/**
* Create an instance of the UsersApi class
*
* Query for information about users
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Users}
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Users-and-Contacts}
*/
constructor(client) {
this._client = client;
}
/**
* Returns information about a user
* @param id Retrieve a specific user's information. If omitted, information for the user associated with the provided access token will be returned.
* @returns Promise containing the requested user information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Users/operation/getUserById}
*/
getUser(id) {
let path = 'user';
if (id) {
path += `/${id}`;
}
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* Return the calling user's contact. The UUID field may be used as a recipient to create an order.
* @returns Promise containing the calling user's contact information
* @see {@link https://docs.acquia.com/acquia-dam/api-v1#tag/Users-and-Contacts/operation/getUserAddress}
*/
getContact() {
const path = 'user/address';
return this._client.sendRequest({
apiVersion: '1',
method: 'GET',
path
});
}
}
class WebhooksApi {
/**
* Create an instance of the WebhooksApi class.
*
* Create, list, read, ping, edit, and delete Acquia DAM webhook configurations. Create, List, and Delete Workflow Webhooks
*
* @param client Provide an instance of ApiClient.
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Acquia-DAM-Webhooks}
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Workflow-Webhooks}
*/
constructor(client) {
this._client = client;
}
/**
* Create a new Assets webhook
* @param params Information about the request
* @returns Promise containing the new webhook configuration ID
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Acquia-DAM-Webhooks/operation/createWebhook}
*/
createAssetsWebhook(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'webhooks/configurations',
body: params
});
}
/**
* Create a Workflow webhook
* @param params Information about the request
* @returns Promise containing information about the created webhook
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Workflow-Webhooks/operation/workflowAddWebhook}
*/
createWorkflowWebhook(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'POST',
path: 'workflow/webhooks',
body: params
});
}
/**
* Delete an Assets webhook
* @param id Assets Webhook configuration ID
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Acquia-DAM-Webhooks/operation/deleteWebhook}
*/
deleteAssetsWebhook(id) {
const path = `webhooks/configurations/${id}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'DELETE',
path
});
}
/**
* Delete a Workflow webhook
* @param event The event name
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Workflow-Webhooks/operation/workflowDeleteWebhook}
*/
deleteWorkflowWebhook(event) {
const body = {
event
};
return this._client.sendRequest({
apiVersion: '2',
method: 'DELETE',
path: 'workflow/webhooks',
body
});
}
/**
* Edit an Assets webhook configuration
* @param params Information about the request
* @returns Promise containing no information
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Acquia-DAM-Webhooks/operation/deleteWebhook}
*/
editAssetsWebhook(params) {
const {
id,
patch,
...body
} = params;
const path = `webhooks/configurations/${id}`;
const queryStringParams = {
patch: patch ?? Object.keys(body)
};
return this._client.sendRequest({
apiVersion: '2',
method: 'PUT',
body,
path,
queryStringParams
});
}
/**
* Retrieve information about an Assets webhook
* @param id Webhook configuration ID
* @returns Promise containing information about a webhook
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Acquia-DAM-Webhooks/operation/getWebhook}
*/
getAssetsWebhook(id) {
const path = `webhooks/configurations/${id}`;
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path
});
}
/**
* Retrieve a list of Assets webhooks
* @param params Information about the request
* @returns Promise containing a list of Assets webhooks
* @see {@link https://docs.acquia.com/acquia-dam/api-v2#tag/Acquia-DAM-Webhooks/operation/listWebhooks}
*/
listAssetsWebhooks(params) {
return this._client.sendRequest({
apiVersion: '2',
method: 'GET',
path: