UNPKG

21.3 kBTypeScriptView Raw
1import { Stream } from 'stream';
2import { CreateTeamMembershipProps } from './entities/team-membership';
3import { CreateTeamProps } from './entities/team';
4import { CreateOrganizationInvitationProps } from './entities/organization-invitation';
5import { MakeRequest, QueryOptions } from './common-types';
6import { CreateAppDefinitionProps } from './entities/app-definition';
7import { CreateAppSigningSecretProps } from './entities/app-signing-secret';
8import { CreateAppDetailsProps } from './entities/app-details';
9/**
10 * @private
11 */
12export declare type ContentfulOrganizationAPI = ReturnType<typeof createOrganizationApi>;
13/**
14 * Creates API object with methods to access the Organization API
15 * @param {MakeRequest} makeRequest - function to make requests via an adapter
16 * @return {ContentfulOrganizationAPI}
17 * @private
18 */
19export default function createOrganizationApi(makeRequest: MakeRequest): {
20 /**
21 * Gets a User
22 * @return Promise for a User
23 * @example ```javascript
24 * const contentful = require('contentful-management')
25 * const client = contentful.createClient({
26 * accessToken: '<content_management_api_key>'
27 * })
28 *
29 * client.getOrganization('<organization_id>')
30 * .then((organization) => organization.getUser('id'))
31 * .then((user) => console.log(user))
32 * .catch(console.error)
33 * ```
34 */
35 getUser(id: string): Promise<import("./export-types").UserProps & {
36 toPlainObject(): import("./export-types").UserProps;
37 }>;
38 /**
39 * Gets a collection of Users in organization
40 * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
41 * @return Promise a collection of Users in organization
42 * @example ```javascript
43 * const contentful = require('contentful-management')
44 * const client = contentful.createClient({
45 * accessToken: '<content_management_api_key>'
46 * })
47 *
48 * client.getOrganization('<organization_id>')
49 * .then((organization) => organization.getUsers())
50 * .then((user) => console.log(user))
51 * .catch(console.error)
52 * ```
53 */
54 getUsers(query?: QueryOptions): Promise<import("./common-types").Collection<import("./export-types").UserProps & {
55 toPlainObject(): import("./export-types").UserProps;
56 }, import("./export-types").UserProps>>;
57 /**
58 * Gets an Organization Membership
59 * @param id - Organization Membership ID
60 * @return Promise for an Organization Membership
61 * @example ```javascript
62 * const contentful = require('contentful-management')
63 * const client = contentful.createClient({
64 * accessToken: '<content_management_api_key>'
65 * })
66 *
67 * client.getOrganization('organization_id')
68 * .then((organization) => organization.getOrganizationMembership('organizationMembership_id'))
69 * .then((organizationMembership) => console.log(organizationMembership))
70 * .catch(console.error)
71 * ```
72 */
73 getOrganizationMembership(id: string): Promise<import("./export-types").OrganizationMembership>;
74 /**
75 * Gets a collection of Organization Memberships
76 * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
77 * @return Promise for a collection of Organization Memberships
78 * @example ```javascript
79 * const contentful = require('contentful-management')
80 * const client = contentful.createClient({
81 * accessToken: '<content_management_api_key>'
82 * })
83 *
84 * client.getOrganization('organization_id')
85 * .then((organization) => organization.getOrganizationMemberships({'limit': 100})) // you can add more queries as 'key': 'value'
86 * .then((response) => console.log(response.items))
87 * .catch(console.error)
88 * ```
89 */
90 getOrganizationMemberships(query?: QueryOptions): Promise<import("./common-types").Collection<import("./export-types").OrganizationMembership, import("./export-types").OrganizationMembershipProps>>;
91 /**
92 * Creates a Team
93 * @param data representation of the Team to be created
94 * @example ```javascript
95 * const contentful = require('contentful-management')
96 * const client = contentful.createClient({
97 * accessToken: '<content_management_api_key>'
98 * })
99 *
100 * client.getOrganization('<org_id>')
101 * .then((org) => org.createTeam({
102 * name: 'new team',
103 * description: 'new team description'
104 * }))
105 * .then((team) => console.log(team))
106 * .catch(console.error)
107 * ```
108 */
109 createTeam(data: CreateTeamProps): Promise<import("./entities/team").Team>;
110 /**
111 * Gets an Team
112 * @example ```javascript
113 * const contentful = require('contentful-management')
114 * const client = contentful.createClient({
115 * accessToken: '<content_management_api_key>'
116 * })
117 *
118 * client.getOrganization('orgId')
119 * .then((organization) => organization.getTeam('teamId'))
120 * .then((team) => console.log(team))
121 * .catch(console.error)
122 * ```
123 */
124 getTeam(teamId: string): Promise<import("./entities/team").Team>;
125 /**
126 * Gets all Teams in an organization
127 * @example ```javascript
128 * const contentful = require('contentful-management')
129 * const client = contentful.createClient({
130 * accessToken: '<content_management_api_key>'
131 * })
132 *
133 * client.getOrganization('orgId')
134 * .then((organization) => organization.getTeams())
135 * .then((teams) => console.log(teams))
136 * .catch(console.error)
137 * ```
138 */
139 getTeams(query?: QueryOptions): Promise<import("./common-types").Collection<import("./entities/team").Team, import("./entities/team").TeamProps>>;
140 /**
141 * Creates a Team membership
142 * @param teamId - Id of the team the membership will be created in
143 * @param data - Object representation of the Team Membership to be created
144 * @return Promise for the newly created TeamMembership
145 * @example ```javascript
146 * const contentful = require('contentful-management')
147 * const client = contentful.createClient({
148 * accessToken: '<content_management_api_key>'
149 * })
150 *
151 * client.getOrganization('organizationId')
152 * .then((org) => org.createTeamMembership('teamId', {
153 * admin: true,
154 * organizationMembershipId: 'organizationMembershipId'
155 * }))
156 * .then((teamMembership) => console.log(teamMembership))
157 * .catch(console.error)
158 * ```
159 */
160 createTeamMembership(teamId: string, data: CreateTeamMembershipProps): Promise<import("./entities/team-membership").TeamMembership>;
161 /**
162 * Gets an Team Membership from the team with given teamId
163 * @return Promise for an Team Membership
164 * @example ```javascript
165 * const contentful = require('contentful-management')
166 * const client = contentful.createClient({
167 * accessToken: '<content_management_api_key>'
168 * })
169 *
170 * client.getOrganization('organizationId')
171 * .then((organization) => organization.getTeamMembership('teamId', 'teamMembership_id'))
172 * .then((teamMembership) => console.log(teamMembership))
173 * .catch(console.error)
174 * ```
175 */
176 getTeamMembership(teamId: string, teamMembershipId: string): Promise<import("./entities/team-membership").TeamMembership>;
177 /**
178 * Get all Team Memberships. If teamID is provided in the optional config object, it will return all Team Memberships in that team. By default, returns all team memberships for the organization.
179 * @return Promise for a Team Membership Collection
180 * @example ```javascript
181 * const contentful = require('contentful-management')
182 * const client = contentful.createClient({
183 * accessToken: '<content_management_api_key>'
184 * })
185 *
186 * client.getOrganization('organizationId')
187 * .then((organization) => organization.getTeamMemberships('teamId'))
188 * .then((teamMemberships) => console.log(teamMemberships))
189 * .catch(console.error)
190 * ```
191 */
192 getTeamMemberships(opts?: {
193 teamId?: string;
194 query?: QueryOptions;
195 }): Promise<import("./common-types").Collection<import("./entities/team-membership").TeamMembership, import("./entities/team-membership").TeamMembershipProps>>;
196 /**
197 * Get all Team Space Memberships. If teamID is provided in the optional config object, it will return all Team Space Memberships in that team. By default, returns all team space memberships across all teams in the organization.
198 * @return Promise for a Team Space Membership Collection
199 * @example ```javascript
200 * const contentful = require('contentful-management')
201 * const client = contentful.createClient({
202 * accessToken: '<content_management_api_key>'
203 * })
204 *
205 * client.getOrganization('organizationId')
206 * .then((organization) => organization.getTeamSpaceMemberships('teamId'))
207 * .then((teamSpaceMemberships) => console.log(teamSpaceMemberships))
208 * .catch(console.error)
209 * ```
210 */
211 getTeamSpaceMemberships(opts?: {
212 teamId?: string;
213 query?: QueryOptions;
214 }): Promise<import("./common-types").Collection<import("./export-types").TeamSpaceMembership, import("./export-types").TeamSpaceMembershipProps>>;
215 /**
216 * Get a Team Space Membership with given teamSpaceMembershipId
217 * @return Promise for a Team Space Membership
218 * @example ```javascript
219 * const contentful = require('contentful-management')
220 * const client = contentful.createClient({
221 * accessToken: '<content_management_api_key>'
222 * })
223 *
224 * client.getOrganization('organizationId')
225 * .then((organization) => organization.getTeamSpaceMembership('teamSpaceMembershipId'))
226 * .then((teamSpaceMembership) => console.log(teamSpaceMembership))
227 * .catch(console.error)]
228 * ```
229 */
230 getTeamSpaceMembership(teamSpaceMembershipId: string): Promise<import("./export-types").TeamSpaceMembership>;
231 /**
232 * Gets an Space Membership in Organization
233 * @param id - Organiztion Space Membership ID
234 * @return Promise for a Space Membership in an organization
235 * @example ```javascript
236 * const contentful = require('contentful-management')
237 * const client = contentful.createClient({
238 * accessToken: '<content_management_api_key>'
239 * })
240 *
241 * client.getOrganization('organization_id')
242 * .then((organization) => organization.getOrganizationSpaceMembership('organizationSpaceMembership_id'))
243 * .then((organizationMembership) => console.log(organizationMembership))
244 * .catch(console.error)
245 * ```
246 */
247 getOrganizationSpaceMembership(id: string): Promise<import("./export-types").SpaceMembership>;
248 /**
249 * Gets a collection Space Memberships in organization
250 * @param query - Object with search parameters. Check the <a href="https://www.contentful.com/developers/docs/javascript/tutorials/using-js-cda-sdk/#retrieving-entries-with-search-parameters">JS SDK tutorial</a> and the <a href="https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/search-parameters">REST API reference</a> for more details.
251 * @return Promise for a Space Membership collection across all spaces in the organization
252 * @example ```javascript
253 * const contentful = require('contentful-management')
254 * const client = contentful.createClient({
255 * accessToken: '<content_management_api_key>'
256 * })
257 *
258 * client.getOrganization('organization_id')
259 * .then((organization) => organization.getOrganizationSpaceMemberships()) // you can add queries like 'limit': 100
260 * .then((response) => console.log(response.items))
261 * .catch(console.error)
262 * ```
263 */
264 getOrganizationSpaceMemberships(query?: QueryOptions): Promise<import("./common-types").Collection<import("./export-types").SpaceMembership, import("./export-types").SpaceMembershipProps>>;
265 /**
266 * Gets an Invitation in Organization
267 * @return Promise for a OrganizationInvitation in an organization
268 * @example ```javascript
269 * const contentful = require('contentful-management')
270 * const client = contentful.createClient({
271 * accessToken: '<content_management_api_key>'
272 * })
273 *
274 * client.getOrganization('<org_id>')
275 * .then((organization) => organization.getOrganizationInvitation('invitation_id'))
276 * .then((invitation) => console.log(invitation))
277 * .catch(console.error)
278 * ```
279 */
280 getOrganizationInvitation(invitationId: string): Promise<import("./entities/organization-invitation").OrganizationInvitation>;
281 /**
282 * Create an Invitation in Organization
283 * @return Promise for a OrganizationInvitation in an organization
284 * @example ```javascript
285 * const contentful = require('contentful-management')
286 * const client = contentful.createClient({
287 * accessToken: '<content_management_api_key>'
288 * })
289 *
290 * client.getOrganization('<org_id>')
291 * .then((organization) => organization.createOrganizationInvitation({
292 * email: 'user.email@example.com'
293 * firstName: 'User First Name'
294 * lastName: 'User Last Name'
295 * role: 'developer'
296 * })
297 * .catch(console.error)
298 * ```
299 */
300 createOrganizationInvitation(data: CreateOrganizationInvitationProps): Promise<import("./entities/organization-invitation").OrganizationInvitation>;
301 /**
302 * Creates an app definition
303 * @param Object representation of the App Definition to be created
304 * @return Promise for the newly created AppDefinition
305 * @example ```javascript
306 * const contentful = require('contentful-management')
307 * const client = contentful.createClient({
308 * accessToken: '<content_management_api_key>'
309 * })
310 *
311 * client.getOrganization('<org_id>')
312 * .then((org) => org.createAppDefinition({
313 * name: 'Example app',
314 * locations: [{ location: 'app-config' }],
315 * src: "http://my-app-host.com/my-app"
316 * }))
317 * .then((appDefinition) => console.log(appDefinition))
318 * .catch(console.error)
319 * ```
320 */
321 createAppDefinition(data: CreateAppDefinitionProps): Promise<import("./entities/app-definition").AppDefinition>;
322 /**
323 * Gets all app definitions
324 * @return Promise for a collection of App Definitions
325 * @example ```javascript
326 * const contentful = require('contentful-management')
327 * const client = contentful.createClient({
328 * accessToken: '<content_management_api_key>'
329 * })
330 *
331 * client.getOrganization('<org_id>')
332 * .then((org) => org.getAppDefinitions())
333 * .then((response) => console.log(response.items))
334 * .catch(console.error)
335 * ```
336 */
337 getAppDefinitions(query?: QueryOptions): Promise<import("./common-types").Collection<import("./entities/app-definition").AppDefinition, import("./entities/app-definition").AppDefinitionProps>>;
338 /**
339 * Gets an app definition
340 * @return Promise for an App Definition
341 * @example ```javascript
342 * const contentful = require('contentful-management')
343 * const client = contentful.createClient({
344 * accessToken: '<content_management_api_key>'
345 * })
346 *
347 * client.getOrganization('<org_id>')
348 * .then((org) => org.getAppDefinition('<app_definition_id>'))
349 * .then((appDefinition) => console.log(appDefinition))
350 * .catch(console.error)
351 * ```
352 */
353 getAppDefinition(id: string): Promise<import("./entities/app-definition").AppDefinition>;
354 /**
355 * Gets an app upload
356 * @return Promise for an App Upload
357 * @example ```javascript
358 * const contentful = require('contentful-management')
359 * const client = contentful.createClient({
360 * accessToken: '<content_management_api_key>'
361 * })
362 *
363 * client.getOrganization('<org_id>')
364 * .then((org) => org.getAppUpload('<app_upload_id>'))
365 * .then((appUpload) => console.log(appUpload))
366 * .catch(console.error)
367 * ```
368 */
369 getAppUpload(appUploadId: string): Promise<import("./export-types").AppUpload>;
370 /**
371 * Creates an app upload
372 * @return Promise for an App Upload
373 * @example ```javascript
374 * const contentful = require('contentful-management')
375 * const client = contentful.createClient({
376 * accessToken: '<content_management_api_key>'
377 * })
378 *
379 * client.getOrganization('<org_id>')
380 * .then((org) => org.createAppUpload('some_zip_file'))
381 * .then((appUpload) => console.log(appUpload))
382 * .catch(console.error)
383 * ```
384 */
385 createAppUpload(file: string | ArrayBuffer | Stream): Promise<import("./export-types").AppUpload>;
386 /**
387 * Creates or updates an app signing secret
388 * @return Promise for an App SigningSecret
389 * @example ```javascript
390 * const contentful = require('contentful-management')
391 * const client = contentful.createClient({
392 * accessToken: '<content_management_api_key>'
393 * })
394 *
395 * client.getOrganization('<org_id>')
396 * .then((org) => org.upsertAppSigningSecret('app_definition_id', { value: 'tsren3s1....wn1e' }))
397 * .then((appSigningSecret) => console.log(appSigningSecret))
398 * .catch(console.error)
399 * ```
400 */
401 upsertAppSigningSecret(appDefinitionId: string, data: CreateAppSigningSecretProps): Promise<import("./entities/app-signing-secret").AppSigningSecret>;
402 /**
403 * Gets an app signing secret
404 * @return Promise for an App SigningSecret
405 * @example ```javascript
406 * const contentful = require('contentful-management')
407 * const client = contentful.createClient({
408 * accessToken: '<content_management_api_key>'
409 * })
410 *
411 * client.getOrganization('<org_id>')
412 * .then((org) => org.getAppSigningSecret('app_definition_id'))
413 * .then((appSigningSecret) => console.log(appSigningSecret))
414 * .catch(console.error)
415 * ```
416 */
417 getAppSigningSecret(appDefinitionId: string): Promise<import("./entities/app-signing-secret").AppSigningSecret>;
418 /**
419 * Deletes an app signing secret
420 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
421 * @example ```javascript
422 * const contentful = require('contentful-management')
423 * const client = contentful.createClient({
424 * accessToken: '<content_management_api_key>'
425 * })
426 *
427 * client.getOrganization('<org_id>')
428 * .then((org) => org.deleteAppSigningSecret('app_definition_id'))
429 * .then((result) => console.log(result))
430 * .catch(console.error)
431 * ```
432 */
433 deleteAppSigningSecret(appDefinitionId: string): Promise<void>;
434 /**
435 * Creates or updates an app details entity
436 * @return Promise for an App Details
437 * @example ```javascript
438 * const contentful = require('contentful-management')
439 * const client = contentful.createClient({
440 * accessToken: '<content_management_api_key>'
441 * })
442 *
443 * client.getOrganization('<org_id>')
444 * .then((org) => org.upsertAppDetails('app_definition_id',
445 * { icon: { value: 'base_64_image', type: 'base64' }}
446 * ))
447 * .then((appDetails) => console.log(appDetails))
448 * .catch(console.error)
449 * ```
450 */
451 upsertAppDetails(appDefinitionId: string, data: CreateAppDetailsProps): Promise<import("./entities/app-details").AppDetails>;
452 /**
453 * Gets an app details entity
454 * @return Promise for an App Details
455 * @example ```javascript
456 * const contentful = require('contentful-management')
457 * const client = contentful.createClient({
458 * accessToken: '<content_management_api_key>'
459 * })
460 *
461 * client.getOrganization('<org_id>')
462 * .then((org) => org.getAppDetails('app_definition_id'))
463 * .then((appDetails) => console.log(appDetails))
464 * .catch(console.error)
465 * ```
466 */
467 getAppDetails(appDefinitionId: string): Promise<import("./entities/app-details").AppDetails>;
468 /**
469 * Deletes an app details entity.
470 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
471 * @example ```javascript
472 * const contentful = require('contentful-management')
473 * const client = contentful.createClient({
474 * accessToken: '<content_management_api_key>'
475 * })
476 *
477 * client.getOrganization('<org_id>')
478 * .then((org) => org.deleteAppDetails('app_definition_id'))
479 * .then((result) => console.log(result))
480 * .catch(console.error)
481 * ```
482 */
483 deleteAppDetails(appDefinitionId: string): Promise<void>;
484};