Skip to content

feat(secret_manager): add AccessSecretVersionByPath endpoint #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scaleway-async/scaleway_async/secret/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .types import BrowseSecretsResponseItem
from .types import SecretVersion
from .types import Secret
from .types import AccessSecretVersionByPathRequest
from .types import AccessSecretVersionRequest
from .types import AccessSecretVersionResponse
from .types import AddSecretOwnerRequest
Expand All @@ -34,6 +35,9 @@
from .types import ListTagsRequest
from .types import ListTagsResponse
from .types import ProtectSecretRequest
from .types import SecretTypeBasicCredentials
from .types import SecretTypeDatabaseCredentials
from .types import SecretTypeSSHKey
from .types import UnprotectSecretRequest
from .types import UpdateSecretRequest
from .types import UpdateSecretVersionRequest
Expand All @@ -54,6 +58,7 @@
"BrowseSecretsResponseItem",
"SecretVersion",
"Secret",
"AccessSecretVersionByPathRequest",
"AccessSecretVersionRequest",
"AccessSecretVersionResponse",
"AddSecretOwnerRequest",
Expand All @@ -74,6 +79,9 @@
"ListTagsRequest",
"ListTagsResponse",
"ProtectSecretRequest",
"SecretTypeBasicCredentials",
"SecretTypeDatabaseCredentials",
"SecretTypeSSHKey",
"UnprotectSecretRequest",
"UpdateSecretRequest",
"UpdateSecretVersionRequest",
Expand Down
50 changes: 50 additions & 0 deletions scaleway-async/scaleway_async/secret/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,56 @@ async def access_secret_version(
self._throw_on_error(res)
return unmarshal_AccessSecretVersionResponse(res.json())

async def access_secret_version_by_path(
self,
*,
secret_path: str,
secret_name: str,
revision: str,
region: Optional[Region] = None,
project_id: Optional[str] = None,
) -> AccessSecretVersionResponse:
"""
Access a secret's version using the secret's name and path.
Access sensitive data in a secret's version specified by the `region`, `secret_name`, `secret_path` and `revision` parameters.
:param secret_path: Secret's path.
:param secret_name: Secret's name.
:param revision: The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either:
- an integer (the revision number)
- "latest" (the latest revision)
- "latest_enabled" (the latest enabled revision).
:param region: Region to target. If none is passed will use default region from the config.
:param project_id: ID of the Project to target.
:return: :class:`AccessSecretVersionResponse <AccessSecretVersionResponse>`

Usage:
::

result = await api.access_secret_version_by_path(
secret_path="example",
secret_name="example",
revision="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_revision = validate_path_param("revision", revision)

res = self._request(
"GET",
f"/secret-manager/v1beta1/regions/{param_region}/secrets-by-path/versions/{param_revision}/access",
params={
"project_id": project_id or self.client.default_project_id,
"secret_name": secret_name,
"secret_path": secret_path,
},
)

self._throw_on_error(res)
return unmarshal_AccessSecretVersionResponse(res.json())

async def enable_secret_version(
self,
*,
Expand Down
85 changes: 85 additions & 0 deletions scaleway-async/scaleway_async/secret/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,37 @@ class Secret:
"""


@dataclass
class AccessSecretVersionByPathRequest:
secret_path: str
"""
Secret's path.
"""

secret_name: str
"""
Secret's name.
"""

revision: str
"""
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either:
- an integer (the revision number)
- "latest" (the latest revision)
- "latest_enabled" (the latest enabled revision).
"""

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""

project_id: Optional[str]
"""
ID of the Project to target.
"""


@dataclass
class AccessSecretVersionRequest:
secret_id: str
Expand Down Expand Up @@ -725,6 +756,60 @@ class ProtectSecretRequest:
"""


@dataclass
class SecretTypeBasicCredentials:
username: str
"""
The username or identifier associated with the credentials.
"""

password: str
"""
The password associated with the credentials.
"""


@dataclass
class SecretTypeDatabaseCredentials:
engine: str
"""
Supported database engines are: 'postgres', 'mysql', 'other'.
"""

username: str
"""
The username used to authenticate to the database server.
"""

password: str
"""
The password used to authenticate to the database server.
"""

host: str
"""
The hostname or resolvable DNS name of the database server.
"""

dbname: str
"""
The name of the database to connect to.
"""

port: str
"""
The port must be an integer ranging from 0 to 65535.
"""


@dataclass
class SecretTypeSSHKey:
ssh_private_key: str
"""
The private SSH key.
"""


@dataclass
class UnprotectSecretRequest:
secret_id: str
Expand Down
8 changes: 8 additions & 0 deletions scaleway/scaleway/secret/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .types import BrowseSecretsResponseItem
from .types import SecretVersion
from .types import Secret
from .types import AccessSecretVersionByPathRequest
from .types import AccessSecretVersionRequest
from .types import AccessSecretVersionResponse
from .types import AddSecretOwnerRequest
Expand All @@ -34,6 +35,9 @@
from .types import ListTagsRequest
from .types import ListTagsResponse
from .types import ProtectSecretRequest
from .types import SecretTypeBasicCredentials
from .types import SecretTypeDatabaseCredentials
from .types import SecretTypeSSHKey
from .types import UnprotectSecretRequest
from .types import UpdateSecretRequest
from .types import UpdateSecretVersionRequest
Expand All @@ -54,6 +58,7 @@
"BrowseSecretsResponseItem",
"SecretVersion",
"Secret",
"AccessSecretVersionByPathRequest",
"AccessSecretVersionRequest",
"AccessSecretVersionResponse",
"AddSecretOwnerRequest",
Expand All @@ -74,6 +79,9 @@
"ListTagsRequest",
"ListTagsResponse",
"ProtectSecretRequest",
"SecretTypeBasicCredentials",
"SecretTypeDatabaseCredentials",
"SecretTypeSSHKey",
"UnprotectSecretRequest",
"UpdateSecretRequest",
"UpdateSecretVersionRequest",
Expand Down
50 changes: 50 additions & 0 deletions scaleway/scaleway/secret/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,56 @@ def access_secret_version(
self._throw_on_error(res)
return unmarshal_AccessSecretVersionResponse(res.json())

def access_secret_version_by_path(
self,
*,
secret_path: str,
secret_name: str,
revision: str,
region: Optional[Region] = None,
project_id: Optional[str] = None,
) -> AccessSecretVersionResponse:
"""
Access a secret's version using the secret's name and path.
Access sensitive data in a secret's version specified by the `region`, `secret_name`, `secret_path` and `revision` parameters.
:param secret_path: Secret's path.
:param secret_name: Secret's name.
:param revision: The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either:
- an integer (the revision number)
- "latest" (the latest revision)
- "latest_enabled" (the latest enabled revision).
:param region: Region to target. If none is passed will use default region from the config.
:param project_id: ID of the Project to target.
:return: :class:`AccessSecretVersionResponse <AccessSecretVersionResponse>`

Usage:
::

result = api.access_secret_version_by_path(
secret_path="example",
secret_name="example",
revision="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_revision = validate_path_param("revision", revision)

res = self._request(
"GET",
f"/secret-manager/v1beta1/regions/{param_region}/secrets-by-path/versions/{param_revision}/access",
params={
"project_id": project_id or self.client.default_project_id,
"secret_name": secret_name,
"secret_path": secret_path,
},
)

self._throw_on_error(res)
return unmarshal_AccessSecretVersionResponse(res.json())

def enable_secret_version(
self,
*,
Expand Down
85 changes: 85 additions & 0 deletions scaleway/scaleway/secret/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,37 @@ class Secret:
"""


@dataclass
class AccessSecretVersionByPathRequest:
secret_path: str
"""
Secret's path.
"""

secret_name: str
"""
Secret's name.
"""

revision: str
"""
The first version of the secret is numbered 1, and all subsequent revisions augment by 1. Value can be either:
- an integer (the revision number)
- "latest" (the latest revision)
- "latest_enabled" (the latest enabled revision).
"""

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""

project_id: Optional[str]
"""
ID of the Project to target.
"""


@dataclass
class AccessSecretVersionRequest:
secret_id: str
Expand Down Expand Up @@ -725,6 +756,60 @@ class ProtectSecretRequest:
"""


@dataclass
class SecretTypeBasicCredentials:
username: str
"""
The username or identifier associated with the credentials.
"""

password: str
"""
The password associated with the credentials.
"""


@dataclass
class SecretTypeDatabaseCredentials:
engine: str
"""
Supported database engines are: 'postgres', 'mysql', 'other'.
"""

username: str
"""
The username used to authenticate to the database server.
"""

password: str
"""
The password used to authenticate to the database server.
"""

host: str
"""
The hostname or resolvable DNS name of the database server.
"""

dbname: str
"""
The name of the database to connect to.
"""

port: str
"""
The port must be an integer ranging from 0 to 65535.
"""


@dataclass
class SecretTypeSSHKey:
ssh_private_key: str
"""
The private SSH key.
"""


@dataclass
class UnprotectSecretRequest:
secret_id: str
Expand Down