contentful-management
Version:
Client for Contentful's Content Management API
197 lines (196 loc) • 9.16 kB
TypeScript
import type { BasicCursorPaginationOptions, MakeRequest } from './common-types';
import type { EnvironmentTemplateProps } from './entities/environment-template';
import type { CreateEnvironmentTemplateInstallationProps, ValidateEnvironmentTemplateInstallationProps } from './entities/environment-template-installation';
export type ContentfulEnvironmentTemplateApi = ReturnType<typeof createEnvironmentTemplateApi>;
export declare function createEnvironmentTemplateApi(makeRequest: MakeRequest, organizationId: string): {
/**
* Updates a environment template
* @return Promise for new version of the template
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then((environmentTemplate) => {
* environmentTemplate.name = 'New name'
* return environmentTemplate.update()
* })
* .then((environmentTemplate) =>
* console.log(`Environment template ${environmentTemplate.sys.id} renamed.`)
* ).catch(console.error)
* ```
*/
update: () => Promise<import("./entities/environment-template").EnvironmentTemplate>;
/**
* Updates environment template version data
* @param version.versionName - Name of the environment template version
* @param version.versionDescription - Description of the environment template version
* @return Promise for an updated EnvironmentTemplate
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then((environmentTemplate) => {
* return environmentTemplate.updateVersion({
* versionName: 'New Name',
* versionDescription: 'New Description',
* })
* })
* .then((environmentTemplate) =>
* console.log(`Environment template version ${environmentTemplate.sys.id} renamed.`)
* ).catch(console.error)
* ```
*/
updateVersion: ({ versionName, versionDescription, }: {
versionName: string;
versionDescription: string;
}) => Promise<import("./entities/environment-template").EnvironmentTemplate>;
/**
* Deletes the environment template
* @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
* @example ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then((environmentTemplate) => environmentTemplate.delete())
* .then(() => console.log('Environment template deleted.'))
* .catch(console.error)
* ```
*/
delete: () => Promise<void>;
/**
* Gets a collection of all versions for the environment template
* @return Promise for a EnvironmentTemplate
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then((environmentTemplate) => environmentTemplate.getVersions())
* .then((environmentTemplateVersions) => console.log(environmentTemplateVersions.items))
* .catch(console.error)
* ```
*/
getVersions: () => Promise<import("./common-types").CursorPaginatedCollection<import("./entities/environment-template").EnvironmentTemplate, EnvironmentTemplateProps>>;
/**
* Gets a collection of all installations for the environment template
* @param [installationParams.spaceId] - Space ID to filter installations by space and environment
* @param [installationParams.environmentId] - Environment ID to filter installations by space and environment
* @return Promise for a collection of EnvironmentTemplateInstallations
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then((environmentTemplate) => environmentTemplate.getInstallations())
* .then((environmentTemplateInstallations) =>
* console.log(environmentTemplateInstallations.items)
* )
* .catch(console.error)
* ```
*/
getInstallations: ({ spaceId, environmentId, ...query }?: {
spaceId?: string;
environmentId?: string;
} & BasicCursorPaginationOptions) => Promise<import("./common-types").CursorPaginatedCollection<import("./entities/environment-template-installation").EnvironmentTemplateInstallation, import("./entities/environment-template-installation").EnvironmentTemplateInstallationProps>>;
/**
* Validates an environment template against a given space and environment
* @param params.spaceId - Space ID where the template should be installed into
* @param params.environmentId - Environment ID where the template should be installed into
* @param [params.version] - Version of the template
* @param [params.installation.takeover] - Already existing Content types to takeover in the target environment
* @param [params.changeSet] - Change set which should be applied
* @return Promise for a EnvironmentTemplateValidation
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then((environmentTemplate) => environmentTemplate.validate({
* spaceId: '<space_id>',
* environmentId: '<environment_id>',
* version: <version>,
* }))
* .then((validationResult) => console.log(validationResult))
* .catch(console.error)
* ```
*/
validate: ({ spaceId, environmentId, version, takeover, changeSet, }: {
spaceId: string;
environmentId: string;
version?: number;
} & ValidateEnvironmentTemplateInstallationProps) => Promise<import("./entities/environment-template-installation").EnvironmentTemplateValidationProps>;
/**
* Installs a template against a given space and environment
* @param params.spaceId - Space ID where the template should be installed into
* @param params.environmentId - Environment ID where the template should be installed into
* @param params.installation.version- Template version which should be installed
* @param [params.installation.takeover] - Already existing Content types tp takeover in the target environment
* @param [params.changeSet] - Change set which should be applied
* @return Promise for a EnvironmentTemplateInstallation
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then((environmentTemplate) => environmentTemplate.validate({
* spaceId: '<space_id>',
* environmentId: '<environment_id>',
* installation: {
* version: <version>,
* }
* }))
* .then((installation) => console.log(installation))
* .catch(console.error)
* ```
*/
install: ({ spaceId, environmentId, installation, }: {
spaceId: string;
environmentId: string;
installation: CreateEnvironmentTemplateInstallationProps;
}) => Promise<import("./entities/environment-template-installation").EnvironmentTemplateInstallationProps>;
/**
* Disconnects the template from a given environment
* @param params.spaceId - Space ID where the template should be installed into
* @param params.environmentId - Environment ID where the template should be installed into
* @return Promise for the disconnection with no data
* ```javascript
* const contentful = require('contentful-management')
*
* const client = contentful.createClient({
* accessToken: '<content_management_api_key>'
* })
*
* client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
* .then(environmentTemplate) => environmentTemplate.disconnected())
* .then(() => console.log('Template disconnected'))
* .catch(console.error)
* ```
*/
disconnect: ({ spaceId, environmentId, }: {
spaceId: string;
environmentId: string;
}) => Promise<void>;
};