diff --git a/scaleway-async/scaleway_async/secret/v1alpha1/__init__.py b/scaleway-async/scaleway_async/secret/v1alpha1/__init__.py index 57b89214..e0f3bb62 100644 --- a/scaleway-async/scaleway_async/secret/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/secret/v1alpha1/__init__.py @@ -1,13 +1,15 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. +from .types import EphemeralPolicyAction from .types import ListFoldersRequestOrderBy from .types import ListSecretsRequestOrderBy from .types import Product -from .types import SecretEphemeralAction from .types import SecretStatus from .types import SecretType from .types import SecretVersionStatus from .types import AccessSecretVersionResponse +from .types import EphemeralPolicy +from .types import EphemeralStatus from .types import Folder from .types import ListFoldersResponse from .types import ListSecretVersionsResponse @@ -19,14 +21,16 @@ from .api import SecretV1Alpha1API __all__ = [ + "EphemeralPolicyAction", "ListFoldersRequestOrderBy", "ListSecretsRequestOrderBy", "Product", - "SecretEphemeralAction", "SecretStatus", "SecretType", "SecretVersionStatus", "AccessSecretVersionResponse", + "EphemeralPolicy", + "EphemeralStatus", "Folder", "ListFoldersResponse", "ListSecretVersionsResponse", diff --git a/scaleway-async/scaleway_async/secret/v1alpha1/api.py b/scaleway-async/scaleway_async/secret/v1alpha1/api.py index bdd026b1..81a169fa 100644 --- a/scaleway-async/scaleway_async/secret/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/secret/v1alpha1/api.py @@ -1,7 +1,6 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from datetime import datetime from typing import List, Optional from scaleway_core.api import API @@ -16,10 +15,11 @@ ListFoldersRequestOrderBy, ListSecretsRequestOrderBy, Product, - SecretEphemeralAction, SecretType, SecretVersionStatus, AccessSecretVersionResponse, + EphemeralPolicy, + EphemeralStatus, Folder, ListFoldersResponse, ListSecretVersionsResponse, @@ -68,13 +68,12 @@ async def create_secret( *, name: str, type_: SecretType, - ephemeral_action: SecretEphemeralAction, region: Optional[Region] = None, project_id: Optional[str] = None, tags: Optional[List[str]] = None, description: Optional[str] = None, path: Optional[str] = None, - expires_at: Optional[datetime] = None, + ephemeral_policy_template: Optional[EphemeralPolicy] = None, ) -> Secret: """ Create a secret. @@ -88,9 +87,8 @@ async def create_secret( (Optional.) See `Secret.Type` enum for description of values. If not specified, the type is `Opaque`. :param path: Path of the secret. (Optional.) Location of the secret in the directory structure. If not specified, the path is `/`. - :param expires_at: Expiration date of the secret. - (Optional.) Date on which the secret will be deleted or deactivated. - :param ephemeral_action: Action to be taken when the secret expires. + :param ephemeral_policy_template: Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. :return: :class:`Secret ` Usage: @@ -99,7 +97,6 @@ async def create_secret( result = await api.create_secret( name="example", type_=unknown_secret_type, - ephemeral_action=unknown_ephemeral_action, ) """ @@ -114,13 +111,12 @@ async def create_secret( CreateSecretRequest( name=name, type_=type_, - ephemeral_action=ephemeral_action, region=region, project_id=project_id, tags=tags, description=description, path=path, - expires_at=expires_at, + ephemeral_policy_template=ephemeral_policy_template, ), self.client, ), @@ -257,10 +253,11 @@ async def update_secret( tags: Optional[List[str]] = None, description: Optional[str] = None, path: Optional[str] = None, + ephemeral_policy_template: Optional[EphemeralPolicy] = None, ) -> Secret: """ Update metadata of a secret. - 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. + 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. :param region: Region to target. If none is passed will use default region from the config. :param secret_id: ID of the secret. :param name: Secret's updated name (optional). @@ -268,6 +265,8 @@ async def update_secret( :param description: Description of the secret. :param path: Path of the folder. (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`. + :param ephemeral_policy_template: Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. :return: :class:`Secret ` Usage: @@ -292,6 +291,7 @@ async def update_secret( tags=tags, description=description, path=path, + ephemeral_policy_template=ephemeral_policy_template, ), self.client, ), @@ -905,6 +905,7 @@ async def update_secret_version( revision: str, region: Optional[Region] = None, description: Optional[str] = None, + ephemeral_status: Optional[EphemeralStatus] = None, ) -> SecretVersion: """ Update metadata of a version. @@ -917,6 +918,8 @@ async def update_secret_version( - "latest" (the latest revision) - "latest_enabled" (the latest enabled revision). :param description: Description of the version. + :param ephemeral_status: Ephemeral status of the version. + (Optional.) Status 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. :return: :class:`SecretVersion ` Usage: @@ -943,6 +946,7 @@ async def update_secret_version( revision=revision, region=region, description=description, + ephemeral_status=ephemeral_status, ), self.client, ), diff --git a/scaleway-async/scaleway_async/secret/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/secret/v1alpha1/marshalling.py index 7369e7cf..4379b297 100644 --- a/scaleway-async/scaleway_async/secret/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/secret/v1alpha1/marshalling.py @@ -10,10 +10,12 @@ ) from dateutil import parser from .types import ( + EphemeralPolicyAction, Product, - SecretEphemeralAction, SecretType, AccessSecretVersionResponse, + EphemeralPolicy, + EphemeralStatus, Folder, ListFoldersResponse, ListSecretVersionsResponse, @@ -32,6 +34,46 @@ ) +def unmarshal_EphemeralPolicy(data: Any) -> EphemeralPolicy: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'EphemeralPolicy' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("action", None) + args["action"] = field + + field = data.get("expires_once_accessed", None) + args["expires_once_accessed"] = field + + field = data.get("time_to_live", None) + args["time_to_live"] = field + + return EphemeralPolicy(**args) + + +def unmarshal_EphemeralStatus(data: Any) -> EphemeralStatus: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'EphemeralStatus' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("action", None) + args["action"] = field + + field = data.get("expires_at", None) + args["expires_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("expires_once_accessed", None) + args["expires_once_accessed"] = field + + return EphemeralStatus(**args) + + def unmarshal_Folder(data: Any) -> Folder: if type(data) is not dict: raise TypeError( @@ -75,11 +117,10 @@ def unmarshal_Secret(data: Any) -> Secret: field = data.get("description", None) args["description"] = field - field = data.get("ephemeral_action", None) - args["ephemeral_action"] = field - - field = data.get("expires_at", None) - args["expires_at"] = parser.isoparse(field) if type(field) is str else field + field = data.get("ephemeral_policy_template", None) + args["ephemeral_policy_template"] = ( + unmarshal_EphemeralPolicy(field) if field is not None else None + ) field = data.get("id", None) args["id"] = field @@ -134,6 +175,11 @@ def unmarshal_SecretVersion(data: Any) -> SecretVersion: field = data.get("description", None) args["description"] = field + field = data.get("ephemeral_status", None) + args["ephemeral_status"] = ( + unmarshal_EphemeralStatus(field) if field is not None else None + ) + field = data.get("is_latest", None) args["is_latest"] = field @@ -249,6 +295,42 @@ def unmarshal_ListTagsResponse(data: Any) -> ListTagsResponse: return ListTagsResponse(**args) +def marshal_EphemeralPolicy( + request: EphemeralPolicy, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.action is not None: + output["action"] = EphemeralPolicyAction(request.action) + + if request.expires_once_accessed is not None: + output["expires_once_accessed"] = request.expires_once_accessed + + if request.time_to_live is not None: + output["time_to_live"] = request.time_to_live + + return output + + +def marshal_EphemeralStatus( + request: EphemeralStatus, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.action is not None: + output["action"] = EphemeralPolicyAction(request.action) + + if request.expires_at is not None: + output["expires_at"] = request.expires_at.astimezone().isoformat() + + if request.expires_once_accessed is not None: + output["expires_once_accessed"] = request.expires_once_accessed + + return output + + def marshal_PasswordGenerationParams( request: PasswordGenerationParams, defaults: ProfileDefaults, @@ -315,11 +397,10 @@ def marshal_CreateSecretRequest( if request.description is not None: output["description"] = request.description - if request.ephemeral_action is not None: - output["ephemeral_action"] = SecretEphemeralAction(request.ephemeral_action) - - if request.expires_at is not None: - output["expires_at"] = request.expires_at.astimezone().isoformat() + if request.ephemeral_policy_template is not None: + output["ephemeral_policy_template"] = marshal_EphemeralPolicy( + request.ephemeral_policy_template, defaults + ) if request.name is not None: output["name"] = request.name @@ -413,6 +494,11 @@ def marshal_UpdateSecretRequest( if request.description is not None: output["description"] = request.description + if request.ephemeral_policy_template is not None: + output["ephemeral_policy_template"] = marshal_EphemeralPolicy( + request.ephemeral_policy_template, defaults + ) + if request.name is not None: output["name"] = request.name @@ -434,4 +520,9 @@ def marshal_UpdateSecretVersionRequest( if request.description is not None: output["description"] = request.description + if request.ephemeral_status is not None: + output["ephemeral_status"] = marshal_EphemeralStatus( + request.ephemeral_status, defaults + ) + return output diff --git a/scaleway-async/scaleway_async/secret/v1alpha1/types.py b/scaleway-async/scaleway_async/secret/v1alpha1/types.py index a6e713de..a85ddacc 100644 --- a/scaleway-async/scaleway_async/secret/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/secret/v1alpha1/types.py @@ -15,6 +15,15 @@ ) +class EphemeralPolicyAction(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_ACTION = "unknown_action" + DELETE = "delete" + DISABLE = "disable" + + def __str__(self) -> str: + return str(self.value) + + class ListFoldersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -45,15 +54,6 @@ def __str__(self) -> str: return str(self.value) -class SecretEphemeralAction(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_EPHEMERAL_ACTION = "unknown_ephemeral_action" - DELETE_SECRET = "delete_secret" - DISABLE_SECRET = "disable_secret" - - def __str__(self) -> str: - return str(self.value) - - class SecretStatus(str, Enum, metaclass=StrEnumMeta): READY = "ready" LOCKED = "locked" @@ -111,6 +111,54 @@ class AccessSecretVersionResponse: """ +@dataclass +class EphemeralPolicy: + """ + Ephemeral policy. + """ + + time_to_live: Optional[str] + """ + Time frame, from one second and up to one year, during which the secret's versions are valid. + """ + + expires_once_accessed: Optional[bool] + """ + Returns `true` if the version expires after a single user access. + """ + + action: EphemeralPolicyAction + """ + Action to perform when the version of a secret expires. + See the `EphemeralPolicy.Action` enum for a description of values. + """ + + +@dataclass +class EphemeralStatus: + """ + Ephemeral status. + """ + + expires_at: Optional[datetime] + """ + The version's expiration date. + (Optional.) If not specified, the version does not have an expiration date. + """ + + expires_once_accessed: Optional[bool] + """ + Returns `true` if the version expires after a single user access. + (Optional.) If not specified, the version can be accessed an unlimited amount of times. + """ + + action: EphemeralPolicyAction + """ + Action to perform when the version of a secret expires. + See `EphemeralPolicy.Action` enum for a description of values. + """ + + @dataclass class Folder: """ @@ -324,16 +372,10 @@ class Secret: Location of the secret in the directory structure. """ - expires_at: Optional[datetime] - """ - Expiration date of the secret. - (Optional.) Date on which the secret will be deleted or deactivated. - """ - - ephemeral_action: SecretEphemeralAction + ephemeral_policy_template: Optional[EphemeralPolicy] """ - Action to be taken when the secret expires. - See `Secret.EphemeralAction` enum for description of values. + Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. """ region: Region @@ -388,6 +430,12 @@ class SecretVersion: Returns `true` if the version is the latest. """ + ephemeral_status: Optional[EphemeralStatus] + """ + Status of the ephemeral version. + 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. + """ + @dataclass class CreateSecretRequest: @@ -428,15 +476,10 @@ class CreateSecretRequest: (Optional.) Location of the secret in the directory structure. If not specified, the path is `/`. """ - expires_at: Optional[datetime] - """ - Expiration date of the secret. - (Optional.) Date on which the secret will be deleted or deactivated. - """ - - ephemeral_action: SecretEphemeralAction + ephemeral_policy_template: Optional[EphemeralPolicy] """ - Action to be taken when the secret expires. + Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. """ @@ -529,6 +572,12 @@ class UpdateSecretRequest: (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`. """ + ephemeral_policy_template: Optional[EphemeralPolicy] + """ + Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. + """ + @dataclass class ListSecretsRequest: @@ -849,6 +898,12 @@ class UpdateSecretVersionRequest: Description of the version. """ + ephemeral_status: Optional[EphemeralStatus] + """ + Ephemeral status of the version. + (Optional.) Status 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. + """ + @dataclass class ListSecretVersionsRequest: diff --git a/scaleway/scaleway/secret/v1alpha1/__init__.py b/scaleway/scaleway/secret/v1alpha1/__init__.py index 57b89214..e0f3bb62 100644 --- a/scaleway/scaleway/secret/v1alpha1/__init__.py +++ b/scaleway/scaleway/secret/v1alpha1/__init__.py @@ -1,13 +1,15 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. +from .types import EphemeralPolicyAction from .types import ListFoldersRequestOrderBy from .types import ListSecretsRequestOrderBy from .types import Product -from .types import SecretEphemeralAction from .types import SecretStatus from .types import SecretType from .types import SecretVersionStatus from .types import AccessSecretVersionResponse +from .types import EphemeralPolicy +from .types import EphemeralStatus from .types import Folder from .types import ListFoldersResponse from .types import ListSecretVersionsResponse @@ -19,14 +21,16 @@ from .api import SecretV1Alpha1API __all__ = [ + "EphemeralPolicyAction", "ListFoldersRequestOrderBy", "ListSecretsRequestOrderBy", "Product", - "SecretEphemeralAction", "SecretStatus", "SecretType", "SecretVersionStatus", "AccessSecretVersionResponse", + "EphemeralPolicy", + "EphemeralStatus", "Folder", "ListFoldersResponse", "ListSecretVersionsResponse", diff --git a/scaleway/scaleway/secret/v1alpha1/api.py b/scaleway/scaleway/secret/v1alpha1/api.py index ddcf9a41..f73e40f3 100644 --- a/scaleway/scaleway/secret/v1alpha1/api.py +++ b/scaleway/scaleway/secret/v1alpha1/api.py @@ -1,7 +1,6 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from datetime import datetime from typing import List, Optional from scaleway_core.api import API @@ -16,10 +15,11 @@ ListFoldersRequestOrderBy, ListSecretsRequestOrderBy, Product, - SecretEphemeralAction, SecretType, SecretVersionStatus, AccessSecretVersionResponse, + EphemeralPolicy, + EphemeralStatus, Folder, ListFoldersResponse, ListSecretVersionsResponse, @@ -68,13 +68,12 @@ def create_secret( *, name: str, type_: SecretType, - ephemeral_action: SecretEphemeralAction, region: Optional[Region] = None, project_id: Optional[str] = None, tags: Optional[List[str]] = None, description: Optional[str] = None, path: Optional[str] = None, - expires_at: Optional[datetime] = None, + ephemeral_policy_template: Optional[EphemeralPolicy] = None, ) -> Secret: """ Create a secret. @@ -88,9 +87,8 @@ def create_secret( (Optional.) See `Secret.Type` enum for description of values. If not specified, the type is `Opaque`. :param path: Path of the secret. (Optional.) Location of the secret in the directory structure. If not specified, the path is `/`. - :param expires_at: Expiration date of the secret. - (Optional.) Date on which the secret will be deleted or deactivated. - :param ephemeral_action: Action to be taken when the secret expires. + :param ephemeral_policy_template: Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. :return: :class:`Secret ` Usage: @@ -99,7 +97,6 @@ def create_secret( result = api.create_secret( name="example", type_=unknown_secret_type, - ephemeral_action=unknown_ephemeral_action, ) """ @@ -114,13 +111,12 @@ def create_secret( CreateSecretRequest( name=name, type_=type_, - ephemeral_action=ephemeral_action, region=region, project_id=project_id, tags=tags, description=description, path=path, - expires_at=expires_at, + ephemeral_policy_template=ephemeral_policy_template, ), self.client, ), @@ -257,10 +253,11 @@ def update_secret( tags: Optional[List[str]] = None, description: Optional[str] = None, path: Optional[str] = None, + ephemeral_policy_template: Optional[EphemeralPolicy] = None, ) -> Secret: """ Update metadata of a secret. - 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. + 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. :param region: Region to target. If none is passed will use default region from the config. :param secret_id: ID of the secret. :param name: Secret's updated name (optional). @@ -268,6 +265,8 @@ def update_secret( :param description: Description of the secret. :param path: Path of the folder. (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`. + :param ephemeral_policy_template: Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. :return: :class:`Secret ` Usage: @@ -292,6 +291,7 @@ def update_secret( tags=tags, description=description, path=path, + ephemeral_policy_template=ephemeral_policy_template, ), self.client, ), @@ -905,6 +905,7 @@ def update_secret_version( revision: str, region: Optional[Region] = None, description: Optional[str] = None, + ephemeral_status: Optional[EphemeralStatus] = None, ) -> SecretVersion: """ Update metadata of a version. @@ -917,6 +918,8 @@ def update_secret_version( - "latest" (the latest revision) - "latest_enabled" (the latest enabled revision). :param description: Description of the version. + :param ephemeral_status: Ephemeral status of the version. + (Optional.) Status 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. :return: :class:`SecretVersion ` Usage: @@ -943,6 +946,7 @@ def update_secret_version( revision=revision, region=region, description=description, + ephemeral_status=ephemeral_status, ), self.client, ), diff --git a/scaleway/scaleway/secret/v1alpha1/marshalling.py b/scaleway/scaleway/secret/v1alpha1/marshalling.py index 7369e7cf..4379b297 100644 --- a/scaleway/scaleway/secret/v1alpha1/marshalling.py +++ b/scaleway/scaleway/secret/v1alpha1/marshalling.py @@ -10,10 +10,12 @@ ) from dateutil import parser from .types import ( + EphemeralPolicyAction, Product, - SecretEphemeralAction, SecretType, AccessSecretVersionResponse, + EphemeralPolicy, + EphemeralStatus, Folder, ListFoldersResponse, ListSecretVersionsResponse, @@ -32,6 +34,46 @@ ) +def unmarshal_EphemeralPolicy(data: Any) -> EphemeralPolicy: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'EphemeralPolicy' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("action", None) + args["action"] = field + + field = data.get("expires_once_accessed", None) + args["expires_once_accessed"] = field + + field = data.get("time_to_live", None) + args["time_to_live"] = field + + return EphemeralPolicy(**args) + + +def unmarshal_EphemeralStatus(data: Any) -> EphemeralStatus: + if type(data) is not dict: + raise TypeError( + f"Unmarshalling the type 'EphemeralStatus' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("action", None) + args["action"] = field + + field = data.get("expires_at", None) + args["expires_at"] = parser.isoparse(field) if type(field) is str else field + + field = data.get("expires_once_accessed", None) + args["expires_once_accessed"] = field + + return EphemeralStatus(**args) + + def unmarshal_Folder(data: Any) -> Folder: if type(data) is not dict: raise TypeError( @@ -75,11 +117,10 @@ def unmarshal_Secret(data: Any) -> Secret: field = data.get("description", None) args["description"] = field - field = data.get("ephemeral_action", None) - args["ephemeral_action"] = field - - field = data.get("expires_at", None) - args["expires_at"] = parser.isoparse(field) if type(field) is str else field + field = data.get("ephemeral_policy_template", None) + args["ephemeral_policy_template"] = ( + unmarshal_EphemeralPolicy(field) if field is not None else None + ) field = data.get("id", None) args["id"] = field @@ -134,6 +175,11 @@ def unmarshal_SecretVersion(data: Any) -> SecretVersion: field = data.get("description", None) args["description"] = field + field = data.get("ephemeral_status", None) + args["ephemeral_status"] = ( + unmarshal_EphemeralStatus(field) if field is not None else None + ) + field = data.get("is_latest", None) args["is_latest"] = field @@ -249,6 +295,42 @@ def unmarshal_ListTagsResponse(data: Any) -> ListTagsResponse: return ListTagsResponse(**args) +def marshal_EphemeralPolicy( + request: EphemeralPolicy, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.action is not None: + output["action"] = EphemeralPolicyAction(request.action) + + if request.expires_once_accessed is not None: + output["expires_once_accessed"] = request.expires_once_accessed + + if request.time_to_live is not None: + output["time_to_live"] = request.time_to_live + + return output + + +def marshal_EphemeralStatus( + request: EphemeralStatus, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.action is not None: + output["action"] = EphemeralPolicyAction(request.action) + + if request.expires_at is not None: + output["expires_at"] = request.expires_at.astimezone().isoformat() + + if request.expires_once_accessed is not None: + output["expires_once_accessed"] = request.expires_once_accessed + + return output + + def marshal_PasswordGenerationParams( request: PasswordGenerationParams, defaults: ProfileDefaults, @@ -315,11 +397,10 @@ def marshal_CreateSecretRequest( if request.description is not None: output["description"] = request.description - if request.ephemeral_action is not None: - output["ephemeral_action"] = SecretEphemeralAction(request.ephemeral_action) - - if request.expires_at is not None: - output["expires_at"] = request.expires_at.astimezone().isoformat() + if request.ephemeral_policy_template is not None: + output["ephemeral_policy_template"] = marshal_EphemeralPolicy( + request.ephemeral_policy_template, defaults + ) if request.name is not None: output["name"] = request.name @@ -413,6 +494,11 @@ def marshal_UpdateSecretRequest( if request.description is not None: output["description"] = request.description + if request.ephemeral_policy_template is not None: + output["ephemeral_policy_template"] = marshal_EphemeralPolicy( + request.ephemeral_policy_template, defaults + ) + if request.name is not None: output["name"] = request.name @@ -434,4 +520,9 @@ def marshal_UpdateSecretVersionRequest( if request.description is not None: output["description"] = request.description + if request.ephemeral_status is not None: + output["ephemeral_status"] = marshal_EphemeralStatus( + request.ephemeral_status, defaults + ) + return output diff --git a/scaleway/scaleway/secret/v1alpha1/types.py b/scaleway/scaleway/secret/v1alpha1/types.py index a6e713de..a85ddacc 100644 --- a/scaleway/scaleway/secret/v1alpha1/types.py +++ b/scaleway/scaleway/secret/v1alpha1/types.py @@ -15,6 +15,15 @@ ) +class EphemeralPolicyAction(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_ACTION = "unknown_action" + DELETE = "delete" + DISABLE = "disable" + + def __str__(self) -> str: + return str(self.value) + + class ListFoldersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -45,15 +54,6 @@ def __str__(self) -> str: return str(self.value) -class SecretEphemeralAction(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_EPHEMERAL_ACTION = "unknown_ephemeral_action" - DELETE_SECRET = "delete_secret" - DISABLE_SECRET = "disable_secret" - - def __str__(self) -> str: - return str(self.value) - - class SecretStatus(str, Enum, metaclass=StrEnumMeta): READY = "ready" LOCKED = "locked" @@ -111,6 +111,54 @@ class AccessSecretVersionResponse: """ +@dataclass +class EphemeralPolicy: + """ + Ephemeral policy. + """ + + time_to_live: Optional[str] + """ + Time frame, from one second and up to one year, during which the secret's versions are valid. + """ + + expires_once_accessed: Optional[bool] + """ + Returns `true` if the version expires after a single user access. + """ + + action: EphemeralPolicyAction + """ + Action to perform when the version of a secret expires. + See the `EphemeralPolicy.Action` enum for a description of values. + """ + + +@dataclass +class EphemeralStatus: + """ + Ephemeral status. + """ + + expires_at: Optional[datetime] + """ + The version's expiration date. + (Optional.) If not specified, the version does not have an expiration date. + """ + + expires_once_accessed: Optional[bool] + """ + Returns `true` if the version expires after a single user access. + (Optional.) If not specified, the version can be accessed an unlimited amount of times. + """ + + action: EphemeralPolicyAction + """ + Action to perform when the version of a secret expires. + See `EphemeralPolicy.Action` enum for a description of values. + """ + + @dataclass class Folder: """ @@ -324,16 +372,10 @@ class Secret: Location of the secret in the directory structure. """ - expires_at: Optional[datetime] - """ - Expiration date of the secret. - (Optional.) Date on which the secret will be deleted or deactivated. - """ - - ephemeral_action: SecretEphemeralAction + ephemeral_policy_template: Optional[EphemeralPolicy] """ - Action to be taken when the secret expires. - See `Secret.EphemeralAction` enum for description of values. + Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. """ region: Region @@ -388,6 +430,12 @@ class SecretVersion: Returns `true` if the version is the latest. """ + ephemeral_status: Optional[EphemeralStatus] + """ + Status of the ephemeral version. + 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. + """ + @dataclass class CreateSecretRequest: @@ -428,15 +476,10 @@ class CreateSecretRequest: (Optional.) Location of the secret in the directory structure. If not specified, the path is `/`. """ - expires_at: Optional[datetime] - """ - Expiration date of the secret. - (Optional.) Date on which the secret will be deleted or deactivated. - """ - - ephemeral_action: SecretEphemeralAction + ephemeral_policy_template: Optional[EphemeralPolicy] """ - Action to be taken when the secret expires. + Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. By default, the policy is applied to all the secret's versions. """ @@ -529,6 +572,12 @@ class UpdateSecretRequest: (Optional.) Location of the folder in the directory structure. If not specified, the path is `/`. """ + ephemeral_policy_template: Optional[EphemeralPolicy] + """ + Ephemeral policy of the secret. + (Optional.) Policy that defines whether/when a secret's versions expire. + """ + @dataclass class ListSecretsRequest: @@ -849,6 +898,12 @@ class UpdateSecretVersionRequest: Description of the version. """ + ephemeral_status: Optional[EphemeralStatus] + """ + Ephemeral status of the version. + (Optional.) Status 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. + """ + @dataclass class ListSecretVersionsRequest: