Skip to content

Commit c578ecd

Browse files
authored
docs(secret_manager): revamp secret manager (#158)
1 parent cfd5331 commit c578ecd

File tree

4 files changed

+342
-344
lines changed

4 files changed

+342
-344
lines changed

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

Lines changed: 106 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242

4343
class SecretV1Alpha1API(API):
4444
"""
45-
Secret Manager API documentation.
45+
Secret Manager API.
4646
47+
Secret Manager API.
4748
This API allows you to conveniently store, access and share sensitive data.
48-
Secret Manager API documentation.
4949
"""
5050

5151
async def create_secret(
@@ -207,74 +207,31 @@ async def update_secret(
207207
self._throw_on_error(res)
208208
return unmarshal_Secret(res.json())
209209

210-
async def add_secret_owner(
211-
self,
212-
*,
213-
secret_id: str,
214-
product_name: str,
215-
region: Optional[Region] = None,
216-
) -> Optional[None]:
217-
"""
218-
Allow another product to use the secret.
219-
:param region: Region to target. If none is passed will use default region from the config.
220-
:param secret_id: ID of the secret.
221-
:param product_name: Name of the product to add.
222-
223-
Usage:
224-
::
225-
226-
result = await api.add_secret_owner(
227-
secret_id="example",
228-
product_name="example",
229-
)
230-
"""
231-
232-
param_region = validate_path_param(
233-
"region", region or self.client.default_region
234-
)
235-
param_secret_id = validate_path_param("secret_id", secret_id)
236-
237-
res = self._request(
238-
"POST",
239-
f"/secret-manager/v1alpha1/regions/{param_region}/secrets/{param_secret_id}/add-owner",
240-
body=marshal_AddSecretOwnerRequest(
241-
AddSecretOwnerRequest(
242-
secret_id=secret_id,
243-
product_name=product_name,
244-
region=region,
245-
),
246-
self.client,
247-
),
248-
)
249-
250-
self._throw_on_error(res)
251-
return None
252-
253210
async def list_secrets(
254211
self,
255212
*,
256213
region: Optional[Region] = None,
257214
organization_id: Optional[str] = None,
258215
project_id: Optional[str] = None,
259-
name: Optional[str] = None,
260-
tags: Optional[List[str]] = None,
261-
is_managed: Optional[bool] = None,
262216
order_by: ListSecretsRequestOrderBy = ListSecretsRequestOrderBy.NAME_ASC,
263217
page: Optional[int] = None,
264218
page_size: Optional[int] = None,
219+
tags: Optional[List[str]] = None,
220+
name: Optional[str] = None,
221+
is_managed: Optional[bool] = None,
265222
) -> ListSecretsResponse:
266223
"""
267224
List secrets.
268225
Retrieve the list of secrets created within an Organization and/or Project. You must specify either the `organization_id` or the `project_id` and the `region`.
269226
:param region: Region to target. If none is passed will use default region from the config.
270227
:param organization_id: Filter by Organization ID (optional).
271228
:param project_id: Filter by Project ID (optional).
272-
:param name: Filter by secret name (optional).
273-
:param tags: List of tags to filter on (optional).
274-
:param is_managed: Filter by managed / not managed (optional).
275229
:param order_by:
276230
:param page:
277231
:param page_size:
232+
:param tags: List of tags to filter on (optional).
233+
:param name: Filter by secret name (optional).
234+
:param is_managed: Filter by managed / not managed (optional).
278235
:return: :class:`ListSecretsResponse <ListSecretsResponse>`
279236
280237
Usage:
@@ -312,25 +269,25 @@ async def list_secrets_all(
312269
region: Optional[Region] = None,
313270
organization_id: Optional[str] = None,
314271
project_id: Optional[str] = None,
315-
name: Optional[str] = None,
316-
tags: Optional[List[str]] = None,
317-
is_managed: Optional[bool] = None,
318272
order_by: Optional[ListSecretsRequestOrderBy] = None,
319273
page: Optional[int] = None,
320274
page_size: Optional[int] = None,
275+
tags: Optional[List[str]] = None,
276+
name: Optional[str] = None,
277+
is_managed: Optional[bool] = None,
321278
) -> List[Secret]:
322279
"""
323280
List secrets.
324281
Retrieve the list of secrets created within an Organization and/or Project. You must specify either the `organization_id` or the `project_id` and the `region`.
325282
:param region: Region to target. If none is passed will use default region from the config.
326283
:param organization_id: Filter by Organization ID (optional).
327284
:param project_id: Filter by Project ID (optional).
328-
:param name: Filter by secret name (optional).
329-
:param tags: List of tags to filter on (optional).
330-
:param is_managed: Filter by managed / not managed (optional).
331285
:param order_by:
332286
:param page:
333287
:param page_size:
288+
:param tags: List of tags to filter on (optional).
289+
:param name: Filter by secret name (optional).
290+
:param is_managed: Filter by managed / not managed (optional).
334291
:return: :class:`List[ListSecretsResponse] <List[ListSecretsResponse]>`
335292
336293
Usage:
@@ -347,12 +304,12 @@ async def list_secrets_all(
347304
"region": region,
348305
"organization_id": organization_id,
349306
"project_id": project_id,
350-
"name": name,
351-
"tags": tags,
352-
"is_managed": is_managed,
353307
"order_by": order_by,
354308
"page": page,
355309
"page_size": page_size,
310+
"tags": tags,
311+
"name": name,
312+
"is_managed": is_managed,
356313
},
357314
)
358315

@@ -387,16 +344,59 @@ async def delete_secret(
387344
self._throw_on_error(res)
388345
return None
389346

347+
async def add_secret_owner(
348+
self,
349+
*,
350+
secret_id: str,
351+
product_name: str,
352+
region: Optional[Region] = None,
353+
) -> Optional[None]:
354+
"""
355+
Allow a product to use the secret.
356+
:param region: Region to target. If none is passed will use default region from the config.
357+
:param secret_id: ID of the secret.
358+
:param product_name: Name of the product to add.
359+
360+
Usage:
361+
::
362+
363+
result = await api.add_secret_owner(
364+
secret_id="example",
365+
product_name="example",
366+
)
367+
"""
368+
369+
param_region = validate_path_param(
370+
"region", region or self.client.default_region
371+
)
372+
param_secret_id = validate_path_param("secret_id", secret_id)
373+
374+
res = self._request(
375+
"POST",
376+
f"/secret-manager/v1alpha1/regions/{param_region}/secrets/{param_secret_id}/add-owner",
377+
body=marshal_AddSecretOwnerRequest(
378+
AddSecretOwnerRequest(
379+
secret_id=secret_id,
380+
product_name=product_name,
381+
region=region,
382+
),
383+
self.client,
384+
),
385+
)
386+
387+
self._throw_on_error(res)
388+
return None
389+
390390
async def create_secret_version(
391391
self,
392392
*,
393393
secret_id: str,
394394
data: str,
395-
disable_previous: bool,
396-
data_crc32: int,
397395
region: Optional[Region] = None,
398396
description: Optional[str] = None,
397+
disable_previous: Optional[bool] = None,
399398
password_generation: Optional[PasswordGenerationParams] = None,
399+
data_crc32: Optional[int] = None,
400400
) -> SecretVersion:
401401
"""
402402
Create a version.
@@ -406,13 +406,13 @@ async def create_secret_version(
406406
:param data: The base64-encoded secret payload of the version.
407407
:param description: Description of the version.
408408
:param disable_previous: Disable the previous secret version.
409-
If there is no previous version or if the previous version was already disabled, does nothing.
409+
Optional. If there is no previous version or if the previous version was already disabled, does nothing.
410410
:param password_generation: Options to generate a password.
411-
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.
411+
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.
412412
413413
One-of ('_password_generation'): at most one of 'password_generation' could be set.
414414
:param data_crc32: The CRC32 checksum of the data as a base-10 integer.
415-
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.
415+
Optional. If specified, 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.
416416
:return: :class:`SecretVersion <SecretVersion>`
417417
418418
Usage:
@@ -421,8 +421,6 @@ async def create_secret_version(
421421
result = await api.create_secret_version(
422422
secret_id="example",
423423
data="example",
424-
disable_previous=True,
425-
data_crc32=1,
426424
)
427425
"""
428426

@@ -438,11 +436,11 @@ async def create_secret_version(
438436
CreateSecretVersionRequest(
439437
secret_id=secret_id,
440438
data=data,
441-
disable_previous=disable_previous,
442-
data_crc32=data_crc32,
443439
region=region,
444440
description=description,
441+
disable_previous=disable_previous,
445442
password_generation=password_generation,
443+
data_crc32=data_crc32,
446444
),
447445
self.client,
448446
),
@@ -741,45 +739,6 @@ async def list_secret_versions_by_name_all(
741739
},
742740
)
743741

744-
async def destroy_secret_version(
745-
self,
746-
*,
747-
secret_id: str,
748-
revision: str,
749-
region: Optional[Region] = None,
750-
) -> SecretVersion:
751-
"""
752-
Delete a version.
753-
Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone.
754-
:param region: Region to target. If none is passed will use default region from the config.
755-
:param secret_id: ID of the secret.
756-
:param revision: Version number.
757-
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
758-
:return: :class:`SecretVersion <SecretVersion>`
759-
760-
Usage:
761-
::
762-
763-
result = await api.destroy_secret_version(
764-
secret_id="example",
765-
revision="example",
766-
)
767-
"""
768-
769-
param_region = validate_path_param(
770-
"region", region or self.client.default_region
771-
)
772-
param_secret_id = validate_path_param("secret_id", secret_id)
773-
param_revision = validate_path_param("revision", revision)
774-
775-
res = self._request(
776-
"POST",
777-
f"/secret-manager/v1alpha1/regions/{param_region}/secrets/{param_secret_id}/versions/{param_revision}/destroy",
778-
)
779-
780-
self._throw_on_error(res)
781-
return unmarshal_SecretVersion(res.json())
782-
783742
async def enable_secret_version(
784743
self,
785744
*,
@@ -935,3 +894,42 @@ async def access_secret_version_by_name(
935894

936895
self._throw_on_error(res)
937896
return unmarshal_AccessSecretVersionResponse(res.json())
897+
898+
async def destroy_secret_version(
899+
self,
900+
*,
901+
secret_id: str,
902+
revision: str,
903+
region: Optional[Region] = None,
904+
) -> SecretVersion:
905+
"""
906+
Delete a version.
907+
Delete a secret's version and the sensitive data contained in it. Deleting a version is permanent and cannot be undone.
908+
:param region: Region to target. If none is passed will use default region from the config.
909+
:param secret_id: ID of the secret.
910+
:param revision: Version number.
911+
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
912+
:return: :class:`SecretVersion <SecretVersion>`
913+
914+
Usage:
915+
::
916+
917+
result = await api.destroy_secret_version(
918+
secret_id="example",
919+
revision="example",
920+
)
921+
"""
922+
923+
param_region = validate_path_param(
924+
"region", region or self.client.default_region
925+
)
926+
param_secret_id = validate_path_param("secret_id", secret_id)
927+
param_revision = validate_path_param("revision", revision)
928+
929+
res = self._request(
930+
"POST",
931+
f"/secret-manager/v1alpha1/regions/{param_region}/secrets/{param_secret_id}/versions/{param_revision}/destroy",
932+
)
933+
934+
self._throw_on_error(res)
935+
return unmarshal_SecretVersion(res.json())

0 commit comments

Comments
 (0)