Skip to content

Commit 680f53e

Browse files
authored
feat(secret_manager): add ephemeral action to secret creation (#352)
1 parent 92079fc commit 680f53e

File tree

8 files changed

+152
-0
lines changed

8 files changed

+152
-0
lines changed

scaleway-async/scaleway_async/secret/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .types import ListFoldersRequestOrderBy
44
from .types import ListSecretsRequestOrderBy
55
from .types import Product
6+
from .types import SecretEphemeralAction
67
from .types import SecretStatus
78
from .types import SecretType
89
from .types import SecretVersionStatus
@@ -21,6 +22,7 @@
2122
"ListFoldersRequestOrderBy",
2223
"ListSecretsRequestOrderBy",
2324
"Product",
25+
"SecretEphemeralAction",
2426
"SecretStatus",
2527
"SecretType",
2628
"SecretVersionStatus",

scaleway-async/scaleway_async/secret/v1alpha1/api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
33

4+
from datetime import datetime
45
from typing import List, Optional
56

67
from scaleway_core.api import API
@@ -15,6 +16,7 @@
1516
ListFoldersRequestOrderBy,
1617
ListSecretsRequestOrderBy,
1718
Product,
19+
SecretEphemeralAction,
1820
SecretType,
1921
SecretVersionStatus,
2022
AccessSecretVersionResponse,
@@ -66,11 +68,13 @@ async def create_secret(
6668
*,
6769
name: str,
6870
type_: SecretType,
71+
ephemeral_action: SecretEphemeralAction,
6972
region: Optional[Region] = None,
7073
project_id: Optional[str] = None,
7174
tags: Optional[List[str]] = None,
7275
description: Optional[str] = None,
7376
path: Optional[str] = None,
77+
expires_at: Optional[datetime] = None,
7478
) -> Secret:
7579
"""
7680
Create a secret.
@@ -84,6 +88,9 @@ async def create_secret(
8488
(Optional.) See `Secret.Type` enum for description of values. If not specified, the type is `Opaque`.
8589
:param path: Path of the secret.
8690
(Optional.) Location of the secret in the directory structure. If not specified, the path is `/`.
91+
:param expires_at: Expiration date of the secret.
92+
(Optional.) Date on which the secret will be deleted or deactivated.
93+
:param ephemeral_action: Action to be taken when the secret expires.
8794
:return: :class:`Secret <Secret>`
8895
8996
Usage:
@@ -92,6 +99,7 @@ async def create_secret(
9299
result = await api.create_secret(
93100
name="example",
94101
type_=unknown_secret_type,
102+
ephemeral_action=unknown_ephemeral_action,
95103
)
96104
"""
97105

@@ -106,11 +114,13 @@ async def create_secret(
106114
CreateSecretRequest(
107115
name=name,
108116
type_=type_,
117+
ephemeral_action=ephemeral_action,
109118
region=region,
110119
project_id=project_id,
111120
tags=tags,
112121
description=description,
113122
path=path,
123+
expires_at=expires_at,
114124
),
115125
self.client,
116126
),
@@ -303,6 +313,7 @@ async def list_secrets(
303313
name: Optional[str] = None,
304314
is_managed: Optional[bool] = None,
305315
path: Optional[str] = None,
316+
is_ephemeral: Optional[bool] = None,
306317
) -> ListSecretsResponse:
307318
"""
308319
List secrets.
@@ -317,6 +328,7 @@ async def list_secrets(
317328
:param name: Filter by secret name (optional).
318329
:param is_managed: Filter by managed / not managed (optional).
319330
:param path: Filter by path (optional).
331+
:param is_ephemeral: Filter by ephemeral / not ephemeral (optional).
320332
:return: :class:`ListSecretsResponse <ListSecretsResponse>`
321333
322334
Usage:
@@ -333,6 +345,7 @@ async def list_secrets(
333345
"GET",
334346
f"/secret-manager/v1alpha1/regions/{param_region}/secrets",
335347
params={
348+
"is_ephemeral": is_ephemeral,
336349
"is_managed": is_managed,
337350
"name": name,
338351
"order_by": order_by,
@@ -362,6 +375,7 @@ async def list_secrets_all(
362375
name: Optional[str] = None,
363376
is_managed: Optional[bool] = None,
364377
path: Optional[str] = None,
378+
is_ephemeral: Optional[bool] = None,
365379
) -> List[Secret]:
366380
"""
367381
List secrets.
@@ -376,6 +390,7 @@ async def list_secrets_all(
376390
:param name: Filter by secret name (optional).
377391
:param is_managed: Filter by managed / not managed (optional).
378392
:param path: Filter by path (optional).
393+
:param is_ephemeral: Filter by ephemeral / not ephemeral (optional).
379394
:return: :class:`List[ListSecretsResponse] <List[ListSecretsResponse]>`
380395
381396
Usage:
@@ -399,6 +414,7 @@ async def list_secrets_all(
399414
"name": name,
400415
"is_managed": is_managed,
401416
"path": path,
417+
"is_ephemeral": is_ephemeral,
402418
},
403419
)
404420

scaleway-async/scaleway_async/secret/v1alpha1/marshalling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from dateutil import parser
1212
from .types import (
1313
Product,
14+
SecretEphemeralAction,
1415
SecretType,
1516
AccessSecretVersionResponse,
1617
Folder,
@@ -71,9 +72,18 @@ def unmarshal_Secret(data: Any) -> Secret:
7172
field = data.get("description", None)
7273
args["description"] = field
7374

75+
field = data.get("ephemeral_action", None)
76+
args["ephemeral_action"] = field
77+
78+
field = data.get("expires_at", None)
79+
args["expires_at"] = parser.isoparse(field) if type(field) is str else field
80+
7481
field = data.get("id", None)
7582
args["id"] = field
7683

84+
field = data.get("is_ephemeral", None)
85+
args["is_ephemeral"] = field
86+
7787
field = data.get("is_managed", None)
7888
args["is_managed"] = field
7989

@@ -305,6 +315,12 @@ def marshal_CreateSecretRequest(
305315
if request.description is not None:
306316
output["description"] = request.description
307317

318+
if request.ephemeral_action is not None:
319+
output["ephemeral_action"] = SecretEphemeralAction(request.ephemeral_action)
320+
321+
if request.expires_at is not None:
322+
output["expires_at"] = request.expires_at.astimezone().isoformat()
323+
308324
if request.name is not None:
309325
output["name"] = request.name
310326

scaleway-async/scaleway_async/secret/v1alpha1/types.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ def __str__(self) -> str:
4444
return str(self.value)
4545

4646

47+
class SecretEphemeralAction(str, Enum, metaclass=StrEnumMeta):
48+
UNKNOWN_EPHEMERAL_ACTION = "unknown_ephemeral_action"
49+
DELETE_SECRET = "delete_secret"
50+
DISABLE_SECRET = "disable_secret"
51+
52+
def __str__(self) -> str:
53+
return str(self.value)
54+
55+
4756
class SecretStatus(str, Enum, metaclass=StrEnumMeta):
4857
READY = "ready"
4958
LOCKED = "locked"
@@ -309,6 +318,23 @@ class Secret:
309318
Location of the secret in the directory structure.
310319
"""
311320

321+
expires_at: Optional[datetime]
322+
"""
323+
Expiration date of the secret.
324+
(Optional.) Date on which the secret will be deleted or deactivated.
325+
"""
326+
327+
ephemeral_action: SecretEphemeralAction
328+
"""
329+
Action to be taken when the secret expires.
330+
See `Secret.EphemeralAction` enum for description of values.
331+
"""
332+
333+
is_ephemeral: bool
334+
"""
335+
Returns `true` for secrets that are ephemeral.
336+
"""
337+
312338
region: Region
313339
"""
314340
Region of the secret.
@@ -401,6 +427,17 @@ class CreateSecretRequest:
401427
(Optional.) Location of the secret in the directory structure. If not specified, the path is `/`.
402428
"""
403429

430+
expires_at: Optional[datetime]
431+
"""
432+
Expiration date of the secret.
433+
(Optional.) Date on which the secret will be deleted or deactivated.
434+
"""
435+
436+
ephemeral_action: SecretEphemeralAction
437+
"""
438+
Action to be taken when the secret expires.
439+
"""
440+
404441

405442
@dataclass
406443
class CreateFolderRequest:
@@ -535,6 +572,11 @@ class ListSecretsRequest:
535572
Filter by path (optional).
536573
"""
537574

575+
is_ephemeral: Optional[bool]
576+
"""
577+
Filter by ephemeral / not ephemeral (optional).
578+
"""
579+
538580

539581
@dataclass
540582
class ListFoldersRequest:

scaleway/scaleway/secret/v1alpha1/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .types import ListFoldersRequestOrderBy
44
from .types import ListSecretsRequestOrderBy
55
from .types import Product
6+
from .types import SecretEphemeralAction
67
from .types import SecretStatus
78
from .types import SecretType
89
from .types import SecretVersionStatus
@@ -21,6 +22,7 @@
2122
"ListFoldersRequestOrderBy",
2223
"ListSecretsRequestOrderBy",
2324
"Product",
25+
"SecretEphemeralAction",
2426
"SecretStatus",
2527
"SecretType",
2628
"SecretVersionStatus",

scaleway/scaleway/secret/v1alpha1/api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file was automatically generated. DO NOT EDIT.
22
# If you have any remark or suggestion do not hesitate to open an issue.
33

4+
from datetime import datetime
45
from typing import List, Optional
56

67
from scaleway_core.api import API
@@ -15,6 +16,7 @@
1516
ListFoldersRequestOrderBy,
1617
ListSecretsRequestOrderBy,
1718
Product,
19+
SecretEphemeralAction,
1820
SecretType,
1921
SecretVersionStatus,
2022
AccessSecretVersionResponse,
@@ -66,11 +68,13 @@ def create_secret(
6668
*,
6769
name: str,
6870
type_: SecretType,
71+
ephemeral_action: SecretEphemeralAction,
6972
region: Optional[Region] = None,
7073
project_id: Optional[str] = None,
7174
tags: Optional[List[str]] = None,
7275
description: Optional[str] = None,
7376
path: Optional[str] = None,
77+
expires_at: Optional[datetime] = None,
7478
) -> Secret:
7579
"""
7680
Create a secret.
@@ -84,6 +88,9 @@ def create_secret(
8488
(Optional.) See `Secret.Type` enum for description of values. If not specified, the type is `Opaque`.
8589
:param path: Path of the secret.
8690
(Optional.) Location of the secret in the directory structure. If not specified, the path is `/`.
91+
:param expires_at: Expiration date of the secret.
92+
(Optional.) Date on which the secret will be deleted or deactivated.
93+
:param ephemeral_action: Action to be taken when the secret expires.
8794
:return: :class:`Secret <Secret>`
8895
8996
Usage:
@@ -92,6 +99,7 @@ def create_secret(
9299
result = api.create_secret(
93100
name="example",
94101
type_=unknown_secret_type,
102+
ephemeral_action=unknown_ephemeral_action,
95103
)
96104
"""
97105

@@ -106,11 +114,13 @@ def create_secret(
106114
CreateSecretRequest(
107115
name=name,
108116
type_=type_,
117+
ephemeral_action=ephemeral_action,
109118
region=region,
110119
project_id=project_id,
111120
tags=tags,
112121
description=description,
113122
path=path,
123+
expires_at=expires_at,
114124
),
115125
self.client,
116126
),
@@ -303,6 +313,7 @@ def list_secrets(
303313
name: Optional[str] = None,
304314
is_managed: Optional[bool] = None,
305315
path: Optional[str] = None,
316+
is_ephemeral: Optional[bool] = None,
306317
) -> ListSecretsResponse:
307318
"""
308319
List secrets.
@@ -317,6 +328,7 @@ def list_secrets(
317328
:param name: Filter by secret name (optional).
318329
:param is_managed: Filter by managed / not managed (optional).
319330
:param path: Filter by path (optional).
331+
:param is_ephemeral: Filter by ephemeral / not ephemeral (optional).
320332
:return: :class:`ListSecretsResponse <ListSecretsResponse>`
321333
322334
Usage:
@@ -333,6 +345,7 @@ def list_secrets(
333345
"GET",
334346
f"/secret-manager/v1alpha1/regions/{param_region}/secrets",
335347
params={
348+
"is_ephemeral": is_ephemeral,
336349
"is_managed": is_managed,
337350
"name": name,
338351
"order_by": order_by,
@@ -362,6 +375,7 @@ def list_secrets_all(
362375
name: Optional[str] = None,
363376
is_managed: Optional[bool] = None,
364377
path: Optional[str] = None,
378+
is_ephemeral: Optional[bool] = None,
365379
) -> List[Secret]:
366380
"""
367381
List secrets.
@@ -376,6 +390,7 @@ def list_secrets_all(
376390
:param name: Filter by secret name (optional).
377391
:param is_managed: Filter by managed / not managed (optional).
378392
:param path: Filter by path (optional).
393+
:param is_ephemeral: Filter by ephemeral / not ephemeral (optional).
379394
:return: :class:`List[ListSecretsResponse] <List[ListSecretsResponse]>`
380395
381396
Usage:
@@ -399,6 +414,7 @@ def list_secrets_all(
399414
"name": name,
400415
"is_managed": is_managed,
401416
"path": path,
417+
"is_ephemeral": is_ephemeral,
402418
},
403419
)
404420

0 commit comments

Comments
 (0)