diff --git a/scaleway-async/scaleway_async/annotations/v1/marshalling.py b/scaleway-async/scaleway_async/annotations/v1/marshalling.py index 9c9606884..36c2658cc 100644 --- a/scaleway-async/scaleway_async/annotations/v1/marshalling.py +++ b/scaleway-async/scaleway_async/annotations/v1/marshalling.py @@ -2,6 +2,7 @@ # If you have any remark or suggestion do not hesitate to open an issue. from typing import Any +from dateutil import parser from scaleway_core.profile import ProfileDefaults from .types import ( @@ -123,6 +124,18 @@ def unmarshal_Binding(data: Any) -> Binding: else: args["value"] = None + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + return Binding(**args) @@ -158,6 +171,18 @@ def unmarshal_Key(data: Any) -> Key: else: args["description"] = None + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + return Key(**args) @@ -199,6 +224,18 @@ def unmarshal_Value(data: Any) -> Value: else: args["description"] = None + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + return Value(**args) diff --git a/scaleway-async/scaleway_async/annotations/v1/types.py b/scaleway-async/scaleway_async/annotations/v1/types.py index c7d019788..3af9bfc29 100644 --- a/scaleway-async/scaleway_async/annotations/v1/types.py +++ b/scaleway-async/scaleway_async/annotations/v1/types.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass +from datetime import datetime from typing import Optional @@ -120,6 +121,16 @@ class Binding: Value associated to the binding. """ + created_at: Optional[datetime] = None + """ + Timestamp of creation of the binding. + """ + + updated_at: Optional[datetime] = None + """ + Timestamp of the last update of the binding. + """ + @dataclass class Key: @@ -143,6 +154,16 @@ class Key: Description of the annotation key. """ + created_at: Optional[datetime] = None + """ + Timestamp of creation of the annotation key. + """ + + updated_at: Optional[datetime] = None + """ + Timestamp of the last update of the annotation key. + """ + @dataclass class Value: @@ -171,6 +192,16 @@ class Value: Description of the value. """ + created_at: Optional[datetime] = None + """ + Timestamp of creation of the value. + """ + + updated_at: Optional[datetime] = None + """ + Timestamp of the last update of the value. + """ + @dataclass class CreateBindingRequest: diff --git a/scaleway-async/scaleway_async/dataorchestrator/v1alpha2/api.py b/scaleway-async/scaleway_async/dataorchestrator/v1alpha2/api.py index 193c9f3d2..6174dc0fe 100644 --- a/scaleway-async/scaleway_async/dataorchestrator/v1alpha2/api.py +++ b/scaleway-async/scaleway_async/dataorchestrator/v1alpha2/api.py @@ -53,7 +53,7 @@ class DataorchestratorV1Alpha2API(API): """ - This API is a boilerplate for products. + This API allows you to manage your Data Orchestrator. """ async def create_workflow_definition( diff --git a/scaleway-async/scaleway_async/dataviz/v1alpha1/__init__.py b/scaleway-async/scaleway_async/dataviz/v1alpha1/__init__.py index 7cb5f2b91..a8cba30af 100644 --- a/scaleway-async/scaleway_async/dataviz/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/dataviz/v1alpha1/__init__.py @@ -2,6 +2,7 @@ # If you have any remark or suggestion do not hesitate to open an issue. from .types import DeploymentStatus from .content import DEPLOYMENT_TRANSIENT_STATUSES +from .types import ListCertificatesRequestOrderBy from .types import ListDeploymentsRequestOrderBy from .types import ListNodeTypesRequestOrderBy from .types import ListUsersRequestOrderBy @@ -17,11 +18,11 @@ from .types import Volume from .types import NodeTypeVolumeType from .types import EndpointSpec +from .types import Certificate from .types import Deployment from .types import NodeType from .types import User from .types import Version -from .types import Certificate from .types import CreateCertificateRequest from .types import CreateDeploymentRequest from .types import CreateEndpointRequest @@ -31,6 +32,8 @@ from .types import DeleteUserRequest from .types import DownloadDeploymentCertificateAuthorityRequest from .types import GetDeploymentRequest +from .types import ListCertificatesRequest +from .types import ListCertificatesResponse from .types import ListDeploymentsRequest from .types import ListDeploymentsResponse from .types import ListNodeTypesRequest @@ -47,6 +50,7 @@ __all__ = [ "DeploymentStatus", "DEPLOYMENT_TRANSIENT_STATUSES", + "ListCertificatesRequestOrderBy", "ListDeploymentsRequestOrderBy", "ListNodeTypesRequestOrderBy", "ListUsersRequestOrderBy", @@ -62,11 +66,11 @@ "Volume", "NodeTypeVolumeType", "EndpointSpec", + "Certificate", "Deployment", "NodeType", "User", "Version", - "Certificate", "CreateCertificateRequest", "CreateDeploymentRequest", "CreateEndpointRequest", @@ -76,6 +80,8 @@ "DeleteUserRequest", "DownloadDeploymentCertificateAuthorityRequest", "GetDeploymentRequest", + "ListCertificatesRequest", + "ListCertificatesResponse", "ListDeploymentsRequest", "ListDeploymentsResponse", "ListNodeTypesRequest", diff --git a/scaleway-async/scaleway_async/dataviz/v1alpha1/api.py b/scaleway-async/scaleway_async/dataviz/v1alpha1/api.py index a2c3c996b..5f9a873b8 100644 --- a/scaleway-async/scaleway_async/dataviz/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/dataviz/v1alpha1/api.py @@ -16,6 +16,7 @@ wait_for_resource_async, ) from .types import ( + ListCertificatesRequestOrderBy, ListDeploymentsRequestOrderBy, ListNodeTypesRequestOrderBy, ListUsersRequestOrderBy, @@ -28,6 +29,7 @@ Deployment, Endpoint, EndpointSpec, + ListCertificatesResponse, ListDeploymentsResponse, ListNodeTypesResponse, ListUsersResponse, @@ -45,9 +47,10 @@ ) from .marshalling import ( unmarshal_Endpoint, + unmarshal_Certificate, unmarshal_Deployment, unmarshal_User, - unmarshal_Certificate, + unmarshal_ListCertificatesResponse, unmarshal_ListDeploymentsResponse, unmarshal_ListNodeTypesResponse, unmarshal_ListUsersResponse, @@ -955,3 +958,90 @@ async def create_certificate( self._throw_on_error(res) return unmarshal_Certificate(res.json()) + + async def list_certificates( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCertificatesRequestOrderBy] = None, + name: Optional[str] = None, + ) -> ListCertificatesResponse: + """ + :param deployment_id: + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param name: + :return: :class:`ListCertificatesResponse ` + + Usage: + :: + + result = await api.list_certificates( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "GET", + f"/dataviz/v1alpha1/regions/{param_region}/deployments/{param_deployment_id}/certificates", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListCertificatesResponse(res.json()) + + async def list_certificates_all( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCertificatesRequestOrderBy] = None, + name: Optional[str] = None, + ) -> list[Certificate]: + """ + :param deployment_id: + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param name: + :return: :class:`list[Certificate] ` + + Usage: + :: + + result = await api.list_certificates_all( + deployment_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListCertificatesResponse, + key="certificates", + fetcher=self.list_certificates, + args={ + "deployment_id": deployment_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "name": name, + }, + ) diff --git a/scaleway-async/scaleway_async/dataviz/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/dataviz/v1alpha1/marshalling.py index f61c50d2b..4674ddfe4 100644 --- a/scaleway-async/scaleway_async/dataviz/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/dataviz/v1alpha1/marshalling.py @@ -17,10 +17,11 @@ EndpointPublicDetails, EndpointService, Endpoint, + Certificate, Volume, Deployment, User, - Certificate, + ListCertificatesResponse, ListDeploymentsResponse, NodeTypeVolumeType, NodeType, @@ -147,6 +148,59 @@ def unmarshal_Endpoint(data: Any) -> Endpoint: return Endpoint(**args) +def unmarshal_Certificate(data: Any) -> Certificate: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Certificate' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("deployment_id", None) + if field is not None: + args["deployment_id"] = field + else: + args["deployment_id"] = None + + field = data.get("content", None) + if field is not None: + args["content"] = field + else: + args["content"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("srn", None) + if field is not None: + args["srn"] = field + else: + args["srn"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + return Certificate(**args) + + def unmarshal_Volume(data: Any) -> Volume: if not isinstance(data, dict): raise TypeError( @@ -308,57 +362,29 @@ def unmarshal_User(data: Any) -> User: return User(**args) -def unmarshal_Certificate(data: Any) -> Certificate: +def unmarshal_ListCertificatesResponse(data: Any) -> ListCertificatesResponse: if not isinstance(data, dict): raise TypeError( - "Unmarshalling the type 'Certificate' failed as data isn't a dictionary." + "Unmarshalling the type 'ListCertificatesResponse' failed as data isn't a dictionary." ) args: dict[str, Any] = {} - field = data.get("id", None) + field = data.get("certificates", None) if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("deployment_id", None) - if field is not None: - args["deployment_id"] = field - else: - args["deployment_id"] = None - - field = data.get("content", None) - if field is not None: - args["content"] = field - else: - args["content"] = None - - field = data.get("region", None) - if field is not None: - args["region"] = field - else: - args["region"] = None - - field = data.get("srn", None) - if field is not None: - args["srn"] = field + args["certificates"] = ( + [unmarshal_Certificate(v) for v in field] if field is not None else None + ) else: - args["srn"] = None + args["certificates"] = None - field = data.get("created_at", None) + field = data.get("total_count", None) if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + args["total_count"] = field else: - args["created_at"] = None + args["total_count"] = None - return Certificate(**args) + return ListCertificatesResponse(**args) def unmarshal_ListDeploymentsResponse(data: Any) -> ListDeploymentsResponse: diff --git a/scaleway-async/scaleway_async/dataviz/v1alpha1/types.py b/scaleway-async/scaleway_async/dataviz/v1alpha1/types.py index eec52004f..a5a42156b 100644 --- a/scaleway-async/scaleway_async/dataviz/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/dataviz/v1alpha1/types.py @@ -31,6 +31,16 @@ def __str__(self) -> str: return str(self.value) +class ListCertificatesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + class ListDeploymentsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -173,6 +183,21 @@ class EndpointSpec: private_network: Optional[EndpointSpecPrivateNetworkDetails] = None +@dataclass +class Certificate: + id: str + name: str + deployment_id: str + content: str + region: ScwRegion + """ + Region to target. If none is passed will use default region from the config. + """ + + srn: str + created_at: Optional[datetime] = None + + @dataclass class Deployment: id: str @@ -365,21 +390,6 @@ class Version: """ -@dataclass -class Certificate: - id: str - name: str - deployment_id: str - content: str - region: ScwRegion - """ - Region to target. If none is passed will use default region from the config. - """ - - srn: str - created_at: Optional[datetime] = None - - @dataclass class CreateCertificateRequest: deployment_id: str @@ -584,6 +594,26 @@ class GetDeploymentRequest: """ +@dataclass +class ListCertificatesRequest: + deployment_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListCertificatesRequestOrderBy] = None + name: Optional[str] = None + + +@dataclass +class ListCertificatesResponse: + certificates: list[Certificate] + total_count: int + + @dataclass class ListDeploymentsRequest: """ diff --git a/scaleway-async/scaleway_async/datawarehouse/v1beta1/api.py b/scaleway-async/scaleway_async/datawarehouse/v1beta1/api.py index 35bdfc0d3..efdc446ed 100644 --- a/scaleway-async/scaleway_async/datawarehouse/v1beta1/api.py +++ b/scaleway-async/scaleway_async/datawarehouse/v1beta1/api.py @@ -394,6 +394,7 @@ async def create_deployment( shard_count: Optional[int] = None, endpoints: Optional[list[EndpointSpec]] = None, move_factor: Optional[float] = None, + kms_key_id: Optional[str] = None, ) -> Deployment: """ Create a deployment. @@ -411,6 +412,7 @@ async def create_deployment( :param shard_count: Number of shard for the deployment. :param endpoints: Endpoints to associate with the deployment. :param move_factor: For the `tiered` storage policy, controls when data is moved from the hot volume (Block Storage) to the cold volume (Object Storage). Data is moved once free space on the hot volume drops below this fraction of its capacity. Value between 0 and 1 (default 0.1, i.e. data is moved when the hot volume is 90% full). + :param kms_key_id: ID of a Key Manager key of the Project, used to encrypt the deployment data at rest. The key must be enabled, with a symmetric encryption usage. Encryption can only be chosen at creation, it cannot be enabled, disabled or changed afterwards. :return: :class:`Deployment ` Usage: @@ -449,6 +451,7 @@ async def create_deployment( shard_count=shard_count, endpoints=endpoints, move_factor=move_factor, + kms_key_id=kms_key_id, ), self.client, ), diff --git a/scaleway-async/scaleway_async/datawarehouse/v1beta1/marshalling.py b/scaleway-async/scaleway_async/datawarehouse/v1beta1/marshalling.py index 04b20d6fe..0ed0e9c00 100644 --- a/scaleway-async/scaleway_async/datawarehouse/v1beta1/marshalling.py +++ b/scaleway-async/scaleway_async/datawarehouse/v1beta1/marshalling.py @@ -348,6 +348,12 @@ def unmarshal_Deployment(data: Any) -> Deployment: else: args["srn"] = None + field = data.get("kms_key_id", None) + if field is not None: + args["kms_key_id"] = field + else: + args["kms_key_id"] = None + return Deployment(**args) @@ -699,6 +705,9 @@ def marshal_CreateDeploymentRequest( if request.move_factor is not None: output["move_factor"] = request.move_factor + if request.kms_key_id is not None: + output["kms_key_id"] = request.kms_key_id + return output diff --git a/scaleway-async/scaleway_async/datawarehouse/v1beta1/types.py b/scaleway-async/scaleway_async/datawarehouse/v1beta1/types.py index 72dbb1437..e0a226b21 100644 --- a/scaleway-async/scaleway_async/datawarehouse/v1beta1/types.py +++ b/scaleway-async/scaleway_async/datawarehouse/v1beta1/types.py @@ -291,6 +291,11 @@ class Deployment: Last modification date of the deployment. """ + kms_key_id: Optional[str] = None + """ + ID of the Key Manager key encrypting the deployment data at rest. Empty if the deployment is not encrypted. + """ + @dataclass class Preset: @@ -456,6 +461,11 @@ class CreateDeploymentRequest: For the `tiered` storage policy, controls when data is moved from the hot volume (Block Storage) to the cold volume (Object Storage). Data is moved once free space on the hot volume drops below this fraction of its capacity. Value between 0 and 1 (default 0.1, i.e. data is moved when the hot volume is 90% full). """ + kms_key_id: Optional[str] = None + """ + ID of a Key Manager key of the Project, used to encrypt the deployment data at rest. The key must be enabled, with a symmetric encryption usage. Encryption can only be chosen at creation, it cannot be enabled, disabled or changed afterwards. + """ + @dataclass class CreateEndpointRequest: diff --git a/scaleway-async/scaleway_async/instance/v1/marshalling.py b/scaleway-async/scaleway_async/instance/v1/marshalling.py index c7c96c908..65903653a 100644 --- a/scaleway-async/scaleway_async/instance/v1/marshalling.py +++ b/scaleway-async/scaleway_async/instance/v1/marshalling.py @@ -2670,12 +2670,6 @@ def unmarshal_ServerType(data: Any) -> ServerType: else: args["monthly_price"] = None - field = data.get("hourly_price", None) - if field is not None: - args["hourly_price"] = field - else: - args["hourly_price"] = 0.0 - field = data.get("alt_names", None) if field is not None: args["alt_names"] = field @@ -2700,6 +2694,12 @@ def unmarshal_ServerType(data: Any) -> ServerType: else: args["arch"] = Arch.UNKNOWN_ARCH + field = data.get("hourly_price", None) + if field is not None: + args["hourly_price"] = field + else: + args["hourly_price"] = None + field = data.get("per_volume_constraint", None) if field is not None: args["per_volume_constraint"] = unmarshal_ServerTypeVolumeConstraintsByType( diff --git a/scaleway-async/scaleway_async/instance/v1/types.py b/scaleway-async/scaleway_async/instance/v1/types.py index 7237c85f6..e6536d07c 100644 --- a/scaleway-async/scaleway_async/instance/v1/types.py +++ b/scaleway-async/scaleway_async/instance/v1/types.py @@ -1304,11 +1304,6 @@ class GetServerTypesAvailabilityResponseAvailability: @dataclass class ServerType: - hourly_price: float - """ - Hourly price in Euro. - """ - alt_names: list[str] """ Alternative Instance name, if any. @@ -1349,6 +1344,11 @@ class ServerType: Estimated monthly price, for a 30 days month, in Euro. """ + hourly_price: Optional[float] = None + """ + Hourly price in Euro. + """ + per_volume_constraint: Optional[ServerTypeVolumeConstraintsByType] = None """ Additional volume constraints. diff --git a/scaleway/scaleway/annotations/v1/marshalling.py b/scaleway/scaleway/annotations/v1/marshalling.py index 9c9606884..36c2658cc 100644 --- a/scaleway/scaleway/annotations/v1/marshalling.py +++ b/scaleway/scaleway/annotations/v1/marshalling.py @@ -2,6 +2,7 @@ # If you have any remark or suggestion do not hesitate to open an issue. from typing import Any +from dateutil import parser from scaleway_core.profile import ProfileDefaults from .types import ( @@ -123,6 +124,18 @@ def unmarshal_Binding(data: Any) -> Binding: else: args["value"] = None + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + return Binding(**args) @@ -158,6 +171,18 @@ def unmarshal_Key(data: Any) -> Key: else: args["description"] = None + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + return Key(**args) @@ -199,6 +224,18 @@ def unmarshal_Value(data: Any) -> Value: else: args["description"] = None + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + return Value(**args) diff --git a/scaleway/scaleway/annotations/v1/types.py b/scaleway/scaleway/annotations/v1/types.py index c7d019788..3af9bfc29 100644 --- a/scaleway/scaleway/annotations/v1/types.py +++ b/scaleway/scaleway/annotations/v1/types.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass +from datetime import datetime from typing import Optional @@ -120,6 +121,16 @@ class Binding: Value associated to the binding. """ + created_at: Optional[datetime] = None + """ + Timestamp of creation of the binding. + """ + + updated_at: Optional[datetime] = None + """ + Timestamp of the last update of the binding. + """ + @dataclass class Key: @@ -143,6 +154,16 @@ class Key: Description of the annotation key. """ + created_at: Optional[datetime] = None + """ + Timestamp of creation of the annotation key. + """ + + updated_at: Optional[datetime] = None + """ + Timestamp of the last update of the annotation key. + """ + @dataclass class Value: @@ -171,6 +192,16 @@ class Value: Description of the value. """ + created_at: Optional[datetime] = None + """ + Timestamp of creation of the value. + """ + + updated_at: Optional[datetime] = None + """ + Timestamp of the last update of the value. + """ + @dataclass class CreateBindingRequest: diff --git a/scaleway/scaleway/dataorchestrator/v1alpha2/api.py b/scaleway/scaleway/dataorchestrator/v1alpha2/api.py index e99050b89..2669aee06 100644 --- a/scaleway/scaleway/dataorchestrator/v1alpha2/api.py +++ b/scaleway/scaleway/dataorchestrator/v1alpha2/api.py @@ -53,7 +53,7 @@ class DataorchestratorV1Alpha2API(API): """ - This API is a boilerplate for products. + This API allows you to manage your Data Orchestrator. """ def create_workflow_definition( diff --git a/scaleway/scaleway/dataviz/v1alpha1/__init__.py b/scaleway/scaleway/dataviz/v1alpha1/__init__.py index 7cb5f2b91..a8cba30af 100644 --- a/scaleway/scaleway/dataviz/v1alpha1/__init__.py +++ b/scaleway/scaleway/dataviz/v1alpha1/__init__.py @@ -2,6 +2,7 @@ # If you have any remark or suggestion do not hesitate to open an issue. from .types import DeploymentStatus from .content import DEPLOYMENT_TRANSIENT_STATUSES +from .types import ListCertificatesRequestOrderBy from .types import ListDeploymentsRequestOrderBy from .types import ListNodeTypesRequestOrderBy from .types import ListUsersRequestOrderBy @@ -17,11 +18,11 @@ from .types import Volume from .types import NodeTypeVolumeType from .types import EndpointSpec +from .types import Certificate from .types import Deployment from .types import NodeType from .types import User from .types import Version -from .types import Certificate from .types import CreateCertificateRequest from .types import CreateDeploymentRequest from .types import CreateEndpointRequest @@ -31,6 +32,8 @@ from .types import DeleteUserRequest from .types import DownloadDeploymentCertificateAuthorityRequest from .types import GetDeploymentRequest +from .types import ListCertificatesRequest +from .types import ListCertificatesResponse from .types import ListDeploymentsRequest from .types import ListDeploymentsResponse from .types import ListNodeTypesRequest @@ -47,6 +50,7 @@ __all__ = [ "DeploymentStatus", "DEPLOYMENT_TRANSIENT_STATUSES", + "ListCertificatesRequestOrderBy", "ListDeploymentsRequestOrderBy", "ListNodeTypesRequestOrderBy", "ListUsersRequestOrderBy", @@ -62,11 +66,11 @@ "Volume", "NodeTypeVolumeType", "EndpointSpec", + "Certificate", "Deployment", "NodeType", "User", "Version", - "Certificate", "CreateCertificateRequest", "CreateDeploymentRequest", "CreateEndpointRequest", @@ -76,6 +80,8 @@ "DeleteUserRequest", "DownloadDeploymentCertificateAuthorityRequest", "GetDeploymentRequest", + "ListCertificatesRequest", + "ListCertificatesResponse", "ListDeploymentsRequest", "ListDeploymentsResponse", "ListNodeTypesRequest", diff --git a/scaleway/scaleway/dataviz/v1alpha1/api.py b/scaleway/scaleway/dataviz/v1alpha1/api.py index 74b6cc0e5..e59c86a4a 100644 --- a/scaleway/scaleway/dataviz/v1alpha1/api.py +++ b/scaleway/scaleway/dataviz/v1alpha1/api.py @@ -16,6 +16,7 @@ wait_for_resource, ) from .types import ( + ListCertificatesRequestOrderBy, ListDeploymentsRequestOrderBy, ListNodeTypesRequestOrderBy, ListUsersRequestOrderBy, @@ -28,6 +29,7 @@ Deployment, Endpoint, EndpointSpec, + ListCertificatesResponse, ListDeploymentsResponse, ListNodeTypesResponse, ListUsersResponse, @@ -45,9 +47,10 @@ ) from .marshalling import ( unmarshal_Endpoint, + unmarshal_Certificate, unmarshal_Deployment, unmarshal_User, - unmarshal_Certificate, + unmarshal_ListCertificatesResponse, unmarshal_ListDeploymentsResponse, unmarshal_ListNodeTypesResponse, unmarshal_ListUsersResponse, @@ -953,3 +956,90 @@ def create_certificate( self._throw_on_error(res) return unmarshal_Certificate(res.json()) + + def list_certificates( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCertificatesRequestOrderBy] = None, + name: Optional[str] = None, + ) -> ListCertificatesResponse: + """ + :param deployment_id: + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param name: + :return: :class:`ListCertificatesResponse ` + + Usage: + :: + + result = api.list_certificates( + deployment_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_deployment_id = validate_path_param("deployment_id", deployment_id) + + res = self._request( + "GET", + f"/dataviz/v1alpha1/regions/{param_region}/deployments/{param_deployment_id}/certificates", + params={ + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListCertificatesResponse(res.json()) + + def list_certificates_all( + self, + *, + deployment_id: str, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCertificatesRequestOrderBy] = None, + name: Optional[str] = None, + ) -> list[Certificate]: + """ + :param deployment_id: + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param name: + :return: :class:`list[Certificate] ` + + Usage: + :: + + result = api.list_certificates_all( + deployment_id="example", + ) + """ + + return fetch_all_pages( + type=ListCertificatesResponse, + key="certificates", + fetcher=self.list_certificates, + args={ + "deployment_id": deployment_id, + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "name": name, + }, + ) diff --git a/scaleway/scaleway/dataviz/v1alpha1/marshalling.py b/scaleway/scaleway/dataviz/v1alpha1/marshalling.py index f61c50d2b..4674ddfe4 100644 --- a/scaleway/scaleway/dataviz/v1alpha1/marshalling.py +++ b/scaleway/scaleway/dataviz/v1alpha1/marshalling.py @@ -17,10 +17,11 @@ EndpointPublicDetails, EndpointService, Endpoint, + Certificate, Volume, Deployment, User, - Certificate, + ListCertificatesResponse, ListDeploymentsResponse, NodeTypeVolumeType, NodeType, @@ -147,6 +148,59 @@ def unmarshal_Endpoint(data: Any) -> Endpoint: return Endpoint(**args) +def unmarshal_Certificate(data: Any) -> Certificate: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Certificate' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("deployment_id", None) + if field is not None: + args["deployment_id"] = field + else: + args["deployment_id"] = None + + field = data.get("content", None) + if field is not None: + args["content"] = field + else: + args["content"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("srn", None) + if field is not None: + args["srn"] = field + else: + args["srn"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + return Certificate(**args) + + def unmarshal_Volume(data: Any) -> Volume: if not isinstance(data, dict): raise TypeError( @@ -308,57 +362,29 @@ def unmarshal_User(data: Any) -> User: return User(**args) -def unmarshal_Certificate(data: Any) -> Certificate: +def unmarshal_ListCertificatesResponse(data: Any) -> ListCertificatesResponse: if not isinstance(data, dict): raise TypeError( - "Unmarshalling the type 'Certificate' failed as data isn't a dictionary." + "Unmarshalling the type 'ListCertificatesResponse' failed as data isn't a dictionary." ) args: dict[str, Any] = {} - field = data.get("id", None) + field = data.get("certificates", None) if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("deployment_id", None) - if field is not None: - args["deployment_id"] = field - else: - args["deployment_id"] = None - - field = data.get("content", None) - if field is not None: - args["content"] = field - else: - args["content"] = None - - field = data.get("region", None) - if field is not None: - args["region"] = field - else: - args["region"] = None - - field = data.get("srn", None) - if field is not None: - args["srn"] = field + args["certificates"] = ( + [unmarshal_Certificate(v) for v in field] if field is not None else None + ) else: - args["srn"] = None + args["certificates"] = None - field = data.get("created_at", None) + field = data.get("total_count", None) if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + args["total_count"] = field else: - args["created_at"] = None + args["total_count"] = None - return Certificate(**args) + return ListCertificatesResponse(**args) def unmarshal_ListDeploymentsResponse(data: Any) -> ListDeploymentsResponse: diff --git a/scaleway/scaleway/dataviz/v1alpha1/types.py b/scaleway/scaleway/dataviz/v1alpha1/types.py index eec52004f..a5a42156b 100644 --- a/scaleway/scaleway/dataviz/v1alpha1/types.py +++ b/scaleway/scaleway/dataviz/v1alpha1/types.py @@ -31,6 +31,16 @@ def __str__(self) -> str: return str(self.value) +class ListCertificatesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + + def __str__(self) -> str: + return str(self.value) + + class ListDeploymentsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -173,6 +183,21 @@ class EndpointSpec: private_network: Optional[EndpointSpecPrivateNetworkDetails] = None +@dataclass +class Certificate: + id: str + name: str + deployment_id: str + content: str + region: ScwRegion + """ + Region to target. If none is passed will use default region from the config. + """ + + srn: str + created_at: Optional[datetime] = None + + @dataclass class Deployment: id: str @@ -365,21 +390,6 @@ class Version: """ -@dataclass -class Certificate: - id: str - name: str - deployment_id: str - content: str - region: ScwRegion - """ - Region to target. If none is passed will use default region from the config. - """ - - srn: str - created_at: Optional[datetime] = None - - @dataclass class CreateCertificateRequest: deployment_id: str @@ -584,6 +594,26 @@ class GetDeploymentRequest: """ +@dataclass +class ListCertificatesRequest: + deployment_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListCertificatesRequestOrderBy] = None + name: Optional[str] = None + + +@dataclass +class ListCertificatesResponse: + certificates: list[Certificate] + total_count: int + + @dataclass class ListDeploymentsRequest: """ diff --git a/scaleway/scaleway/datawarehouse/v1beta1/api.py b/scaleway/scaleway/datawarehouse/v1beta1/api.py index 9ba7b7acc..7c173f7cd 100644 --- a/scaleway/scaleway/datawarehouse/v1beta1/api.py +++ b/scaleway/scaleway/datawarehouse/v1beta1/api.py @@ -392,6 +392,7 @@ def create_deployment( shard_count: Optional[int] = None, endpoints: Optional[list[EndpointSpec]] = None, move_factor: Optional[float] = None, + kms_key_id: Optional[str] = None, ) -> Deployment: """ Create a deployment. @@ -409,6 +410,7 @@ def create_deployment( :param shard_count: Number of shard for the deployment. :param endpoints: Endpoints to associate with the deployment. :param move_factor: For the `tiered` storage policy, controls when data is moved from the hot volume (Block Storage) to the cold volume (Object Storage). Data is moved once free space on the hot volume drops below this fraction of its capacity. Value between 0 and 1 (default 0.1, i.e. data is moved when the hot volume is 90% full). + :param kms_key_id: ID of a Key Manager key of the Project, used to encrypt the deployment data at rest. The key must be enabled, with a symmetric encryption usage. Encryption can only be chosen at creation, it cannot be enabled, disabled or changed afterwards. :return: :class:`Deployment ` Usage: @@ -447,6 +449,7 @@ def create_deployment( shard_count=shard_count, endpoints=endpoints, move_factor=move_factor, + kms_key_id=kms_key_id, ), self.client, ), diff --git a/scaleway/scaleway/datawarehouse/v1beta1/marshalling.py b/scaleway/scaleway/datawarehouse/v1beta1/marshalling.py index 04b20d6fe..0ed0e9c00 100644 --- a/scaleway/scaleway/datawarehouse/v1beta1/marshalling.py +++ b/scaleway/scaleway/datawarehouse/v1beta1/marshalling.py @@ -348,6 +348,12 @@ def unmarshal_Deployment(data: Any) -> Deployment: else: args["srn"] = None + field = data.get("kms_key_id", None) + if field is not None: + args["kms_key_id"] = field + else: + args["kms_key_id"] = None + return Deployment(**args) @@ -699,6 +705,9 @@ def marshal_CreateDeploymentRequest( if request.move_factor is not None: output["move_factor"] = request.move_factor + if request.kms_key_id is not None: + output["kms_key_id"] = request.kms_key_id + return output diff --git a/scaleway/scaleway/datawarehouse/v1beta1/types.py b/scaleway/scaleway/datawarehouse/v1beta1/types.py index 72dbb1437..e0a226b21 100644 --- a/scaleway/scaleway/datawarehouse/v1beta1/types.py +++ b/scaleway/scaleway/datawarehouse/v1beta1/types.py @@ -291,6 +291,11 @@ class Deployment: Last modification date of the deployment. """ + kms_key_id: Optional[str] = None + """ + ID of the Key Manager key encrypting the deployment data at rest. Empty if the deployment is not encrypted. + """ + @dataclass class Preset: @@ -456,6 +461,11 @@ class CreateDeploymentRequest: For the `tiered` storage policy, controls when data is moved from the hot volume (Block Storage) to the cold volume (Object Storage). Data is moved once free space on the hot volume drops below this fraction of its capacity. Value between 0 and 1 (default 0.1, i.e. data is moved when the hot volume is 90% full). """ + kms_key_id: Optional[str] = None + """ + ID of a Key Manager key of the Project, used to encrypt the deployment data at rest. The key must be enabled, with a symmetric encryption usage. Encryption can only be chosen at creation, it cannot be enabled, disabled or changed afterwards. + """ + @dataclass class CreateEndpointRequest: diff --git a/scaleway/scaleway/instance/v1/marshalling.py b/scaleway/scaleway/instance/v1/marshalling.py index c7c96c908..65903653a 100644 --- a/scaleway/scaleway/instance/v1/marshalling.py +++ b/scaleway/scaleway/instance/v1/marshalling.py @@ -2670,12 +2670,6 @@ def unmarshal_ServerType(data: Any) -> ServerType: else: args["monthly_price"] = None - field = data.get("hourly_price", None) - if field is not None: - args["hourly_price"] = field - else: - args["hourly_price"] = 0.0 - field = data.get("alt_names", None) if field is not None: args["alt_names"] = field @@ -2700,6 +2694,12 @@ def unmarshal_ServerType(data: Any) -> ServerType: else: args["arch"] = Arch.UNKNOWN_ARCH + field = data.get("hourly_price", None) + if field is not None: + args["hourly_price"] = field + else: + args["hourly_price"] = None + field = data.get("per_volume_constraint", None) if field is not None: args["per_volume_constraint"] = unmarshal_ServerTypeVolumeConstraintsByType( diff --git a/scaleway/scaleway/instance/v1/types.py b/scaleway/scaleway/instance/v1/types.py index 7237c85f6..e6536d07c 100644 --- a/scaleway/scaleway/instance/v1/types.py +++ b/scaleway/scaleway/instance/v1/types.py @@ -1304,11 +1304,6 @@ class GetServerTypesAvailabilityResponseAvailability: @dataclass class ServerType: - hourly_price: float - """ - Hourly price in Euro. - """ - alt_names: list[str] """ Alternative Instance name, if any. @@ -1349,6 +1344,11 @@ class ServerType: Estimated monthly price, for a 30 days month, in Euro. """ + hourly_price: Optional[float] = None + """ + Hourly price in Euro. + """ + per_volume_constraint: Optional[ServerTypeVolumeConstraintsByType] = None """ Additional volume constraints.