Skip to content

Commit 7bb5847

Browse files
authored
feat(secret-manager): add project_id field in requests (#190)
1 parent 21db091 commit 7bb5847

File tree

4 files changed

+114
-14
lines changed

4 files changed

+114
-14
lines changed

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

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,15 @@ async def get_secret_by_name(
133133
*,
134134
secret_name: str,
135135
region: Optional[Region] = None,
136+
project_id: Optional[str] = None,
136137
) -> Secret:
137138
"""
138139
Get metadata using the secret's ID.
139-
Retrieve the metadata of a secret specified by the `region` and the `secret_id` parameters.
140+
Retrieve the metadata of a secret specified by the `region`, `secret_id` and `project_id` parameters.
140141
:param region: Region to target. If none is passed will use default region from the config.
141142
:param secret_name: Name of the secret.
143+
:param project_id: ID of the Project to target.
144+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
142145
:return: :class:`Secret <Secret>`
143146
144147
Usage:
@@ -155,6 +158,9 @@ async def get_secret_by_name(
155158
res = self._request(
156159
"GET",
157160
f"/secret-manager/v1alpha1/regions/{param_region}/secrets-by-name/{param_secret_name}",
161+
params={
162+
"project_id": project_id or self.client.default_project_id,
163+
},
158164
)
159165

160166
self._throw_on_error(res)
@@ -406,7 +412,7 @@ async def create_secret_version(
406412
:param data: The base64-encoded secret payload of the version.
407413
:param description: Description of the version.
408414
:param disable_previous: Disable the previous secret version.
409-
Optional. If there is no previous version or if the previous version was already disabled, does nothing.
415+
(Optional.) If there is no previous version or if the previous version was already disabled, does nothing.
410416
:param data_crc32: (Optional.) The CRC32 checksum of the data as a base-10 integer.
411417
If specified, Secret Manager will verify the integrity of the data received against the given CRC32 checksum. An error is returned if the CRC32 does not match. If, however, the CRC32 matches, it will be stored and returned along with the SecretVersion on future access requests.
412418
:return: :class:`SecretVersion <SecretVersion>`
@@ -553,14 +559,17 @@ async def get_secret_version_by_name(
553559
secret_name: str,
554560
revision: str,
555561
region: Optional[Region] = None,
562+
project_id: Optional[str] = None,
556563
) -> SecretVersion:
557564
"""
558565
Get metadata of a secret's version using the secret's name.
559-
Retrieve the metadata of a secret's given version specified by the `region`, `secret_name` and `revision` parameters.
566+
Retrieve the metadata of a secret's given version specified by the `region`, `secret_name`, `revision` and `project_id` parameters.
560567
:param region: Region to target. If none is passed will use default region from the config.
561568
:param secret_name: Name of the secret.
562569
:param revision: Version number.
563570
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
571+
:param project_id: ID of the Project to target.
572+
(Optional.) If not specified, Secret Manager will look for the secret version in all Projects.
564573
:return: :class:`SecretVersion <SecretVersion>`
565574
566575
Usage:
@@ -581,6 +590,9 @@ async def get_secret_version_by_name(
581590
res = self._request(
582591
"GET",
583592
f"/secret-manager/v1alpha1/regions/{param_region}/secrets-by-name/{param_secret_name}/versions/{param_revision}",
593+
params={
594+
"project_id": project_id or self.client.default_project_id,
595+
},
584596
)
585597

586598
self._throw_on_error(res)
@@ -725,15 +737,18 @@ async def list_secret_versions_by_name(
725737
page: Optional[int] = None,
726738
page_size: Optional[int] = None,
727739
status: Optional[List[SecretVersionStatus]] = None,
740+
project_id: Optional[str] = None,
728741
) -> ListSecretVersionsResponse:
729742
"""
730743
List versions of a secret using the secret's name.
731-
Retrieve the list of a given secret's versions specified by the `secret_name` and `region` parameters.
744+
Retrieve the list of a given secret's versions specified by the `secret_name`,`region` and `project_id` parameters.
732745
:param region: Region to target. If none is passed will use default region from the config.
733746
:param secret_name: Name of the secret.
734747
:param page:
735748
:param page_size:
736749
:param status: Filter results by status.
750+
:param project_id: ID of the Project to target.
751+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
737752
:return: :class:`ListSecretVersionsResponse <ListSecretVersionsResponse>`
738753
739754
Usage:
@@ -753,6 +768,7 @@ async def list_secret_versions_by_name(
753768
params={
754769
"page": page,
755770
"page_size": page_size or self.client.default_page_size,
771+
"project_id": project_id or self.client.default_project_id,
756772
"status": status,
757773
},
758774
)
@@ -768,15 +784,18 @@ async def list_secret_versions_by_name_all(
768784
page: Optional[int] = None,
769785
page_size: Optional[int] = None,
770786
status: Optional[List[SecretVersionStatus]] = None,
787+
project_id: Optional[str] = None,
771788
) -> List[SecretVersion]:
772789
"""
773790
List versions of a secret using the secret's name.
774-
Retrieve the list of a given secret's versions specified by the `secret_name` and `region` parameters.
791+
Retrieve the list of a given secret's versions specified by the `secret_name`,`region` and `project_id` parameters.
775792
:param region: Region to target. If none is passed will use default region from the config.
776793
:param secret_name: Name of the secret.
777794
:param page:
778795
:param page_size:
779796
:param status: Filter results by status.
797+
:param project_id: ID of the Project to target.
798+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
780799
:return: :class:`List[ListSecretVersionsResponse] <List[ListSecretVersionsResponse]>`
781800
782801
Usage:
@@ -795,6 +814,7 @@ async def list_secret_versions_by_name_all(
795814
"page": page,
796815
"page_size": page_size,
797816
"status": status,
817+
"project_id": project_id,
798818
},
799819
)
800820

@@ -921,14 +941,17 @@ async def access_secret_version_by_name(
921941
secret_name: str,
922942
revision: str,
923943
region: Optional[Region] = None,
944+
project_id: Optional[str] = None,
924945
) -> AccessSecretVersionResponse:
925946
"""
926947
Access a secret's version using the secret's name.
927-
Access sensitive data in a secret's version specified by the `region`, `secret_name` and `revision` parameters.
948+
Access sensitive data in a secret's version specified by the `region`, `secret_name`, `revision` and `project_id` parameters.
928949
:param region: Region to target. If none is passed will use default region from the config.
929950
:param secret_name: Name of the secret.
930951
:param revision: Version number.
931952
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
953+
:param project_id: ID of the Project to target.
954+
(Optional.) If not specified, Secret Manager will look for the secret version in all Projects.
932955
:return: :class:`AccessSecretVersionResponse <AccessSecretVersionResponse>`
933956
934957
Usage:
@@ -949,6 +972,9 @@ async def access_secret_version_by_name(
949972
res = self._request(
950973
"GET",
951974
f"/secret-manager/v1alpha1/regions/{param_region}/secrets-by-name/{param_secret_name}/versions/{param_revision}/access",
975+
params={
976+
"project_id": project_id or self.client.default_project_id,
977+
},
952978
)
953979

954980
self._throw_on_error(res)

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ class GetSecretByNameRequest:
301301
Name of the secret.
302302
"""
303303

304+
project_id: Optional[str]
305+
"""
306+
ID of the Project to target.
307+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
308+
"""
309+
304310

305311
@dataclass
306312
class UpdateSecretRequest:
@@ -425,7 +431,7 @@ class CreateSecretVersionRequest:
425431
disable_previous: Optional[bool]
426432
"""
427433
Disable the previous secret version.
428-
Optional. If there is no previous version or if the previous version was already disabled, does nothing.
434+
(Optional.) If there is no previous version or if the previous version was already disabled, does nothing.
429435
"""
430436

431437
data_crc32: Optional[int]
@@ -521,6 +527,12 @@ class GetSecretVersionByNameRequest:
521527
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
522528
"""
523529

530+
project_id: Optional[str]
531+
"""
532+
ID of the Project to target.
533+
(Optional.) If not specified, Secret Manager will look for the secret version in all Projects.
534+
"""
535+
524536

525537
@dataclass
526538
class UpdateSecretVersionRequest:
@@ -589,6 +601,12 @@ class ListSecretVersionsByNameRequest:
589601
Filter results by status.
590602
"""
591603

604+
project_id: Optional[str]
605+
"""
606+
ID of the Project to target.
607+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
608+
"""
609+
592610

593611
@dataclass
594612
class EnableSecretVersionRequest:
@@ -665,6 +683,12 @@ class AccessSecretVersionByNameRequest:
665683
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
666684
"""
667685

686+
project_id: Optional[str]
687+
"""
688+
ID of the Project to target.
689+
(Optional.) If not specified, Secret Manager will look for the secret version in all Projects.
690+
"""
691+
668692

669693
@dataclass
670694
class DestroySecretVersionRequest:

scaleway/scaleway/secret/v1alpha1/api.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,15 @@ def get_secret_by_name(
133133
*,
134134
secret_name: str,
135135
region: Optional[Region] = None,
136+
project_id: Optional[str] = None,
136137
) -> Secret:
137138
"""
138139
Get metadata using the secret's ID.
139-
Retrieve the metadata of a secret specified by the `region` and the `secret_id` parameters.
140+
Retrieve the metadata of a secret specified by the `region`, `secret_id` and `project_id` parameters.
140141
:param region: Region to target. If none is passed will use default region from the config.
141142
:param secret_name: Name of the secret.
143+
:param project_id: ID of the Project to target.
144+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
142145
:return: :class:`Secret <Secret>`
143146
144147
Usage:
@@ -155,6 +158,9 @@ def get_secret_by_name(
155158
res = self._request(
156159
"GET",
157160
f"/secret-manager/v1alpha1/regions/{param_region}/secrets-by-name/{param_secret_name}",
161+
params={
162+
"project_id": project_id or self.client.default_project_id,
163+
},
158164
)
159165

160166
self._throw_on_error(res)
@@ -406,7 +412,7 @@ def create_secret_version(
406412
:param data: The base64-encoded secret payload of the version.
407413
:param description: Description of the version.
408414
:param disable_previous: Disable the previous secret version.
409-
Optional. If there is no previous version or if the previous version was already disabled, does nothing.
415+
(Optional.) If there is no previous version or if the previous version was already disabled, does nothing.
410416
:param data_crc32: (Optional.) The CRC32 checksum of the data as a base-10 integer.
411417
If specified, Secret Manager will verify the integrity of the data received against the given CRC32 checksum. An error is returned if the CRC32 does not match. If, however, the CRC32 matches, it will be stored and returned along with the SecretVersion on future access requests.
412418
:return: :class:`SecretVersion <SecretVersion>`
@@ -553,14 +559,17 @@ def get_secret_version_by_name(
553559
secret_name: str,
554560
revision: str,
555561
region: Optional[Region] = None,
562+
project_id: Optional[str] = None,
556563
) -> SecretVersion:
557564
"""
558565
Get metadata of a secret's version using the secret's name.
559-
Retrieve the metadata of a secret's given version specified by the `region`, `secret_name` and `revision` parameters.
566+
Retrieve the metadata of a secret's given version specified by the `region`, `secret_name`, `revision` and `project_id` parameters.
560567
:param region: Region to target. If none is passed will use default region from the config.
561568
:param secret_name: Name of the secret.
562569
:param revision: Version number.
563570
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
571+
:param project_id: ID of the Project to target.
572+
(Optional.) If not specified, Secret Manager will look for the secret version in all Projects.
564573
:return: :class:`SecretVersion <SecretVersion>`
565574
566575
Usage:
@@ -581,6 +590,9 @@ def get_secret_version_by_name(
581590
res = self._request(
582591
"GET",
583592
f"/secret-manager/v1alpha1/regions/{param_region}/secrets-by-name/{param_secret_name}/versions/{param_revision}",
593+
params={
594+
"project_id": project_id or self.client.default_project_id,
595+
},
584596
)
585597

586598
self._throw_on_error(res)
@@ -725,15 +737,18 @@ def list_secret_versions_by_name(
725737
page: Optional[int] = None,
726738
page_size: Optional[int] = None,
727739
status: Optional[List[SecretVersionStatus]] = None,
740+
project_id: Optional[str] = None,
728741
) -> ListSecretVersionsResponse:
729742
"""
730743
List versions of a secret using the secret's name.
731-
Retrieve the list of a given secret's versions specified by the `secret_name` and `region` parameters.
744+
Retrieve the list of a given secret's versions specified by the `secret_name`,`region` and `project_id` parameters.
732745
:param region: Region to target. If none is passed will use default region from the config.
733746
:param secret_name: Name of the secret.
734747
:param page:
735748
:param page_size:
736749
:param status: Filter results by status.
750+
:param project_id: ID of the Project to target.
751+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
737752
:return: :class:`ListSecretVersionsResponse <ListSecretVersionsResponse>`
738753
739754
Usage:
@@ -753,6 +768,7 @@ def list_secret_versions_by_name(
753768
params={
754769
"page": page,
755770
"page_size": page_size or self.client.default_page_size,
771+
"project_id": project_id or self.client.default_project_id,
756772
"status": status,
757773
},
758774
)
@@ -768,15 +784,18 @@ def list_secret_versions_by_name_all(
768784
page: Optional[int] = None,
769785
page_size: Optional[int] = None,
770786
status: Optional[List[SecretVersionStatus]] = None,
787+
project_id: Optional[str] = None,
771788
) -> List[SecretVersion]:
772789
"""
773790
List versions of a secret using the secret's name.
774-
Retrieve the list of a given secret's versions specified by the `secret_name` and `region` parameters.
791+
Retrieve the list of a given secret's versions specified by the `secret_name`,`region` and `project_id` parameters.
775792
:param region: Region to target. If none is passed will use default region from the config.
776793
:param secret_name: Name of the secret.
777794
:param page:
778795
:param page_size:
779796
:param status: Filter results by status.
797+
:param project_id: ID of the Project to target.
798+
(Optional.) If not specified, Secret Manager will look for the secret in all Projects.
780799
:return: :class:`List[ListSecretVersionsResponse] <List[ListSecretVersionsResponse]>`
781800
782801
Usage:
@@ -795,6 +814,7 @@ def list_secret_versions_by_name_all(
795814
"page": page,
796815
"page_size": page_size,
797816
"status": status,
817+
"project_id": project_id,
798818
},
799819
)
800820

@@ -921,14 +941,17 @@ def access_secret_version_by_name(
921941
secret_name: str,
922942
revision: str,
923943
region: Optional[Region] = None,
944+
project_id: Optional[str] = None,
924945
) -> AccessSecretVersionResponse:
925946
"""
926947
Access a secret's version using the secret's name.
927-
Access sensitive data in a secret's version specified by the `region`, `secret_name` and `revision` parameters.
948+
Access sensitive data in a secret's version specified by the `region`, `secret_name`, `revision` and `project_id` parameters.
928949
:param region: Region to target. If none is passed will use default region from the config.
929950
:param secret_name: Name of the secret.
930951
:param revision: Version number.
931952
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be a number or "latest".
953+
:param project_id: ID of the Project to target.
954+
(Optional.) If not specified, Secret Manager will look for the secret version in all Projects.
932955
:return: :class:`AccessSecretVersionResponse <AccessSecretVersionResponse>`
933956
934957
Usage:
@@ -949,6 +972,9 @@ def access_secret_version_by_name(
949972
res = self._request(
950973
"GET",
951974
f"/secret-manager/v1alpha1/regions/{param_region}/secrets-by-name/{param_secret_name}/versions/{param_revision}/access",
975+
params={
976+
"project_id": project_id or self.client.default_project_id,
977+
},
952978
)
953979

954980
self._throw_on_error(res)

0 commit comments

Comments
 (0)