Skip to content

Commit f3efa9a

Browse files
feat(key_manager): add v1alpha1 (#1279)
Co-authored-by: Vincent Germain <[email protected]>
1 parent d67f471 commit f3efa9a

File tree

6 files changed

+873
-0
lines changed

6 files changed

+873
-0
lines changed

packages/clients/src/api/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export * as IPAM from './ipam'
1717
export * as IPFS from './ipfs'
1818
export * as Jobs from './jobs'
1919
export * as K8S from './k8s'
20+
export * as KeyManager from './key_manager'
2021
export * as LB from './lb'
2122
export * as LLMInference from './llm_inference'
2223
export * as Marketplace from './marketplace'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as v1alpha1 from './v1alpha1/index.gen'
Lines changed: 327 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,327 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
import {
4+
API as ParentAPI,
5+
enrichForPagination,
6+
urlParams,
7+
validatePathParam,
8+
} from '../../../bridge'
9+
import type { Region } from '../../../bridge'
10+
import {
11+
marshalCreateKeyRequest,
12+
marshalDecryptRequest,
13+
marshalEncryptRequest,
14+
marshalGenerateDataKeyRequest,
15+
marshalUpdateKeyRequest,
16+
unmarshalDataKey,
17+
unmarshalDecryptResponse,
18+
unmarshalEncryptResponse,
19+
unmarshalKey,
20+
unmarshalListKeysResponse,
21+
} from './marshalling.gen'
22+
import type {
23+
CreateKeyRequest,
24+
DataKey,
25+
DecryptRequest,
26+
DecryptResponse,
27+
DeleteKeyRequest,
28+
DisableKeyRequest,
29+
EnableKeyRequest,
30+
EncryptRequest,
31+
EncryptResponse,
32+
GenerateDataKeyRequest,
33+
GetKeyRequest,
34+
Key,
35+
ListKeysRequest,
36+
ListKeysResponse,
37+
ProtectKeyRequest,
38+
RotateKeyRequest,
39+
UnprotectKeyRequest,
40+
UpdateKeyRequest,
41+
} from './types.gen'
42+
43+
const jsonContentHeaders = {
44+
'Content-Type': 'application/json; charset=utf-8',
45+
}
46+
47+
/**
48+
* Key Manager API.
49+
*
50+
* This API allows you to create, manage and use cryptographic keys in a
51+
* centralized and secure service.
52+
*/
53+
export class API extends ParentAPI {
54+
/** Lists the available regions of the API. */
55+
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw']
56+
57+
/**
58+
* Create a key. Create a key in a given region specified by the `region`
59+
* parameter. Keys only support symmetric encryption. You can use keys to
60+
* encrypt or decrypt arbitrary payloads, or to generate data encryption keys
61+
* that can be used without being stored in Key Manager.
62+
*
63+
* @param request - The request {@link CreateKeyRequest}
64+
* @returns A Promise of Key
65+
*/
66+
createKey = (request: Readonly<CreateKeyRequest>) =>
67+
this.client.fetch<Key>(
68+
{
69+
body: JSON.stringify(
70+
marshalCreateKeyRequest(request, this.client.settings),
71+
),
72+
headers: jsonContentHeaders,
73+
method: 'POST',
74+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys`,
75+
},
76+
unmarshalKey,
77+
)
78+
79+
/**
80+
* Get key metadata. Retrieve the metadata of a key specified by the `region`
81+
* and `key_id` parameters.
82+
*
83+
* @param request - The request {@link GetKeyRequest}
84+
* @returns A Promise of Key
85+
*/
86+
getKey = (request: Readonly<GetKeyRequest>) =>
87+
this.client.fetch<Key>(
88+
{
89+
method: 'GET',
90+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}`,
91+
},
92+
unmarshalKey,
93+
)
94+
95+
/**
96+
* Update a key. Update a key's metadata (name, description and tags),
97+
* specified by the `key_id` and `region` parameters.
98+
*
99+
* @param request - The request {@link UpdateKeyRequest}
100+
* @returns A Promise of Key
101+
*/
102+
updateKey = (request: Readonly<UpdateKeyRequest>) =>
103+
this.client.fetch<Key>(
104+
{
105+
body: JSON.stringify(
106+
marshalUpdateKeyRequest(request, this.client.settings),
107+
),
108+
headers: jsonContentHeaders,
109+
method: 'PATCH',
110+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}`,
111+
},
112+
unmarshalKey,
113+
)
114+
115+
/**
116+
* Delete a key. Delete an existing key specified by the `region` and `key_id`
117+
* parameters. Deleting a key is permanent and cannot be undone. All data
118+
* encrypted using this key, including data encryption keys, will become
119+
* unusable.
120+
*
121+
* @param request - The request {@link DeleteKeyRequest}
122+
*/
123+
deleteKey = (request: Readonly<DeleteKeyRequest>) =>
124+
this.client.fetch<void>({
125+
method: 'DELETE',
126+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}`,
127+
})
128+
129+
/**
130+
* Rotate a key. Generate a new version of an existing key with randomly
131+
* generated key material. Rotated keys can still be used to decrypt
132+
* previously encrypted data. The key's new material will be used for
133+
* subsequent encryption operations and data key generation.
134+
*
135+
* @param request - The request {@link RotateKeyRequest}
136+
* @returns A Promise of Key
137+
*/
138+
rotateKey = (request: Readonly<RotateKeyRequest>) =>
139+
this.client.fetch<Key>(
140+
{
141+
body: '{}',
142+
headers: jsonContentHeaders,
143+
method: 'POST',
144+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/rotate`,
145+
},
146+
unmarshalKey,
147+
)
148+
149+
/**
150+
* Apply key protection. Apply key protection to a given key specified by the
151+
* `key_id` parameter. Applying key protection means that your key can be used
152+
* and modified, but it cannot be deleted.
153+
*
154+
* @param request - The request {@link ProtectKeyRequest}
155+
* @returns A Promise of Key
156+
*/
157+
protectKey = (request: Readonly<ProtectKeyRequest>) =>
158+
this.client.fetch<Key>(
159+
{
160+
body: '{}',
161+
headers: jsonContentHeaders,
162+
method: 'POST',
163+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/protect`,
164+
},
165+
unmarshalKey,
166+
)
167+
168+
/**
169+
* Remove key protection. Remove key protection from a given key specified by
170+
* the `key_id` parameter. Removing key protection means that your key can be
171+
* deleted anytime.
172+
*
173+
* @param request - The request {@link UnprotectKeyRequest}
174+
* @returns A Promise of Key
175+
*/
176+
unprotectKey = (request: Readonly<UnprotectKeyRequest>) =>
177+
this.client.fetch<Key>(
178+
{
179+
body: '{}',
180+
headers: jsonContentHeaders,
181+
method: 'POST',
182+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/unprotect`,
183+
},
184+
unmarshalKey,
185+
)
186+
187+
/**
188+
* Enable key. Enable a given key to be used for cryptographic operations.
189+
* Enabling a key allows you to make a disabled key usable again. You must
190+
* specify the `region` and `key_id` parameters.
191+
*
192+
* @param request - The request {@link EnableKeyRequest}
193+
* @returns A Promise of Key
194+
*/
195+
enableKey = (request: Readonly<EnableKeyRequest>) =>
196+
this.client.fetch<Key>(
197+
{
198+
body: '{}',
199+
headers: jsonContentHeaders,
200+
method: 'POST',
201+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/enable`,
202+
},
203+
unmarshalKey,
204+
)
205+
206+
/**
207+
* Disable key. Disable a given key to be used for cryptographic operations.
208+
* Disabling a key renders it unusable. You must specify the `region` and
209+
* `key_id` parameters.
210+
*
211+
* @param request - The request {@link DisableKeyRequest}
212+
* @returns A Promise of Key
213+
*/
214+
disableKey = (request: Readonly<DisableKeyRequest>) =>
215+
this.client.fetch<Key>(
216+
{
217+
body: '{}',
218+
headers: jsonContentHeaders,
219+
method: 'POST',
220+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/disable`,
221+
},
222+
unmarshalKey,
223+
)
224+
225+
protected pageOfListKeys = (request: Readonly<ListKeysRequest> = {}) =>
226+
this.client.fetch<ListKeysResponse>(
227+
{
228+
method: 'GET',
229+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys`,
230+
urlParams: urlParams(
231+
['name', request.name],
232+
['order_by', request.orderBy],
233+
['organization_id', request.organizationId],
234+
['page', request.page],
235+
[
236+
'page_size',
237+
request.pageSize ?? this.client.settings.defaultPageSize,
238+
],
239+
['project_id', request.projectId],
240+
['tags', request.tags],
241+
),
242+
},
243+
unmarshalListKeysResponse,
244+
)
245+
246+
/**
247+
* List keys. Retrieve the list of keys created within all Projects of an
248+
* Organization or in a given Project. You must specify the `region`, and
249+
* either the `organization_id` or the `project_id`.
250+
*
251+
* @param request - The request {@link ListKeysRequest}
252+
* @returns A Promise of ListKeysResponse
253+
*/
254+
listKeys = (request: Readonly<ListKeysRequest> = {}) =>
255+
enrichForPagination('keys', this.pageOfListKeys, request)
256+
257+
/**
258+
* Generate a data encryption key. Generate a new data encryption key to use
259+
* for cryptographic operations outside of Key Manager. Note that Key Manager
260+
* does not store your data encryption key. The data encryption key is
261+
* encrypted and must be decrypted using the key you have created in Key
262+
* Manager. The data encryption key's plaintext is returned in the response
263+
* object, for immediate usage.
264+
*
265+
* Always store the data encryption key's ciphertext, rather than its
266+
* plaintext, which must not be stored. To retrieve your key's plaintext, call
267+
* the Decrypt endpoint with your key's ID and ciphertext.
268+
*
269+
* @param request - The request {@link GenerateDataKeyRequest}
270+
* @returns A Promise of DataKey
271+
*/
272+
generateDataKey = (request: Readonly<GenerateDataKeyRequest>) =>
273+
this.client.fetch<DataKey>(
274+
{
275+
body: JSON.stringify(
276+
marshalGenerateDataKeyRequest(request, this.client.settings),
277+
),
278+
headers: jsonContentHeaders,
279+
method: 'POST',
280+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/generate-data-key`,
281+
},
282+
unmarshalDataKey,
283+
)
284+
285+
/**
286+
* Encrypt data. Encrypt data using an existing key, specified by the `key_id`
287+
* parameter. Only keys with a usage set to **symmetric_encryption** are
288+
* supported by this method. The maximum payload size that can be encrypted is
289+
* 64KB of plaintext.
290+
*
291+
* @param request - The request {@link EncryptRequest}
292+
* @returns A Promise of EncryptResponse
293+
*/
294+
encrypt = (request: Readonly<EncryptRequest>) =>
295+
this.client.fetch<EncryptResponse>(
296+
{
297+
body: JSON.stringify(
298+
marshalEncryptRequest(request, this.client.settings),
299+
),
300+
headers: jsonContentHeaders,
301+
method: 'POST',
302+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/encrypt`,
303+
},
304+
unmarshalEncryptResponse,
305+
)
306+
307+
/**
308+
* Decrypt data. Decrypt data using an existing key, specified by the `key_id`
309+
* parameter. The maximum payload size that can be decrypted is the result of
310+
* the encryption of 64KB of data (around 131KB).
311+
*
312+
* @param request - The request {@link DecryptRequest}
313+
* @returns A Promise of DecryptResponse
314+
*/
315+
decrypt = (request: Readonly<DecryptRequest>) =>
316+
this.client.fetch<DecryptResponse>(
317+
{
318+
body: JSON.stringify(
319+
marshalDecryptRequest(request, this.client.settings),
320+
),
321+
headers: jsonContentHeaders,
322+
method: 'POST',
323+
path: `/key-manager/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/keys/${validatePathParam('keyId', request.keyId)}/decrypt`,
324+
},
325+
unmarshalDecryptResponse,
326+
)
327+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// This file was automatically generated. DO NOT EDIT.
2+
// If you have any remark or suggestion do not hesitate to open an issue.
3+
export { API } from './api.gen'
4+
export type {
5+
CreateKeyRequest,
6+
DataKey,
7+
DataKeyAlgorithmSymmetricEncryption,
8+
DecryptRequest,
9+
DecryptResponse,
10+
DeleteKeyRequest,
11+
DisableKeyRequest,
12+
EnableKeyRequest,
13+
EncryptRequest,
14+
EncryptResponse,
15+
GenerateDataKeyRequest,
16+
GetKeyRequest,
17+
Key,
18+
KeyAlgorithmSymmetricEncryption,
19+
KeyRotationPolicy,
20+
KeyState,
21+
KeyUsage,
22+
ListKeysRequest,
23+
ListKeysRequestOrderBy,
24+
ListKeysResponse,
25+
ProtectKeyRequest,
26+
RotateKeyRequest,
27+
UnprotectKeyRequest,
28+
UpdateKeyRequest,
29+
} from './types.gen'

0 commit comments

Comments
 (0)