UNPKG

2.47 kBTypeScriptView Raw
1import type { DefaultElements, MakeRequest, MetaLinkProps, MetaSysProps } from '../common-types';
2export type ApiKeyProps = {
3 sys: MetaSysProps;
4 name: string;
5 accessToken: string;
6 environments: {
7 sys: MetaLinkProps;
8 }[];
9 preview_api_key: {
10 sys: MetaLinkProps;
11 };
12 description?: string;
13 policies?: {
14 effect: string;
15 action: string;
16 }[];
17};
18export type CreateApiKeyProps = Pick<ApiKeyProps, 'name' | 'environments' | 'description'>;
19export interface ApiKey extends ApiKeyProps, DefaultElements<ApiKeyProps> {
20 /**
21 * Deletes this object on the server.
22 * @return Promise for the deletion. It contains no data, but the Promise error case should be handled.
23 * @example ```javascript
24 * const contentful = require('contentful-management')
25 *
26 * const client = contentful.createClient({
27 * accessToken: '<content_management_api_key>'
28 * })
29 * client.getSpace('<space_id>')
30 * .then((space) => space.getApiKey(<api-key-id>))
31 * .then((apiKey) => apiKey.delete())
32 * .then(() => console.log('apikey deleted'))
33 * .catch(console.error)
34 * ```
35 */
36 delete(): Promise<void>;
37 /**
38 * Sends an update to the server with any changes made to the object's properties
39 * @return Object returned from the server with updated changes.
40 * @example ```javascript
41 * const contentful = require('contentful-management')
42 *
43 * const client = contentful.createClient({
44 * accessToken: '<content_management_api_key>'
45 * })
46 * client.getSpace('<space_id>')
47 * .then((space) => space.getApiKey(<api-key-id>))
48 * .then((apiKey) => {
49 * apiKey.name = 'New name'
50 * return apiKey.update()
51 * })
52 * .then(apiKey => console.log(apiKey.name))
53 * .catch(console.error)
54 * ```
55 */
56 update(): Promise<ApiKey>;
57}
58/**
59 * @private
60 * @param makeRequest - function to make requests via an adapter
61 * @param data - Raw api key data
62 */
63export declare function wrapApiKey(makeRequest: MakeRequest, data: ApiKeyProps): ApiKey;
64/**
65 * @private
66 * @param makeRequest - function to make requests via an adapter
67 * @param data - Raw api key collection data
68 * @return Wrapped api key collection data
69 */
70export declare const wrapApiKeyCollection: (makeRequest: MakeRequest, data: import("../common-types").CollectionProp<ApiKeyProps>) => import("../common-types").Collection<ApiKey, ApiKeyProps>;