3939 _ = namegenerator .GetRandomName
4040)
4141
42+ type EphemeralPolicyAction string
43+
44+ const (
45+ EphemeralPolicyActionUnknownAction = EphemeralPolicyAction ("unknown_action" )
46+ // The version is deleted once it expires.
47+ EphemeralPolicyActionDelete = EphemeralPolicyAction ("delete" )
48+ // The version is disabled once it expires.
49+ EphemeralPolicyActionDisable = EphemeralPolicyAction ("disable" )
50+ )
51+
52+ func (enum EphemeralPolicyAction ) String () string {
53+ if enum == "" {
54+ // return default value if empty
55+ return "unknown_action"
56+ }
57+ return string (enum )
58+ }
59+
60+ func (enum EphemeralPolicyAction ) MarshalJSON () ([]byte , error ) {
61+ return []byte (fmt .Sprintf (`"%s"` , enum )), nil
62+ }
63+
64+ func (enum * EphemeralPolicyAction ) UnmarshalJSON (data []byte ) error {
65+ tmp := ""
66+
67+ if err := json .Unmarshal (data , & tmp ); err != nil {
68+ return err
69+ }
70+
71+ * enum = EphemeralPolicyAction (EphemeralPolicyAction (tmp ).String ())
72+ return nil
73+ }
74+
4275type ListFoldersRequestOrderBy string
4376
4477const (
@@ -135,39 +168,6 @@ func (enum *Product) UnmarshalJSON(data []byte) error {
135168 return nil
136169}
137170
138- type SecretEphemeralAction string
139-
140- const (
141- SecretEphemeralActionUnknownEphemeralAction = SecretEphemeralAction ("unknown_ephemeral_action" )
142- // After expiration, the secret and all its versions will be deleted.
143- SecretEphemeralActionDeleteSecret = SecretEphemeralAction ("delete_secret" )
144- // After expiration, all versions of the secret will be disabled.
145- SecretEphemeralActionDisableSecret = SecretEphemeralAction ("disable_secret" )
146- )
147-
148- func (enum SecretEphemeralAction ) String () string {
149- if enum == "" {
150- // return default value if empty
151- return "unknown_ephemeral_action"
152- }
153- return string (enum )
154- }
155-
156- func (enum SecretEphemeralAction ) MarshalJSON () ([]byte , error ) {
157- return []byte (fmt .Sprintf (`"%s"` , enum )), nil
158- }
159-
160- func (enum * SecretEphemeralAction ) UnmarshalJSON (data []byte ) error {
161- tmp := ""
162-
163- if err := json .Unmarshal (data , & tmp ); err != nil {
164- return err
165- }
166-
167- * enum = SecretEphemeralAction (SecretEphemeralAction (tmp ).String ())
168- return nil
169- }
170-
171171type SecretStatus string
172172
173173const (
@@ -265,6 +265,32 @@ func (enum *SecretVersionStatus) UnmarshalJSON(data []byte) error {
265265 return nil
266266}
267267
268+ // EphemeralProperties: ephemeral properties.
269+ type EphemeralProperties struct {
270+ // ExpiresAt: (Optional.) If not specified, the version does not have an expiration date.
271+ ExpiresAt * time.Time `json:"expires_at"`
272+
273+ // ExpiresOnceAccessed: (Optional.) If not specified, the version can be accessed an unlimited amount of times.
274+ ExpiresOnceAccessed * bool `json:"expires_once_accessed"`
275+
276+ // Action: see `EphemeralPolicy.Action` enum for a description of values.
277+ // Default value: unknown_action
278+ Action EphemeralPolicyAction `json:"action"`
279+ }
280+
281+ // EphemeralPolicy: ephemeral policy.
282+ type EphemeralPolicy struct {
283+ // TimeToLive: time frame, from one second and up to one year, during which the secret's versions are valid.
284+ TimeToLive * scw.Duration `json:"time_to_live"`
285+
286+ // ExpiresOnceAccessed: returns `true` if the version expires after a single user access.
287+ ExpiresOnceAccessed * bool `json:"expires_once_accessed"`
288+
289+ // Action: see the `EphemeralPolicy.Action` enum for a description of values.
290+ // Default value: unknown_action
291+ Action EphemeralPolicyAction `json:"action"`
292+ }
293+
268294// PasswordGenerationParams: password generation params.
269295type PasswordGenerationParams struct {
270296 // Length: length of the password to generate (between 1 and 1024).
@@ -330,6 +356,9 @@ type SecretVersion struct {
330356
331357 // IsLatest: returns `true` if the version is the latest.
332358 IsLatest bool `json:"is_latest"`
359+
360+ // EphemeralProperties: returns the version's expiration date, whether it expires after being accessed once, and the action to perform (disable or delete) once the version expires.
361+ EphemeralProperties * EphemeralProperties `json:"ephemeral_properties"`
333362}
334363
335364// Secret: secret.
@@ -376,12 +405,8 @@ type Secret struct {
376405 // Path: location of the secret in the directory structure.
377406 Path string `json:"path"`
378407
379- // ExpiresAt: (Optional.) Date on which the secret will be deleted or deactivated.
380- ExpiresAt * time.Time `json:"expires_at"`
381-
382- // EphemeralAction: see `Secret.EphemeralAction` enum for description of values.
383- // Default value: unknown_ephemeral_action
384- EphemeralAction SecretEphemeralAction `json:"ephemeral_action"`
408+ // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions.
409+ EphemeralPolicy * EphemeralPolicy `json:"ephemeral_policy"`
385410
386411 // Region: region of the secret.
387412 Region scw.Region `json:"region"`
@@ -490,12 +515,8 @@ type CreateSecretRequest struct {
490515 // Path: (Optional.) Location of the secret in the directory structure. If not specified, the path is `/`.
491516 Path * string `json:"path,omitempty"`
492517
493- // ExpiresAt: (Optional.) Date on which the secret will be deleted or deactivated.
494- ExpiresAt * time.Time `json:"expires_at,omitempty"`
495-
496- // EphemeralAction: action to be taken when the secret expires.
497- // Default value: unknown_ephemeral_action
498- EphemeralAction SecretEphemeralAction `json:"ephemeral_action"`
518+ // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions.
519+ EphemeralPolicy * EphemeralPolicy `json:"ephemeral_policy,omitempty"`
499520}
500521
501522// CreateSecretVersionRequest: create secret version request.
@@ -919,6 +940,9 @@ type UpdateSecretRequest struct {
919940
920941 // Path: (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`.
921942 Path * string `json:"path,omitempty"`
943+
944+ // EphemeralPolicy: (Optional.) Policy that defines whether/when a secret's versions expire.
945+ EphemeralPolicy * EphemeralPolicy `json:"ephemeral_policy,omitempty"`
922946}
923947
924948// UpdateSecretVersionRequest: update secret version request.
@@ -937,6 +961,9 @@ type UpdateSecretVersionRequest struct {
937961
938962 // Description: description of the version.
939963 Description * string `json:"description,omitempty"`
964+
965+ // EphemeralProperties: (Optional.) Properties that defines the version's expiration date, whether it expires after being accessed once, and the action to perform (disable or delete) once the version expires.
966+ EphemeralProperties * EphemeralProperties `json:"ephemeral_properties,omitempty"`
940967}
941968
942969// This API allows you to conveniently store, access and share sensitive data.
@@ -1098,7 +1125,7 @@ func (s *API) GetSecretByName(req *GetSecretByNameRequest, opts ...scw.RequestOp
10981125 return & resp , nil
10991126}
11001127
1101- // UpdateSecret: Edit a secret's metadata such as name, tag(s) and description . The secret to update is specified by the `secret_id` and `region` parameters.
1128+ // UpdateSecret: Edit a secret's metadata such as name, tag(s), description and ephemeral policy . The secret to update is specified by the `secret_id` and `region` parameters.
11021129func (s * API ) UpdateSecret (req * UpdateSecretRequest , opts ... scw.RequestOption ) (* Secret , error ) {
11031130 var err error
11041131
0 commit comments