File tree Expand file tree Collapse file tree 4 files changed +88
-0
lines changed
packages_generated/key_manager/src/v1alpha1 Expand file tree Collapse file tree 4 files changed +88
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
2222 unmarshalDecryptResponse ,
2323 unmarshalEncryptResponse ,
2424 unmarshalKey ,
25+ unmarshalListAlgorithmsResponse ,
2526 unmarshalListKeysResponse ,
2627 unmarshalPublicKey ,
2728 unmarshalSignResponse ,
@@ -43,6 +44,8 @@ import type {
4344 GetPublicKeyRequest ,
4445 ImportKeyMaterialRequest ,
4546 Key ,
47+ ListAlgorithmsRequest ,
48+ ListAlgorithmsResponse ,
4649 ListKeysRequest ,
4750 ListKeysResponse ,
4851 ProtectKeyRequest ,
@@ -414,4 +417,20 @@ The data encryption key is returned in plaintext and ciphertext but it should on
414417 } ,
415418 unmarshalKey ,
416419 )
420+
421+ /**
422+ * List all available algorithms. Lists all cryptographic algorithms supported by the Key Manager service.
423+ *
424+ * @param request - The request {@link ListAlgorithmsRequest}
425+ * @returns A Promise of ListAlgorithmsResponse
426+ */
427+ listAlgorithms = ( request : Readonly < ListAlgorithmsRequest > = { } ) =>
428+ this . client . fetch < ListAlgorithmsResponse > (
429+ {
430+ method : 'GET' ,
431+ path : `/key-manager/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /algorithms` ,
432+ urlParams : urlParams ( [ 'usages' , request . usages ] ) ,
433+ } ,
434+ unmarshalListAlgorithmsResponse ,
435+ )
417436}
Original file line number Diff line number Diff line change @@ -26,6 +26,10 @@ export type {
2626 KeyRotationPolicy ,
2727 KeyState ,
2828 KeyUsage ,
29+ ListAlgorithmsRequest ,
30+ ListAlgorithmsRequestUsage ,
31+ ListAlgorithmsResponse ,
32+ ListAlgorithmsResponseAlgorithm ,
2933 ListKeysRequest ,
3034 ListKeysRequestOrderBy ,
3135 ListKeysRequestUsage ,
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ import type {
2020 Key ,
2121 KeyRotationPolicy ,
2222 KeyUsage ,
23+ ListAlgorithmsResponse ,
24+ ListAlgorithmsResponseAlgorithm ,
2325 ListKeysResponse ,
2426 PublicKey ,
2527 SignRequest ,
@@ -135,6 +137,39 @@ export const unmarshalEncryptResponse = (data: unknown): EncryptResponse => {
135137 } as EncryptResponse
136138}
137139
140+ const unmarshalListAlgorithmsResponseAlgorithm = (
141+ data : unknown ,
142+ ) : ListAlgorithmsResponseAlgorithm => {
143+ if ( ! isJSONObject ( data ) ) {
144+ throw new TypeError (
145+ `Unmarshalling the type 'ListAlgorithmsResponseAlgorithm' failed as data isn't a dictionary.` ,
146+ )
147+ }
148+
149+ return {
150+ name : data . name ,
151+ recommended : data . recommended ,
152+ usage : data . usage ,
153+ } as ListAlgorithmsResponseAlgorithm
154+ }
155+
156+ export const unmarshalListAlgorithmsResponse = (
157+ data : unknown ,
158+ ) : ListAlgorithmsResponse => {
159+ if ( ! isJSONObject ( data ) ) {
160+ throw new TypeError (
161+ `Unmarshalling the type 'ListAlgorithmsResponse' failed as data isn't a dictionary.` ,
162+ )
163+ }
164+
165+ return {
166+ algorithms : unmarshalArrayOfObject (
167+ data . algorithms ,
168+ unmarshalListAlgorithmsResponseAlgorithm ,
169+ ) ,
170+ } as ListAlgorithmsResponse
171+ }
172+
138173export const unmarshalListKeysResponse = ( data : unknown ) : ListKeysResponse => {
139174 if ( ! isJSONObject ( data ) ) {
140175 throw new TypeError (
Original file line number Diff line number Diff line change @@ -36,6 +36,12 @@ export type KeyState =
3636 | 'pending_key_material'
3737 | 'scheduled_for_deletion'
3838
39+ export type ListAlgorithmsRequestUsage =
40+ | 'unknown_usage'
41+ | 'symmetric_encryption'
42+ | 'asymmetric_encryption'
43+ | 'asymmetric_signing'
44+
3945export type ListKeysRequestOrderBy =
4046 | 'name_asc'
4147 | 'name_desc'
@@ -80,6 +86,12 @@ export interface KeyUsage {
8086 asymmetricSigning ?: KeyAlgorithmAsymmetricSigning
8187}
8288
89+ export interface ListAlgorithmsResponseAlgorithm {
90+ usage : string
91+ name : string
92+ recommended : boolean
93+ }
94+
8395export interface Key {
8496 /**
8597 * ID of the key.
@@ -382,6 +394,24 @@ export type ImportKeyMaterialRequest = {
382394 salt ?: string
383395}
384396
397+ export type ListAlgorithmsRequest = {
398+ /**
399+ * Region to target. If none is passed will use default region from the config.
400+ */
401+ region ?: ScwRegion
402+ /**
403+ * Filter by key usage.
404+ */
405+ usages ?: ListAlgorithmsRequestUsage [ ]
406+ }
407+
408+ export interface ListAlgorithmsResponse {
409+ /**
410+ * Returns a list of algorithms matching the requested criteria.
411+ */
412+ algorithms : ListAlgorithmsResponseAlgorithm [ ]
413+ }
414+
385415export type ListKeysRequest = {
386416 /**
387417 * Region to target. If none is passed will use default region from the config.
You can’t perform that action at this time.
0 commit comments