import type { Stream } from 'stream'; import type { CreateTeamMembershipProps } from './entities/team-membership'; import type { CreateTeamProps } from './entities/team'; import type { CreateOrganizationInvitationProps } from './entities/organization-invitation'; import type { BasicQueryOptions, MakeRequest, QueryOptions, QueryParams } from './common-types'; import type { CreateAppDefinitionProps } from './entities/app-definition'; import type { CreateAppActionProps } from './entities/app-action'; import type { CreateAppSigningSecretProps } from './entities/app-signing-secret'; import type { CreateAppEventSubscriptionProps } from './entities/app-event-subscription'; import type { CreateAppKeyProps } from './entities/app-key'; import type { CreateAppDetailsProps } from './entities/app-details'; /** * @private */ export type ContentfulOrganizationAPI = ReturnType; /** * Creates API object with methods to access the Organization API * @param {MakeRequest} makeRequest - function to make requests via an adapter * @return {ContentfulOrganizationAPI} * @private */ export default function createOrganizationApi(makeRequest: MakeRequest): { /** * Gets a collection of spaces in the organization * @param query - Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. * @return Promise a collection of Spaces in the organization * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((organization) => organization.getSpaces()) * .then((spaces) => console.log(spaces)) * .catch(console.error) * ``` */ getSpaces(query?: QueryOptions): Promise>; /** * Gets a User * @return Promise for a User * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((organization) => organization.getUser('id')) * .then((user) => console.log(user)) * .catch(console.error) * ``` */ getUser(id: string): Promise; /** * Gets a collection of Users in organization * @param query - Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. * @return Promise a collection of Users in organization * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((organization) => organization.getUsers()) * .then((users) => console.log(users)) * .catch(console.error) * ``` */ getUsers(query?: QueryOptions): Promise>; /** * Gets an Organization Membership * @param id - Organization Membership ID * @return Promise for an Organization Membership * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organization_id') * .then((organization) => organization.getOrganizationMembership('organizationMembership_id')) * .then((organizationMembership) => console.log(organizationMembership)) * .catch(console.error) * ``` */ getOrganizationMembership(id: string): Promise; /** * Gets a collection of Organization Memberships * @param params - Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. * @return Promise for a collection of Organization Memberships * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organization_id') * .then((organization) => organization.getOrganizationMemberships({'limit': 100})) // you can add more queries as 'key': 'value' * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getOrganizationMemberships(params?: QueryParams): Promise>; /** * Creates a Team * @param data representation of the Team to be created * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.createTeam({ * name: 'new team', * description: 'new team description' * })) * .then((team) => console.log(team)) * .catch(console.error) * ``` */ createTeam(data: CreateTeamProps): Promise; /** * Gets an Team * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('orgId') * .then((organization) => organization.getTeam('teamId')) * .then((team) => console.log(team)) * .catch(console.error) * ``` */ getTeam(teamId: string): Promise; /** * Gets all Teams in an organization * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('orgId') * .then((organization) => organization.getTeams()) * .then((teams) => console.log(teams)) * .catch(console.error) * ``` */ getTeams(query?: QueryOptions): Promise>; /** * Creates a Team membership * @param teamId - Id of the team the membership will be created in * @param data - Object representation of the Team Membership to be created * @return Promise for the newly created TeamMembership * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organizationId') * .then((org) => org.createTeamMembership('teamId', { * admin: true, * organizationMembershipId: 'organizationMembershipId' * })) * .then((teamMembership) => console.log(teamMembership)) * .catch(console.error) * ``` */ createTeamMembership(teamId: string, data: CreateTeamMembershipProps): Promise; /** * Gets an Team Membership from the team with given teamId * @return Promise for an Team Membership * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organizationId') * .then((organization) => organization.getTeamMembership('teamId', 'teamMembership_id')) * .then((teamMembership) => console.log(teamMembership)) * .catch(console.error) * ``` */ getTeamMembership(teamId: string, teamMembershipId: string): Promise; /** * 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. * @return Promise for a Team Membership Collection * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organizationId') * .then((organization) => organization.getTeamMemberships('teamId')) * .then((teamMemberships) => console.log(teamMemberships)) * .catch(console.error) * ``` */ getTeamMemberships(opts?: { teamId?: string; query?: QueryOptions; }): Promise>; /** * 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. * @return Promise for a Team Space Membership Collection * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organizationId') * .then((organization) => organization.getTeamSpaceMemberships('teamId')) * .then((teamSpaceMemberships) => console.log(teamSpaceMemberships)) * .catch(console.error) * ``` */ getTeamSpaceMemberships(opts?: { teamId?: string; query?: QueryOptions; }): Promise>; /** * Get a Team Space Membership with given teamSpaceMembershipId * @return Promise for a Team Space Membership * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organizationId') * .then((organization) => organization.getTeamSpaceMembership('teamSpaceMembershipId')) * .then((teamSpaceMembership) => console.log(teamSpaceMembership)) * .catch(console.error)] * ``` */ getTeamSpaceMembership(teamSpaceMembershipId: string): Promise; /** * Gets an Space Membership in Organization * @param id - Organiztion Space Membership ID * @return Promise for a Space Membership in an organization * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organization_id') * .then((organization) => organization.getOrganizationSpaceMembership('organizationSpaceMembership_id')) * .then((organizationMembership) => console.log(organizationMembership)) * .catch(console.error) * ``` */ getOrganizationSpaceMembership(id: string): Promise; /** * Gets a collection Space Memberships in organization * @param query - Object with search parameters. Check the JS SDK tutorial and the REST API reference for more details. * @return Promise for a Space Membership collection across all spaces in the organization * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('organization_id') * .then((organization) => organization.getOrganizationSpaceMemberships()) // you can add queries like 'limit': 100 * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getOrganizationSpaceMemberships(query?: QueryOptions): Promise>; /** * Gets an Invitation in Organization * @return Promise for a OrganizationInvitation in an organization * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((organization) => organization.getOrganizationInvitation('invitation_id')) * .then((invitation) => console.log(invitation)) * .catch(console.error) * ``` */ getOrganizationInvitation(invitationId: string): Promise; /** * Create an Invitation in Organization * @return Promise for a OrganizationInvitation in an organization * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((organization) => organization.createOrganizationInvitation({ * email: 'user.email@example.com' * firstName: 'User First Name' * lastName: 'User Last Name' * role: 'developer' * }) * .catch(console.error) * ``` */ createOrganizationInvitation(data: CreateOrganizationInvitationProps): Promise; /** * Gets a collection of Roles * @return Promise for a collection of Roles * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getRoles()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getRoles(query?: QueryOptions): Promise>; /** * Creates an app definition * @param Object representation of the App Definition to be created * @return Promise for the newly created AppDefinition * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.createAppDefinition({ * name: 'Example app', * locations: [{ location: 'app-config' }], * src: "http://my-app-host.com/my-app" * })) * .then((appDefinition) => console.log(appDefinition)) * .catch(console.error) * ``` */ createAppDefinition(data: CreateAppDefinitionProps): Promise; /** * Gets all app definitions * @return Promise for a collection of App Definitions * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDefinitions()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getAppDefinitions(query?: QueryOptions): Promise>; /** * Gets an app definition * @return Promise for an App Definition * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDefinition('')) * .then((appDefinition) => console.log(appDefinition)) * .catch(console.error) * ``` */ getAppDefinition(id: string): Promise; /** * Gets an app upload * @return Promise for an App Upload * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppUpload('')) * .then((appUpload) => console.log(appUpload)) * .catch(console.error) * ``` */ getAppUpload(appUploadId: string): Promise; /** * Creates an app upload * @return Promise for an App Upload * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.createAppUpload('some_zip_file')) * .then((appUpload) => console.log(appUpload)) * .catch(console.error) * ``` */ createAppUpload(file: string | ArrayBuffer | Stream): Promise; /** * Creates or updates an app signing secret * @return Promise for an App SigningSecret * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.upsertAppSigningSecret('app_definition_id', { value: 'tsren3s1....wn1e' })) * .then((appSigningSecret) => console.log(appSigningSecret)) * .catch(console.error) * ``` */ upsertAppSigningSecret(appDefinitionId: string, data: CreateAppSigningSecretProps): Promise; /** * Gets an app signing secret * @return Promise for an App SigningSecret * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppSigningSecret('app_definition_id')) * .then((appSigningSecret) => console.log(appSigningSecret)) * .catch(console.error) * ``` */ getAppSigningSecret(appDefinitionId: string): Promise; /** * Deletes an app signing secret * @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: '' * }) * * client.getOrganization('') * .then((org) => org.deleteAppSigningSecret('app_definition_id')) * .then((result) => console.log(result)) * .catch(console.error) * ``` */ deleteAppSigningSecret(appDefinitionId: string): Promise; /** * Creates or updates an app event subscription * @return Promise for an App Event Subscription * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.upsertAppEventSubscription('app_definition_id', { targetUrl: '', topics: [''] })) * .then((appEventSubscription) => console.log(appEventSubscription)) * .catch(console.error) * ``` */ upsertAppEventSubscription(appDefinitionId: string, data: CreateAppEventSubscriptionProps): Promise; /** * Gets an app event subscription * @return Promise for an App Event Subscription * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppEventSubscription('app_definition_id')) * .then((appEventSubscription) => console.log(appEventSubscription)) * .catch(console.error) * ``` */ getAppEventSubscription(appDefinitionId: string): Promise; /** * Deletes the current App Event Subscription for the given App * @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: '' * }) * * client.getOrganization('') * .then((org) => org.deleteAppEventSubscription('app_definition_id')) * .then((result) => console.log(result)) * .catch(console.error) * ``` */ deleteAppEventSubscription(appDefinitionId: string): Promise; /** * Creates or updates an app event subscription * @return Promise for an App Event Subscription * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * // generate a new private key * client.getOrganization('') * .then((org) => org.upsertAppEventSubscription('app_definition_id', { generate: true })) * .then((appEventSubscription) => console.log(appEventSubscription)) * .catch(console.error) * * // or use an existing JSON Web Key * client.getOrganization('') * .then((org) => org.upsertAppEventSubscription('app_definition_id', { jwk: 'jwk' })) * .then((appEventSubscription) => console.log(appEventSubscription)) * .catch(console.error) * ``` */ createAppKey(appDefinitionId: string, data: CreateAppKeyProps): Promise; /** * Gets an app key by fingerprint * @return Promise for an App Key * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppKey('app_definition_id', 'fingerprint')) * .then((appKey) => console.log(appKey)) * .catch(console.error) * ``` */ getAppKey(appDefinitionId: string, fingerprint: string): Promise; /** * Gets all keys for the given app * @return Promise for an array of App Keys * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * // with default pagination * client.getOrganization('') * .then((org) => org.getAppKeys('app_definition_id')) * .then((appKeys) => console.log(appKeys)) * .catch(console.error) * * // with explicit pagination * client.getOrganization('') * .then((org) => org.getAppKeys('app_definition_id', { skip: 'skip', limit: 'limit' })) * .then((appKeys) => console.log(appKeys)) * .catch(console.error) * ``` */ getAppKeys(appDefinitionId: string, query?: BasicQueryOptions): Promise>; /** * Deletes an app key by fingerprint. * @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: '' * }) * * client.getOrganization('') * .then((org) => org.deleteAppKey('app_definition_id', 'fingerprint')) * .then((result) => console.log(result)) * .catch(console.error) * ``` */ deleteAppKey(appDefinitionId: string, fingerprint: string): Promise; /** * Creates or updates an app details entity * @return Promise for an App Details * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.upsertAppDetails('app_definition_id', * { icon: { value: 'base_64_image', type: 'base64' }} * )) * .then((appDetails) => console.log(appDetails)) * .catch(console.error) * ``` */ upsertAppDetails(appDefinitionId: string, data: CreateAppDetailsProps): Promise; /** * Gets an app details entity * @return Promise for an App Details * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppDetails('app_definition_id')) * .then((appDetails) => console.log(appDetails)) * .catch(console.error) * ``` */ getAppDetails(appDefinitionId: string): Promise; /** * Deletes an app details entity. * @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: '' * }) * * client.getOrganization('') * .then((org) => org.deleteAppDetails('app_definition_id')) * .then((result) => console.log(result)) * .catch(console.error) * ``` */ deleteAppDetails(appDefinitionId: string): Promise; /** * Creates an app action entity. * @return Promise that resolves an App Action entity * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.createAppAction('app_definition_id', { * type: 'endpoint', * name: 'my nice new app action', * url: 'https://www.somewhere.com/action' * })) * .then((appAction) => console.log(appAction)) * .catch(console.error) * ``` */ createAppAction(appDefinitionId: string, data: CreateAppActionProps): Promise<({ category: "Entries.v1.0" | "Notification.v1.0"; } & { sys: { type: string; id: string; createdBy?: import("./common-types").SysLink | undefined; createdAt: string; updatedBy?: import("./common-types").SysLink | undefined; updatedAt: string; } & { appDefinition: import("./common-types").SysLink; organization: import("./common-types").SysLink; }; url: string; name: string; description?: string; type?: import("./entities/app-action").AppActionType; } & import("./common-types").DefaultElements & { delete(): Promise; }) | ({ category: "Custom"; parameters: import("./entities/app-action").AppActionParameterDefinition[]; } & { sys: { type: string; id: string; createdBy?: import("./common-types").SysLink | undefined; createdAt: string; updatedBy?: import("./common-types").SysLink | undefined; updatedAt: string; } & { appDefinition: import("./common-types").SysLink; organization: import("./common-types").SysLink; }; url: string; name: string; description?: string; type?: import("./entities/app-action").AppActionType; } & import("./common-types").DefaultElements & { delete(): Promise; })>; /** * Updates an existing app action entity. * @return Promise that resolves an App Action entity * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.updateAppAction('app_definition_id', 'app_action_id', { * type: 'endpoint', * name: 'my nice updated app action', * url: 'https://www.somewhere-else.com/action' * })) * .then((appAction) => console.log(appAction)) * .catch(console.error) * ``` */ updateAppAction(appDefinitionId: string, appActionId: string, data: CreateAppActionProps): Promise<({ category: "Entries.v1.0" | "Notification.v1.0"; } & { sys: { type: string; id: string; createdBy?: import("./common-types").SysLink | undefined; createdAt: string; updatedBy?: import("./common-types").SysLink | undefined; updatedAt: string; } & { appDefinition: import("./common-types").SysLink; organization: import("./common-types").SysLink; }; url: string; name: string; description?: string; type?: import("./entities/app-action").AppActionType; } & import("./common-types").DefaultElements & { delete(): Promise; }) | ({ category: "Custom"; parameters: import("./entities/app-action").AppActionParameterDefinition[]; } & { sys: { type: string; id: string; createdBy?: import("./common-types").SysLink | undefined; createdAt: string; updatedBy?: import("./common-types").SysLink | undefined; updatedAt: string; } & { appDefinition: import("./common-types").SysLink; organization: import("./common-types").SysLink; }; url: string; name: string; description?: string; type?: import("./entities/app-action").AppActionType; } & import("./common-types").DefaultElements & { delete(): Promise; })>; /** * Deletes an app action entity. * @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: '' * }) * * client.getOrganization('') * .then((org) => org.deleteAppAction('app_definition_id', 'app_action_id')) * .then((result) => console.log(result)) * .catch(console.error) * ``` */ deleteAppAction(appDefinitionId: string, appActionId: string): Promise; /** * Gets an existing app action entity. * @return Promise that resolves an App Action entity * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppAction('app_definition_id', 'app_action_id')) * .then((appAction) => console.log(appAction)) * .catch(console.error) * ``` */ getAppAction(appDefinitionId: string, appActionId: string): Promise<({ category: "Entries.v1.0" | "Notification.v1.0"; } & { sys: { type: string; id: string; createdBy?: import("./common-types").SysLink | undefined; createdAt: string; updatedBy?: import("./common-types").SysLink | undefined; updatedAt: string; } & { appDefinition: import("./common-types").SysLink; organization: import("./common-types").SysLink; }; url: string; name: string; description?: string; type?: import("./entities/app-action").AppActionType; } & import("./common-types").DefaultElements & { delete(): Promise; }) | ({ category: "Custom"; parameters: import("./entities/app-action").AppActionParameterDefinition[]; } & { sys: { type: string; id: string; createdBy?: import("./common-types").SysLink | undefined; createdAt: string; updatedBy?: import("./common-types").SysLink | undefined; updatedAt: string; } & { appDefinition: import("./common-types").SysLink; organization: import("./common-types").SysLink; }; url: string; name: string; description?: string; type?: import("./entities/app-action").AppActionType; } & import("./common-types").DefaultElements & { delete(): Promise; })>; /** * Gets existing app actions for an App Definition. * @return Promise that resolves an App Action entity * @example ```javascript * const contentful = require('contentful-management') * const client = contentful.createClient({ * accessToken: '' * }) * * client.getOrganization('') * .then((org) => org.getAppActions('app_definition_id')) * .then((appActions) => console.log(appActions)) * .catch(console.error) * ``` */ getAppActions(appDefinitionId: string): Promise>; };