UNPKG

9.16 kBTypeScriptView Raw
1import type { BasicCursorPaginationOptions, MakeRequest } from './common-types';
2import type { EnvironmentTemplateProps } from './entities/environment-template';
3import type { CreateEnvironmentTemplateInstallationProps, ValidateEnvironmentTemplateInstallationProps } from './entities/environment-template-installation';
4export type ContentfulEnvironmentTemplateApi = ReturnType<typeof createEnvironmentTemplateApi>;
5export declare function createEnvironmentTemplateApi(makeRequest: MakeRequest, organizationId: string): {
6 /**
7 * Updates a environment template
8 * @return Promise for new version of the template
9 * ```javascript
10 * const contentful = require('contentful-management')
11 *
12 * const client = contentful.createClient({
13 * accessToken: '<content_management_api_key>'
14 * })
15 *
16 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
17 * .then((environmentTemplate) => {
18 * environmentTemplate.name = 'New name'
19 * return environmentTemplate.update()
20 * })
21 * .then((environmentTemplate) =>
22 * console.log(`Environment template ${environmentTemplate.sys.id} renamed.`)
23 * ).catch(console.error)
24 * ```
25 */
26 update: () => Promise<import("./entities/environment-template").EnvironmentTemplate>;
27 /**
28 * Updates environment template version data
29 * @param version.versionName - Name of the environment template version
30 * @param version.versionDescription - Description of the environment template version
31 * @return Promise for an updated EnvironmentTemplate
32 * ```javascript
33 * const contentful = require('contentful-management')
34 *
35 * const client = contentful.createClient({
36 * accessToken: '<content_management_api_key>'
37 * })
38 *
39 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
40 * .then((environmentTemplate) => {
41 * return environmentTemplate.updateVersion({
42 * versionName: 'New Name',
43 * versionDescription: 'New Description',
44 * })
45 * })
46 * .then((environmentTemplate) =>
47 * console.log(`Environment template version ${environmentTemplate.sys.id} renamed.`)
48 * ).catch(console.error)
49 * ```
50 */
51 updateVersion: ({ versionName, versionDescription, }: {
52 versionName: string;
53 versionDescription: string;
54 }) => Promise<import("./entities/environment-template").EnvironmentTemplate>;
55 /**
56 * Deletes the environment template
57 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
58 * @example ```javascript
59 * const contentful = require('contentful-management')
60 *
61 * const client = contentful.createClient({
62 * accessToken: '<content_management_api_key>'
63 * })
64 *
65 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
66 * .then((environmentTemplate) => environmentTemplate.delete())
67 * .then(() => console.log('Environment template deleted.'))
68 * .catch(console.error)
69 * ```
70 */
71 delete: () => Promise<void>;
72 /**
73 * Gets a collection of all versions for the environment template
74 * @return Promise for a EnvironmentTemplate
75 * ```javascript
76 * const contentful = require('contentful-management')
77 *
78 * const client = contentful.createClient({
79 * accessToken: '<content_management_api_key>'
80 * })
81 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
82 * .then((environmentTemplate) => environmentTemplate.getVersions())
83 * .then((environmentTemplateVersions) => console.log(environmentTemplateVersions.items))
84 * .catch(console.error)
85 * ```
86 */
87 getVersions: () => Promise<import("./common-types").CursorPaginatedCollection<import("./entities/environment-template").EnvironmentTemplate, EnvironmentTemplateProps>>;
88 /**
89 * Gets a collection of all installations for the environment template
90 * @param [installationParams.spaceId] - Space ID to filter installations by space and environment
91 * @param [installationParams.environmentId] - Environment ID to filter installations by space and environment
92 * @return Promise for a collection of EnvironmentTemplateInstallations
93 * ```javascript
94 * const contentful = require('contentful-management')
95 *
96 * const client = contentful.createClient({
97 * accessToken: '<content_management_api_key>'
98 * })
99 *
100 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
101 * .then((environmentTemplate) => environmentTemplate.getInstallations())
102 * .then((environmentTemplateInstallations) =>
103 * console.log(environmentTemplateInstallations.items)
104 * )
105 * .catch(console.error)
106 * ```
107 */
108 getInstallations: ({ spaceId, environmentId, ...query }?: {
109 spaceId?: string;
110 environmentId?: string;
111 } & BasicCursorPaginationOptions) => Promise<import("./common-types").CursorPaginatedCollection<import("./entities/environment-template-installation").EnvironmentTemplateInstallation, import("./entities/environment-template-installation").EnvironmentTemplateInstallationProps>>;
112 /**
113 * Validates an environment template against a given space and environment
114 * @param params.spaceId - Space ID where the template should be installed into
115 * @param params.environmentId - Environment ID where the template should be installed into
116 * @param [params.version] - Version of the template
117 * @param [params.installation.takeover] - Already existing Content types to takeover in the target environment
118 * @param [params.changeSet] - Change set which should be applied
119 * @return Promise for a EnvironmentTemplateValidation
120 * ```javascript
121 * const contentful = require('contentful-management')
122 *
123 * const client = contentful.createClient({
124 * accessToken: '<content_management_api_key>'
125 * })
126 *
127 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
128 * .then((environmentTemplate) => environmentTemplate.validate({
129 * spaceId: '<space_id>',
130 * environmentId: '<environment_id>',
131 * version: <version>,
132 * }))
133 * .then((validationResult) => console.log(validationResult))
134 * .catch(console.error)
135 * ```
136 */
137 validate: ({ spaceId, environmentId, version, takeover, changeSet, }: {
138 spaceId: string;
139 environmentId: string;
140 version?: number;
141 } & ValidateEnvironmentTemplateInstallationProps) => Promise<import("./entities/environment-template-installation").EnvironmentTemplateValidationProps>;
142 /**
143 * Installs a template against a given space and environment
144 * @param params.spaceId - Space ID where the template should be installed into
145 * @param params.environmentId - Environment ID where the template should be installed into
146 * @param params.installation.version- Template version which should be installed
147 * @param [params.installation.takeover] - Already existing Content types tp takeover in the target environment
148 * @param [params.changeSet] - Change set which should be applied
149 * @return Promise for a EnvironmentTemplateInstallation
150 * ```javascript
151 * const contentful = require('contentful-management')
152 *
153 * const client = contentful.createClient({
154 * accessToken: '<content_management_api_key>'
155 * })
156 *
157 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
158 * .then((environmentTemplate) => environmentTemplate.validate({
159 * spaceId: '<space_id>',
160 * environmentId: '<environment_id>',
161 * installation: {
162 * version: <version>,
163 * }
164 * }))
165 * .then((installation) => console.log(installation))
166 * .catch(console.error)
167 * ```
168 */
169 install: ({ spaceId, environmentId, installation, }: {
170 spaceId: string;
171 environmentId: string;
172 installation: CreateEnvironmentTemplateInstallationProps;
173 }) => Promise<import("./entities/environment-template-installation").EnvironmentTemplateInstallationProps>;
174 /**
175 * Disconnects the template from a given environment
176 * @param params.spaceId - Space ID where the template should be installed into
177 * @param params.environmentId - Environment ID where the template should be installed into
178 * @return Promise for the disconnection with no data
179 * ```javascript
180 * const contentful = require('contentful-management')
181 *
182 * const client = contentful.createClient({
183 * accessToken: '<content_management_api_key>'
184 * })
185 *
186 * client.getEnvironmentTemplate('<organization_id>', '<environment_template_id>')
187 * .then(environmentTemplate) => environmentTemplate.disconnected())
188 * .then(() => console.log('Template disconnected'))
189 * .catch(console.error)
190 * ```
191 */
192 disconnect: ({ spaceId, environmentId, }: {
193 spaceId: string;
194 environmentId: string;
195 }) => Promise<void>;
196};