UNPKG

4.12 kBTypeScriptView Raw
1import type { RawAxiosRequestHeaders } from 'axios';
2import type { CollectionProp, GetSpaceEnvironmentParams, GetSpaceParams, PaginationQueryParams } from '../../common-types';
3import type { CreateEnvironmentProps, EnvironmentProps } from '../../entities/environment';
4import type { OptionalDefaults } from '../wrappers/wrap';
5export type EnvironmentPlainClientAPI = {
6 /**
7 * Fetch an environment
8 * @param params a space and environment id
9 * @returns the environment
10 * @throws if the environment does not exist
11 * @example
12 * ```javascript
13 * const environment = await client.environment.get({
14 * spaceId: '<space_id>',
15 * environmentId: '<environment_id>'
16 * })
17 * ```
18 */
19 get(params: OptionalDefaults<GetSpaceEnvironmentParams>): Promise<EnvironmentProps>;
20 /**
21 * Fetch all environments in a space
22 * @param params a space Id and optional pagination parameters
23 * @returns a collection of environments
24 * @throws if the space does not exist
25 * @example
26 * ```javascript
27 * const environments = await client.environment.getMany({
28 * spaceId: '<space_id>'
29 * })
30 * ```
31 */
32 getMany(params: OptionalDefaults<GetSpaceParams & PaginationQueryParams>): Promise<CollectionProp<EnvironmentProps>>;
33 /**
34 * Create an environment
35 * @param params a space ID to create the environment in
36 * @param rawData the environment metadata
37 * @param headers optional custom headers
38 * @returns the created environment
39 * @throws if the space does not exist, or `rawData` is invalid
40 * @example
41 * ```javascript
42 * const environment = await client.environment.create(
43 * {
44 * spaceId: '<space_id>'
45 * },
46 * {
47 * name: 'new-env'
48 * }
49 * )
50 * ```
51 */
52 create(params: OptionalDefaults<GetSpaceParams>, rawData: Partial<Pick<EnvironmentProps, 'name'>>, headers?: RawAxiosRequestHeaders): Promise<EnvironmentProps>;
53 /**
54 * Create an environment with a specific ID
55 * @param params a space ID to create the environment in
56 * @param rawData the environment metadata
57 * @param headers optional custom headers
58 * @returns the created environment
59 * @throws if the space does not exist, or `rawData` is invalid
60 * @example
61 * ```javascript
62 * const environment = await client.environment.createWithId(
63 * {
64 * spaceId: '<space_id>',
65 * environmentId: '<environment_id>'
66 * },
67 * {
68 * name: 'new-env'
69 * }
70 * )
71 * ```
72 */
73 createWithId(params: OptionalDefaults<GetSpaceEnvironmentParams & {
74 sourceEnvironmentId?: string;
75 }>, rawData: CreateEnvironmentProps, headers?: RawAxiosRequestHeaders): Promise<EnvironmentProps>;
76 /**
77 * Update an environment
78 * @param params a space and environment id
79 * @param rawData the environment metadata
80 * @param headers optional custom headers
81 * @returns the updated environment
82 * @throws if the environment does not exist, or `rawData` is invalid
83 * @example
84 * ```javascript
85 * let environment = await client.environment.get({
86 * spaceId: '<space_id>',
87 * environmentId: '<environment_id>'
88 * })
89 *
90 * environment = await client.environment.update(
91 * {
92 * spaceId: '<space_id>',
93 * environmentId: '<environment_id>'
94 * },
95 * {
96 * name: 'updated-env'
97 * }
98 * )
99 * ```
100 */
101 update(params: OptionalDefaults<GetSpaceEnvironmentParams>, rawData: EnvironmentProps, headers?: RawAxiosRequestHeaders): Promise<EnvironmentProps>;
102 /**
103 * Delete an environment
104 * @param params a space and environment id
105 * @returns an empty object
106 * @throws if the environment does not exist
107 * @example
108 * ```javascript
109 * await client.environment.delete({
110 * spaceId: '<space_id>',
111 * environmentId: '<environment_id>'
112 * })
113 * ```
114 */
115 delete(params: OptionalDefaults<GetSpaceEnvironmentParams>): Promise<any>;
116};