UNPKG

contentful-management

Version:
1,151 lines (1,150 loc) 44.2 kB
/** * Contentful Space API. Contains methods to access any operations at a space * level, such as creating and reading entities contained in a space. */ import type { MakeRequest, PaginationQueryOptions, QueryOptions } from './common-types'; import type { CreateApiKeyProps } from './entities/api-key'; import type { CreateEnvironmentProps } from './entities/environment'; import type { CreateEnvironmentAliasProps } from './entities/environment-alias'; import type { CreateRoleProps, RoleProps } from './entities/role'; import type { ScheduledActionProps, ScheduledActionQueryOptions } from './entities/scheduled-action'; import type { CreateSpaceMembershipProps } from './entities/space-membership'; import type { CreateTeamSpaceMembershipProps } from './entities/team-space-membership'; import type { CreateWebhooksProps, UpsertWebhookSigningSecretPayload, WebhookRetryPolicyPayload } from './entities/webhook'; import type { AiActionProps, AiActionQueryOptions, CreateAiActionProps } from './entities/ai-action'; /** * @private */ export type ContentfulSpaceAPI = ReturnType<typeof createSpaceApi>; /** * Creates API object with methods to access the Space API * @param {MakeRequest} makeRequest - function to make requests via an adapter * @return {ContentfulSpaceAPI} * @private */ export default function createSpaceApi(makeRequest: MakeRequest): { /** * Deletes the space * @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.getSpace('<space_id>') * .then((space) => space.delete()) * .then(() => console.log('Space deleted.')) * .catch(console.error) * ``` */ delete: () => Promise<void>; /** * Updates the space * @return Promise for the updated space. * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => { * space.name = 'New name' * return space.update() * }) * .then((space) => console.log(`Space ${space.sys.id} renamed.`) * .catch(console.error) * ``` */ update: () => Promise<import("./entities/space").Space>; /** * Gets an environment * @param id - Environment ID * @return Promise for an Environment * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getEnvironment('<environment_id>')) * .then((environment) => console.log(environment)) * .catch(console.error) * ``` */ getEnvironment(environmentId: string): Promise<import("./entities/environment").Environment>; /** * Gets a collection of Environments * @return Promise for a collection of Environment * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getEnvironments()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getEnvironments(query?: PaginationQueryOptions): Promise<import("./common-types").Collection<import("./entities/environment").Environment, import("./entities/environment").EnvironmentProps>>; /** * Creates an environment * @param data - Object representation of the Environment to be created * @return Promise for the newly created Environment * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createEnvironment({ name: 'Staging' })) * .then((environment) => console.log(environment)) * .catch(console.error) * ``` */ createEnvironment(data?: CreateEnvironmentProps): Promise<import("./entities/environment").Environment>; /** * Creates an Environment with a custom ID * @param id - Environment ID * @param data - Object representation of the Environment to be created * @param sourceEnvironmentId - ID of the source environment that will be copied to create the new environment. Default is "master" * @return Promise for the newly created Environment * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createEnvironmentWithId('<environment-id>', { name: 'Staging'}, 'master')) * .then((environment) => console.log(environment)) * .catch(console.error) * ``` */ createEnvironmentWithId(id: string, data: CreateEnvironmentProps, sourceEnvironmentId?: string): Promise<import("./entities/environment").Environment>; /** * Gets a Webhook * @param id - Webhook ID * @return Promise for a Webhook * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getWebhook('<webhook_id>')) * .then((webhook) => console.log(webhook)) * .catch(console.error) * ``` */ getWebhook(id: string): Promise<import("./entities/webhook").WebHooks>; /** * Gets a collection of Webhooks * @return Promise for a collection of Webhooks * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getWebhooks()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getWebhooks(): Promise<import("./common-types").Collection<import("./entities/webhook").WebHooks, import("./entities/webhook").WebhookProps>>; /** * Fetch a webhook signing secret * @returns Promise for the redacted webhook signing secret in this space * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getWebhookSigningSecret()) * .then((response) => console.log(response.redactedValue)) * .catch(console.error) * ``` */ getWebhookSigningSecret: () => Promise<import("./entities/webhook").WebhookSigningSecretProps>; /** * Fetch a webhook retry policy * @returns Promise for the redacted webhook retry policy in this space * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getRetryPolicy()) * .then((response) => console.log(response.redactedValue)) * .catch(console.error) * ``` */ getWebhookRetryPolicy: () => Promise<import("./entities/webhook").WebhookRetryPolicyProps>; /** * Creates a Webhook * @param data - Object representation of the Webhook to be created * @return Promise for the newly created Webhook * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.createWebhook({ * 'name': 'My webhook', * 'url': 'https://www.example.com/test', * 'topics': [ * 'Entry.create', * 'ContentType.create', * '*.publish', * 'Asset.*' * ] * })) * .then((webhook) => console.log(webhook)) * .catch(console.error) * ``` */ createWebhook(data: CreateWebhooksProps): Promise<import("./entities/webhook").WebHooks>; /** * Creates a Webhook with a custom ID * @param id - Webhook ID * @param data - Object representation of the Webhook to be created * @return Promise for the newly created Webhook * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.createWebhookWithId('<webhook_id>', { * 'name': 'My webhook', * 'url': 'https://www.example.com/test', * 'topics': [ * 'Entry.create', * 'ContentType.create', * '*.publish', * 'Asset.*' * ] * })) * .then((webhook) => console.log(webhook)) * .catch(console.error) * ``` */ createWebhookWithId(id: string, data: CreateWebhooksProps): Promise<import("./entities/webhook").WebHooks>; /** * Create or update the webhook signing secret for this space * @param data 64 character string that will be used to sign the webhook calls * @returns Promise for the redacted webhook signing secret that was created or updated * @example ```javascript * const contentful = require('contentful-management') * const crypto = require('crypto') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * const signingSecret = client.getSpace('<space_id>') * .then((space) => space.upsertWebhookSigningSecret({ * value: crypto.randomBytes(32).toString('hex') * })) * .then((response) => console.log(response.redactedValue)) * .catch(console.error) * ``` */ upsertWebhookSigningSecret: (data: UpsertWebhookSigningSecretPayload) => Promise<import("./entities/webhook").WebhookSigningSecretProps>; /** * Create or update the webhook retry policy for this space * @param data the maxRetries with integer value >= 2 and <= 99 value to set in the Retry Policy * @returns Promise for the redacted webhook retry policy that was created or updated * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * const retryPolicy = client.getSpace('<space_id>') * .then((space) => space.upsertWebhookRetryPolicy({ * maxRetries: 15 * })) * .then((response) => console.log(response.redactedValue)) * .catch(console.error) * ``` */ upsertWebhookRetryPolicy: (data: WebhookRetryPolicyPayload) => Promise<import("./entities/webhook").WebhookRetryPolicyProps>; /** * Delete the webhook signing secret for this space * @returns Promise<void> * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.deleteWebhookSigningSecret()) * .then(() => console.log("success")) * .catch(console.error) * ``` */ deleteWebhookSigningSecret: () => Promise<void>; /** * Delete the webhook retry policy for this space * @returns Promise<void> * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.deleteWebhookRetryPolicy()) * .then(() => console.log("success")) * .catch(console.error) * ``` */ deleteWebhookRetryPolicy: () => Promise<void>; /** * Gets a Role * @param id - Role ID * @return Promise for a Role * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createRole({ * fields: { * title: { * 'en-US': 'Role title' * } * } * })) * .then((role) => console.log(role)) * .catch(console.error) * ``` */ getRole(id: string): Promise<import("./entities/role").Role>; /** * Gets a collection of Roles * @return Promise for a collection of Roles * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getRoles()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getRoles(query?: QueryOptions): Promise<import("./common-types").Collection<import("./entities/role").Role, RoleProps>>; /** * Creates a Role * @param data - Object representation of the Role to be created * @return Promise for the newly created Role * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * client.getSpace('<space_id>') * .then((space) => space.createRole({ * name: 'My Role', * description: 'foobar role', * permissions: { * ContentDelivery: 'all', * ContentModel: ['read'], * Settings: [] * }, * policies: [ * { * effect: 'allow', * actions: 'all', * constraint: { * and: [ * { * equals: [ * { doc: 'sys.type' }, * 'Entry' * ] * }, * { * equals: [ * { doc: 'sys.type' }, * 'Asset' * ] * } * ] * } * } * ] * })) * .then((role) => console.log(role)) * .catch(console.error) * ``` */ createRole(data: CreateRoleProps): Promise<import("./entities/role").Role>; /** * Creates a Role with a custom ID * @param id - Role ID * @param data - Object representation of the Role to be created * @return Promise for the newly created Role * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * client.getSpace('<space_id>') * .then((space) => space.createRoleWithId('<role-id>', { * name: 'My Role', * description: 'foobar role', * permissions: { * ContentDelivery: 'all', * ContentModel: ['read'], * Settings: [] * }, * policies: [ * { * effect: 'allow', * actions: 'all', * constraint: { * and: [ * { * equals: [ * { doc: 'sys.type' }, * 'Entry' * ] * }, * { * equals: [ * { doc: 'sys.type' }, * 'Asset' * ] * } * ] * } * } * ] * })) * .then((role) => console.log(role)) * .catch(console.error) * ``` */ createRoleWithId(id: string, roleData: Omit<RoleProps, "sys">): Promise<import("./entities/role").Role>; /** * Gets a User * @param userId - User ID * @return Promise for a User * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getSpaceUser('id')) * .then((user) => console.log(user)) * .catch(console.error) * ``` */ getSpaceUser(userId: string): Promise<import("./export-types").UserProps & { toPlainObject(): import("./export-types").UserProps; }>; /** * Gets a collection of Users in a space * @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. * @return Promise a collection of Users in a space * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getSpaceUsers(query)) * .then((data) => console.log(data)) * .catch(console.error) * ``` */ getSpaceUsers(query?: QueryOptions): Promise<import("./common-types").Collection<import("./export-types").UserProps & { toPlainObject(): import("./export-types").UserProps; }, import("./export-types").UserProps>>; /** * Gets a collection of teams for a space * @param query * @return Promise for a collection of teams for a space * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getTeams()) * .then((teamsCollection) => console.log(teamsCollection)) * .catch(console.error) * ``` */ getTeams(query?: QueryOptions): Promise<import("./common-types").Collection<import("./export-types").Team, import("./export-types").TeamProps>>; /** * Gets a Space Member * @param id Get Space Member by user_id * @return Promise for a Space Member * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getSpaceMember(id)) * .then((spaceMember) => console.log(spaceMember)) * .catch(console.error) * ``` */ getSpaceMember(id: string): Promise<import("./export-types").SpaceMemberProps & { toPlainObject(): import("./export-types").SpaceMemberProps; }>; /** * Gets a collection of Space Members * @param query * @return Promise for a collection of Space Members * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getSpaceMembers({'limit': 100})) * .then((spaceMemberCollection) => console.log(spaceMemberCollection)) * .catch(console.error) * ``` */ getSpaceMembers(query?: QueryOptions): Promise<import("./common-types").Collection<import("./export-types").SpaceMemberProps & { toPlainObject(): import("./export-types").SpaceMemberProps; }, import("./export-types").SpaceMemberProps>>; /** * Gets a Space Membership * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user). * @param id - Space Membership ID * @return Promise for a Space Membership * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getSpaceMembership('id')) * .then((spaceMembership) => console.log(spaceMembership)) * .catch(console.error) * ``` */ getSpaceMembership(id: string): Promise<import("./entities/space-membership").SpaceMembership>; /** * Gets a collection of Space Memberships * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user). * @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. * @return Promise for a collection of Space Memberships * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getSpaceMemberships({'limit': 100})) // you can add more queries as 'key': 'value' * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getSpaceMemberships(query?: QueryOptions): Promise<import("./common-types").Collection<import("./entities/space-membership").SpaceMembership, import("./entities/space-membership").SpaceMembershipProps>>; /** * Creates a Space Membership * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user). * @param data - Object representation of the Space Membership to be created * @return Promise for the newly created Space Membership * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createSpaceMembership({ * admin: false, * roles: [ * { * type: 'Link', * linkType: 'Role', * id: '<role_id>' * } * ], * email: 'foo@example.com' * })) * .then((spaceMembership) => console.log(spaceMembership)) * .catch(console.error) * ``` */ createSpaceMembership(data: CreateSpaceMembershipProps): Promise<import("./entities/space-membership").SpaceMembership>; /** * Creates a Space Membership with a custom ID * Warning: the user attribute in the space membership root is deprecated. The attribute has been moved inside the sys object (i.e. sys.user). * @param id - Space Membership ID * @param data - Object representation of the Space Membership to be created * @return Promise for the newly created Space Membership * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createSpaceMembershipWithId('<space-membership-id>', { * admin: false, * roles: [ * { * type: 'Link', * linkType: 'Role', * id: '<role_id>' * } * ], * email: 'foo@example.com' * })) * .then((spaceMembership) => console.log(spaceMembership)) * .catch(console.error) * ``` */ createSpaceMembershipWithId(id: string, data: CreateSpaceMembershipProps): Promise<import("./entities/space-membership").SpaceMembership>; /** * Gets a Team Space Membership * @param id - Team Space Membership ID * @return Promise for a Team Space Membership * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getTeamSpaceMembership('team_space_membership_id')) * .then((teamSpaceMembership) => console.log(teamSpaceMembership)) * .catch(console.error) * ``` */ getTeamSpaceMembership(teamSpaceMembershipId: string): Promise<import("./entities/team-space-membership").TeamSpaceMembership>; /** * Gets a collection of Team Space Memberships * @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. * @return Promise for a collection of Team Space Memberships * @example ```javascript * const contentful = require('contentful-management') * * client.getSpace('<space_id>') * .then((space) => space.getTeamSpaceMemberships()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getTeamSpaceMemberships(query?: QueryOptions): Promise<import("./common-types").Collection<import("./entities/team-space-membership").TeamSpaceMembership, import("./entities/team-space-membership").TeamSpaceMembershipProps>>; /** * Creates a Team Space Membership * @param id - Team ID * @param data - Object representation of the Team Space Membership to be created * @return Promise for the newly created Team Space Membership * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createTeamSpaceMembership('team_id', { * admin: false, * roles: [ * { sys: { * type: 'Link', * linkType: 'Role', * id: '<role_id>' * } * } * ], * })) * .then((teamSpaceMembership) => console.log(teamSpaceMembership)) * .catch(console.error) * ``` */ createTeamSpaceMembership(teamId: string, data: CreateTeamSpaceMembershipProps): Promise<import("./entities/team-space-membership").TeamSpaceMembership>; /** * Gets a Api Key * @param id - API Key ID * @return Promise for a Api Key * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getApiKey('<apikey-id>')) * .then((apikey) => console.log(apikey)) * .catch(console.error) * ``` */ getApiKey(id: string): Promise<import("./entities/api-key").ApiKey>; /** * Gets a collection of Api Keys * @return Promise for a collection of Api Keys * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getApiKeys()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getApiKeys(): Promise<import("./common-types").Collection<import("./entities/api-key").ApiKey, import("./entities/api-key").ApiKeyProps>>; /** * Gets a collection of preview Api Keys * @return Promise for a collection of Preview Api Keys * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getPreviewApiKeys()) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getPreviewApiKeys(): Promise<import("./common-types").Collection<import("./export-types").PreviewApiKey, import("./export-types").PreviewApiKeyProps>>; /** * Gets a preview Api Key * @param id - Preview API Key ID * @return Promise for a Preview Api Key * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getPreviewApiKey('<preview-apikey-id>')) * .then((previewApikey) => console.log(previewApikey)) * .catch(console.error) * ``` */ getPreviewApiKey(id: string): Promise<import("./export-types").PreviewApiKey>; /** * Creates a Api Key * @param payload - Object representation of the Api Key to be created * @return Promise for the newly created Api Key * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createApiKey({ * name: 'API Key name', * environments:[ * { * sys: { * type: 'Link' * linkType: 'Environment', * id:'<environment_id>' * } * } * ] * } * })) * .then((apiKey) => console.log(apiKey)) * .catch(console.error) * ``` */ createApiKey: (payload: CreateApiKeyProps) => Promise<import("./entities/api-key").ApiKey>; /** * Creates a Api Key with a custom ID * @param id - Api Key ID * @param payload - Object representation of the Api Key to be created * @return Promise for the newly created Api Key * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createApiKeyWithId('<api-key-id>', { * name: 'API Key name' * environments:[ * { * sys: { * type: 'Link' * linkType: 'Environment', * id:'<environment_id>' * } * } * ] * } * })) * .then((apiKey) => console.log(apiKey)) * .catch(console.error) * ``` */ createApiKeyWithId(id: string, payload: CreateApiKeyProps): Promise<import("./entities/api-key").ApiKey>; /** * Creates an EnvironmentAlias with a custom ID * @param environmentAliasId - EnvironmentAlias ID * @param data - Object representation of the EnvironmentAlias to be created * @return Promise for the newly created EnvironmentAlias * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createEnvironmentAliasWithId('<environment-alias-id>', { * environment: { * sys: { type: 'Link', linkType: 'Environment', id: 'targetEnvironment' } * } * })) * .then((environmentAlias) => console.log(environmentAlias)) * .catch(console.error) * ``` */ createEnvironmentAliasWithId(environmentAliasId: string, data: CreateEnvironmentAliasProps): Promise<import("./entities/environment-alias").EnvironmentAlias>; /** * Gets an Environment Alias * @param Environment Alias ID * @return Promise for an Environment Alias * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getEnvironmentAlias('<alias-id>')) * .then((alias) => console.log(alias)) * .catch(console.error) * ``` */ getEnvironmentAlias(environmentAliasId: string): Promise<import("./entities/environment-alias").EnvironmentAlias>; /** * Gets a collection of Environment Aliases * @return Promise for a collection of Environment Aliases * @example ```javascript * const contentful = require('contentful-management') * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getEnvironmentAliases() * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getEnvironmentAliases(): Promise<import("./common-types").Collection<import("./entities/environment-alias").EnvironmentAlias, import("./entities/environment-alias").EnvironmentAliasProps>>; /** * Query for scheduled actions in space. * @param query - Object with search parameters. The enviroment id field is mandatory. Check the <a href="https://www.contentful.com/developers/docs/references/content-management-api/#/reference/scheduled-actions/scheduled-actions-collection">REST API reference</a> for more details. * @return Promise for the scheduled actions query * * @example ```javascript * const contentful = require('contentful-management'); * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getScheduledActions({ * 'environment.sys.id': '<environment_id>', * 'sys.status': 'scheduled' * })) * .then((scheduledActionCollection) => console.log(scheduledActionCollection.items)) * .catch(console.error) * ``` */ getScheduledActions(query: ScheduledActionQueryOptions): Promise<import("./common-types").Collection<import("./entities/scheduled-action").ScheduledAction, ScheduledActionProps>>; /** * Get a Scheduled Action in the current space by environment and ID. * * @throws if the Scheduled Action cannot be found or the user doesn't have permission to read schedules from the entity of the scheduled action itself. * @returns Promise with the Scheduled Action * @example ```javascript * const contentful = require('contentful-management'); * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.getScheduledAction({ * scheduledActionId: '<scheduled-action-id>', * environmentId: '<environmentId>' * })) * .then((scheduledAction) => console.log(scheduledAction)) * .catch(console.error) * ``` */ getScheduledAction({ scheduledActionId, environmentId, }: { scheduledActionId: string; environmentId: string; }): Promise<import("./entities/scheduled-action").ScheduledAction>; /** * Creates a scheduled action * @param data - Object representation of the scheduled action to be created * @return Promise for the newly created scheduled actions * @example ```javascript * const contentful = require('contentful-management'); * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => space.createScheduledAction({ * entity: { * sys: { * type: 'Link', * linkType: 'Entry', * id: '<entry_id>' * } * }, * environment: { * sys: { * type: 'Link', * linkType: 'Environment', * id: '<environment_id>' * } * }, * action: 'publish', * scheduledFor: { * datetime: <ISO_date_string>, * timezone: 'Europe/Berlin' * } * })) * .then((scheduledAction) => console.log(scheduledAction)) * .catch(console.error) * ``` */ createScheduledAction(data: Omit<ScheduledActionProps, "sys">): Promise<import("./entities/scheduled-action").ScheduledAction>; /** * Update a scheduled action * @param {object} options * @param options.scheduledActionId the id of the scheduled action to update * @param options.version the sys.version of the scheduled action to be updated * @param payload the scheduled actions object with updates, omitting sys object * @returns Promise containing a wrapped scheduled action with helper methods * @example ```javascript * const contentful = require('contentful-management'); * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * client.getSpace('<space_id>') * .then((space) => { * return space.createScheduledAction({ * entity: { * sys: { * type: 'Link', * linkType: 'Entry', * id: '<entry_id>' * } * }, * environment: { * sys: { * type: 'Link', * linkType: 'Environment', * id: '<environment_id>' * } * }, * action: 'publish', * scheduledFor: { * datetime: <ISO_date_string>, * timezone: 'Europe/Berlin' * } * }) * .then((scheduledAction) => { * const { _sys, ...payload } = scheduledAction; * return space.updateScheduledAction({ * ...payload, * scheduledFor: { * ...payload.scheduledFor, * timezone: 'Europe/Paris' * } * }) * }) * .then((scheduledAction) => console.log(scheduledAction)) * .catch(console.error); * ``` */ updateScheduledAction({ scheduledActionId, payload, version, }: { scheduledActionId: string; payload: Omit<ScheduledActionProps, "sys">; version: number; }): Promise<import("./entities/scheduled-action").ScheduledAction>; /** * Cancels a Scheduled Action. * Only cancels actions that have not yet executed. * * @param {object} options * @param options.scheduledActionId the id of the scheduled action to be canceled * @param options.environmentId the environment ID of the scheduled action to be canceled * @throws if the Scheduled Action cannot be found or the user doesn't have permissions in the entity in the action. * @returns Promise containing a wrapped Scheduled Action with helper methods * @example ```javascript * const contentful = require('contentful-management'); * * const client = contentful.createClient({ * accessToken: '<content_management_api_key>' * }) * * // Given that an Scheduled Action is scheduled * client.getSpace('<space_id>') * .then((space) => space.deleteScheduledAction({ * environmentId: '<environment-id>', * scheduledActionId: '<scheduled-action-id>' * })) * // The scheduled Action sys.status is now 'canceled' * .then((scheduledAction) => console.log(scheduledAction)) * .catch(console.error); * ``` */ deleteScheduledAction({ scheduledActionId, environmentId, }: { scheduledActionId: string; environmentId: string; }): Promise<import("./entities/scheduled-action").ScheduledAction>; /** * Gets a single AI Action. * @param aiActionId - AI Action ID * @return Promise for an AI Action * @example * ```javascript * client.getSpace('<space_id>') * .then((space) => space.getAiAction('<ai_action_id>')) * .then((aiAction) => console.log(aiAction)) * .catch(console.error) * ``` */ getAiAction(aiActionId: string): Promise<import("./entities/ai-action").AiAction>; /** * Gets a collection of AI Actions. * @param query - Object with search parameters. * @return Promise for a collection of AI Actions * @example * ```javascript * client.getSpace('<space_id>') * .then((space) => space.getAiActions({ limit: 10 })) * .then((response) => console.log(response.items)) * .catch(console.error) * ``` */ getAiActions(query?: AiActionQueryOptions): Promise<import("./common-types").Collection<import("./entities/ai-action").AiAction, AiActionProps>>; /** * Creates an AI Action. * @param data - Object representation of the AI Action to be created * @return Promise for the newly created AI Action * @example * ```javascript * client.getSpace('<space_id>') * .then((space) => space.createAiAction({ * name: 'My AI Action', * description: 'Description here', * configuration: { modelType: 'model-x', modelTemperature: 0.7 }, * instruction: { template: 'Do something: {{var.input}}', variables: [], conditions: [] }, * testCases: [] * })) * .then((aiAction) => console.log(aiAction)) * .catch(console.error) * ``` */ createAiAction(data: CreateAiActionProps): Promise<import("./entities/ai-action").AiAction>; /** * Updates an AI Action. * @param aiActionId - AI Action ID * @param data - Object representation of the AI Action update * @return Promise for the updated AI Action * @example * ```javascript * client.getSpace('<space_id>') * .then((space) => space.updateAiAction('<ai_action_id>', { name: 'New Name', ... })) * .then((aiAction) => console.log(aiAction)) * .catch(console.error) * ``` */ updateAiAction(aiActionId: string, data: AiActionProps): Promise<import("./entities/ai-action").AiAction>; /** * Publishes an AI Action. * @param aiActionId - AI Action ID * @param data - Object representation of the AI Action to be published * @return Promise for the published AI Action * @example * ```javascript * client.getSpace('<space_id>') * .then((space) => space.publishAiAction('<ai_action_id>', { ... })) * .then((aiAction) => console.log(aiAction)) * .catch(console.error) * ``` */ publishAiAction(aiActionId: string, { version }: { version: number; }): Promise<import("./entities/ai-action").AiAction>; /** * Unpublishes an AI Action. * @param aiActionId - AI Action ID * @return Promise for the unpublished AI Action * @example * ```javascript * client.getSpace('<space_id>') * .then((space) => space.unpublishAiAction('<ai_action_id>')) * .then((aiAction) => console.log(aiAction)) * .catch(console.error) * ``` */ unpublishAiAction(aiActionId: string): Promise<import("./entities/ai-action").AiAction>; /** * Deletes an AI Action. * @param aiActionId - AI Action ID * @return Promise for deletion (void) * @example * ```javascript * client.getSpace('<space_id>') * .then((space) => space.deleteAiAction('<ai_action_id>')) * .then(() => console.log('AI Action deleted')) * .catch(console.error) * ``` */ deleteAiAction(aiActionId: string): Promise<any>; };