@@ -159,23 +159,23 @@ type AccessSecretVersionResponse struct {
159159 Data []byte `json:"data"`
160160 // DataCrc32: the CRC32 checksum of the data as a base-10 integer.
161161 // This field is present only if a CRC32 was supplied during the creation of the version.
162- DataCrc32 uint32 `json:"data_crc32"`
162+ DataCrc32 * uint32 `json:"data_crc32"`
163163}
164164
165165// ListSecretVersionsResponse: list secret versions response.
166166type ListSecretVersionsResponse struct {
167- // TotalCount: number of versions.
168- TotalCount uint32 `json:"total_count"`
169167 // Versions: single page of versions.
170168 Versions []* SecretVersion `json:"versions"`
169+ // TotalCount: number of versions.
170+ TotalCount uint32 `json:"total_count"`
171171}
172172
173173// ListSecretsResponse: list secrets response.
174174type ListSecretsResponse struct {
175- // TotalCount: count of all secrets matching the requested criteria.
176- TotalCount uint32 `json:"total_count"`
177175 // Secrets: single page of secrets matching the requested criteria.
178176 Secrets []* Secret `json:"secrets"`
177+ // TotalCount: count of all secrets matching the requested criteria.
178+ TotalCount uint32 `json:"total_count"`
179179}
180180
181181// PasswordGenerationParams: password generation params.
@@ -211,37 +211,38 @@ type Secret struct {
211211 UpdatedAt * time.Time `json:"updated_at"`
212212 // Tags: list of the secret's tags.
213213 Tags []string `json:"tags"`
214- // Region: region of the secret.
215- Region scw.Region `json:"region"`
216214 // VersionCount: number of versions for this secret.
217215 VersionCount uint32 `json:"version_count"`
218216 // Description: updated description of the secret.
219217 Description * string `json:"description"`
220218 // IsManaged: true for secrets that are managed by another product.
221219 IsManaged bool `json:"is_managed"`
220+ // Region: region of the secret.
221+ Region scw.Region `json:"region"`
222222}
223223
224224// SecretVersion: secret version.
225225type SecretVersion struct {
226+ // Revision: version number.
227+ // The first version of the secret is numbered 1, and all subsequent revisions augment by 1.
228+ Revision uint32 `json:"revision"`
226229 // SecretID: ID of the secret.
227230 SecretID string `json:"secret_id"`
228- // Revision: version number. The first version of the secret is numbered 1, and all subsequent revisions augment by 1.
229- Revision uint32 `json:"revision"`
230231 // Status: current status of the version.
231232 // * `unknown`: the version is in an invalid state.
232233 // * `enabled`: the version is accessible.
233234 // * `disabled`: the version is not accessible but can be enabled.
234235 // * `destroyed`: the version is permanently deleted. It is not possible to recover it.
235236 // Default value: unknown
236237 Status SecretVersionStatus `json:"status"`
237- // IsLatest: true if the version is the latest one.
238- IsLatest bool `json:"is_latest"`
239238 // CreatedAt: date and time of the version's creation.
240239 CreatedAt * time.Time `json:"created_at"`
241240 // UpdatedAt: last update of the version.
242241 UpdatedAt * time.Time `json:"updated_at"`
243242 // Description: description of the version.
244243 Description * string `json:"description"`
244+ // IsLatest: true if the version is the latest one.
245+ IsLatest bool `json:"is_latest"`
245246}
246247
247248// Service API
@@ -517,12 +518,12 @@ func (s *API) ListSecrets(req *ListSecretsRequest, opts ...scw.RequestOption) (*
517518 query := url.Values {}
518519 parameter .AddToQuery (query , "organization_id" , req .OrganizationID )
519520 parameter .AddToQuery (query , "project_id" , req .ProjectID )
520- parameter .AddToQuery (query , "name" , req .Name )
521- parameter .AddToQuery (query , "tags" , req .Tags )
522- parameter .AddToQuery (query , "is_managed" , req .IsManaged )
523521 parameter .AddToQuery (query , "order_by" , req .OrderBy )
524522 parameter .AddToQuery (query , "page" , req .Page )
525523 parameter .AddToQuery (query , "page_size" , req .PageSize )
524+ parameter .AddToQuery (query , "tags" , req .Tags )
525+ parameter .AddToQuery (query , "name" , req .Name )
526+ parameter .AddToQuery (query , "is_managed" , req .IsManaged )
526527
527528 if fmt .Sprint (req .Region ) == "" {
528529 return nil , errors .New ("field Region cannot be empty in request" )
@@ -592,15 +593,15 @@ type CreateSecretVersionRequest struct {
592593 // Description: description of the version.
593594 Description * string `json:"description"`
594595 // DisablePrevious: disable the previous secret version.
595- // If there is no previous version or if the previous version was already disabled, does nothing.
596- DisablePrevious bool `json:"disable_previous"`
596+ // Optional. If there is no previous version or if the previous version was already disabled, does nothing.
597+ DisablePrevious * bool `json:"disable_previous"`
597598 // PasswordGeneration: options to generate a password.
598- // If specified, a random password will be generated. The data field must be empty. By default, the generator will use upper and lower case letters, and digits. This behavior can be tuned using the generation parameters.
599+ // Optional. If specified, a random password will be generated. The data and data_crc32 fields must be empty. By default, the generator will use upper and lower case letters, and digits. This behavior can be tuned using the generation parameters.
599600 // Precisely one of PasswordGeneration must be set.
600601 PasswordGeneration * PasswordGenerationParams `json:"password_generation,omitempty"`
601602 // DataCrc32: the CRC32 checksum of the data as a base-10 integer.
602- // This field is optional and can be set to 0 . If greater than 0 , the Secret Manager will verify the integrity of the data received against the given CRC32. An error is returned if the CRC32 does not match. Otherwise, the CRC32 will be stored and returned along with the SecretVersion on futur accesses.
603- DataCrc32 uint32 `json:"data_crc32"`
603+ // Optional . If specified , the Secret Manager will verify the integrity of the data received against the given CRC32. An error is returned if the CRC32 does not match. Otherwise, the CRC32 will be stored and returned along with the SecretVersion on futur accesses.
604+ DataCrc32 * uint32 `json:"data_crc32"`
604605}
605606
606607// CreateSecretVersion: create a version.
@@ -903,7 +904,7 @@ func (s *API) ListSecretVersionsByName(req *ListSecretVersionsByNameRequest, opt
903904 return & resp , nil
904905}
905906
906- type DestroySecretVersionRequest struct {
907+ type EnableSecretVersionRequest struct {
907908 // Region: region to target. If none is passed will use default region from the config.
908909 Region scw.Region `json:"-"`
909910 // SecretID: ID of the secret.
@@ -913,9 +914,9 @@ type DestroySecretVersionRequest struct {
913914 Revision string `json:"-"`
914915}
915916
916- // DestroySecretVersion: delete a version.
917- // Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone .
918- func (s * API ) DestroySecretVersion (req * DestroySecretVersionRequest , opts ... scw.RequestOption ) (* SecretVersion , error ) {
917+ // EnableSecretVersion: enable a version.
918+ // Make a specific version accessible. You must specify the `region`, `secret_id` and `revision` parameters .
919+ func (s * API ) EnableSecretVersion (req * EnableSecretVersionRequest , opts ... scw.RequestOption ) (* SecretVersion , error ) {
919920 var err error
920921
921922 if req .Region == "" {
@@ -937,7 +938,7 @@ func (s *API) DestroySecretVersion(req *DestroySecretVersionRequest, opts ...scw
937938
938939 scwReq := & scw.ScalewayRequest {
939940 Method : "POST" ,
940- Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/destroy " ,
941+ Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/enable " ,
941942 Headers : http.Header {},
942943 }
943944
@@ -955,7 +956,7 @@ func (s *API) DestroySecretVersion(req *DestroySecretVersionRequest, opts ...scw
955956 return & resp , nil
956957}
957958
958- type EnableSecretVersionRequest struct {
959+ type DisableSecretVersionRequest struct {
959960 // Region: region to target. If none is passed will use default region from the config.
960961 Region scw.Region `json:"-"`
961962 // SecretID: ID of the secret.
@@ -965,9 +966,9 @@ type EnableSecretVersionRequest struct {
965966 Revision string `json:"-"`
966967}
967968
968- // EnableSecretVersion: enable a version.
969- // Make a specific version accessible . You must specify the `region`, `secret_id` and `revision` parameters.
970- func (s * API ) EnableSecretVersion (req * EnableSecretVersionRequest , opts ... scw.RequestOption ) (* SecretVersion , error ) {
969+ // DisableSecretVersion: disable a version.
970+ // Make a specific version inaccessible . You must specify the `region`, `secret_id` and `revision` parameters.
971+ func (s * API ) DisableSecretVersion (req * DisableSecretVersionRequest , opts ... scw.RequestOption ) (* SecretVersion , error ) {
971972 var err error
972973
973974 if req .Region == "" {
@@ -989,7 +990,7 @@ func (s *API) EnableSecretVersion(req *EnableSecretVersionRequest, opts ...scw.R
989990
990991 scwReq := & scw.ScalewayRequest {
991992 Method : "POST" ,
992- Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/enable " ,
993+ Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/disable " ,
993994 Headers : http.Header {},
994995 }
995996
@@ -1007,7 +1008,7 @@ func (s *API) EnableSecretVersion(req *EnableSecretVersionRequest, opts ...scw.R
10071008 return & resp , nil
10081009}
10091010
1010- type DisableSecretVersionRequest struct {
1011+ type AccessSecretVersionRequest struct {
10111012 // Region: region to target. If none is passed will use default region from the config.
10121013 Region scw.Region `json:"-"`
10131014 // SecretID: ID of the secret.
@@ -1017,9 +1018,9 @@ type DisableSecretVersionRequest struct {
10171018 Revision string `json:"-"`
10181019}
10191020
1020- // DisableSecretVersion: disable a version.
1021- // Make a specific version inaccessible. You must specify the `region`, `secret_id` and `revision` parameters.
1022- func (s * API ) DisableSecretVersion (req * DisableSecretVersionRequest , opts ... scw.RequestOption ) (* SecretVersion , error ) {
1021+ // AccessSecretVersion: access a secret's version using the secret's ID .
1022+ // Access sensitive data in a secret's version specified by the `region`, `secret_id` and `revision` parameters.
1023+ func (s * API ) AccessSecretVersion (req * AccessSecretVersionRequest , opts ... scw.RequestOption ) (* AccessSecretVersionResponse , error ) {
10231024 var err error
10241025
10251026 if req .Region == "" {
@@ -1040,17 +1041,12 @@ func (s *API) DisableSecretVersion(req *DisableSecretVersionRequest, opts ...scw
10401041 }
10411042
10421043 scwReq := & scw.ScalewayRequest {
1043- Method : "POST " ,
1044- Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/disable " ,
1044+ Method : "GET " ,
1045+ Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/access " ,
10451046 Headers : http.Header {},
10461047 }
10471048
1048- err = scwReq .SetBody (req )
1049- if err != nil {
1050- return nil , err
1051- }
1052-
1053- var resp SecretVersion
1049+ var resp AccessSecretVersionResponse
10541050
10551051 err = s .client .Do (scwReq , & resp , opts ... )
10561052 if err != nil {
@@ -1059,19 +1055,19 @@ func (s *API) DisableSecretVersion(req *DisableSecretVersionRequest, opts ...scw
10591055 return & resp , nil
10601056}
10611057
1062- type AccessSecretVersionRequest struct {
1058+ type AccessSecretVersionByNameRequest struct {
10631059 // Region: region to target. If none is passed will use default region from the config.
10641060 Region scw.Region `json:"-"`
1065- // SecretID: ID of the secret.
1066- SecretID string `json:"-"`
1061+ // SecretName: name of the secret.
1062+ SecretName string `json:"-"`
10671063 // Revision: version number.
10681064 // The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
10691065 Revision string `json:"-"`
10701066}
10711067
1072- // AccessSecretVersion : access a secret's version using the secret's ID .
1073- // Access sensitive data in a secret's version specified by the `region`, `secret_id ` and `revision` parameters.
1074- func (s * API ) AccessSecretVersion (req * AccessSecretVersionRequest , opts ... scw.RequestOption ) (* AccessSecretVersionResponse , error ) {
1068+ // AccessSecretVersionByName : access a secret's version using the secret's name .
1069+ // Access sensitive data in a secret's version specified by the `region`, `secret_name ` and `revision` parameters.
1070+ func (s * API ) AccessSecretVersionByName (req * AccessSecretVersionByNameRequest , opts ... scw.RequestOption ) (* AccessSecretVersionResponse , error ) {
10751071 var err error
10761072
10771073 if req .Region == "" {
@@ -1083,8 +1079,8 @@ func (s *API) AccessSecretVersion(req *AccessSecretVersionRequest, opts ...scw.R
10831079 return nil , errors .New ("field Region cannot be empty in request" )
10841080 }
10851081
1086- if fmt .Sprint (req .SecretID ) == "" {
1087- return nil , errors .New ("field SecretID cannot be empty in request" )
1082+ if fmt .Sprint (req .SecretName ) == "" {
1083+ return nil , errors .New ("field SecretName cannot be empty in request" )
10881084 }
10891085
10901086 if fmt .Sprint (req .Revision ) == "" {
@@ -1093,7 +1089,7 @@ func (s *API) AccessSecretVersion(req *AccessSecretVersionRequest, opts ...scw.R
10931089
10941090 scwReq := & scw.ScalewayRequest {
10951091 Method : "GET" ,
1096- Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/access" ,
1092+ Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets-by-name /" + fmt .Sprint (req .SecretName ) + "/versions/" + fmt .Sprint (req .Revision ) + "/access" ,
10971093 Headers : http.Header {},
10981094 }
10991095
@@ -1106,19 +1102,19 @@ func (s *API) AccessSecretVersion(req *AccessSecretVersionRequest, opts ...scw.R
11061102 return & resp , nil
11071103}
11081104
1109- type AccessSecretVersionByNameRequest struct {
1105+ type DestroySecretVersionRequest struct {
11101106 // Region: region to target. If none is passed will use default region from the config.
11111107 Region scw.Region `json:"-"`
1112- // SecretName: name of the secret.
1113- SecretName string `json:"-"`
1108+ // SecretID: ID of the secret.
1109+ SecretID string `json:"-"`
11141110 // Revision: version number.
11151111 // The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
11161112 Revision string `json:"-"`
11171113}
11181114
1119- // AccessSecretVersionByName: access a secret's version using the secret's name .
1120- // Access sensitive data in a secret's version specified by the `region`, `secret_name` and `revision` parameters .
1121- func (s * API ) AccessSecretVersionByName (req * AccessSecretVersionByNameRequest , opts ... scw.RequestOption ) (* AccessSecretVersionResponse , error ) {
1115+ // DestroySecretVersion: delete a version.
1116+ // Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone .
1117+ func (s * API ) DestroySecretVersion (req * DestroySecretVersionRequest , opts ... scw.RequestOption ) (* SecretVersion , error ) {
11221118 var err error
11231119
11241120 if req .Region == "" {
@@ -1130,21 +1126,26 @@ func (s *API) AccessSecretVersionByName(req *AccessSecretVersionByNameRequest, o
11301126 return nil , errors .New ("field Region cannot be empty in request" )
11311127 }
11321128
1133- if fmt .Sprint (req .SecretName ) == "" {
1134- return nil , errors .New ("field SecretName cannot be empty in request" )
1129+ if fmt .Sprint (req .SecretID ) == "" {
1130+ return nil , errors .New ("field SecretID cannot be empty in request" )
11351131 }
11361132
11371133 if fmt .Sprint (req .Revision ) == "" {
11381134 return nil , errors .New ("field Revision cannot be empty in request" )
11391135 }
11401136
11411137 scwReq := & scw.ScalewayRequest {
1142- Method : "GET " ,
1143- Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets-by-name /" + fmt .Sprint (req .SecretName ) + "/versions/" + fmt .Sprint (req .Revision ) + "/access " ,
1138+ Method : "POST " ,
1139+ Path : "/secret-manager/v1alpha1/regions/" + fmt .Sprint (req .Region ) + "/secrets/" + fmt .Sprint (req .SecretID ) + "/versions/" + fmt .Sprint (req .Revision ) + "/destroy " ,
11441140 Headers : http.Header {},
11451141 }
11461142
1147- var resp AccessSecretVersionResponse
1143+ err = scwReq .SetBody (req )
1144+ if err != nil {
1145+ return nil , err
1146+ }
1147+
1148+ var resp SecretVersion
11481149
11491150 err = s .client .Do (scwReq , & resp , opts ... )
11501151 if err != nil {
0 commit comments