@@ -305,6 +305,47 @@ func (enum *KeyState) UnmarshalJSON(data []byte) error {
305305 return nil
306306}
307307
308+ type ListAlgorithmsRequestUsage string
309+
310+ const (
311+ ListAlgorithmsRequestUsageUnknownUsage = ListAlgorithmsRequestUsage ("unknown_usage" )
312+ ListAlgorithmsRequestUsageSymmetricEncryption = ListAlgorithmsRequestUsage ("symmetric_encryption" )
313+ ListAlgorithmsRequestUsageAsymmetricEncryption = ListAlgorithmsRequestUsage ("asymmetric_encryption" )
314+ ListAlgorithmsRequestUsageAsymmetricSigning = ListAlgorithmsRequestUsage ("asymmetric_signing" )
315+ )
316+
317+ func (enum ListAlgorithmsRequestUsage ) String () string {
318+ if enum == "" {
319+ // return default value if empty
320+ return string (ListAlgorithmsRequestUsageUnknownUsage )
321+ }
322+ return string (enum )
323+ }
324+
325+ func (enum ListAlgorithmsRequestUsage ) Values () []ListAlgorithmsRequestUsage {
326+ return []ListAlgorithmsRequestUsage {
327+ "unknown_usage" ,
328+ "symmetric_encryption" ,
329+ "asymmetric_encryption" ,
330+ "asymmetric_signing" ,
331+ }
332+ }
333+
334+ func (enum ListAlgorithmsRequestUsage ) MarshalJSON () ([]byte , error ) {
335+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
336+ }
337+
338+ func (enum * ListAlgorithmsRequestUsage ) UnmarshalJSON (data []byte ) error {
339+ tmp := ""
340+
341+ if err := json .Unmarshal (data , & tmp ); err != nil {
342+ return err
343+ }
344+
345+ * enum = ListAlgorithmsRequestUsage (ListAlgorithmsRequestUsage (tmp ).String ())
346+ return nil
347+ }
348+
308349type ListKeysRequestOrderBy string
309350
310351const (
@@ -416,6 +457,15 @@ type KeyUsage struct {
416457 AsymmetricSigning * KeyAlgorithmAsymmetricSigning `json:"asymmetric_signing,omitempty"`
417458}
418459
460+ // ListAlgorithmsResponseAlgorithm: list algorithms response algorithm.
461+ type ListAlgorithmsResponseAlgorithm struct {
462+ Usage string `json:"usage"`
463+
464+ Name string `json:"name"`
465+
466+ Recommended bool `json:"recommended"`
467+ }
468+
419469// Key: key.
420470type Key struct {
421471 // ID: ID of the key.
@@ -659,6 +709,21 @@ type ImportKeyMaterialRequest struct {
659709 Salt * []byte `json:"salt,omitempty"`
660710}
661711
712+ // ListAlgorithmsRequest: list algorithms request.
713+ type ListAlgorithmsRequest struct {
714+ // Region: region to target. If none is passed will use default region from the config.
715+ Region scw.Region `json:"-"`
716+
717+ // Usages: filter by key usage.
718+ Usages []ListAlgorithmsRequestUsage `json:"usages"`
719+ }
720+
721+ // ListAlgorithmsResponse: list algorithms response.
722+ type ListAlgorithmsResponse struct {
723+ // Algorithms: returns a list of algorithms matching the requested criteria.
724+ Algorithms []* ListAlgorithmsResponseAlgorithm `json:"algorithms"`
725+ }
726+
662727// ListKeysRequest: list keys request.
663728type ListKeysRequest struct {
664729 // Region: region to target. If none is passed will use default region from the config.
@@ -1516,3 +1581,34 @@ func (s *API) RestoreKey(req *RestoreKeyRequest, opts ...scw.RequestOption) (*Ke
15161581 }
15171582 return & resp , nil
15181583}
1584+
1585+ // ListAlgorithms: Lists all cryptographic algorithms supported by the Key Manager service.
1586+ func (s * API ) ListAlgorithms (req * ListAlgorithmsRequest , opts ... scw.RequestOption ) (* ListAlgorithmsResponse , error ) {
1587+ var err error
1588+
1589+ if req .Region == "" {
1590+ defaultRegion , _ := s .client .GetDefaultRegion ()
1591+ req .Region = defaultRegion
1592+ }
1593+
1594+ query := url.Values {}
1595+ parameter .AddToQuery (query , "usages" , req .Usages )
1596+
1597+ if fmt .Sprint (req .Region ) == "" {
1598+ return nil , errors .New ("field Region cannot be empty in request" )
1599+ }
1600+
1601+ scwReq := & scw.ScalewayRequest {
1602+ Method : "GET" ,
1603+ Path : "/key-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/algorithms" ,
1604+ Query : query ,
1605+ }
1606+
1607+ var resp ListAlgorithmsResponse
1608+
1609+ err = s .client .Do (scwReq , & resp , opts ... )
1610+ if err != nil {
1611+ return nil , err
1612+ }
1613+ return & resp , nil
1614+ }
0 commit comments