diff --git a/scaleway-core/scaleway_core/utils/resolve_one_of.py b/scaleway-core/scaleway_core/utils/resolve_one_of.py index 98ab293f5..7b6c360db 100644 --- a/scaleway-core/scaleway_core/utils/resolve_one_of.py +++ b/scaleway-core/scaleway_core/utils/resolve_one_of.py @@ -1,41 +1,56 @@ +from collections.abc import Callable from dataclasses import dataclass from typing import Any, Dict, Generic, List, Optional, TypeVar +from scaleway_core.profile import ProfileDefaults + T = TypeVar("T") @dataclass class OneOfPossibility(Generic[T]): param: str - value: Optional[T] - - default: Optional[T] = None + default: Optional[T | ProfileDefaults] = None + marshal_func: Optional[Callable[[T, T | None], Dict[str, Any]]] = None def resolve_one_of( possibilities: List[OneOfPossibility[Any]], is_required: bool = False -) -> Dict[str, Any]: +) -> dict[str, Any | None] | str | dict[Any, Any]: """ Resolves the ideal parameter and value amongst an optional list. + Uses marshal_func if provided. """ - # Get the first non-empty parameter + # Try to resolve using non-None value for possibility in possibilities: if possibility.value is not None: + if possibility.marshal_func is not None: + return { + possibility.param: possibility.marshal_func( + possibility.value, possibility.default + ) + } return {possibility.param: possibility.value} - # Get the first non-empty default + # Try to resolve using non-None default for possibility in possibilities: if possibility.default is not None: + if possibility.marshal_func is not None: + return { + possibility.param: possibility.marshal_func( + None, possibility.default + ) + } return {possibility.param: possibility.default} - # If required, raise an error + # If required but unresolved, raise an error if is_required: possibilities_keys = " or ".join( [possibility.param for possibility in possibilities] ) raise ValueError(f"one of ${possibilities_keys} must be present") - # Else, return an empty dict - return {} + # Else, return empty dict + return {} \ No newline at end of file diff --git a/scaleway/scaleway/__init__.py b/scaleway/scaleway/__init__.py deleted file mode 100644 index 040211548..000000000 --- a/scaleway/scaleway/__init__.py +++ /dev/null @@ -1,55 +0,0 @@ -"""Scaleway SDK for Python""" - -import importlib.metadata - -__version__: str = importlib.metadata.version(__name__) - -from scaleway_core.api import ( - API, - ScalewayException, -) - -from scaleway_core.client import Client - -from scaleway_core.profile import ( - Profile, - ProfileConfig, - ProfileDefaults, -) - -from scaleway_core.utils.waiter import ( - WaitForOptions, - WaitForStopCondition, -) - -from scaleway_core.bridge import ( - Money, - Region, - ALL_REGIONS, - Zone, - ALL_ZONES, - ScwFile, - ServiceInfo, - TimeSeriesPoint, - TimeSeries, -) - -__all__ = [ - "API", - "ScalewayException", - "Client", - "Profile", - "ProfileConfig", - "ProfileDefaults", - "WaitForOptions", - "WaitForStopCondition", - "Money", - "Region", - "ALL_REGIONS", - "Zone", - "ALL_ZONES", - "ScwFile", - "ServiceInfo", - "TimeSeriesPoint", - "TimeSeries", -] diff --git a/scaleway/scaleway/account/v2/__init__.py b/scaleway/scaleway/account/v2/__init__.py deleted file mode 100644 index 455e1bca4..000000000 --- a/scaleway/scaleway/account/v2/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# This file was automatically generated. DO NOT EDIT. -# If you have any remark or suggestion do not hesitate to open an issue. -from .types import ListProjectsRequestOrderBy -from .types import Project -from .types import CreateProjectRequest -from .types import DeleteProjectRequest -from .types import GetProjectRequest -from .types import ListProjectsRequest -from .types import ListProjectsResponse -from .types import UpdateProjectRequest -from .api import AccountV2API - -__all__ = [ - "ListProjectsRequestOrderBy", - "Project", - "CreateProjectRequest", - "DeleteProjectRequest", - "GetProjectRequest", - "ListProjectsRequest", - "ListProjectsResponse", - "UpdateProjectRequest", - "AccountV2API", -] diff --git a/scaleway/scaleway/account/v2/api.py b/scaleway/scaleway/account/v2/api.py deleted file mode 100644 index 120ffe2a6..000000000 --- a/scaleway/scaleway/account/v2/api.py +++ /dev/null @@ -1,261 +0,0 @@ -# This file was automatically generated. DO NOT EDIT. -# If you have any remark or suggestion do not hesitate to open an issue. - -from typing import List, Optional - -from scaleway_core.api import API -from scaleway_core.utils import ( - random_name, - validate_path_param, - fetch_all_pages, -) -from .types import ( - ListProjectsRequestOrderBy, - CreateProjectRequest, - ListProjectsResponse, - Project, - UpdateProjectRequest, -) -from .marshalling import ( - unmarshal_Project, - unmarshal_ListProjectsResponse, - marshal_CreateProjectRequest, - marshal_UpdateProjectRequest, -) - - -class AccountV2API(API): - """ - This API allows you to manage your Scaleway Projects. - """ - - def create_project( - self, - *, - name: Optional[str] = None, - organization_id: Optional[str] = None, - description: Optional[str] = None, - ) -> Project: - """ - Create a new Project for an Organization. - Deprecated in favor of Account API v3. - Generate a new Project for an Organization, specifying its configuration including name and description. - :param name: Name of the Project. - :param organization_id: Organization ID of the Project. - :param description: Description of the Project. - :return: :class:`Project ` - :deprecated - - Usage: - :: - - result = api.create_project() - """ - - res = self._request( - "POST", - "/account/v2/projects", - body=marshal_CreateProjectRequest( - CreateProjectRequest( - name=name or random_name(prefix="proj"), - organization_id=organization_id, - description=description, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_Project(res.json()) - - def list_projects( - self, - *, - organization_id: Optional[str] = None, - name: Optional[str] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - order_by: Optional[ListProjectsRequestOrderBy] = None, - project_ids: Optional[List[str]] = None, - ) -> ListProjectsResponse: - """ - List all Projects of an Organization. - Deprecated in favor of Account API v3. - List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names and IDs. Other information include the creation and update date of the Project. - :param organization_id: Organization ID of the Project. - :param name: Name of the Project. - :param page: Page number for the returned Projects. - :param page_size: Maximum number of Project per page. - :param order_by: Sort order of the returned Projects. - :param project_ids: Project IDs to filter for. The results will be limited to any Projects with an ID in this array. - :return: :class:`ListProjectsResponse ` - :deprecated - - Usage: - :: - - result = api.list_projects() - """ - - res = self._request( - "GET", - "/account/v2/projects", - params={ - "name": name, - "order_by": order_by, - "organization_id": organization_id - or self.client.default_organization_id, - "page": page, - "page_size": page_size or self.client.default_page_size, - "project_ids": project_ids, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListProjectsResponse(res.json()) - - def list_projects_all( - self, - *, - organization_id: Optional[str] = None, - name: Optional[str] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - order_by: Optional[ListProjectsRequestOrderBy] = None, - project_ids: Optional[List[str]] = None, - ) -> List[Project]: - """ - List all Projects of an Organization. - Deprecated in favor of Account API v3. - List all Projects of an Organization. The response will include the total number of Projects as well as their associated Organizations, names and IDs. Other information include the creation and update date of the Project. - :param organization_id: Organization ID of the Project. - :param name: Name of the Project. - :param page: Page number for the returned Projects. - :param page_size: Maximum number of Project per page. - :param order_by: Sort order of the returned Projects. - :param project_ids: Project IDs to filter for. The results will be limited to any Projects with an ID in this array. - :return: :class:`List[Project] ` - :deprecated - - Usage: - :: - - result = api.list_projects_all() - """ - - return fetch_all_pages( - type=ListProjectsResponse, - key="projects", - fetcher=self.list_projects, - args={ - "organization_id": organization_id, - "name": name, - "page": page, - "page_size": page_size, - "order_by": order_by, - "project_ids": project_ids, - }, - ) - - def get_project( - self, - *, - project_id: Optional[str] = None, - ) -> Project: - """ - Get an existing Project. - Deprecated in favor of Account API v3. - Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object. - :param project_id: Project ID of the Project. - :return: :class:`Project ` - :deprecated - - Usage: - :: - - result = api.get_project() - """ - - param_project_id = validate_path_param( - "project_id", project_id or self.client.default_project_id - ) - - res = self._request( - "GET", - f"/account/v2/projects/{param_project_id}", - ) - - self._throw_on_error(res) - return unmarshal_Project(res.json()) - - def delete_project( - self, - *, - project_id: Optional[str] = None, - ) -> None: - """ - Delete an existing Project. - Deprecated in favor of Account API v3. - Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone. - :param project_id: Project ID of the Project. - :deprecated - - Usage: - :: - - result = api.delete_project() - """ - - param_project_id = validate_path_param( - "project_id", project_id or self.client.default_project_id - ) - - res = self._request( - "DELETE", - f"/account/v2/projects/{param_project_id}", - ) - - self._throw_on_error(res) - - def update_project( - self, - *, - project_id: Optional[str] = None, - name: Optional[str] = None, - description: Optional[str] = None, - ) -> Project: - """ - Update Project. - Deprecated in favor of Account API v3. - Update the parameters of an existing Project, specified by its Project ID. These parameters include the name and description. - :param project_id: Project ID of the Project. - :param name: Name of the Project. - :param description: Description of the Project. - :return: :class:`Project ` - :deprecated - - Usage: - :: - - result = api.update_project() - """ - - param_project_id = validate_path_param( - "project_id", project_id or self.client.default_project_id - ) - - res = self._request( - "PATCH", - f"/account/v2/projects/{param_project_id}", - body=marshal_UpdateProjectRequest( - UpdateProjectRequest( - project_id=project_id, - name=name, - description=description, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_Project(res.json()) diff --git a/scaleway/scaleway/account/v2/marshalling.py b/scaleway/scaleway/account/v2/marshalling.py deleted file mode 100644 index c577c2d2d..000000000 --- a/scaleway/scaleway/account/v2/marshalling.py +++ /dev/null @@ -1,108 +0,0 @@ -# This file was automatically generated. DO NOT EDIT. -# If you have any remark or suggestion do not hesitate to open an issue. - -from typing import Any, Dict -from dateutil import parser - -from scaleway_core.profile import ProfileDefaults -from .types import ( - Project, - ListProjectsResponse, - CreateProjectRequest, - UpdateProjectRequest, -) - - -def unmarshal_Project(data: Any) -> Project: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Project' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - - field = data.get("name", None) - if field is not None: - args["name"] = field - - field = data.get("organization_id", None) - if field is not None: - args["organization_id"] = field - - field = data.get("description", None) - if field is not None: - args["description"] = field - - 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 Project(**args) - - -def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListProjectsResponse' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - - field = data.get("projects", None) - if field is not None: - args["projects"] = ( - [unmarshal_Project(v) for v in field] if field is not None else None - ) - - return ListProjectsResponse(**args) - - -def marshal_CreateProjectRequest( - request: CreateProjectRequest, - defaults: ProfileDefaults, -) -> Dict[str, Any]: - output: Dict[str, Any] = {} - - if request.name is not None: - output["name"] = request.name - - if request.organization_id is not None: - output["organization_id"] = ( - request.organization_id or defaults.default_organization_id - ) - - if request.description is not None: - output["description"] = request.description - - return output - - -def marshal_UpdateProjectRequest( - request: UpdateProjectRequest, - defaults: ProfileDefaults, -) -> Dict[str, Any]: - output: Dict[str, Any] = {} - - if request.name is not None: - output["name"] = request.name - - if request.description is not None: - output["description"] = request.description - - return output diff --git a/scaleway/scaleway/account/v2/types.py b/scaleway/scaleway/account/v2/types.py deleted file mode 100644 index bf789c6e1..000000000 --- a/scaleway/scaleway/account/v2/types.py +++ /dev/null @@ -1,153 +0,0 @@ -# This file was automatically generated. DO NOT EDIT. -# If you have any remark or suggestion do not hesitate to open an issue. -from __future__ import annotations - -from dataclasses import dataclass -from datetime import datetime -from enum import Enum -from typing import List, Optional - -from scaleway_core.utils import ( - StrEnumMeta, -) - - -class ListProjectsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): - CREATED_AT_ASC = "created_at_asc" - CREATED_AT_DESC = "created_at_desc" - NAME_ASC = "name_asc" - NAME_DESC = "name_desc" - - def __str__(self) -> str: - return str(self.value) - - -@dataclass -class Project: - id: str - """ - ID of the Project. - """ - - name: str - """ - Name of the Project. - """ - - organization_id: str - """ - Organization ID of the Project. - """ - - description: str - """ - Description of the Project. - """ - - created_at: Optional[datetime] - """ - Creation date of the Project. - """ - - updated_at: Optional[datetime] - """ - Update date of the Project. - """ - - -@dataclass -class CreateProjectRequest: - name: Optional[str] - """ - Name of the Project. - """ - - organization_id: Optional[str] - """ - Organization ID of the Project. - """ - - description: Optional[str] - """ - Description of the Project. - """ - - -@dataclass -class DeleteProjectRequest: - project_id: Optional[str] - """ - Project ID of the Project. - """ - - -@dataclass -class GetProjectRequest: - project_id: Optional[str] - """ - Project ID of the Project. - """ - - -@dataclass -class ListProjectsRequest: - organization_id: Optional[str] - """ - Organization ID of the Project. - """ - - name: Optional[str] - """ - Name of the Project. - """ - - page: Optional[int] - """ - Page number for the returned Projects. - """ - - page_size: Optional[int] - """ - Maximum number of Project per page. - """ - - order_by: Optional[ListProjectsRequestOrderBy] - """ - Sort order of the returned Projects. - """ - - project_ids: Optional[List[str]] - """ - Project IDs to filter for. The results will be limited to any Projects with an ID in this array. - """ - - -@dataclass -class ListProjectsResponse: - total_count: int - """ - Total number of Projects. - """ - - projects: List[Project] - """ - Paginated returned Projects. - """ - - -@dataclass -class UpdateProjectRequest: - project_id: Optional[str] - """ - Project ID of the Project. - """ - - name: Optional[str] - """ - Name of the Project. - """ - - description: Optional[str] - """ - Description of the Project. - """ diff --git a/scaleway/scaleway/account/v3/api.py b/scaleway/scaleway/account/v3/api.py index 0631e5376..84c4a97cc 100644 --- a/scaleway/scaleway/account/v3/api.py +++ b/scaleway/scaleway/account/v3/api.py @@ -1,34 +1,78 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import List, Optional +from datetime import datetime +from typing import Any, Awaitable, Dict, List, Optional, Union from scaleway_core.api import API from scaleway_core.bridge import ( + Money, + Region as ScwRegion, ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, + marshal_Money, + unmarshal_Money, + marshal_ScwFile, unmarshal_ScwFile, + unmarshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, ) from scaleway_core.utils import ( + OneOfPossibility, + WaitForOptions, + project_or_organization_id, random_name, + resolve_one_of, validate_path_param, fetch_all_pages, + wait_for_resource, ) from .types import ( ContractType, ListContractSignaturesRequestOrderBy, ListProjectsRequestOrderBy, + QualificationAiMachineSubUseCase, + QualificationArchitectureType, + QualificationArchiveDataSubUseCase, + QualificationContainerSubUseCase, + QualificationDeploySoftwareSubUseCase, + QualificationHostApplicationSubUseCase, + QualificationHostWebsiteSubUseCase, + QualificationOtherUseCaseSubUseCase, + QualificationSetScalewayEnvironmentSubUseCase, + QualificationShareDataSubUseCase, CheckContractSignatureResponse, + Contract, ContractApiCheckContractSignatureRequest, ContractApiCreateContractSignatureRequest, + ContractApiDownloadContractSignatureRequest, + ContractApiListContractSignaturesRequest, + ContractApiValidateContractSignatureRequest, ContractSignature, ListContractSignaturesResponse, ListProjectsResponse, Project, ProjectApiCreateProjectRequest, + ProjectApiDeleteProjectRequest, + ProjectApiGetProjectRequest, + ProjectApiListProjectsRequest, ProjectApiSetProjectQualificationRequest, ProjectApiUpdateProjectRequest, ProjectQualification, Qualification, + QualificationAiMachine, + QualificationArchiveData, + QualificationContainer, + QualificationDeploySoftware, + QualificationHostApplication, + QualificationHostWebsite, + QualificationOtherUseCase, + QualificationSetScalewayEnvironment, + QualificationShareData, ) from .marshalling import ( unmarshal_ContractSignature, @@ -47,12 +91,10 @@ LanguageCode as StdLanguageCode, ) - class AccountV3ContractAPI(API): """ The Contract API allows you to manage contracts. """ - def download_contract_signature( self, *, @@ -64,19 +106,17 @@ def download_contract_signature( :param contract_signature_id: The contract signature ID. :param locale: The locale requested for the content of the contract. :return: :class:`ScwFile ` - + Usage: :: - + result = api.download_contract_signature( contract_signature_id="example", ) """ - - param_contract_signature_id = validate_path_param( - "contract_signature_id", contract_signature_id - ) - + + param_contract_signature_id = validate_path_param("contract_signature_id", contract_signature_id) + res = self._request( "GET", f"/account/v3/contract-signatures/{param_contract_signature_id}/download", @@ -87,7 +127,7 @@ def download_contract_signature( self._throw_on_error(res) return unmarshal_ScwFile(res.json()) - + def create_contract_signature( self, *, @@ -103,19 +143,20 @@ def create_contract_signature( :param contract_type: The type of the contract. :param organization_id: ID of the Organization. :return: :class:`ContractSignature ` - + Usage: :: - + result = api.create_contract_signature( contract_name="example", validated=False, ) """ - + + res = self._request( "POST", - "/account/v3/contract-signatures", + f"/account/v3/contract-signatures", body=marshal_ContractApiCreateContractSignatureRequest( ContractApiCreateContractSignatureRequest( contract_name=contract_name, @@ -129,7 +170,7 @@ def create_contract_signature( self._throw_on_error(res) return unmarshal_ContractSignature(res.json()) - + def validate_contract_signature( self, *, @@ -139,19 +180,17 @@ def validate_contract_signature( Sign a contract for your Organization. :param contract_signature_id: The contract linked to your Organization you want to sign. :return: :class:`ContractSignature ` - + Usage: :: - + result = api.validate_contract_signature( contract_signature_id="example", ) """ - - param_contract_signature_id = validate_path_param( - "contract_signature_id", contract_signature_id - ) - + + param_contract_signature_id = validate_path_param("contract_signature_id", contract_signature_id) + res = self._request( "POST", f"/account/v3/contract-signatures/{param_contract_signature_id}/validate", @@ -160,7 +199,7 @@ def validate_contract_signature( self._throw_on_error(res) return unmarshal_ContractSignature(res.json()) - + def check_contract_signature( self, *, @@ -174,18 +213,19 @@ def check_contract_signature( :param organization_id: ID of the Organization to check the contract signature for. :param contract_type: Filter on contract type. :return: :class:`CheckContractSignatureResponse ` - + Usage: :: - + result = api.check_contract_signature( contract_name="example", ) """ - + + res = self._request( "POST", - "/account/v3/contract-signatures/check", + f"/account/v3/contract-signatures/check", body=marshal_ContractApiCheckContractSignatureRequest( ContractApiCheckContractSignatureRequest( contract_name=contract_name, @@ -198,7 +238,7 @@ def check_contract_signature( self._throw_on_error(res) return unmarshal_CheckContractSignatureResponse(res.json()) - + def list_contract_signatures( self, *, @@ -214,20 +254,20 @@ def list_contract_signatures( :param order_by: How the contracts are ordered in the response. :param organization_id: Filter on Organization ID. :return: :class:`ListContractSignaturesResponse ` - + Usage: :: - + result = api.list_contract_signatures() """ - + + res = self._request( "GET", - "/account/v3/contract-signatures", + f"/account/v3/contract-signatures", params={ "order_by": order_by, - "organization_id": organization_id - or self.client.default_organization_id, + "organization_id": organization_id or self.client.default_organization_id, "page": page, "page_size": page_size or self.client.default_page_size, }, @@ -235,7 +275,7 @@ def list_contract_signatures( self._throw_on_error(res) return unmarshal_ListContractSignaturesResponse(res.json()) - + def list_contract_signatures_all( self, *, @@ -251,14 +291,14 @@ def list_contract_signatures_all( :param order_by: How the contracts are ordered in the response. :param organization_id: Filter on Organization ID. :return: :class:`List[ContractSignature] ` - + Usage: :: - + result = api.list_contract_signatures_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListContractSignaturesResponse, key="contract_signatures", fetcher=self.list_contract_signatures, @@ -269,13 +309,12 @@ def list_contract_signatures_all( "organization_id": organization_id, }, ) - + class AccountV3ProjectAPI(API): """ This API allows you to manage your Scaleway Projects. """ - def create_project( self, *, @@ -290,18 +329,19 @@ def create_project( :param name: Name of the Project. :param organization_id: Organization ID of the Project. :return: :class:`Project ` - + Usage: :: - + result = api.create_project( description="example", ) """ - + + res = self._request( "POST", - "/account/v3/projects", + f"/account/v3/projects", body=marshal_ProjectApiCreateProjectRequest( ProjectApiCreateProjectRequest( description=description, @@ -314,7 +354,7 @@ def create_project( self._throw_on_error(res) return unmarshal_Project(res.json()) - + def list_projects( self, *, @@ -335,21 +375,21 @@ def list_projects( :param order_by: Sort order of the returned Projects. :param project_ids: Project IDs to filter for. The results will be limited to any Projects with an ID in this array. :return: :class:`ListProjectsResponse ` - + Usage: :: - + result = api.list_projects() """ - + + res = self._request( "GET", - "/account/v3/projects", + f"/account/v3/projects", params={ "name": name, "order_by": order_by, - "organization_id": organization_id - or self.client.default_organization_id, + "organization_id": organization_id or self.client.default_organization_id, "page": page, "page_size": page_size or self.client.default_page_size, "project_ids": project_ids, @@ -358,7 +398,7 @@ def list_projects( self._throw_on_error(res) return unmarshal_ListProjectsResponse(res.json()) - + def list_projects_all( self, *, @@ -379,14 +419,14 @@ def list_projects_all( :param order_by: Sort order of the returned Projects. :param project_ids: Project IDs to filter for. The results will be limited to any Projects with an ID in this array. :return: :class:`List[Project] ` - + Usage: :: - + result = api.list_projects_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListProjectsResponse, key="projects", fetcher=self.list_projects, @@ -399,7 +439,7 @@ def list_projects_all( "project_ids": project_ids, }, ) - + def get_project( self, *, @@ -410,17 +450,15 @@ def get_project( Retrieve information about an existing Project, specified by its Project ID. Its full details, including ID, name and description, are returned in the response object. :param project_id: Project ID of the Project. :return: :class:`Project ` - + Usage: :: - + result = api.get_project() """ - - param_project_id = validate_path_param( - "project_id", project_id or self.client.default_project_id - ) - + + param_project_id = validate_path_param("project_id", project_id or self.client.default_project_id) + res = self._request( "GET", f"/account/v3/projects/{param_project_id}", @@ -428,7 +466,7 @@ def get_project( self._throw_on_error(res) return unmarshal_Project(res.json()) - + def delete_project( self, *, @@ -438,24 +476,21 @@ def delete_project( Delete an existing Project. Delete an existing Project, specified by its Project ID. The Project needs to be empty (meaning there are no resources left in it) to be deleted effectively. Note that deleting a Project is permanent, and cannot be undone. :param project_id: Project ID of the Project. - + Usage: :: - + result = api.delete_project() """ - - param_project_id = validate_path_param( - "project_id", project_id or self.client.default_project_id - ) - + + param_project_id = validate_path_param("project_id", project_id or self.client.default_project_id) + res = self._request( "DELETE", f"/account/v3/projects/{param_project_id}", ) self._throw_on_error(res) - def update_project( self, *, @@ -470,17 +505,15 @@ def update_project( :param name: Name of the Project. :param description: Description of the Project. :return: :class:`Project ` - + Usage: :: - + result = api.update_project() """ - - param_project_id = validate_path_param( - "project_id", project_id or self.client.default_project_id - ) - + + param_project_id = validate_path_param("project_id", project_id or self.client.default_project_id) + res = self._request( "PATCH", f"/account/v3/projects/{param_project_id}", @@ -496,7 +529,7 @@ def update_project( self._throw_on_error(res) return unmarshal_Project(res.json()) - + def set_project_qualification( self, *, @@ -509,17 +542,15 @@ def set_project_qualification( :param project_id: Project ID. :param qualification: Use case chosen for the Project. :return: :class:`ProjectQualification ` - + Usage: :: - + result = api.set_project_qualification() """ - - param_project_id = validate_path_param( - "project_id", project_id or self.client.default_project_id - ) - + + param_project_id = validate_path_param("project_id", project_id or self.client.default_project_id) + res = self._request( "POST", f"/account/v3/projects/{param_project_id}/project-qualification", @@ -534,3 +565,4 @@ def set_project_qualification( self._throw_on_error(res) return unmarshal_ProjectQualification(res.json()) + diff --git a/scaleway/scaleway/account/v3/marshalling.py b/scaleway/scaleway/account/v3/marshalling.py index 2875dfa32..dfacb9e6e 100644 --- a/scaleway/scaleway/account/v3/marshalling.py +++ b/scaleway/scaleway/account/v3/marshalling.py @@ -1,15 +1,45 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import Any, Dict +from decimal import Decimal +from datetime import datetime +from typing import Any, Dict, List, Optional from dateutil import parser from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, + unmarshal_Money, + marshal_Money, + marshal_ScwFile, + marshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, +) from scaleway_core.utils import ( OneOfPossibility, resolve_one_of, ) from .types import ( + ContractType, + ListContractSignaturesRequestOrderBy, + ListProjectsRequestOrderBy, + QualificationAiMachineSubUseCase, + QualificationArchitectureType, + QualificationArchiveDataSubUseCase, + QualificationContainerSubUseCase, + QualificationDeploySoftwareSubUseCase, + QualificationHostApplicationSubUseCase, + QualificationHostWebsiteSubUseCase, + QualificationOtherUseCaseSubUseCase, + QualificationSetScalewayEnvironmentSubUseCase, + QualificationShareDataSubUseCase, Contract, ContractSignature, QualificationAiMachine, @@ -33,7 +63,9 @@ ProjectApiSetProjectQualificationRequest, ProjectApiUpdateProjectRequest, ) - +from ...std.types import ( +LanguageCode as StdLanguageCode, +) def unmarshal_Contract(data: Any) -> Contract: if not isinstance(data, dict): @@ -43,37 +75,26 @@ def unmarshal_Contract(data: Any) -> Contract: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("type", None) - if field is not None: - args["type_"] = field + field = data.get("type", getattr(ContractType, "UNKNOWN_TYPE")) + args["type_"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("version", None) - if field is not None: - args["version"] = field + field = data.get("version", 0) + args["version"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field 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 + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field return Contract(**args) - def unmarshal_ContractSignature(data: Any) -> ContractSignature: if not isinstance(data, dict): raise TypeError( @@ -82,41 +103,26 @@ def unmarshal_ContractSignature(data: Any) -> ContractSignature: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("organization_id", None) - if field is not None: - args["organization_id"] = field + field = data.get("organization_id", str()) + args["organization_id"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("signed_at", None) - if field is not None: - args["signed_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["signed_at"] = None + args["signed_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("expires_at", None) - if field is not None: - args["expires_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["expires_at"] = None + args["expires_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("contract", None) - if field is not None: - args["contract"] = unmarshal_Contract(field) - else: - args["contract"] = None + args["contract"] = unmarshal_Contract(field) if field is not None else None return ContractSignature(**args) - def unmarshal_QualificationAiMachine(data: Any) -> QualificationAiMachine: if not isinstance(data, dict): raise TypeError( @@ -125,13 +131,11 @@ def unmarshal_QualificationAiMachine(data: Any) -> QualificationAiMachine: args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationAiMachine(**args) - def unmarshal_QualificationArchiveData(data: Any) -> QualificationArchiveData: if not isinstance(data, dict): raise TypeError( @@ -140,13 +144,11 @@ def unmarshal_QualificationArchiveData(data: Any) -> QualificationArchiveData: args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationArchiveData(**args) - def unmarshal_QualificationContainer(data: Any) -> QualificationContainer: if not isinstance(data, dict): raise TypeError( @@ -155,13 +157,11 @@ def unmarshal_QualificationContainer(data: Any) -> QualificationContainer: args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationContainer(**args) - def unmarshal_QualificationDeploySoftware(data: Any) -> QualificationDeploySoftware: if not isinstance(data, dict): raise TypeError( @@ -170,13 +170,11 @@ def unmarshal_QualificationDeploySoftware(data: Any) -> QualificationDeploySoftw args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationDeploySoftware(**args) - def unmarshal_QualificationHostApplication(data: Any) -> QualificationHostApplication: if not isinstance(data, dict): raise TypeError( @@ -185,13 +183,11 @@ def unmarshal_QualificationHostApplication(data: Any) -> QualificationHostApplic args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationHostApplication(**args) - def unmarshal_QualificationHostWebsite(data: Any) -> QualificationHostWebsite: if not isinstance(data, dict): raise TypeError( @@ -200,13 +196,11 @@ def unmarshal_QualificationHostWebsite(data: Any) -> QualificationHostWebsite: args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationHostWebsite(**args) - def unmarshal_QualificationOtherUseCase(data: Any) -> QualificationOtherUseCase: if not isinstance(data, dict): raise TypeError( @@ -215,16 +209,12 @@ def unmarshal_QualificationOtherUseCase(data: Any) -> QualificationOtherUseCase: args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationOtherUseCase(**args) - -def unmarshal_QualificationSetScalewayEnvironment( - data: Any, -) -> QualificationSetScalewayEnvironment: +def unmarshal_QualificationSetScalewayEnvironment(data: Any) -> QualificationSetScalewayEnvironment: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'QualificationSetScalewayEnvironment' failed as data isn't a dictionary." @@ -232,13 +222,11 @@ def unmarshal_QualificationSetScalewayEnvironment( args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationSetScalewayEnvironment(**args) - def unmarshal_QualificationShareData(data: Any) -> QualificationShareData: if not isinstance(data, dict): raise TypeError( @@ -247,13 +235,11 @@ def unmarshal_QualificationShareData(data: Any) -> QualificationShareData: args: Dict[str, Any] = {} - field = data.get("sub_use_case", None) - if field is not None: - args["sub_use_case"] = field + field = data.get("sub_use_case", str()) + args["sub_use_case"] = field return QualificationShareData(**args) - def unmarshal_Qualification(data: Any) -> Qualification: if not isinstance(data, dict): raise TypeError( @@ -262,69 +248,38 @@ def unmarshal_Qualification(data: Any) -> Qualification: args: Dict[str, Any] = {} - field = data.get("architecture_type", None) - if field is not None: - args["architecture_type"] = field + field = data.get("architecture_type", getattr(QualificationArchitectureType, "UNKNOWN_ARCHITECTURE_TYPE")) + args["architecture_type"] = field field = data.get("host_website", None) - if field is not None: - args["host_website"] = unmarshal_QualificationHostWebsite(field) - else: - args["host_website"] = None + args["host_website"] = unmarshal_QualificationHostWebsite(field) if field is not None else None field = data.get("host_application", None) - if field is not None: - args["host_application"] = unmarshal_QualificationHostApplication(field) - else: - args["host_application"] = None + args["host_application"] = unmarshal_QualificationHostApplication(field) if field is not None else None field = data.get("deploy_software", None) - if field is not None: - args["deploy_software"] = unmarshal_QualificationDeploySoftware(field) - else: - args["deploy_software"] = None + args["deploy_software"] = unmarshal_QualificationDeploySoftware(field) if field is not None else None field = data.get("set_scaleway_environment", None) - if field is not None: - args["set_scaleway_environment"] = ( - unmarshal_QualificationSetScalewayEnvironment(field) - ) - else: - args["set_scaleway_environment"] = None + args["set_scaleway_environment"] = unmarshal_QualificationSetScalewayEnvironment(field) if field is not None else None field = data.get("ai_machine", None) - if field is not None: - args["ai_machine"] = unmarshal_QualificationAiMachine(field) - else: - args["ai_machine"] = None + args["ai_machine"] = unmarshal_QualificationAiMachine(field) if field is not None else None field = data.get("container", None) - if field is not None: - args["container"] = unmarshal_QualificationContainer(field) - else: - args["container"] = None + args["container"] = unmarshal_QualificationContainer(field) if field is not None else None field = data.get("archive_data", None) - if field is not None: - args["archive_data"] = unmarshal_QualificationArchiveData(field) - else: - args["archive_data"] = None + args["archive_data"] = unmarshal_QualificationArchiveData(field) if field is not None else None field = data.get("share_data", None) - if field is not None: - args["share_data"] = unmarshal_QualificationShareData(field) - else: - args["share_data"] = None + args["share_data"] = unmarshal_QualificationShareData(field) if field is not None else None field = data.get("other_use_case", None) - if field is not None: - args["other_use_case"] = unmarshal_QualificationOtherUseCase(field) - else: - args["other_use_case"] = None + args["other_use_case"] = unmarshal_QualificationOtherUseCase(field) if field is not None else None return Qualification(**args) - def unmarshal_Project(data: Any) -> Project: if not isinstance(data, dict): raise TypeError( @@ -333,46 +288,30 @@ def unmarshal_Project(data: Any) -> Project: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("organization_id", None) - if field is not None: - args["organization_id"] = field + field = data.get("organization_id", str()) + args["organization_id"] = field - field = data.get("description", None) - if field is not None: - args["description"] = field + field = data.get("description", str()) + args["description"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field 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 + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("qualification", None) - if field is not None: - args["qualification"] = unmarshal_Qualification(field) - else: - args["qualification"] = None + args["qualification"] = unmarshal_Qualification(field) if field is not None else None return Project(**args) - -def unmarshal_CheckContractSignatureResponse( - data: Any, -) -> CheckContractSignatureResponse: +def unmarshal_CheckContractSignatureResponse(data: Any) -> CheckContractSignatureResponse: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'CheckContractSignatureResponse' failed as data isn't a dictionary." @@ -380,20 +319,15 @@ def unmarshal_CheckContractSignatureResponse( args: Dict[str, Any] = {} - field = data.get("created", None) - if field is not None: - args["created"] = field + field = data.get("created", False) + args["created"] = field - field = data.get("validated", None) - if field is not None: - args["validated"] = field + field = data.get("validated", False) + args["validated"] = field return CheckContractSignatureResponse(**args) - -def unmarshal_ListContractSignaturesResponse( - data: Any, -) -> ListContractSignaturesResponse: +def unmarshal_ListContractSignaturesResponse(data: Any) -> ListContractSignaturesResponse: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'ListContractSignaturesResponse' failed as data isn't a dictionary." @@ -401,21 +335,14 @@ def unmarshal_ListContractSignaturesResponse( args: Dict[str, Any] = {} - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field - field = data.get("contract_signatures", None) - if field is not None: - args["contract_signatures"] = ( - [unmarshal_ContractSignature(v) for v in field] - if field is not None - else None - ) + field = data.get("contract_signatures", []) + args["contract_signatures"] = [unmarshal_ContractSignature(v) for v in field] if field is not None else None return ListContractSignaturesResponse(**args) - def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse: if not isinstance(data, dict): raise TypeError( @@ -424,19 +351,14 @@ def unmarshal_ListProjectsResponse(data: Any) -> ListProjectsResponse: args: Dict[str, Any] = {} - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field - field = data.get("projects", None) - if field is not None: - args["projects"] = ( - [unmarshal_Project(v) for v in field] if field is not None else None - ) + field = data.get("projects", []) + args["projects"] = [unmarshal_Project(v) for v in field] if field is not None else None return ListProjectsResponse(**args) - def unmarshal_ProjectQualification(data: Any) -> ProjectQualification: if not isinstance(data, dict): raise TypeError( @@ -445,19 +367,14 @@ def unmarshal_ProjectQualification(data: Any) -> ProjectQualification: args: Dict[str, Any] = {} - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field + field = data.get("project_id", str()) + args["project_id"] = field field = data.get("qualification", None) - if field is not None: - args["qualification"] = unmarshal_Qualification(field) - else: - args["qualification"] = None + args["qualification"] = unmarshal_Qualification(field) if field is not None else None return ProjectQualification(**args) - def marshal_ContractApiCheckContractSignatureRequest( request: ContractApiCheckContractSignatureRequest, defaults: ProfileDefaults, @@ -466,17 +383,21 @@ def marshal_ContractApiCheckContractSignatureRequest( if request.contract_name is not None: output["contract_name"] = request.contract_name + else: + output["contract_name"] = str() if request.organization_id is not None: - output["organization_id"] = ( - request.organization_id or defaults.default_organization_id - ) + output["organization_id"] = request.organization_id or defaults.default_organization_id + else: + output["organization_id"] = None if request.contract_type is not None: output["contract_type"] = str(request.contract_type) + else: + output["contract_type"] = None - return output + return output def marshal_ContractApiCreateContractSignatureRequest( request: ContractApiCreateContractSignatureRequest, @@ -486,20 +407,26 @@ def marshal_ContractApiCreateContractSignatureRequest( if request.contract_name is not None: output["contract_name"] = request.contract_name + else: + output["contract_name"] = str() if request.validated is not None: output["validated"] = request.validated + else: + output["validated"] = False if request.contract_type is not None: output["contract_type"] = str(request.contract_type) + else: + output["contract_type"] = None if request.organization_id is not None: - output["organization_id"] = ( - request.organization_id or defaults.default_organization_id - ) + output["organization_id"] = request.organization_id or defaults.default_organization_id + else: + output["organization_id"] = None - return output + return output def marshal_ProjectApiCreateProjectRequest( request: ProjectApiCreateProjectRequest, @@ -509,17 +436,21 @@ def marshal_ProjectApiCreateProjectRequest( if request.description is not None: output["description"] = request.description + else: + output["description"] = str() if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.organization_id is not None: - output["organization_id"] = ( - request.organization_id or defaults.default_organization_id - ) + output["organization_id"] = request.organization_id or defaults.default_organization_id + else: + output["organization_id"] = None - return output + return output def marshal_QualificationAiMachine( request: QualificationAiMachine, @@ -529,9 +460,11 @@ def marshal_QualificationAiMachine( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationArchiveData( request: QualificationArchiveData, @@ -541,9 +474,11 @@ def marshal_QualificationArchiveData( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationContainer( request: QualificationContainer, @@ -553,9 +488,11 @@ def marshal_QualificationContainer( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationDeploySoftware( request: QualificationDeploySoftware, @@ -565,9 +502,11 @@ def marshal_QualificationDeploySoftware( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationHostApplication( request: QualificationHostApplication, @@ -577,9 +516,11 @@ def marshal_QualificationHostApplication( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationHostWebsite( request: QualificationHostWebsite, @@ -589,9 +530,11 @@ def marshal_QualificationHostWebsite( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationOtherUseCase( request: QualificationOtherUseCase, @@ -601,9 +544,11 @@ def marshal_QualificationOtherUseCase( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationSetScalewayEnvironment( request: QualificationSetScalewayEnvironment, @@ -613,9 +558,11 @@ def marshal_QualificationSetScalewayEnvironment( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_QualificationShareData( request: QualificationShareData, @@ -625,9 +572,11 @@ def marshal_QualificationShareData( if request.sub_use_case is not None: output["sub_use_case"] = str(request.sub_use_case) + else: + output["sub_use_case"] = str() - return output + return output def marshal_Qualification( request: Qualification, @@ -635,28 +584,35 @@ def marshal_Qualification( ) -> Dict[str, Any]: output: Dict[str, Any] = {} output.update( - resolve_one_of( - [ - OneOfPossibility("host_website", request.host_website), - OneOfPossibility("host_application", request.host_application), - OneOfPossibility("deploy_software", request.deploy_software), - OneOfPossibility( - "set_scaleway_environment", request.set_scaleway_environment - ), - OneOfPossibility("ai_machine", request.ai_machine), - OneOfPossibility("container", request.container), - OneOfPossibility("archive_data", request.archive_data), - OneOfPossibility("share_data", request.share_data), - OneOfPossibility("other_use_case", request.other_use_case), - ] - ), + resolve_one_of([ + OneOfPossibility(param="host_website", value=request.host_website,marshal_func=marshal_QualificationHostWebsite + ), + OneOfPossibility(param="host_application", value=request.host_application,marshal_func=marshal_QualificationHostApplication + ), + OneOfPossibility(param="deploy_software", value=request.deploy_software,marshal_func=marshal_QualificationDeploySoftware + ), + OneOfPossibility(param="set_scaleway_environment", value=request.set_scaleway_environment,marshal_func=marshal_QualificationSetScalewayEnvironment + ), + OneOfPossibility(param="ai_machine", value=request.ai_machine,marshal_func=marshal_QualificationAiMachine + ), + OneOfPossibility(param="container", value=request.container,marshal_func=marshal_QualificationContainer + ), + OneOfPossibility(param="archive_data", value=request.archive_data,marshal_func=marshal_QualificationArchiveData + ), + OneOfPossibility(param="share_data", value=request.share_data,marshal_func=marshal_QualificationShareData + ), + OneOfPossibility(param="other_use_case", value=request.other_use_case,marshal_func=marshal_QualificationOtherUseCase + ), + ]), ) if request.architecture_type is not None: output["architecture_type"] = str(request.architecture_type) + else: + output["architecture_type"] = getattr(QualificationArchitectureType, "UNKNOWN_ARCHITECTURE_TYPE") - return output + return output def marshal_ProjectApiSetProjectQualificationRequest( request: ProjectApiSetProjectQualificationRequest, @@ -666,9 +622,11 @@ def marshal_ProjectApiSetProjectQualificationRequest( if request.qualification is not None: output["qualification"] = marshal_Qualification(request.qualification, defaults) + else: + output["qualification"] = None - return output + return output def marshal_ProjectApiUpdateProjectRequest( request: ProjectApiUpdateProjectRequest, @@ -678,8 +636,13 @@ def marshal_ProjectApiUpdateProjectRequest( if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.description is not None: output["description"] = request.description + else: + output["description"] = None + return output diff --git a/scaleway/scaleway/account/v3/types.py b/scaleway/scaleway/account/v3/types.py index d8c33dddd..11b2e8627 100644 --- a/scaleway/scaleway/account/v3/types.py +++ b/scaleway/scaleway/account/v3/types.py @@ -3,10 +3,20 @@ from __future__ import annotations from dataclasses import dataclass +from decimal import Decimal from datetime import datetime from enum import Enum -from typing import List, Optional - +from typing import Any, Dict, List, Optional + +from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, +) from scaleway_core.utils import ( StrEnumMeta, ) @@ -15,7 +25,6 @@ LanguageCode as StdLanguageCode, ) - class ContractType(str, Enum, metaclass=StrEnumMeta): UNKNOWN_TYPE = "unknown_type" GLOBAL = "global" @@ -27,7 +36,6 @@ class ContractType(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListContractSignaturesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): SIGNED_AT_ASC = "signed_at_asc" SIGNED_AT_DESC = "signed_at_desc" @@ -39,7 +47,6 @@ class ListContractSignaturesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListProjectsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -49,14 +56,12 @@ class ListProjectsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class QualificationAiMachineSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" def __str__(self) -> str: return str(self.value) - class QualificationArchitectureType(str, Enum, metaclass=StrEnumMeta): UNKNOWN_ARCHITECTURE_TYPE = "unknown_architecture_type" OBJECT_STORAGE = "object_storage" @@ -71,28 +76,24 @@ class QualificationArchitectureType(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class QualificationArchiveDataSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" def __str__(self) -> str: return str(self.value) - class QualificationContainerSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" def __str__(self) -> str: return str(self.value) - class QualificationDeploySoftwareSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" def __str__(self) -> str: return str(self.value) - class QualificationHostApplicationSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" SAAS_APP = "saas_app" @@ -101,7 +102,6 @@ class QualificationHostApplicationSubUseCase(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class QualificationHostWebsiteSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" INFORMATION_WEBSITE = "information_website" @@ -112,72 +112,68 @@ class QualificationHostWebsiteSubUseCase(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class QualificationOtherUseCaseSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" def __str__(self) -> str: return str(self.value) - class QualificationSetScalewayEnvironmentSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" def __str__(self) -> str: return str(self.value) - class QualificationShareDataSubUseCase(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SUB_USE_CASE = "unknown_sub_use_case" def __str__(self) -> str: return str(self.value) - @dataclass class QualificationAiMachine: sub_use_case: QualificationAiMachineSubUseCase - + @dataclass class QualificationArchiveData: sub_use_case: QualificationArchiveDataSubUseCase - + @dataclass class QualificationContainer: sub_use_case: QualificationContainerSubUseCase - + @dataclass class QualificationDeploySoftware: sub_use_case: QualificationDeploySoftwareSubUseCase - + @dataclass class QualificationHostApplication: sub_use_case: QualificationHostApplicationSubUseCase - + @dataclass class QualificationHostWebsite: sub_use_case: QualificationHostWebsiteSubUseCase - + @dataclass class QualificationOtherUseCase: sub_use_case: QualificationOtherUseCaseSubUseCase - + @dataclass class QualificationSetScalewayEnvironment: sub_use_case: QualificationSetScalewayEnvironmentSubUseCase - + @dataclass class QualificationShareData: sub_use_case: QualificationShareDataSubUseCase - + @dataclass class Contract: @@ -185,32 +181,32 @@ class Contract: """ ID of the contract. """ - + type_: ContractType """ The type of the contract. """ - + name: str """ The name of the contract. """ - + version: int """ The version of the contract. """ - + created_at: Optional[datetime] """ The creation date of the contract. """ - + updated_at: Optional[datetime] """ The last modification date of the contract. """ - + @dataclass class Qualification: @@ -218,25 +214,25 @@ class Qualification: """ Architecture type of the qualification. """ - + host_website: Optional[QualificationHostWebsite] - + host_application: Optional[QualificationHostApplication] - + deploy_software: Optional[QualificationDeploySoftware] - + set_scaleway_environment: Optional[QualificationSetScalewayEnvironment] - + ai_machine: Optional[QualificationAiMachine] - + container: Optional[QualificationContainer] - + archive_data: Optional[QualificationArchiveData] - + share_data: Optional[QualificationShareData] - + other_use_case: Optional[QualificationOtherUseCase] - + @dataclass class ContractSignature: @@ -244,32 +240,32 @@ class ContractSignature: """ ID of the contract signature. """ - + organization_id: str """ The Organization ID which signed the contract. """ - + created_at: Optional[datetime] """ The creation date of the contract signature. """ - + signed_at: Optional[datetime] """ The signing date of the contract signature. """ - + expires_at: Optional[datetime] """ The expiration date of the contract signature. """ - + contract: Optional[Contract] """ The contract signed. """ - + @dataclass class Project: @@ -277,37 +273,37 @@ class Project: """ ID of the Project. """ - + name: str """ Name of the Project. """ - + organization_id: str """ Organization ID of the Project. """ - + description: str """ Description of the Project. """ - + created_at: Optional[datetime] """ Creation date of the Project. """ - + updated_at: Optional[datetime] """ Update date of the Project. """ - + qualification: Optional[Qualification] """ Qualification of the Project. """ - + @dataclass class CheckContractSignatureResponse: @@ -315,12 +311,12 @@ class CheckContractSignatureResponse: """ Whether a signature has been requested for this contract. """ - + validated: bool """ Whether the signature for this contract has been validated. """ - + @dataclass class ContractApiCheckContractSignatureRequest: @@ -328,17 +324,17 @@ class ContractApiCheckContractSignatureRequest: """ Filter on contract name. """ - + organization_id: Optional[str] """ ID of the Organization to check the contract signature for. """ - + contract_type: Optional[ContractType] """ Filter on contract type. """ - + @dataclass class ContractApiCreateContractSignatureRequest: @@ -346,22 +342,22 @@ class ContractApiCreateContractSignatureRequest: """ The name of the contract. """ - + validated: bool """ Whether the contract is validated at creation. """ - + contract_type: Optional[ContractType] """ The type of the contract. """ - + organization_id: Optional[str] """ ID of the Organization. """ - + @dataclass class ContractApiDownloadContractSignatureRequest: @@ -369,12 +365,12 @@ class ContractApiDownloadContractSignatureRequest: """ The contract signature ID. """ - + locale: Optional[StdLanguageCode] """ The locale requested for the content of the contract. """ - + @dataclass class ContractApiListContractSignaturesRequest: @@ -382,22 +378,22 @@ class ContractApiListContractSignaturesRequest: """ The page number for the returned contracts. """ - + page_size: Optional[int] """ The maximum number of contracts per page. """ - + order_by: Optional[ListContractSignaturesRequestOrderBy] """ How the contracts are ordered in the response. """ - + organization_id: Optional[str] """ Filter on Organization ID. """ - + @dataclass class ContractApiValidateContractSignatureRequest: @@ -405,7 +401,7 @@ class ContractApiValidateContractSignatureRequest: """ The contract linked to your Organization you want to sign. """ - + @dataclass class ListContractSignaturesResponse: @@ -413,12 +409,12 @@ class ListContractSignaturesResponse: """ The total number of contract signatures. """ - + contract_signatures: List[ContractSignature] """ The paginated returned contract signatures. """ - + @dataclass class ListProjectsResponse: @@ -426,12 +422,12 @@ class ListProjectsResponse: """ Total number of Projects. """ - + projects: List[Project] """ Paginated returned Projects. """ - + @dataclass class ProjectApiCreateProjectRequest: @@ -439,17 +435,17 @@ class ProjectApiCreateProjectRequest: """ Description of the Project. """ - + name: Optional[str] """ Name of the Project. """ - + organization_id: Optional[str] """ Organization ID of the Project. """ - + @dataclass class ProjectApiDeleteProjectRequest: @@ -457,7 +453,7 @@ class ProjectApiDeleteProjectRequest: """ Project ID of the Project. """ - + @dataclass class ProjectApiGetProjectRequest: @@ -465,7 +461,7 @@ class ProjectApiGetProjectRequest: """ Project ID of the Project. """ - + @dataclass class ProjectApiListProjectsRequest: @@ -473,32 +469,32 @@ class ProjectApiListProjectsRequest: """ Organization ID of the Project. """ - + name: Optional[str] """ Name of the Project. """ - + page: Optional[int] """ Page number for the returned Projects. """ - + page_size: Optional[int] """ Maximum number of Project per page. """ - + order_by: Optional[ListProjectsRequestOrderBy] """ Sort order of the returned Projects. """ - + project_ids: Optional[List[str]] """ Project IDs to filter for. The results will be limited to any Projects with an ID in this array. """ - + @dataclass class ProjectApiSetProjectQualificationRequest: @@ -506,12 +502,12 @@ class ProjectApiSetProjectQualificationRequest: """ Project ID. """ - + qualification: Optional[Qualification] """ Use case chosen for the Project. """ - + @dataclass class ProjectApiUpdateProjectRequest: @@ -519,17 +515,17 @@ class ProjectApiUpdateProjectRequest: """ Project ID of the Project. """ - + name: Optional[str] """ Name of the Project. """ - + description: Optional[str] """ Description of the Project. """ - + @dataclass class ProjectQualification: @@ -537,8 +533,9 @@ class ProjectQualification: """ Project ID. """ - + qualification: Optional[Qualification] """ Qualification of the Project. """ + diff --git a/scaleway/scaleway/applesilicon/v1alpha1/api.py b/scaleway/scaleway/applesilicon/v1alpha1/api.py index 0046f76df..065f77c42 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/api.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/api.py @@ -1,37 +1,79 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import Dict, List, Optional +from datetime import datetime +from typing import Any, Awaitable, Dict, List, Optional, Union from scaleway_core.api import API from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, Zone as ScwZone, + marshal_Money, + unmarshal_Money, + marshal_ScwFile, + unmarshal_ScwFile, + unmarshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, ) from scaleway_core.utils import ( + OneOfPossibility, WaitForOptions, + project_or_organization_id, random_name, + resolve_one_of, validate_path_param, fetch_all_pages, wait_for_resource, ) from .types import ( CommitmentType, + ConnectivityDiagnosticActionType, + ConnectivityDiagnosticDiagnosticStatus, ListServerPrivateNetworksRequestOrderBy, ListServersRequestOrderBy, + ServerPrivateNetworkServerStatus, + ServerPrivateNetworkStatus, + ServerStatus, + ServerTypeStock, + Commitment, CommitmentTypeValue, ConnectivityDiagnostic, + ConnectivityDiagnosticServerHealth, CreateServerRequest, + DeleteServerRequest, + GetConnectivityDiagnosticRequest, + GetOSRequest, + GetServerRequest, + GetServerTypeRequest, + ListOSRequest, ListOSResponse, ListServerPrivateNetworksResponse, + ListServerTypesRequest, ListServerTypesResponse, + ListServersRequest, ListServersResponse, OS, PrivateNetworkApiAddServerPrivateNetworkRequest, + PrivateNetworkApiDeleteServerPrivateNetworkRequest, + PrivateNetworkApiGetServerPrivateNetworkRequest, + PrivateNetworkApiListServerPrivateNetworksRequest, PrivateNetworkApiSetServerPrivateNetworksRequest, + RebootServerRequest, ReinstallServerRequest, Server, ServerPrivateNetwork, ServerType, + ServerTypeCPU, + ServerTypeDisk, + ServerTypeGPU, + ServerTypeMemory, + ServerTypeNetwork, SetServerPrivateNetworksResponse, StartConnectivityDiagnosticRequest, StartConnectivityDiagnosticResponse, @@ -39,6 +81,7 @@ ) from .content import ( SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES, + SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES, SERVER_TRANSIENT_STATUSES, ) from .marshalling import ( @@ -61,12 +104,10 @@ marshal_UpdateServerRequest, ) - class ApplesiliconV1Alpha1API(API): """ This API allows you to manage your Apple silicon machines. """ - def list_server_types( self, *, @@ -77,15 +118,15 @@ def list_server_types( List all technical details about Apple silicon server types available in the specified zone. Since there is only one Availability Zone for Apple silicon servers, the targeted value is `fr-par-3`. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`ListServerTypesResponse ` - + Usage: :: - + result = api.list_server_types() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/server-types", @@ -93,7 +134,7 @@ def list_server_types( self._throw_on_error(res) return unmarshal_ListServerTypesResponse(res.json()) - + def get_server_type( self, *, @@ -106,18 +147,18 @@ def get_server_type( :param server_type: Server type identifier. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`ServerType ` - + Usage: :: - + result = api.get_server_type( server_type="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_type = validate_path_param("server_type", server_type) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/server-type/{param_server_type}", @@ -125,7 +166,7 @@ def get_server_type( self._throw_on_error(res) return unmarshal_ServerType(res.json()) - + def create_server( self, *, @@ -150,19 +191,19 @@ def create_server( :param os_id: Create a server & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time. :param commitment_type: Activate commitment for this server. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. :return: :class:`Server ` - + Usage: :: - + result = api.create_server( type="example", enable_vpc=False, public_bandwidth_bps=1, ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "POST", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers", @@ -183,7 +224,7 @@ def create_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def list_servers( self, *, @@ -204,22 +245,21 @@ def list_servers( :param page: Positive integer to choose the page to return. :param page_size: Positive integer lower or equal to 100 to select the number of items to return. :return: :class:`ListServersResponse ` - + Usage: :: - + result = api.list_servers() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers", params={ "order_by": order_by, - "organization_id": organization_id - or self.client.default_organization_id, + "organization_id": organization_id or self.client.default_organization_id, "page": page, "page_size": page_size or self.client.default_page_size, "project_id": project_id or self.client.default_project_id, @@ -228,7 +268,7 @@ def list_servers( self._throw_on_error(res) return unmarshal_ListServersResponse(res.json()) - + def list_servers_all( self, *, @@ -249,14 +289,14 @@ def list_servers_all( :param page: Positive integer to choose the page to return. :param page_size: Positive integer lower or equal to 100 to select the number of items to return. :return: :class:`List[Server] ` - + Usage: :: - + result = api.list_servers_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListServersResponse, key="servers", fetcher=self.list_servers, @@ -269,7 +309,7 @@ def list_servers_all( "page_size": page_size, }, ) - + def list_os( self, *, @@ -288,15 +328,15 @@ def list_os( :param server_type: List of compatible server types. :param name: Filter OS by name (note that "11.1" will return "11.1.2" and "11.1" but not "12")). :return: :class:`ListOSResponse ` - + Usage: :: - + result = api.list_os() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/os", @@ -310,7 +350,7 @@ def list_os( self._throw_on_error(res) return unmarshal_ListOSResponse(res.json()) - + def list_os_all( self, *, @@ -329,14 +369,14 @@ def list_os_all( :param server_type: List of compatible server types. :param name: Filter OS by name (note that "11.1" will return "11.1.2" and "11.1" but not "12")). :return: :class:`List[OS] ` - + Usage: :: - + result = api.list_os_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListOSResponse, key="os", fetcher=self.list_os, @@ -348,7 +388,7 @@ def list_os_all( "name": name, }, ) - + def get_os( self, *, @@ -361,18 +401,18 @@ def get_os( :param os_id: UUID of the OS you want to get. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`OS ` - + Usage: :: - + result = api.get_os( os_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_os_id = validate_path_param("os_id", os_id) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/os/{param_os_id}", @@ -380,7 +420,7 @@ def get_os( self._throw_on_error(res) return unmarshal_OS(res.json()) - + def get_server( self, *, @@ -393,18 +433,18 @@ def get_server( :param server_id: UUID of the server you want to get. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.get_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}", @@ -412,7 +452,7 @@ def get_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def wait_for_server( self, *, @@ -426,10 +466,10 @@ def wait_for_server( :param server_id: UUID of the server you want to get. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.get_server( server_id="example", ) @@ -449,7 +489,7 @@ def wait_for_server( "zone": zone, }, ) - + def update_server( self, *, @@ -472,18 +512,18 @@ def update_server( :param commitment_type: Change commitment. Use 'none' to automatically cancel a renewing commitment. :param public_bandwidth_bps: Public bandwidth to configure for this server. Setting an higher bandwidth incurs additional costs. Supported bandwidth levels depends on server type and can be queried using the `/server-types` endpoint. :return: :class:`Server ` - + Usage: :: - + result = api.update_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "PATCH", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}", @@ -503,7 +543,7 @@ def update_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def delete_server( self, *, @@ -515,25 +555,24 @@ def delete_server( Delete an existing Apple silicon server, specified by its server ID. Deleting a server is permanent, and cannot be undone. Note that the minimum allocation period for Apple silicon-as-a-service is 24 hours, meaning you cannot delete your server prior to that. :param server_id: UUID of the server you want to delete. :param zone: Zone to target. If none is passed will use default zone from the config. - + Usage: :: - + result = api.delete_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "DELETE", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}", ) self._throw_on_error(res) - def reboot_server( self, *, @@ -546,18 +585,18 @@ def reboot_server( :param server_id: UUID of the server you want to reboot. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.reboot_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}/reboot", @@ -566,7 +605,7 @@ def reboot_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def reinstall_server( self, *, @@ -581,18 +620,18 @@ def reinstall_server( :param zone: Zone to target. If none is passed will use default zone from the config. :param os_id: Reinstall the server with the target OS, when no os_id provided the default OS for the server type is used. :return: :class:`Server ` - + Usage: :: - + result = api.reinstall_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}/reinstall", @@ -608,7 +647,7 @@ def reinstall_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def start_connectivity_diagnostic( self, *, @@ -616,20 +655,20 @@ def start_connectivity_diagnostic( zone: Optional[ScwZone] = None, ) -> StartConnectivityDiagnosticResponse: """ - :param server_id: + :param server_id: :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`StartConnectivityDiagnosticResponse ` - + Usage: :: - + result = api.start_connectivity_diagnostic( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "POST", f"/apple-silicon/v1alpha1/zones/{param_zone}/connectivity-diagnostics", @@ -644,7 +683,7 @@ def start_connectivity_diagnostic( self._throw_on_error(res) return unmarshal_StartConnectivityDiagnosticResponse(res.json()) - + def get_connectivity_diagnostic( self, *, @@ -652,21 +691,21 @@ def get_connectivity_diagnostic( zone: Optional[ScwZone] = None, ) -> ConnectivityDiagnostic: """ - :param diagnostic_id: + :param diagnostic_id: :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`ConnectivityDiagnostic ` - + Usage: :: - + result = api.get_connectivity_diagnostic( diagnostic_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_diagnostic_id = validate_path_param("diagnostic_id", diagnostic_id) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/connectivity-diagnostics/{param_diagnostic_id}", @@ -674,13 +713,12 @@ def get_connectivity_diagnostic( self._throw_on_error(res) return unmarshal_ConnectivityDiagnostic(res.json()) - + class ApplesiliconV1Alpha1PrivateNetworkAPI(API): """ Apple silicon - Private Networks API. """ - def get_server_private_network( self, *, @@ -689,26 +727,24 @@ def get_server_private_network( zone: Optional[ScwZone] = None, ) -> ServerPrivateNetwork: """ - :param server_id: - :param private_network_id: + :param server_id: + :param private_network_id: :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`ServerPrivateNetwork ` - + Usage: :: - + result = api.get_server_private_network( server_id="example", private_network_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - param_private_network_id = validate_path_param( - "private_network_id", private_network_id - ) - + param_private_network_id = validate_path_param("private_network_id", private_network_id) + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}/private-networks/{param_private_network_id}", @@ -716,7 +752,7 @@ def get_server_private_network( self._throw_on_error(res) return unmarshal_ServerPrivateNetwork(res.json()) - + def wait_for_server_private_network( self, *, @@ -726,14 +762,14 @@ def wait_for_server_private_network( options: Optional[WaitForOptions[ServerPrivateNetwork, bool]] = None, ) -> ServerPrivateNetwork: """ - :param server_id: - :param private_network_id: + :param server_id: + :param private_network_id: :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`ServerPrivateNetwork ` - + Usage: :: - + result = api.get_server_private_network( server_id="example", private_network_id="example", @@ -744,10 +780,7 @@ def wait_for_server_private_network( options = WaitForOptions() if not options.stop: - options.stop = ( - lambda res: res.status - not in SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES - ) + options.stop = lambda res: res.status not in SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES return wait_for_resource( fetcher=self.get_server_private_network, @@ -758,7 +791,7 @@ def wait_for_server_private_network( "zone": zone, }, ) - + def add_server_private_network( self, *, @@ -775,19 +808,19 @@ def add_server_private_network( :param zone: Zone to target. If none is passed will use default zone from the config. :param ipam_ip_ids: IPAM IDs of IPs to attach to the server. :return: :class:`ServerPrivateNetwork ` - + Usage: :: - + result = api.add_server_private_network( server_id="example", private_network_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}/private-networks", @@ -804,7 +837,7 @@ def add_server_private_network( self._throw_on_error(res) return unmarshal_ServerPrivateNetwork(res.json()) - + def set_server_private_networks( self, *, @@ -819,19 +852,19 @@ def set_server_private_networks( :param per_private_network_ipam_ip_ids: Object where the keys are the IDs of Private Networks and the values are arrays of IPAM IDs representing the IPs to assign to this Apple silicon server on the Private Network. If the array supplied for a Private Network is empty, the next available IP from the Private Network's CIDR block will automatically be used for attachment. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`SetServerPrivateNetworksResponse ` - + Usage: :: - + result = api.set_server_private_networks( server_id="example", per_private_network_ipam_ip_ids={}, ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "PUT", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}/private-networks", @@ -847,7 +880,7 @@ def set_server_private_networks( self._throw_on_error(res) return unmarshal_SetServerPrivateNetworksResponse(res.json()) - + def list_server_private_networks( self, *, @@ -874,23 +907,22 @@ def list_server_private_networks( :param project_id: Filter Private Networks by Project ID. :param ipam_ip_ids: Filter Private Networks by IPAM IP IDs. :return: :class:`ListServerPrivateNetworksResponse ` - + Usage: :: - + result = api.list_server_private_networks() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/apple-silicon/v1alpha1/zones/{param_zone}/server-private-networks", params={ "ipam_ip_ids": ipam_ip_ids, "order_by": order_by, - "organization_id": organization_id - or self.client.default_organization_id, + "organization_id": organization_id or self.client.default_organization_id, "page": page, "page_size": page_size or self.client.default_page_size, "private_network_id": private_network_id, @@ -901,7 +933,7 @@ def list_server_private_networks( self._throw_on_error(res) return unmarshal_ListServerPrivateNetworksResponse(res.json()) - + def list_server_private_networks_all( self, *, @@ -928,14 +960,14 @@ def list_server_private_networks_all( :param project_id: Filter Private Networks by Project ID. :param ipam_ip_ids: Filter Private Networks by IPAM IP IDs. :return: :class:`List[ServerPrivateNetwork] ` - + Usage: :: - + result = api.list_server_private_networks_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListServerPrivateNetworksResponse, key="server_private_networks", fetcher=self.list_server_private_networks, @@ -951,7 +983,7 @@ def list_server_private_networks_all( "ipam_ip_ids": ipam_ip_ids, }, ) - + def delete_server_private_network( self, *, @@ -964,22 +996,20 @@ def delete_server_private_network( :param server_id: ID of the server. :param private_network_id: ID of the Private Network. :param zone: Zone to target. If none is passed will use default zone from the config. - + Usage: :: - + result = api.delete_server_private_network( server_id="example", private_network_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - param_private_network_id = validate_path_param( - "private_network_id", private_network_id - ) - + param_private_network_id = validate_path_param("private_network_id", private_network_id) + res = self._request( "DELETE", f"/apple-silicon/v1alpha1/zones/{param_zone}/servers/{param_server_id}/private-networks/{param_private_network_id}", diff --git a/scaleway/scaleway/applesilicon/v1alpha1/content.py b/scaleway/scaleway/applesilicon/v1alpha1/content.py index d8118f9fb..93bead00a 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/content.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/content.py @@ -7,10 +7,7 @@ ServerPrivateNetworkStatus, ServerStatus, ) - -SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES: List[ - ServerPrivateNetworkServerStatus -] = [ +SERVER_PRIVATE_NETWORK_SERVER_TRANSIENT_STATUSES: List[ServerPrivateNetworkServerStatus] = [ ServerPrivateNetworkServerStatus.ATTACHING, ServerPrivateNetworkServerStatus.DETACHING, ] diff --git a/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py b/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py index b8f5ea4c4..283a1ab66 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py @@ -1,12 +1,41 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import Any, Dict +from decimal import Decimal +from datetime import datetime +from typing import Any, Dict, List, Optional from dateutil import parser from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, + unmarshal_Money, + marshal_Money, + marshal_ScwFile, + marshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, +) +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) from .types import ( + CommitmentType, ConnectivityDiagnosticActionType, + ConnectivityDiagnosticDiagnosticStatus, + ListServerPrivateNetworksRequestOrderBy, + ListServersRequestOrderBy, + ServerPrivateNetworkServerStatus, + ServerPrivateNetworkStatus, + ServerStatus, + ServerTypeStock, OS, Commitment, Server, @@ -34,7 +63,6 @@ UpdateServerRequest, ) - def unmarshal_OS(data: Any) -> OS: if not isinstance(data, dict): raise TypeError( @@ -43,45 +71,35 @@ def unmarshal_OS(data: Any) -> OS: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("label", None) - if field is not None: - args["label"] = field + field = data.get("label", str()) + args["label"] = field - field = data.get("image_url", None) - if field is not None: - args["image_url"] = field + field = data.get("image_url", str()) + args["image_url"] = field - field = data.get("family", None) - if field is not None: - args["family"] = field + field = data.get("family", str()) + args["family"] = field - field = data.get("is_beta", None) - if field is not None: - args["is_beta"] = field + field = data.get("is_beta", False) + args["is_beta"] = field - field = data.get("version", None) - if field is not None: - args["version"] = field + field = data.get("version", str()) + args["version"] = field - field = data.get("xcode_version", None) - if field is not None: - args["xcode_version"] = field + field = data.get("xcode_version", str()) + args["xcode_version"] = field - field = data.get("compatible_server_types", None) - if field is not None: - args["compatible_server_types"] = field + field = data.get("compatible_server_types", []) + args["compatible_server_types"] = field return OS(**args) - def unmarshal_Commitment(data: Any) -> Commitment: if not isinstance(data, dict): raise TypeError( @@ -90,17 +108,14 @@ def unmarshal_Commitment(data: Any) -> Commitment: args: Dict[str, Any] = {} - field = data.get("type", None) - if field is not None: - args["type_"] = field + field = data.get("type", str()) + args["type_"] = field - field = data.get("cancelled", None) - if field is not None: - args["cancelled"] = field + field = data.get("cancelled", str()) + args["cancelled"] = field return Commitment(**args) - def unmarshal_Server(data: Any) -> Server: if not isinstance(data, dict): raise TypeError( @@ -109,105 +124,71 @@ def unmarshal_Server(data: Any) -> Server: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("type", None) - if field is not None: - args["type_"] = field + field = data.get("type", str()) + args["type_"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field + field = data.get("project_id", str()) + args["project_id"] = field - field = data.get("organization_id", None) - if field is not None: - args["organization_id"] = field + field = data.get("organization_id", str()) + args["organization_id"] = field - field = data.get("ip", None) - if field is not None: - args["ip"] = field + field = data.get("ip", str()) + args["ip"] = field - field = data.get("vnc_url", None) - if field is not None: - args["vnc_url"] = field + field = data.get("vnc_url", str()) + args["vnc_url"] = field - field = data.get("ssh_username", None) - if field is not None: - args["ssh_username"] = field + field = data.get("ssh_username", str()) + args["ssh_username"] = field - field = data.get("sudo_password", None) - if field is not None: - args["sudo_password"] = field + field = data.get("sudo_password", str()) + args["sudo_password"] = field - field = data.get("vnc_port", None) - if field is not None: - args["vnc_port"] = field + field = data.get("vnc_port", 0) + args["vnc_port"] = field - field = data.get("status", None) - if field is not None: - args["status"] = field + field = data.get("status", getattr(ServerStatus, "UNKNOWN_STATUS")) + args["status"] = field field = data.get("os", None) - if field is not None: - args["os"] = unmarshal_OS(field) - else: - args["os"] = None + args["os"] = unmarshal_OS(field) if field is not None else 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field 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 + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("deletable_at", None) - if field is not None: - args["deletable_at"] = ( - parser.isoparse(field) if isinstance(field, str) else field - ) - else: - args["deletable_at"] = None + args["deletable_at"] = parser.isoparse(field) if isinstance(field, str) else field - field = data.get("deletion_scheduled", None) - if field is not None: - args["deletion_scheduled"] = field + field = data.get("deletion_scheduled", False) + args["deletion_scheduled"] = field - field = data.get("zone", None) - if field is not None: - args["zone"] = field + field = data.get("zone", ) + args["zone"] = field - field = data.get("delivered", None) - if field is not None: - args["delivered"] = field + field = data.get("delivered", False) + args["delivered"] = field - field = data.get("vpc_status", None) - if field is not None: - args["vpc_status"] = field + field = data.get("vpc_status", getattr(ServerPrivateNetworkStatus, "VPC_UNKNOWN_STATUS")) + args["vpc_status"] = field - field = data.get("public_bandwidth_bps", None) - if field is not None: - args["public_bandwidth_bps"] = field + field = data.get("public_bandwidth_bps", 0) + args["public_bandwidth_bps"] = field field = data.get("commitment", None) - if field is not None: - args["commitment"] = unmarshal_Commitment(field) - else: - args["commitment"] = None + args["commitment"] = unmarshal_Commitment(field) if field is not None else None return Server(**args) - def unmarshal_ServerPrivateNetwork(data: Any) -> ServerPrivateNetwork: if not isinstance(data, dict): raise TypeError( @@ -216,51 +197,35 @@ def unmarshal_ServerPrivateNetwork(data: Any) -> ServerPrivateNetwork: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field + field = data.get("project_id", str()) + args["project_id"] = field - field = data.get("server_id", None) - if field is not None: - args["server_id"] = field + field = data.get("server_id", str()) + args["server_id"] = field - field = data.get("private_network_id", None) - if field is not None: - args["private_network_id"] = field + field = data.get("private_network_id", str()) + args["private_network_id"] = field - field = data.get("status", None) - if field is not None: - args["status"] = field + field = data.get("status", getattr(ServerPrivateNetworkServerStatus, "UNKNOWN_STATUS")) + args["status"] = field - field = data.get("ipam_ip_ids", None) - if field is not None: - args["ipam_ip_ids"] = field + field = data.get("ipam_ip_ids", []) + args["ipam_ip_ids"] = field field = data.get("vlan", None) - if field is not None: - args["vlan"] = field - else: - args["vlan"] = None + args["vlan"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field 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 + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field return ServerPrivateNetwork(**args) - def unmarshal_ServerTypeCPU(data: Any) -> ServerTypeCPU: if not isinstance(data, dict): raise TypeError( @@ -269,21 +234,17 @@ def unmarshal_ServerTypeCPU(data: Any) -> ServerTypeCPU: args: Dict[str, Any] = {} - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("core_count", None) - if field is not None: - args["core_count"] = field + field = data.get("core_count", str()) + args["core_count"] = field - field = data.get("frequency", None) - if field is not None: - args["frequency"] = field + field = data.get("frequency", str()) + args["frequency"] = field return ServerTypeCPU(**args) - def unmarshal_ServerTypeDisk(data: Any) -> ServerTypeDisk: if not isinstance(data, dict): raise TypeError( @@ -292,17 +253,14 @@ def unmarshal_ServerTypeDisk(data: Any) -> ServerTypeDisk: args: Dict[str, Any] = {} - field = data.get("capacity", None) - if field is not None: - args["capacity"] = field + field = data.get("capacity", str()) + args["capacity"] = field - field = data.get("type", None) - if field is not None: - args["type_"] = field + field = data.get("type", str()) + args["type_"] = field return ServerTypeDisk(**args) - def unmarshal_ServerTypeGPU(data: Any) -> ServerTypeGPU: if not isinstance(data, dict): raise TypeError( @@ -311,13 +269,11 @@ def unmarshal_ServerTypeGPU(data: Any) -> ServerTypeGPU: args: Dict[str, Any] = {} - field = data.get("count", None) - if field is not None: - args["count"] = field + field = data.get("count", str()) + args["count"] = field return ServerTypeGPU(**args) - def unmarshal_ServerTypeMemory(data: Any) -> ServerTypeMemory: if not isinstance(data, dict): raise TypeError( @@ -326,17 +282,14 @@ def unmarshal_ServerTypeMemory(data: Any) -> ServerTypeMemory: args: Dict[str, Any] = {} - field = data.get("capacity", None) - if field is not None: - args["capacity"] = field + field = data.get("capacity", str()) + args["capacity"] = field - field = data.get("type", None) - if field is not None: - args["type_"] = field + field = data.get("type", str()) + args["type_"] = field return ServerTypeMemory(**args) - def unmarshal_ServerTypeNetwork(data: Any) -> ServerTypeNetwork: if not isinstance(data, dict): raise TypeError( @@ -345,17 +298,14 @@ def unmarshal_ServerTypeNetwork(data: Any) -> ServerTypeNetwork: args: Dict[str, Any] = {} - field = data.get("public_bandwidth_bps", None) - if field is not None: - args["public_bandwidth_bps"] = field + field = data.get("public_bandwidth_bps", str()) + args["public_bandwidth_bps"] = field - field = data.get("supported_bandwidth", None) - if field is not None: - args["supported_bandwidth"] = field + field = data.get("supported_bandwidth", str()) + args["supported_bandwidth"] = field return ServerTypeNetwork(**args) - def unmarshal_ServerType(data: Any) -> ServerType: if not isinstance(data, dict): raise TypeError( @@ -364,62 +314,36 @@ def unmarshal_ServerType(data: Any) -> ServerType: args: Dict[str, Any] = {} - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("stock", None) - if field is not None: - args["stock"] = field + field = data.get("stock", getattr(ServerTypeStock, "UNKNOWN_STOCK")) + args["stock"] = field field = data.get("cpu", None) - if field is not None: - args["cpu"] = unmarshal_ServerTypeCPU(field) - else: - args["cpu"] = None + args["cpu"] = unmarshal_ServerTypeCPU(field) if field is not None else None field = data.get("disk", None) - if field is not None: - args["disk"] = unmarshal_ServerTypeDisk(field) - else: - args["disk"] = None + args["disk"] = unmarshal_ServerTypeDisk(field) if field is not None else None field = data.get("memory", None) - if field is not None: - args["memory"] = unmarshal_ServerTypeMemory(field) - else: - args["memory"] = None + args["memory"] = unmarshal_ServerTypeMemory(field) if field is not None else None field = data.get("minimum_lease_duration", None) - if field is not None: - args["minimum_lease_duration"] = field - else: - args["minimum_lease_duration"] = None + args["minimum_lease_duration"] = field field = data.get("gpu", None) - if field is not None: - args["gpu"] = unmarshal_ServerTypeGPU(field) - else: - args["gpu"] = None + args["gpu"] = unmarshal_ServerTypeGPU(field) if field is not None else None field = data.get("network", None) - if field is not None: - args["network"] = unmarshal_ServerTypeNetwork(field) - else: - args["network"] = None + args["network"] = unmarshal_ServerTypeNetwork(field) if field is not None else None field = data.get("default_os", None) - if field is not None: - args["default_os"] = unmarshal_OS(field) - else: - args["default_os"] = None + args["default_os"] = unmarshal_OS(field) if field is not None else None return ServerType(**args) - -def unmarshal_ConnectivityDiagnosticServerHealth( - data: Any, -) -> ConnectivityDiagnosticServerHealth: +def unmarshal_ConnectivityDiagnosticServerHealth(data: Any) -> ConnectivityDiagnosticServerHealth: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'ConnectivityDiagnosticServerHealth' failed as data isn't a dictionary." @@ -427,37 +351,26 @@ def unmarshal_ConnectivityDiagnosticServerHealth( args: Dict[str, Any] = {} - field = data.get("is_server_alive", None) - if field is not None: - args["is_server_alive"] = field + field = data.get("is_server_alive", str()) + args["is_server_alive"] = field - field = data.get("is_agent_alive", None) - if field is not None: - args["is_agent_alive"] = field + field = data.get("is_agent_alive", str()) + args["is_agent_alive"] = field - field = data.get("is_mdm_alive", None) - if field is not None: - args["is_mdm_alive"] = field + field = data.get("is_mdm_alive", str()) + args["is_mdm_alive"] = field - field = data.get("is_ssh_port_up", None) - if field is not None: - args["is_ssh_port_up"] = field + field = data.get("is_ssh_port_up", str()) + args["is_ssh_port_up"] = field - field = data.get("is_vnc_port_up", None) - if field is not None: - args["is_vnc_port_up"] = field + field = data.get("is_vnc_port_up", str()) + args["is_vnc_port_up"] = field field = data.get("last_checkin_date", None) - if field is not None: - args["last_checkin_date"] = ( - parser.isoparse(field) if isinstance(field, str) else field - ) - else: - args["last_checkin_date"] = None + args["last_checkin_date"] = parser.isoparse(field) if isinstance(field, str) else field return ConnectivityDiagnosticServerHealth(**args) - def unmarshal_ConnectivityDiagnostic(data: Any) -> ConnectivityDiagnostic: if not isinstance(data, dict): raise TypeError( @@ -466,39 +379,26 @@ def unmarshal_ConnectivityDiagnostic(data: Any) -> ConnectivityDiagnostic: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("status", None) - if field is not None: - args["status"] = field + field = data.get("status", str()) + args["status"] = field - field = data.get("is_healthy", None) - if field is not None: - args["is_healthy"] = field + field = data.get("is_healthy", str()) + args["is_healthy"] = field - field = data.get("supported_actions", None) - if field is not None: - args["supported_actions"] = ( - [ConnectivityDiagnosticActionType(v) for v in field] - if field is not None - else None - ) + field = data.get("supported_actions", str()) + args["supported_actions"] = [ConnectivityDiagnosticActionType(v) for v in field] if field is not None else None - field = data.get("error_message", None) - if field is not None: - args["error_message"] = field + field = data.get("error_message", str()) + args["error_message"] = field field = data.get("health_details", None) - if field is not None: - args["health_details"] = unmarshal_ConnectivityDiagnosticServerHealth(field) - else: - args["health_details"] = None + args["health_details"] = unmarshal_ConnectivityDiagnosticServerHealth(field) if field is not None else None return ConnectivityDiagnostic(**args) - def unmarshal_ListOSResponse(data: Any) -> ListOSResponse: if not isinstance(data, dict): raise TypeError( @@ -507,20 +407,15 @@ def unmarshal_ListOSResponse(data: Any) -> ListOSResponse: args: Dict[str, Any] = {} - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field - field = data.get("os", None) - if field is not None: - args["os"] = [unmarshal_OS(v) for v in field] if field is not None else None + field = data.get("os", []) + args["os"] = [unmarshal_OS(v) for v in field] if field is not None else None return ListOSResponse(**args) - -def unmarshal_ListServerPrivateNetworksResponse( - data: Any, -) -> ListServerPrivateNetworksResponse: +def unmarshal_ListServerPrivateNetworksResponse(data: Any) -> ListServerPrivateNetworksResponse: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'ListServerPrivateNetworksResponse' failed as data isn't a dictionary." @@ -528,21 +423,14 @@ def unmarshal_ListServerPrivateNetworksResponse( args: Dict[str, Any] = {} - field = data.get("server_private_networks", None) - if field is not None: - args["server_private_networks"] = ( - [unmarshal_ServerPrivateNetwork(v) for v in field] - if field is not None - else None - ) + field = data.get("server_private_networks", str()) + args["server_private_networks"] = [unmarshal_ServerPrivateNetwork(v) for v in field] if field is not None else None - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", str()) + args["total_count"] = field return ListServerPrivateNetworksResponse(**args) - def unmarshal_ListServerTypesResponse(data: Any) -> ListServerTypesResponse: if not isinstance(data, dict): raise TypeError( @@ -551,15 +439,11 @@ def unmarshal_ListServerTypesResponse(data: Any) -> ListServerTypesResponse: args: Dict[str, Any] = {} - field = data.get("server_types", None) - if field is not None: - args["server_types"] = ( - [unmarshal_ServerType(v) for v in field] if field is not None else None - ) + field = data.get("server_types", []) + args["server_types"] = [unmarshal_ServerType(v) for v in field] if field is not None else None return ListServerTypesResponse(**args) - def unmarshal_ListServersResponse(data: Any) -> ListServersResponse: if not isinstance(data, dict): raise TypeError( @@ -568,22 +452,15 @@ def unmarshal_ListServersResponse(data: Any) -> ListServersResponse: args: Dict[str, Any] = {} - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field - field = data.get("servers", None) - if field is not None: - args["servers"] = ( - [unmarshal_Server(v) for v in field] if field is not None else None - ) + field = data.get("servers", []) + args["servers"] = [unmarshal_Server(v) for v in field] if field is not None else None return ListServersResponse(**args) - -def unmarshal_SetServerPrivateNetworksResponse( - data: Any, -) -> SetServerPrivateNetworksResponse: +def unmarshal_SetServerPrivateNetworksResponse(data: Any) -> SetServerPrivateNetworksResponse: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'SetServerPrivateNetworksResponse' failed as data isn't a dictionary." @@ -591,20 +468,12 @@ def unmarshal_SetServerPrivateNetworksResponse( args: Dict[str, Any] = {} - field = data.get("server_private_networks", None) - if field is not None: - args["server_private_networks"] = ( - [unmarshal_ServerPrivateNetwork(v) for v in field] - if field is not None - else None - ) + field = data.get("server_private_networks", str()) + args["server_private_networks"] = [unmarshal_ServerPrivateNetwork(v) for v in field] if field is not None else None return SetServerPrivateNetworksResponse(**args) - -def unmarshal_StartConnectivityDiagnosticResponse( - data: Any, -) -> StartConnectivityDiagnosticResponse: +def unmarshal_StartConnectivityDiagnosticResponse(data: Any) -> StartConnectivityDiagnosticResponse: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'StartConnectivityDiagnosticResponse' failed as data isn't a dictionary." @@ -612,13 +481,11 @@ def unmarshal_StartConnectivityDiagnosticResponse( args: Dict[str, Any] = {} - field = data.get("diagnostic_id", None) - if field is not None: - args["diagnostic_id"] = field + field = data.get("diagnostic_id", str()) + args["diagnostic_id"] = field return StartConnectivityDiagnosticResponse(**args) - def marshal_CreateServerRequest( request: CreateServerRequest, defaults: ProfileDefaults, @@ -627,27 +494,41 @@ def marshal_CreateServerRequest( if request.type_ is not None: output["type"] = request.type_ + else: + output["type"] = str() if request.enable_vpc is not None: output["enable_vpc"] = request.enable_vpc + else: + output["enable_vpc"] = False if request.public_bandwidth_bps is not None: output["public_bandwidth_bps"] = request.public_bandwidth_bps + else: + output["public_bandwidth_bps"] = 0 if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.project_id is not None: output["project_id"] = request.project_id or defaults.default_project_id + else: + output["project_id"] = None if request.os_id is not None: output["os_id"] = request.os_id + else: + output["os_id"] = None if request.commitment_type is not None: output["commitment_type"] = str(request.commitment_type) + else: + output["commitment_type"] = None - return output + return output def marshal_PrivateNetworkApiAddServerPrivateNetworkRequest( request: PrivateNetworkApiAddServerPrivateNetworkRequest, @@ -657,12 +538,16 @@ def marshal_PrivateNetworkApiAddServerPrivateNetworkRequest( if request.private_network_id is not None: output["private_network_id"] = request.private_network_id + else: + output["private_network_id"] = str() if request.ipam_ip_ids is not None: output["ipam_ip_ids"] = request.ipam_ip_ids + else: + output["ipam_ip_ids"] = None - return output + return output def marshal_PrivateNetworkApiSetServerPrivateNetworksRequest( request: PrivateNetworkApiSetServerPrivateNetworksRequest, @@ -672,11 +557,14 @@ def marshal_PrivateNetworkApiSetServerPrivateNetworksRequest( if request.per_private_network_ipam_ip_ids is not None: output["per_private_network_ipam_ip_ids"] = { - key: value for key, value in request.per_private_network_ipam_ip_ids.items() + key: value + for key, value in request.per_private_network_ipam_ip_ids.items() } + else: + output["per_private_network_ipam_ip_ids"] = str() - return output + return output def marshal_ReinstallServerRequest( request: ReinstallServerRequest, @@ -686,9 +574,11 @@ def marshal_ReinstallServerRequest( if request.os_id is not None: output["os_id"] = request.os_id + else: + output["os_id"] = None - return output + return output def marshal_StartConnectivityDiagnosticRequest( request: StartConnectivityDiagnosticRequest, @@ -698,9 +588,11 @@ def marshal_StartConnectivityDiagnosticRequest( if request.server_id is not None: output["server_id"] = request.server_id + else: + output["server_id"] = str() - return output + return output def marshal_CommitmentTypeValue( request: CommitmentTypeValue, @@ -710,9 +602,11 @@ def marshal_CommitmentTypeValue( if request.commitment_type is not None: output["commitment_type"] = str(request.commitment_type) + else: + output["commitment_type"] = str() - return output + return output def marshal_UpdateServerRequest( request: UpdateServerRequest, @@ -722,19 +616,28 @@ def marshal_UpdateServerRequest( if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.schedule_deletion is not None: output["schedule_deletion"] = request.schedule_deletion + else: + output["schedule_deletion"] = None if request.enable_vpc is not None: output["enable_vpc"] = request.enable_vpc + else: + output["enable_vpc"] = None if request.commitment_type is not None: - output["commitment_type"] = marshal_CommitmentTypeValue( - request.commitment_type, defaults - ) + output["commitment_type"] = marshal_CommitmentTypeValue(request.commitment_type, defaults) + else: + output["commitment_type"] = None if request.public_bandwidth_bps is not None: output["public_bandwidth_bps"] = request.public_bandwidth_bps + else: + output["public_bandwidth_bps"] = None + return output diff --git a/scaleway/scaleway/applesilicon/v1alpha1/types.py b/scaleway/scaleway/applesilicon/v1alpha1/types.py index 5adbcb259..aa30d1a56 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/types.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/types.py @@ -3,18 +3,24 @@ from __future__ import annotations from dataclasses import dataclass +from decimal import Decimal from datetime import datetime from enum import Enum -from typing import Dict, List, Optional +from typing import Any, Dict, List, Optional from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, Zone as ScwZone, ) from scaleway_core.utils import ( StrEnumMeta, ) - class CommitmentType(str, Enum, metaclass=StrEnumMeta): DURATION_24H = "duration_24h" RENEWED_MONTHLY = "renewed_monthly" @@ -23,7 +29,6 @@ class CommitmentType(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ConnectivityDiagnosticActionType(str, Enum, metaclass=StrEnumMeta): REBOOT_SERVER = "reboot_server" REINSTALL_SERVER = "reinstall_server" @@ -31,7 +36,6 @@ class ConnectivityDiagnosticActionType(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ConnectivityDiagnosticDiagnosticStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" PROCESSING = "processing" @@ -41,7 +45,6 @@ class ConnectivityDiagnosticDiagnosticStatus(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListServerPrivateNetworksRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -51,7 +54,6 @@ class ListServerPrivateNetworksRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListServersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -59,7 +61,6 @@ class ListServersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ServerPrivateNetworkServerStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" ATTACHING = "attaching" @@ -71,7 +72,6 @@ class ServerPrivateNetworkServerStatus(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ServerPrivateNetworkStatus(str, Enum, metaclass=StrEnumMeta): VPC_UNKNOWN_STATUS = "vpc_unknown_status" VPC_ENABLED = "vpc_enabled" @@ -81,7 +81,6 @@ class ServerPrivateNetworkStatus(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ServerStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" STARTING = "starting" @@ -98,7 +97,6 @@ class ServerStatus(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ServerTypeStock(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STOCK = "unknown_stock" NO_STOCK = "no_stock" @@ -108,13 +106,12 @@ class ServerTypeStock(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - @dataclass class Commitment: type_: CommitmentType - + cancelled: bool - + @dataclass class OS: @@ -122,82 +119,82 @@ class OS: """ Unique ID of the OS. """ - + name: str """ OS name. """ - + label: str """ OS name as it should be displayed. """ - + image_url: str """ URL of the image. """ - + family: str """ The OS family to which this OS belongs, eg. 13 or 14. """ - + is_beta: bool """ Describes if the OS is in beta. """ - + version: str """ The OS version number, eg. Sonoma has version number 14.3. """ - + xcode_version: str """ The current xcode version for this OS. """ - + compatible_server_types: List[str] """ List of compatible server types. """ - + @dataclass class ServerTypeCPU: name: str - + core_count: int - + frequency: int - + @dataclass class ServerTypeDisk: capacity: int - + type_: str - + @dataclass class ServerTypeGPU: count: int - + @dataclass class ServerTypeMemory: capacity: int - + type_: str - + @dataclass class ServerTypeNetwork: public_bandwidth_bps: int - + supported_bandwidth: List[int] - + @dataclass class Server: @@ -205,122 +202,122 @@ class Server: """ UUID of the server. """ - + type_: str """ Type of the server. """ - + name: str """ Name of the server. """ - + project_id: str """ Project this server is associated with. """ - + organization_id: str """ Organization this server is associated with. """ - + ip: str """ IPv4 address of the server. """ - + vnc_url: str """ Vnc:// URL to access Apple Remote Desktop. """ - + ssh_username: str """ SSH Username for remote shell. """ - + sudo_password: str """ Admin password required to execute commands. """ - + vnc_port: int """ VNC port to use for remote desktop connection. """ - + status: ServerStatus """ Current status of the server. """ - + os: Optional[OS] """ Initially installed OS, this does not necessarily reflect the current OS version. """ - + created_at: Optional[datetime] """ Date on which the server was created. """ - + updated_at: Optional[datetime] """ Date on which the server was last updated. """ - + deletable_at: Optional[datetime] """ Date from which the server can be deleted. """ - + deletion_scheduled: bool """ Set to true to mark the server for automatic deletion depending on `deletable_at` date. Set to false to cancel an existing deletion schedule. Leave unset otherwise. """ - + zone: ScwZone """ Zone of the server. """ - + delivered: bool """ Set to true once the server has completed its provisioning steps and is ready to use. Some OS configurations might require a reinstallation of the server before delivery depending on the available stock. A reinstallation after the initial delivery will not change this flag and can be tracked using the server status. """ - + vpc_status: ServerPrivateNetworkStatus """ Activation status of optional Private Network feature support for this server. """ - + public_bandwidth_bps: int """ Public bandwidth configured for this server. Expressed in bits per second. """ - + commitment: Optional[Commitment] """ Commitment scheme applied to this server. """ - + @dataclass class ConnectivityDiagnosticServerHealth: is_server_alive: bool - + is_agent_alive: bool - + is_mdm_alive: bool - + is_ssh_port_up: bool - + is_vnc_port_up: bool - + last_checkin_date: Optional[datetime] - + @dataclass class ServerPrivateNetwork: @@ -328,47 +325,47 @@ class ServerPrivateNetwork: """ ID of the Server-to-Private Network mapping. """ - + project_id: str """ Private Network Project ID. """ - + server_id: str """ Apple silicon server ID. """ - + private_network_id: str """ Private Network ID. """ - + status: ServerPrivateNetworkServerStatus """ Configuration status of the Private Network. """ - + ipam_ip_ids: List[str] """ IPAM IP IDs of the server, if it has any. """ - + vlan: Optional[int] """ ID of the VLAN associated with the Private Network. """ - + created_at: Optional[datetime] """ Private Network creation date. """ - + updated_at: Optional[datetime] """ Date the Private Network was last modified. """ - + @dataclass class ServerType: @@ -376,67 +373,67 @@ class ServerType: """ Name of the type. """ - + stock: ServerTypeStock """ Current stock. """ - + cpu: Optional[ServerTypeCPU] """ CPU description. """ - + disk: Optional[ServerTypeDisk] """ Size of the local disk of the server. """ - + memory: Optional[ServerTypeMemory] """ Size of memory available. """ - + minimum_lease_duration: Optional[str] """ Minimum duration of the lease in seconds (example. 3.4s). """ - + gpu: Optional[ServerTypeGPU] """ GPU description. """ - + network: Optional[ServerTypeNetwork] """ Network description. """ - + default_os: Optional[OS] """ The default OS for this server type. """ - + @dataclass class CommitmentTypeValue: commitment_type: CommitmentType - + @dataclass class ConnectivityDiagnostic: id: str - + status: ConnectivityDiagnosticDiagnosticStatus - + is_healthy: bool - + supported_actions: List[ConnectivityDiagnosticActionType] - + error_message: str - + health_details: Optional[ConnectivityDiagnosticServerHealth] - + @dataclass class CreateServerRequest: @@ -444,42 +441,42 @@ class CreateServerRequest: """ Create a server of the given type. """ - + enable_vpc: bool """ Activate the Private Network feature for this server. This feature is configured through the Apple Silicon - Private Networks API. """ - + public_bandwidth_bps: int """ Public bandwidth to configure for this server. This defaults to the minimum bandwidth for this server type. For compatible server types, the bandwidth can be increased which incurs additional costs. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + name: Optional[str] """ Create a server with this given name. """ - + project_id: Optional[str] """ Create a server in the given project ID. """ - + os_id: Optional[str] """ Create a server & install the given os_id, when no os_id provided the default OS for this server type is chosen. Requesting a non-default OS will induce an extended delivery time. """ - + commitment_type: Optional[CommitmentType] """ Activate commitment for this server. If not specified, there is a 24h commitment due to Apple licensing (commitment_type `duration_24h`). It can be updated with the Update Server request. Available commitment depends on server type. """ - + @dataclass class DeleteServerRequest: @@ -487,22 +484,22 @@ class DeleteServerRequest: """ UUID of the server you want to delete. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class GetConnectivityDiagnosticRequest: diagnostic_id: str - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class GetOSRequest: @@ -510,12 +507,12 @@ class GetOSRequest: """ UUID of the OS you want to get. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class GetServerRequest: @@ -523,12 +520,12 @@ class GetServerRequest: """ UUID of the server you want to get. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class GetServerTypeRequest: @@ -536,12 +533,12 @@ class GetServerTypeRequest: """ Server type identifier. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class ListOSRequest: @@ -549,27 +546,27 @@ class ListOSRequest: """ Zone to target. If none is passed will use default zone from the config. """ - + page: Optional[int] """ Positive integer to choose the page to return. """ - + page_size: Optional[int] """ Positive integer lower or equal to 100 to select the number of items to return. """ - + server_type: Optional[str] """ List of compatible server types. """ - + name: Optional[str] """ Filter OS by name (note that "11.1" will return "11.1.2" and "11.1" but not "12")). """ - + @dataclass class ListOSResponse: @@ -577,19 +574,19 @@ class ListOSResponse: """ Total number of OS. """ - + os: List[OS] """ List of OS. """ - + @dataclass class ListServerPrivateNetworksResponse: server_private_networks: List[ServerPrivateNetwork] - + total_count: int - + @dataclass class ListServerTypesRequest: @@ -597,7 +594,7 @@ class ListServerTypesRequest: """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class ListServerTypesResponse: @@ -605,7 +602,7 @@ class ListServerTypesResponse: """ Available server types. """ - + @dataclass class ListServersRequest: @@ -613,32 +610,32 @@ class ListServersRequest: """ Zone to target. If none is passed will use default zone from the config. """ - + order_by: Optional[ListServersRequestOrderBy] """ Sort order of the returned servers. """ - + project_id: Optional[str] """ Only list servers of this project ID. """ - + organization_id: Optional[str] """ Only list servers of this Organization ID. """ - + page: Optional[int] """ Positive integer to choose the page to return. """ - + page_size: Optional[int] """ Positive integer lower or equal to 100 to select the number of items to return. """ - + @dataclass class ListServersResponse: @@ -646,12 +643,12 @@ class ListServersResponse: """ Total number of servers. """ - + servers: List[Server] """ Paginated returned servers. """ - + @dataclass class PrivateNetworkApiAddServerPrivateNetworkRequest: @@ -659,22 +656,22 @@ class PrivateNetworkApiAddServerPrivateNetworkRequest: """ ID of the server. """ - + private_network_id: str """ ID of the Private Network. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + ipam_ip_ids: Optional[List[str]] """ IPAM IDs of IPs to attach to the server. """ - + @dataclass class PrivateNetworkApiDeleteServerPrivateNetworkRequest: @@ -682,29 +679,29 @@ class PrivateNetworkApiDeleteServerPrivateNetworkRequest: """ ID of the server. """ - + private_network_id: str """ ID of the Private Network. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class PrivateNetworkApiGetServerPrivateNetworkRequest: server_id: str - + private_network_id: str - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class PrivateNetworkApiListServerPrivateNetworksRequest: @@ -712,47 +709,47 @@ class PrivateNetworkApiListServerPrivateNetworksRequest: """ Zone to target. If none is passed will use default zone from the config. """ - + order_by: Optional[ListServerPrivateNetworksRequestOrderBy] """ Sort order for the returned Private Networks. """ - + page: Optional[int] """ Page number for the returned Private Networks. """ - + page_size: Optional[int] """ Maximum number of Private Networks per page. """ - + server_id: Optional[str] """ Filter Private Networks by server ID. """ - + private_network_id: Optional[str] """ Filter Private Networks by Private Network ID. """ - + organization_id: Optional[str] """ Filter Private Networks by Organization ID. """ - + project_id: Optional[str] """ Filter Private Networks by Project ID. """ - + ipam_ip_ids: Optional[List[str]] """ Filter Private Networks by IPAM IP IDs. """ - + @dataclass class PrivateNetworkApiSetServerPrivateNetworksRequest: @@ -760,17 +757,17 @@ class PrivateNetworkApiSetServerPrivateNetworksRequest: """ ID of the server. """ - + per_private_network_ipam_ip_ids: Dict[str, List[str]] """ Object where the keys are the IDs of Private Networks and the values are arrays of IPAM IDs representing the IPs to assign to this Apple silicon server on the Private Network. If the array supplied for a Private Network is empty, the next available IP from the Private Network's CIDR block will automatically be used for attachment. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class RebootServerRequest: @@ -778,12 +775,12 @@ class RebootServerRequest: """ UUID of the server you want to reboot. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class ReinstallServerRequest: @@ -791,37 +788,37 @@ class ReinstallServerRequest: """ UUID of the server you want to reinstall. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + os_id: Optional[str] """ Reinstall the server with the target OS, when no os_id provided the default OS for the server type is used. """ - + @dataclass class SetServerPrivateNetworksResponse: server_private_networks: List[ServerPrivateNetwork] - + @dataclass class StartConnectivityDiagnosticRequest: server_id: str - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class StartConnectivityDiagnosticResponse: diagnostic_id: str - + @dataclass class UpdateServerRequest: @@ -829,33 +826,34 @@ class UpdateServerRequest: """ UUID of the server you want to update. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + name: Optional[str] """ Updated name for your server. """ - + schedule_deletion: Optional[bool] """ Specify whether the server should be flagged for automatic deletion. """ - + enable_vpc: Optional[bool] """ Activate or deactivate Private Network support for this server. """ - + commitment_type: Optional[CommitmentTypeValue] """ Change commitment. Use 'none' to automatically cancel a renewing commitment. """ - + public_bandwidth_bps: Optional[int] """ Public bandwidth to configure for this server. Setting an higher bandwidth incurs additional costs. Supported bandwidth levels depends on server type and can be queried using the `/server-types` endpoint. """ + diff --git a/scaleway/scaleway/audit_trail/v1alpha1/api.py b/scaleway/scaleway/audit_trail/v1alpha1/api.py index f2e593c99..2eba8b6c1 100644 --- a/scaleway/scaleway/audit_trail/v1alpha1/api.py +++ b/scaleway/scaleway/audit_trail/v1alpha1/api.py @@ -2,32 +2,67 @@ # If you have any remark or suggestion do not hesitate to open an issue. from datetime import datetime -from typing import Optional +from typing import Any, Awaitable, Dict, List, Optional, Union from scaleway_core.api import API from scaleway_core.bridge import ( + Money, Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, + marshal_Money, + unmarshal_Money, + marshal_ScwFile, + unmarshal_ScwFile, + unmarshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, ) from scaleway_core.utils import ( + OneOfPossibility, + WaitForOptions, + project_or_organization_id, + random_name, + resolve_one_of, validate_path_param, + fetch_all_pages, + wait_for_resource, ) from .types import ( ListEventsRequestOrderBy, ResourceType, + AccountOrganizationInfo, + AccountUserInfo, + Event, + EventPrincipal, + InstanceServerInfo, + KeyManagerKeyInfo, + KubernetesACLInfo, + KubernetesClusterInfo, + KubernetesNodeInfo, + KubernetesPoolInfo, + ListEventsRequest, ListEventsResponse, + ListProductsRequest, ListProductsResponse, + Product, + ProductService, + Resource, + SecretManagerSecretInfo, + SecretManagerSecretVersionInfo, ) from .marshalling import ( unmarshal_ListEventsResponse, unmarshal_ListProductsResponse, ) - class AuditTrailV1Alpha1API(API): """ This API allows you to ensure accountability and security by recording events and changes performed within your Scaleway Organization. """ - def list_events( self, *, @@ -56,31 +91,28 @@ def list_events( :param status: (Optional) HTTP status code of the request. Returns either `200` if the request was successful or `403` if the permission was denied. :param recorded_after: (Optional) The `recorded_after` parameter defines the earliest timestamp from which Audit Trail events are retrieved. Returns `one hour ago` by default. :param recorded_before: (Optional) The `recorded_before` parameter defines the latest timestamp up to which Audit Trail events are retrieved. Returns `now` by default. - :param order_by: - :param page_size: - :param page_token: + :param order_by: + :param page_size: + :param page_token: :param product_name: (Optional) Name of the Scaleway resource in a hyphenated format. :param service_name: (Optional) Name of the service of the API call performed. :return: :class:`ListEventsResponse ` - + Usage: :: - + result = api.list_events() """ - - param_region = validate_path_param( - "region", region or self.client.default_region - ) - + + param_region = validate_path_param("region", region or self.client.default_region) + res = self._request( "GET", f"/audit-trail/v1alpha1/regions/{param_region}/events", params={ "method_name": method_name, "order_by": order_by, - "organization_id": organization_id - or self.client.default_organization_id, + "organization_id": organization_id or self.client.default_organization_id, "page_size": page_size or self.client.default_page_size, "page_token": page_token, "product_name": product_name, @@ -95,7 +127,7 @@ def list_events( self._throw_on_error(res) return unmarshal_ListEventsResponse(res.json()) - + def list_products( self, *, @@ -107,25 +139,23 @@ def list_products( :param region: Region to target. If none is passed will use default region from the config. :param organization_id: ID of the Organization containing the Audit Trail events. :return: :class:`ListProductsResponse ` - + Usage: :: - + result = api.list_products() """ - - param_region = validate_path_param( - "region", region or self.client.default_region - ) - + + param_region = validate_path_param("region", region or self.client.default_region) + res = self._request( "GET", f"/audit-trail/v1alpha1/regions/{param_region}/products", params={ - "organization_id": organization_id - or self.client.default_organization_id, + "organization_id": organization_id or self.client.default_organization_id, }, ) self._throw_on_error(res) return unmarshal_ListProductsResponse(res.json()) + diff --git a/scaleway/scaleway/audit_trail/v1alpha1/marshalling.py b/scaleway/scaleway/audit_trail/v1alpha1/marshalling.py index 615537865..48eb3bcf0 100644 --- a/scaleway/scaleway/audit_trail/v1alpha1/marshalling.py +++ b/scaleway/scaleway/audit_trail/v1alpha1/marshalling.py @@ -1,10 +1,34 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import Any, Dict +from decimal import Decimal +from datetime import datetime +from typing import Any, Dict, List, Optional from dateutil import parser +from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, + unmarshal_Money, + marshal_Money, + marshal_ScwFile, + marshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, +) +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) from .types import ( + ListEventsRequestOrderBy, + ResourceType, AccountOrganizationInfo, AccountUserInfo, InstanceServerInfo, @@ -24,7 +48,6 @@ ListProductsResponse, ) - def unmarshal_AccountOrganizationInfo(data: Any) -> AccountOrganizationInfo: if not isinstance(data, dict): raise TypeError( @@ -35,7 +58,6 @@ def unmarshal_AccountOrganizationInfo(data: Any) -> AccountOrganizationInfo: return AccountOrganizationInfo(**args) - def unmarshal_AccountUserInfo(data: Any) -> AccountUserInfo: if not isinstance(data, dict): raise TypeError( @@ -44,19 +66,14 @@ def unmarshal_AccountUserInfo(data: Any) -> AccountUserInfo: args: Dict[str, Any] = {} - field = data.get("email", None) - if field is not None: - args["email"] = field + field = data.get("email", str()) + args["email"] = field field = data.get("phone_number", None) - if field is not None: - args["phone_number"] = field - else: - args["phone_number"] = None + args["phone_number"] = field return AccountUserInfo(**args) - def unmarshal_InstanceServerInfo(data: Any) -> InstanceServerInfo: if not isinstance(data, dict): raise TypeError( @@ -65,13 +82,11 @@ def unmarshal_InstanceServerInfo(data: Any) -> InstanceServerInfo: args: Dict[str, Any] = {} - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field return InstanceServerInfo(**args) - def unmarshal_KeyManagerKeyInfo(data: Any) -> KeyManagerKeyInfo: if not isinstance(data, dict): raise TypeError( @@ -82,7 +97,6 @@ def unmarshal_KeyManagerKeyInfo(data: Any) -> KeyManagerKeyInfo: return KeyManagerKeyInfo(**args) - def unmarshal_KubernetesACLInfo(data: Any) -> KubernetesACLInfo: if not isinstance(data, dict): raise TypeError( @@ -93,7 +107,6 @@ def unmarshal_KubernetesACLInfo(data: Any) -> KubernetesACLInfo: return KubernetesACLInfo(**args) - def unmarshal_KubernetesClusterInfo(data: Any) -> KubernetesClusterInfo: if not isinstance(data, dict): raise TypeError( @@ -104,7 +117,6 @@ def unmarshal_KubernetesClusterInfo(data: Any) -> KubernetesClusterInfo: return KubernetesClusterInfo(**args) - def unmarshal_KubernetesNodeInfo(data: Any) -> KubernetesNodeInfo: if not isinstance(data, dict): raise TypeError( @@ -113,17 +125,14 @@ def unmarshal_KubernetesNodeInfo(data: Any) -> KubernetesNodeInfo: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field return KubernetesNodeInfo(**args) - def unmarshal_KubernetesPoolInfo(data: Any) -> KubernetesPoolInfo: if not isinstance(data, dict): raise TypeError( @@ -132,17 +141,14 @@ def unmarshal_KubernetesPoolInfo(data: Any) -> KubernetesPoolInfo: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field return KubernetesPoolInfo(**args) - def unmarshal_SecretManagerSecretInfo(data: Any) -> SecretManagerSecretInfo: if not isinstance(data, dict): raise TypeError( @@ -151,22 +157,15 @@ def unmarshal_SecretManagerSecretInfo(data: Any) -> SecretManagerSecretInfo: args: Dict[str, Any] = {} - field = data.get("path", None) - if field is not None: - args["path"] = field + field = data.get("path", str()) + args["path"] = field field = data.get("key_id", None) - if field is not None: - args["key_id"] = field - else: - args["key_id"] = None + args["key_id"] = field return SecretManagerSecretInfo(**args) - -def unmarshal_SecretManagerSecretVersionInfo( - data: Any, -) -> SecretManagerSecretVersionInfo: +def unmarshal_SecretManagerSecretVersionInfo(data: Any) -> SecretManagerSecretVersionInfo: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'SecretManagerSecretVersionInfo' failed as data isn't a dictionary." @@ -174,13 +173,11 @@ def unmarshal_SecretManagerSecretVersionInfo( args: Dict[str, Any] = {} - field = data.get("revision", None) - if field is not None: - args["revision"] = field + field = data.get("revision", str()) + args["revision"] = field return SecretManagerSecretVersionInfo(**args) - def unmarshal_EventPrincipal(data: Any) -> EventPrincipal: if not isinstance(data, dict): raise TypeError( @@ -189,13 +186,11 @@ def unmarshal_EventPrincipal(data: Any) -> EventPrincipal: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field return EventPrincipal(**args) - def unmarshal_Resource(data: Any) -> Resource: if not isinstance(data, dict): raise TypeError( @@ -204,123 +199,65 @@ def unmarshal_Resource(data: Any) -> Resource: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("type", None) - if field is not None: - args["type_"] = field + field = data.get("type", str()) + args["type_"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field 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 + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("deleted_at", None) - if field is not None: - args["deleted_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["deleted_at"] = None + args["deleted_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None + args["name"] = field field = data.get("secm_secret_info", None) - if field is not None: - args["secm_secret_info"] = unmarshal_SecretManagerSecretInfo(field) - else: - args["secm_secret_info"] = None + args["secm_secret_info"] = unmarshal_SecretManagerSecretInfo(field) if field is not None else None field = data.get("secm_secret_version_info", None) - if field is not None: - args["secm_secret_version_info"] = unmarshal_SecretManagerSecretVersionInfo( - field - ) - else: - args["secm_secret_version_info"] = None + args["secm_secret_version_info"] = unmarshal_SecretManagerSecretVersionInfo(field) if field is not None else None field = data.get("kube_cluster_info", None) - if field is not None: - args["kube_cluster_info"] = unmarshal_KubernetesClusterInfo(field) - else: - args["kube_cluster_info"] = None + args["kube_cluster_info"] = unmarshal_KubernetesClusterInfo(field) if field is not None else None field = data.get("kube_pool_info", None) - if field is not None: - args["kube_pool_info"] = unmarshal_KubernetesPoolInfo(field) - else: - args["kube_pool_info"] = None + args["kube_pool_info"] = unmarshal_KubernetesPoolInfo(field) if field is not None else None field = data.get("kube_node_info", None) - if field is not None: - args["kube_node_info"] = unmarshal_KubernetesNodeInfo(field) - else: - args["kube_node_info"] = None + args["kube_node_info"] = unmarshal_KubernetesNodeInfo(field) if field is not None else None field = data.get("kube_acl_info", None) - if field is not None: - args["kube_acl_info"] = unmarshal_KubernetesACLInfo(field) - else: - args["kube_acl_info"] = None + args["kube_acl_info"] = unmarshal_KubernetesACLInfo(field) if field is not None else None field = data.get("keym_key_info", None) - if field is not None: - args["keym_key_info"] = unmarshal_KeyManagerKeyInfo(field) - else: - args["keym_key_info"] = None + args["keym_key_info"] = unmarshal_KeyManagerKeyInfo(field) if field is not None else None field = data.get("secret_manager_secret_info", None) - if field is not None: - args["secret_manager_secret_info"] = unmarshal_SecretManagerSecretInfo(field) - else: - args["secret_manager_secret_info"] = None + args["secret_manager_secret_info"] = unmarshal_SecretManagerSecretInfo(field) if field is not None else None field = data.get("secret_manager_version_info", None) - if field is not None: - args["secret_manager_version_info"] = unmarshal_SecretManagerSecretVersionInfo( - field - ) - else: - args["secret_manager_version_info"] = None + args["secret_manager_version_info"] = unmarshal_SecretManagerSecretVersionInfo(field) if field is not None else None field = data.get("key_manager_key_info", None) - if field is not None: - args["key_manager_key_info"] = unmarshal_KeyManagerKeyInfo(field) - else: - args["key_manager_key_info"] = None + args["key_manager_key_info"] = unmarshal_KeyManagerKeyInfo(field) if field is not None else None field = data.get("account_user_info", None) - if field is not None: - args["account_user_info"] = unmarshal_AccountUserInfo(field) - else: - args["account_user_info"] = None + args["account_user_info"] = unmarshal_AccountUserInfo(field) if field is not None else None field = data.get("account_organization_info", None) - if field is not None: - args["account_organization_info"] = unmarshal_AccountOrganizationInfo(field) - else: - args["account_organization_info"] = None + args["account_organization_info"] = unmarshal_AccountOrganizationInfo(field) if field is not None else None field = data.get("instance_server_info", None) - if field is not None: - args["instance_server_info"] = unmarshal_InstanceServerInfo(field) - else: - args["instance_server_info"] = None + args["instance_server_info"] = unmarshal_InstanceServerInfo(field) if field is not None else None return Resource(**args) - def unmarshal_Event(data: Any) -> Event: if not isinstance(data, dict): raise TypeError( @@ -329,89 +266,56 @@ def unmarshal_Event(data: Any) -> Event: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("locality", None) - if field is not None: - args["locality"] = field + field = data.get("locality", str()) + args["locality"] = field - field = data.get("organization_id", None) - if field is not None: - args["organization_id"] = field + field = data.get("organization_id", str()) + args["organization_id"] = field - field = data.get("source_ip", None) - if field is not None: - args["source_ip"] = field + field = data.get("source_ip", str()) + args["source_ip"] = field field = data.get("recorded_at", None) - if field is not None: - args["recorded_at"] = ( - parser.isoparse(field) if isinstance(field, str) else field - ) - else: - args["recorded_at"] = None + args["recorded_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("principal", None) - if field is not None: - args["principal"] = unmarshal_EventPrincipal(field) - else: - args["principal"] = None + args["principal"] = unmarshal_EventPrincipal(field) if field is not None else None field = data.get("project_id", None) - if field is not None: - args["project_id"] = field - else: - args["project_id"] = None + args["project_id"] = field field = data.get("user_agent", None) - if field is not None: - args["user_agent"] = field - else: - args["user_agent"] = None - - field = data.get("product_name", None) - if field is not None: - args["product_name"] = field - - field = data.get("service_name", None) - if field is not None: - args["service_name"] = field - - field = data.get("method_name", None) - if field is not None: - args["method_name"] = field - - field = data.get("resources", None) - if field is not None: - args["resources"] = ( - [unmarshal_Resource(v) for v in field] if field is not None else None - ) + args["user_agent"] = field + + field = data.get("product_name", str()) + args["product_name"] = field - field = data.get("request_id", None) - if field is not None: - args["request_id"] = field + field = data.get("service_name", str()) + args["service_name"] = field - field = data.get("status_code", None) - if field is not None: - args["status_code"] = field + field = data.get("method_name", str()) + args["method_name"] = field + + field = data.get("resources", []) + args["resources"] = [unmarshal_Resource(v) for v in field] if field is not None else None + + field = data.get("request_id", str()) + args["request_id"] = field + + field = data.get("status_code", 0) + args["status_code"] = field field = data.get("resource", None) - if field is not None: - args["resource"] = unmarshal_Resource(field) - else: - args["resource"] = None + args["resource"] = unmarshal_Resource(field) if field is not None else None field = data.get("request_body", None) - if field is not None: - args["request_body"] = field - else: - args["request_body"] = None + args["request_body"] = field return Event(**args) - def unmarshal_ListEventsResponse(data: Any) -> ListEventsResponse: if not isinstance(data, dict): raise TypeError( @@ -420,21 +324,14 @@ def unmarshal_ListEventsResponse(data: Any) -> ListEventsResponse: args: Dict[str, Any] = {} - field = data.get("events", None) - if field is not None: - args["events"] = ( - [unmarshal_Event(v) for v in field] if field is not None else None - ) + field = data.get("events", []) + args["events"] = [unmarshal_Event(v) for v in field] if field is not None else None field = data.get("next_page_token", None) - if field is not None: - args["next_page_token"] = field - else: - args["next_page_token"] = None + args["next_page_token"] = field return ListEventsResponse(**args) - def unmarshal_ProductService(data: Any) -> ProductService: if not isinstance(data, dict): raise TypeError( @@ -443,17 +340,14 @@ def unmarshal_ProductService(data: Any) -> ProductService: args: Dict[str, Any] = {} - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("methods", None) - if field is not None: - args["methods"] = field + field = data.get("methods", str()) + args["methods"] = field return ProductService(**args) - def unmarshal_Product(data: Any) -> Product: if not isinstance(data, dict): raise TypeError( @@ -462,23 +356,17 @@ def unmarshal_Product(data: Any) -> Product: args: Dict[str, Any] = {} - field = data.get("title", None) - if field is not None: - args["title"] = field + field = data.get("title", str()) + args["title"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("services", None) - if field is not None: - args["services"] = ( - [unmarshal_ProductService(v) for v in field] if field is not None else None - ) + field = data.get("services", []) + args["services"] = [unmarshal_ProductService(v) for v in field] if field is not None else None return Product(**args) - def unmarshal_ListProductsResponse(data: Any) -> ListProductsResponse: if not isinstance(data, dict): raise TypeError( @@ -487,14 +375,10 @@ def unmarshal_ListProductsResponse(data: Any) -> ListProductsResponse: args: Dict[str, Any] = {} - field = data.get("products", None) - if field is not None: - args["products"] = ( - [unmarshal_Product(v) for v in field] if field is not None else None - ) + field = data.get("products", []) + args["products"] = [unmarshal_Product(v) for v in field] if field is not None else None - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field return ListProductsResponse(**args) diff --git a/scaleway/scaleway/audit_trail/v1alpha1/types.py b/scaleway/scaleway/audit_trail/v1alpha1/types.py index aa1ccf764..57027290d 100644 --- a/scaleway/scaleway/audit_trail/v1alpha1/types.py +++ b/scaleway/scaleway/audit_trail/v1alpha1/types.py @@ -3,18 +3,24 @@ from __future__ import annotations from dataclasses import dataclass +from decimal import Decimal from datetime import datetime from enum import Enum from typing import Any, Dict, List, Optional from scaleway_core.bridge import ( + Money, Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, ) from scaleway_core.utils import ( StrEnumMeta, ) - class ListEventsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): RECORDED_AT_DESC = "recorded_at_desc" RECORDED_AT_ASC = "recorded_at_asc" @@ -22,7 +28,6 @@ class ListEventsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ResourceType(str, Enum, metaclass=StrEnumMeta): UNKNOWN_TYPE = "unknown_type" SECM_SECRET = "secm_secret" @@ -49,117 +54,112 @@ class ResourceType(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - @dataclass class AccountOrganizationInfo: pass - @dataclass class AccountUserInfo: email: str - + phone_number: Optional[str] - + @dataclass class InstanceServerInfo: name: str - + @dataclass class KeyManagerKeyInfo: pass - @dataclass class KubernetesACLInfo: pass - @dataclass class KubernetesClusterInfo: pass - @dataclass class KubernetesNodeInfo: id: str - + name: str - + @dataclass class KubernetesPoolInfo: id: str - + name: str - + @dataclass class SecretManagerSecretInfo: path: str - + key_id: Optional[str] - + @dataclass class SecretManagerSecretVersionInfo: revision: int - + @dataclass class EventPrincipal: id: str - + @dataclass class Resource: id: str - + type_: ResourceType - + created_at: Optional[datetime] - + updated_at: Optional[datetime] - + deleted_at: Optional[datetime] - + name: Optional[str] - + secm_secret_info: Optional[SecretManagerSecretInfo] - + secm_secret_version_info: Optional[SecretManagerSecretVersionInfo] - + kube_cluster_info: Optional[KubernetesClusterInfo] - + kube_pool_info: Optional[KubernetesPoolInfo] - + kube_node_info: Optional[KubernetesNodeInfo] - + kube_acl_info: Optional[KubernetesACLInfo] - + keym_key_info: Optional[KeyManagerKeyInfo] - + secret_manager_secret_info: Optional[SecretManagerSecretInfo] - + secret_manager_version_info: Optional[SecretManagerSecretVersionInfo] - + key_manager_key_info: Optional[KeyManagerKeyInfo] - + account_user_info: Optional[AccountUserInfo] - + account_organization_info: Optional[AccountOrganizationInfo] - + instance_server_info: Optional[InstanceServerInfo] - + @dataclass class ProductService: name: str - + methods: List[str] - + @dataclass class Event: @@ -167,82 +167,82 @@ class Event: """ ID of the event. """ - + locality: str """ Locality of the resource attached to the event. """ - + organization_id: str """ Organization ID containing the event. """ - + source_ip: str """ IP address at the origin of the event. """ - + recorded_at: Optional[datetime] """ Timestamp of the event. """ - + principal: Optional[EventPrincipal] """ User or IAM application at the origin of the event. """ - + project_id: Optional[str] """ (Optional) Project of the resource attached to the event. """ - + user_agent: Optional[str] """ User Agent at the origin of the event. """ - + product_name: str """ Product name of the resource attached to the event. """ - + service_name: str """ API name called to trigger the event. """ - + method_name: str """ API method called to trigger the event. """ - + resources: List[Resource] """ Resources attached to the event. """ - + request_id: str """ Unique identifier of the request at the origin of the event. """ - + status_code: int """ HTTP status code resulting of the API call. """ - + resource: Optional[Resource] """ Resource attached to the event. """ - + request_body: Optional[Dict[str, Any]] """ Request at the origin of the event. """ - + @dataclass class Product: @@ -250,17 +250,17 @@ class Product: """ Product title. """ - + name: str """ Product name. """ - + services: List[ProductService] """ Specifies the API versions of the products integrated with Audit Trail. Each version defines the methods logged by Audit Trail. """ - + @dataclass class ListEventsRequest: @@ -268,58 +268,58 @@ class ListEventsRequest: """ Region to target. If none is passed will use default region from the config. """ - + project_id: Optional[str] """ (Optional) ID of the Project containing the Audit Trail events. """ - + organization_id: Optional[str] """ ID of the Organization containing the Audit Trail events. """ - + resource_type: Optional[ResourceType] """ (Optional) Returns a paginated list of Scaleway resources' features. """ - + method_name: Optional[str] """ (Optional) Name of the method of the API call performed. """ - + status: Optional[int] """ (Optional) HTTP status code of the request. Returns either `200` if the request was successful or `403` if the permission was denied. """ - + recorded_after: Optional[datetime] """ (Optional) The `recorded_after` parameter defines the earliest timestamp from which Audit Trail events are retrieved. Returns `one hour ago` by default. """ - + recorded_before: Optional[datetime] """ (Optional) The `recorded_before` parameter defines the latest timestamp up to which Audit Trail events are retrieved. Returns `now` by default. """ - + order_by: Optional[ListEventsRequestOrderBy] - + page_size: Optional[int] - + page_token: Optional[str] - + product_name: Optional[str] """ (Optional) Name of the Scaleway resource in a hyphenated format. """ - + service_name: Optional[str] """ (Optional) Name of the service of the API call performed. """ - + @dataclass class ListEventsResponse: @@ -327,12 +327,12 @@ class ListEventsResponse: """ Single page of events matching the requested criteria. """ - + next_page_token: Optional[str] """ Page token to use in following calls to keep listing. """ - + @dataclass class ListProductsRequest: @@ -340,12 +340,12 @@ class ListProductsRequest: """ Region to target. If none is passed will use default region from the config. """ - + organization_id: Optional[str] """ ID of the Organization containing the Audit Trail events. """ - + @dataclass class ListProductsResponse: @@ -353,8 +353,9 @@ class ListProductsResponse: """ List of all products integrated with Audit Trail. """ - + total_count: int """ Number of integrated products. """ + diff --git a/scaleway/scaleway/autoscaling/v1alpha1/api.py b/scaleway/scaleway/autoscaling/v1alpha1/api.py index cbcf02510..67da14592 100644 --- a/scaleway/scaleway/autoscaling/v1alpha1/api.py +++ b/scaleway/scaleway/autoscaling/v1alpha1/api.py @@ -1,34 +1,74 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import Dict, List, Optional +from datetime import datetime +from typing import Any, Awaitable, Dict, List, Optional, Union from scaleway_core.api import API from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, Zone as ScwZone, + marshal_Money, + unmarshal_Money, + marshal_ScwFile, + unmarshal_ScwFile, + unmarshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, ) from scaleway_core.utils import ( + OneOfPossibility, + WaitForOptions, + project_or_organization_id, + random_name, + resolve_one_of, validate_path_param, fetch_all_pages, + wait_for_resource, ) from .types import ( + InstanceGroupEventLevel, + InstanceGroupEventSource, InstancePolicyAction, InstancePolicyType, + InstanceTemplateStatus, ListInstanceGroupEventsRequestOrderBy, ListInstanceGroupsRequestOrderBy, ListInstancePoliciesRequestOrderBy, ListInstanceTemplatesRequestOrderBy, + MetricAggregate, + MetricManagedMetric, + MetricOperator, + UpdateInstancePolicyRequestMetricAggregate, + UpdateInstancePolicyRequestMetricManagedMetric, + UpdateInstancePolicyRequestMetricOperator, + VolumeInstanceTemplateVolumeType, Capacity, CreateInstanceGroupRequest, CreateInstancePolicyRequest, CreateInstanceTemplateRequest, + DeleteInstanceGroupRequest, + DeleteInstancePolicyRequest, + DeleteInstanceTemplateRequest, + GetInstanceGroupRequest, + GetInstancePolicyRequest, + GetInstanceTemplateRequest, InstanceGroup, InstanceGroupEvent, InstancePolicy, InstanceTemplate, + ListInstanceGroupEventsRequest, ListInstanceGroupEventsResponse, + ListInstanceGroupsRequest, ListInstanceGroupsResponse, + ListInstancePoliciesRequest, ListInstancePoliciesResponse, + ListInstanceTemplatesRequest, ListInstanceTemplatesResponse, Loadbalancer, Metric, @@ -39,6 +79,8 @@ UpdateInstancePolicyRequestMetric, UpdateInstanceTemplateRequest, VolumeInstanceTemplate, + VolumeInstanceTemplateFromEmpty, + VolumeInstanceTemplateFromSnapshot, ) from .marshalling import ( unmarshal_InstanceGroup, @@ -56,10 +98,10 @@ marshal_UpdateInstanceTemplateRequest, ) - class AutoscalingV1Alpha1API(API): - """ """ - + """ + + """ def get_instance_group( self, *, @@ -72,20 +114,18 @@ def get_instance_group( :param instance_group_id: ID of the requested Instance group. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`InstanceGroup ` - + Usage: :: - + result = api.get_instance_group( instance_group_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - param_instance_group_id = validate_path_param( - "instance_group_id", instance_group_id - ) - + param_instance_group_id = validate_path_param("instance_group_id", instance_group_id) + res = self._request( "GET", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", @@ -93,7 +133,7 @@ def get_instance_group( self._throw_on_error(res) return unmarshal_InstanceGroup(res.json()) - + def create_instance_group( self, *, @@ -116,10 +156,10 @@ def create_instance_group( :param project_id: Project ID to filter for, only Instance groups from this Project will be returned. :param tags: List of tags for the Instance group. :return: :class:`InstanceGroup ` - + Usage: :: - + result = api.create_instance_group( name="example", template_id="example", @@ -127,9 +167,9 @@ def create_instance_group( loadbalancer=Loadbalancer(), ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "POST", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups", @@ -149,7 +189,7 @@ def create_instance_group( self._throw_on_error(res) return unmarshal_InstanceGroup(res.json()) - + def list_instance_groups( self, *, @@ -166,15 +206,15 @@ def list_instance_groups( :param page: Page number to return, from the paginated results. :param page_size: Number of Instance groups to return per page. :return: :class:`ListInstanceGroupsResponse ` - + Usage: :: - + result = api.list_instance_groups() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups", @@ -187,7 +227,7 @@ def list_instance_groups( self._throw_on_error(res) return unmarshal_ListInstanceGroupsResponse(res.json()) - + def list_instance_groups_all( self, *, @@ -204,14 +244,14 @@ def list_instance_groups_all( :param page: Page number to return, from the paginated results. :param page_size: Number of Instance groups to return per page. :return: :class:`List[InstanceGroup] ` - + Usage: :: - + result = api.list_instance_groups_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListInstanceGroupsResponse, key="instance_groups", fetcher=self.list_instance_groups, @@ -222,7 +262,7 @@ def list_instance_groups_all( "page_size": page_size, }, ) - + def update_instance_group( self, *, @@ -243,20 +283,18 @@ def update_instance_group( :param capacity: Specification of the minimum and maximum replicas for the Instance group, and the cooldown interval between two scaling events. :param loadbalancer: Specification of the Load Balancer to link to the Instance group. :return: :class:`InstanceGroup ` - + Usage: :: - + result = api.update_instance_group( instance_group_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - param_instance_group_id = validate_path_param( - "instance_group_id", instance_group_id - ) - + param_instance_group_id = validate_path_param("instance_group_id", instance_group_id) + res = self._request( "PATCH", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", @@ -275,7 +313,7 @@ def update_instance_group( self._throw_on_error(res) return unmarshal_InstanceGroup(res.json()) - + def delete_instance_group( self, *, @@ -287,27 +325,24 @@ def delete_instance_group( Delete an existing Instance group, specified by its `instance_group_id`. Deleting an Instance group is permanent, and cannot be undone. :param instance_group_id: ID of the Instance group to delete. :param zone: Zone to target. If none is passed will use default zone from the config. - + Usage: :: - + result = api.delete_instance_group( instance_group_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - param_instance_group_id = validate_path_param( - "instance_group_id", instance_group_id - ) - + param_instance_group_id = validate_path_param("instance_group_id", instance_group_id) + res = self._request( "DELETE", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", ) self._throw_on_error(res) - def create_instance_template( self, *, @@ -342,19 +377,19 @@ def create_instance_template( :param private_network_ids: Private Network IDs to attach to the new Instance. :param cloud_init: Cloud-config file must be passed in Base64 format. Cloud-config files are special scripts designed to be run by the cloud-init process. These are generally used for initial configuration on the very first boot of a server. :return: :class:`InstanceTemplate ` - + Usage: :: - + result = api.create_instance_template( commercial_type="example", volumes={}, name="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "POST", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-templates", @@ -380,7 +415,7 @@ def create_instance_template( self._throw_on_error(res) return unmarshal_InstanceTemplate(res.json()) - + def update_instance_template( self, *, @@ -415,18 +450,18 @@ def update_instance_template( :param private_network_ids: Private Network IDs to attach to the new Instance. :param cloud_init: Cloud-config file must be passed in Base64 format. Cloud-config files are special scripts designed to be run by the cloud-init process. These are generally used for initial configuration on the very first boot of a server. :return: :class:`InstanceTemplate ` - + Usage: :: - + result = api.update_instance_template( template_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_template_id = validate_path_param("template_id", template_id) - + res = self._request( "PATCH", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-templates/{param_template_id}", @@ -452,7 +487,7 @@ def update_instance_template( self._throw_on_error(res) return unmarshal_InstanceTemplate(res.json()) - + def get_instance_template( self, *, @@ -465,18 +500,18 @@ def get_instance_template( :param template_id: Template ID of the resource. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`InstanceTemplate ` - + Usage: :: - + result = api.get_instance_template( template_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_template_id = validate_path_param("template_id", template_id) - + res = self._request( "GET", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-templates/{param_template_id}", @@ -484,7 +519,7 @@ def get_instance_template( self._throw_on_error(res) return unmarshal_InstanceTemplate(res.json()) - + def delete_instance_template( self, *, @@ -496,25 +531,24 @@ def delete_instance_template( Delete an existing Instance template. This action is permanent and cannot be undone. :param template_id: ID of the template to delete. :param zone: Zone to target. If none is passed will use default zone from the config. - + Usage: :: - + result = api.delete_instance_template( template_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_template_id = validate_path_param("template_id", template_id) - + res = self._request( "DELETE", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-templates/{param_template_id}", ) self._throw_on_error(res) - def list_instance_templates( self, *, @@ -531,15 +565,15 @@ def list_instance_templates( :param page: Page number to return, from the paginated results. :param page_size: Number of Instance groups to return per page. :return: :class:`ListInstanceTemplatesResponse ` - + Usage: :: - + result = api.list_instance_templates() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-templates", @@ -552,7 +586,7 @@ def list_instance_templates( self._throw_on_error(res) return unmarshal_ListInstanceTemplatesResponse(res.json()) - + def list_instance_templates_all( self, *, @@ -569,14 +603,14 @@ def list_instance_templates_all( :param page: Page number to return, from the paginated results. :param page_size: Number of Instance groups to return per page. :return: :class:`List[InstanceTemplate] ` - + Usage: :: - + result = api.list_instance_templates_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListInstanceTemplatesResponse, key="instance_templates", fetcher=self.list_instance_templates, @@ -587,7 +621,7 @@ def list_instance_templates_all( "page_size": page_size, }, ) - + def create_instance_policy( self, *, @@ -613,10 +647,10 @@ def create_instance_policy( :param metric: Cockpit metric to use when determining whether to trigger a scale up/down action. One-Of ('trigger'): at most one of 'metric' could be set. :return: :class:`InstancePolicy ` - + Usage: :: - + result = api.create_instance_policy( name="example", action=InstancePolicyAction.unknown_action, @@ -626,9 +660,9 @@ def create_instance_policy( instance_group_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "POST", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-policies", @@ -649,7 +683,7 @@ def create_instance_policy( self._throw_on_error(res) return unmarshal_InstancePolicy(res.json()) - + def update_instance_policy( self, *, @@ -675,18 +709,18 @@ def update_instance_policy( :param value: Value to update (number representing the magnitude of the scaling action to take for the Instance group). :param priority: Priority to update (priority of this policy compared to all other scaling policies. The lower the number, the higher the priority). :return: :class:`InstancePolicy ` - + Usage: :: - + result = api.update_instance_policy( policy_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_policy_id = validate_path_param("policy_id", policy_id) - + res = self._request( "PATCH", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-policies/{param_policy_id}", @@ -707,7 +741,7 @@ def update_instance_policy( self._throw_on_error(res) return unmarshal_InstancePolicy(res.json()) - + def list_instance_policies( self, *, @@ -726,17 +760,17 @@ def list_instance_policies( :param page: Page number to return, from the paginated results. :param page_size: Number of scaling policies to return per page. :return: :class:`ListInstancePoliciesResponse ` - + Usage: :: - + result = api.list_instance_policies( instance_group_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-policies", @@ -750,7 +784,7 @@ def list_instance_policies( self._throw_on_error(res) return unmarshal_ListInstancePoliciesResponse(res.json()) - + def list_instance_policies_all( self, *, @@ -769,16 +803,16 @@ def list_instance_policies_all( :param page: Page number to return, from the paginated results. :param page_size: Number of scaling policies to return per page. :return: :class:`List[InstancePolicy] ` - + Usage: :: - + result = api.list_instance_policies_all( instance_group_id="example", ) """ - return fetch_all_pages( + return fetch_all_pages( type=ListInstancePoliciesResponse, key="policies", fetcher=self.list_instance_policies, @@ -790,7 +824,7 @@ def list_instance_policies_all( "page_size": page_size, }, ) - + def get_instance_policy( self, *, @@ -803,18 +837,18 @@ def get_instance_policy( :param policy_id: Policy ID. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`InstancePolicy ` - + Usage: :: - + result = api.get_instance_policy( policy_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_policy_id = validate_path_param("policy_id", policy_id) - + res = self._request( "GET", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-policies/{param_policy_id}", @@ -822,7 +856,7 @@ def get_instance_policy( self._throw_on_error(res) return unmarshal_InstancePolicy(res.json()) - + def delete_instance_policy( self, *, @@ -834,25 +868,24 @@ def delete_instance_policy( Delete an existing scaling policy, specified by its `policy_id`. Deleting a scaling policy is permanent, and cannot be undone. :param policy_id: ID of the policy to delete. :param zone: Zone to target. If none is passed will use default zone from the config. - + Usage: :: - + result = api.delete_instance_policy( policy_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_policy_id = validate_path_param("policy_id", policy_id) - + res = self._request( "DELETE", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-policies/{param_policy_id}", ) self._throw_on_error(res) - def list_instance_group_events( self, *, @@ -871,20 +904,18 @@ def list_instance_group_events( :param page: Page number to return, from the paginated results. :param page_size: Number of Instance groups to return per page. :return: :class:`ListInstanceGroupEventsResponse ` - + Usage: :: - + result = api.list_instance_group_events( instance_group_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - param_instance_group_id = validate_path_param( - "instance_group_id", instance_group_id - ) - + param_instance_group_id = validate_path_param("instance_group_id", instance_group_id) + res = self._request( "GET", f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}/events", @@ -897,7 +928,7 @@ def list_instance_group_events( self._throw_on_error(res) return unmarshal_ListInstanceGroupEventsResponse(res.json()) - + def list_instance_group_events_all( self, *, @@ -916,16 +947,16 @@ def list_instance_group_events_all( :param page: Page number to return, from the paginated results. :param page_size: Number of Instance groups to return per page. :return: :class:`List[InstanceGroupEvent] ` - + Usage: :: - + result = api.list_instance_group_events_all( instance_group_id="example", ) """ - return fetch_all_pages( + return fetch_all_pages( type=ListInstanceGroupEventsResponse, key="instance_events", fetcher=self.list_instance_group_events, @@ -937,3 +968,4 @@ def list_instance_group_events_all( "page_size": page_size, }, ) + diff --git a/scaleway/scaleway/autoscaling/v1alpha1/marshalling.py b/scaleway/scaleway/autoscaling/v1alpha1/marshalling.py index 0558608f9..b8f4ee0e8 100644 --- a/scaleway/scaleway/autoscaling/v1alpha1/marshalling.py +++ b/scaleway/scaleway/autoscaling/v1alpha1/marshalling.py @@ -1,15 +1,48 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import Any, Dict +from decimal import Decimal +from datetime import datetime +from typing import Any, Dict, List, Optional from dateutil import parser from scaleway_core.profile import ProfileDefaults +from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, + Zone as ScwZone, + unmarshal_Money, + marshal_Money, + marshal_ScwFile, + marshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, +) from scaleway_core.utils import ( OneOfPossibility, resolve_one_of, ) from .types import ( + InstanceGroupEventLevel, + InstanceGroupEventSource, + InstancePolicyAction, + InstancePolicyType, + InstanceTemplateStatus, + ListInstanceGroupEventsRequestOrderBy, + ListInstanceGroupsRequestOrderBy, + ListInstancePoliciesRequestOrderBy, + ListInstanceTemplatesRequestOrderBy, + MetricAggregate, + MetricManagedMetric, + MetricOperator, + UpdateInstancePolicyRequestMetricAggregate, + UpdateInstancePolicyRequestMetricManagedMetric, + UpdateInstancePolicyRequestMetricOperator, + VolumeInstanceTemplateVolumeType, Capacity, Loadbalancer, InstanceGroup, @@ -35,7 +68,6 @@ UpdateInstanceTemplateRequest, ) - def unmarshal_Capacity(data: Any) -> Capacity: if not isinstance(data, dict): raise TypeError( @@ -44,23 +76,17 @@ def unmarshal_Capacity(data: Any) -> Capacity: args: Dict[str, Any] = {} - field = data.get("max_replicas", None) - if field is not None: - args["max_replicas"] = field + field = data.get("max_replicas", 0) + args["max_replicas"] = field - field = data.get("min_replicas", None) - if field is not None: - args["min_replicas"] = field + field = data.get("min_replicas", 0) + args["min_replicas"] = field field = data.get("cooldown_delay", None) - if field is not None: - args["cooldown_delay"] = field - else: - args["cooldown_delay"] = None + args["cooldown_delay"] = field return Capacity(**args) - def unmarshal_Loadbalancer(data: Any) -> Loadbalancer: if not isinstance(data, dict): raise TypeError( @@ -69,21 +95,17 @@ def unmarshal_Loadbalancer(data: Any) -> Loadbalancer: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("backend_ids", None) - if field is not None: - args["backend_ids"] = field + field = data.get("backend_ids", []) + args["backend_ids"] = field - field = data.get("private_network_id", None) - if field is not None: - args["private_network_id"] = field + field = data.get("private_network_id", str()) + args["private_network_id"] = field return Loadbalancer(**args) - def unmarshal_InstanceGroup(data: Any) -> InstanceGroup: if not isinstance(data, dict): raise TypeError( @@ -92,53 +114,38 @@ def unmarshal_InstanceGroup(data: Any) -> InstanceGroup: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field + field = data.get("project_id", str()) + args["project_id"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("tags", None) - if field is not None: - args["tags"] = field + field = data.get("tags", []) + args["tags"] = field - field = data.get("instance_template_id", None) - if field is not None: - args["instance_template_id"] = field + field = data.get("instance_template_id", str()) + args["instance_template_id"] = field - field = data.get("capacity", None) - if field is not None: - args["capacity"] = unmarshal_Capacity(field) + field = data.get("capacity", str()) + args["capacity"] = unmarshal_Capacity(field) if field is not None else None - field = data.get("loadbalancer", None) - if field is not None: - args["loadbalancer"] = unmarshal_Loadbalancer(field) + field = data.get("loadbalancer", str()) + args["loadbalancer"] = unmarshal_Loadbalancer(field) if field is not None else None - field = data.get("error_messages", None) - if field is not None: - args["error_messages"] = field + field = data.get("error_messages", []) + args["error_messages"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field 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 + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field return InstanceGroup(**args) - def unmarshal_Metric(data: Any) -> Metric: if not isinstance(data, dict): raise TypeError( @@ -147,41 +154,29 @@ def unmarshal_Metric(data: Any) -> Metric: args: Dict[str, Any] = {} - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("operator", None) - if field is not None: - args["operator"] = field + field = data.get("operator", getattr(MetricOperator, "OPERATOR_UNKNOWN")) + args["operator"] = field - field = data.get("aggregate", None) - if field is not None: - args["aggregate"] = field + field = data.get("aggregate", getattr(MetricAggregate, "AGGREGATE_UNKNOWN")) + args["aggregate"] = field - field = data.get("sampling_range_min", None) - if field is not None: - args["sampling_range_min"] = field + field = data.get("sampling_range_min", 0) + args["sampling_range_min"] = field - field = data.get("threshold", None) - if field is not None: - args["threshold"] = field + field = data.get("threshold", 0.0) + args["threshold"] = field field = data.get("managed_metric", None) - if field is not None: - args["managed_metric"] = field - else: - args["managed_metric"] = None + args["managed_metric"] = field field = data.get("cockpit_metric_name", None) - if field is not None: - args["cockpit_metric_name"] = field - else: - args["cockpit_metric_name"] = None + args["cockpit_metric_name"] = field return Metric(**args) - def unmarshal_InstancePolicy(data: Any) -> InstancePolicy: if not isinstance(data, dict): raise TypeError( @@ -190,46 +185,33 @@ def unmarshal_InstancePolicy(data: Any) -> InstancePolicy: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("action", None) - if field is not None: - args["action"] = field + field = data.get("action", getattr(InstancePolicyAction, "UNKNOWN_ACTION")) + args["action"] = field - field = data.get("type", None) - if field is not None: - args["type_"] = field + field = data.get("type", getattr(InstancePolicyType, "UNKNOWN_TYPE")) + args["type_"] = field - field = data.get("value", None) - if field is not None: - args["value"] = field + field = data.get("value", 0) + args["value"] = field - field = data.get("priority", None) - if field is not None: - args["priority"] = field + field = data.get("priority", 0) + args["priority"] = field - field = data.get("instance_group_id", None) - if field is not None: - args["instance_group_id"] = field + field = data.get("instance_group_id", str()) + args["instance_group_id"] = field field = data.get("metric", None) - if field is not None: - args["metric"] = unmarshal_Metric(field) - else: - args["metric"] = None + args["metric"] = unmarshal_Metric(field) if field is not None else None return InstancePolicy(**args) - -def unmarshal_VolumeInstanceTemplateFromEmpty( - data: Any, -) -> VolumeInstanceTemplateFromEmpty: +def unmarshal_VolumeInstanceTemplateFromEmpty(data: Any) -> VolumeInstanceTemplateFromEmpty: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'VolumeInstanceTemplateFromEmpty' failed as data isn't a dictionary." @@ -237,16 +219,12 @@ def unmarshal_VolumeInstanceTemplateFromEmpty( args: Dict[str, Any] = {} - field = data.get("size", None) - if field is not None: - args["size"] = field + field = data.get("size", str()) + args["size"] = field return VolumeInstanceTemplateFromEmpty(**args) - -def unmarshal_VolumeInstanceTemplateFromSnapshot( - data: Any, -) -> VolumeInstanceTemplateFromSnapshot: +def unmarshal_VolumeInstanceTemplateFromSnapshot(data: Any) -> VolumeInstanceTemplateFromSnapshot: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'VolumeInstanceTemplateFromSnapshot' failed as data isn't a dictionary." @@ -254,19 +232,14 @@ def unmarshal_VolumeInstanceTemplateFromSnapshot( args: Dict[str, Any] = {} - field = data.get("snapshot_id", None) - if field is not None: - args["snapshot_id"] = field + field = data.get("snapshot_id", str()) + args["snapshot_id"] = field field = data.get("size", None) - if field is not None: - args["size"] = field - else: - args["size"] = None + args["size"] = field return VolumeInstanceTemplateFromSnapshot(**args) - def unmarshal_VolumeInstanceTemplate(data: Any) -> VolumeInstanceTemplate: if not isinstance(data, dict): raise TypeError( @@ -275,43 +248,29 @@ def unmarshal_VolumeInstanceTemplate(data: Any) -> VolumeInstanceTemplate: args: Dict[str, Any] = {} - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("tags", None) - if field is not None: - args["tags"] = field + field = data.get("tags", []) + args["tags"] = field - field = data.get("boot", None) - if field is not None: - args["boot"] = field + field = data.get("boot", False) + args["boot"] = field - field = data.get("volume_type", None) - if field is not None: - args["volume_type"] = field + field = data.get("volume_type", getattr(VolumeInstanceTemplateVolumeType, "UNKNOWN_VOLUME_TYPE")) + args["volume_type"] = field field = data.get("perf_iops", None) - if field is not None: - args["perf_iops"] = field - else: - args["perf_iops"] = None + args["perf_iops"] = field field = data.get("from_empty", None) - if field is not None: - args["from_empty"] = unmarshal_VolumeInstanceTemplateFromEmpty(field) - else: - args["from_empty"] = None + args["from_empty"] = unmarshal_VolumeInstanceTemplateFromEmpty(field) if field is not None else None field = data.get("from_snapshot", None) - if field is not None: - args["from_snapshot"] = unmarshal_VolumeInstanceTemplateFromSnapshot(field) - else: - args["from_snapshot"] = None + args["from_snapshot"] = unmarshal_VolumeInstanceTemplateFromSnapshot(field) if field is not None else None return VolumeInstanceTemplate(**args) - def unmarshal_InstanceTemplate(data: Any) -> InstanceTemplate: if not isinstance(data, dict): raise TypeError( @@ -320,96 +279,57 @@ def unmarshal_InstanceTemplate(data: Any) -> InstanceTemplate: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field - - field = data.get("commercial_type", None) - if field is not None: - args["commercial_type"] = field - - field = data.get("volumes", None) - if field is not None: - args["volumes"] = ( - { - key: unmarshal_VolumeInstanceTemplate(value) - for key, value in field.items() - } - if field is not None - else None - ) + field = data.get("id", str()) + args["id"] = field + + field = data.get("commercial_type", str()) + args["commercial_type"] = field + + field = data.get("volumes", {}) + args["volumes"] = {key: unmarshal_VolumeInstanceTemplate(value)for key, value in field.items() + } if field is not None else None - field = data.get("tags", None) - if field is not None: - args["tags"] = field + field = data.get("tags", []) + args["tags"] = field - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field + field = data.get("project_id", str()) + args["project_id"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field - field = data.get("private_network_ids", None) - if field is not None: - args["private_network_ids"] = field + field = data.get("private_network_ids", []) + args["private_network_ids"] = field field = data.get("image_id", None) - if field is not None: - args["image_id"] = field - else: - args["image_id"] = None + args["image_id"] = field field = data.get("security_group_id", None) - if field is not None: - args["security_group_id"] = field - else: - args["security_group_id"] = None + args["security_group_id"] = field field = data.get("placement_group_id", None) - if field is not None: - args["placement_group_id"] = field - else: - args["placement_group_id"] = None + args["placement_group_id"] = field field = data.get("public_ips_v4_count", None) - if field is not None: - args["public_ips_v4_count"] = field - else: - args["public_ips_v4_count"] = None + args["public_ips_v4_count"] = field field = data.get("public_ips_v6_count", None) - if field is not None: - args["public_ips_v6_count"] = field - else: - args["public_ips_v6_count"] = None + args["public_ips_v6_count"] = field - field = data.get("status", None) - if field is not None: - args["status"] = field + field = data.get("status", getattr(InstanceTemplateStatus, "UNKNOWN_STATUS")) + args["status"] = field field = data.get("cloud_init", None) - if field is not None: - args["cloud_init"] = field - else: - args["cloud_init"] = None + args["cloud_init"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field 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 + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field return InstanceTemplate(**args) - def unmarshal_InstanceGroupEvent(data: Any) -> InstanceGroupEvent: if not isinstance(data, dict): raise TypeError( @@ -418,40 +338,27 @@ def unmarshal_InstanceGroupEvent(data: Any) -> InstanceGroupEvent: args: Dict[str, Any] = {} - field = data.get("id", None) - if field is not None: - args["id"] = field + field = data.get("id", str()) + args["id"] = field - field = data.get("source", None) - if field is not None: - args["source"] = field + field = data.get("source", getattr(InstanceGroupEventSource, "UNKNOWN_SOURCE")) + args["source"] = field - field = data.get("level", None) - if field is not None: - args["level"] = field + field = data.get("level", getattr(InstanceGroupEventLevel, "INFO")) + args["level"] = field - field = data.get("name", None) - if field is not None: - args["name"] = field + field = data.get("name", str()) + args["name"] = field 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 + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field field = data.get("details", None) - if field is not None: - args["details"] = field - else: - args["details"] = None + args["details"] = field return InstanceGroupEvent(**args) - -def unmarshal_ListInstanceGroupEventsResponse( - data: Any, -) -> ListInstanceGroupEventsResponse: +def unmarshal_ListInstanceGroupEventsResponse(data: Any) -> ListInstanceGroupEventsResponse: if not isinstance(data, dict): raise TypeError( "Unmarshalling the type 'ListInstanceGroupEventsResponse' failed as data isn't a dictionary." @@ -459,21 +366,14 @@ def unmarshal_ListInstanceGroupEventsResponse( args: Dict[str, Any] = {} - field = data.get("instance_events", None) - if field is not None: - args["instance_events"] = ( - [unmarshal_InstanceGroupEvent(v) for v in field] - if field is not None - else None - ) + field = data.get("instance_events", []) + args["instance_events"] = [unmarshal_InstanceGroupEvent(v) for v in field] if field is not None else None - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field return ListInstanceGroupEventsResponse(**args) - def unmarshal_ListInstanceGroupsResponse(data: Any) -> ListInstanceGroupsResponse: if not isinstance(data, dict): raise TypeError( @@ -482,19 +382,14 @@ def unmarshal_ListInstanceGroupsResponse(data: Any) -> ListInstanceGroupsRespons args: Dict[str, Any] = {} - field = data.get("instance_groups", None) - if field is not None: - args["instance_groups"] = ( - [unmarshal_InstanceGroup(v) for v in field] if field is not None else None - ) + field = data.get("instance_groups", []) + args["instance_groups"] = [unmarshal_InstanceGroup(v) for v in field] if field is not None else None - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field return ListInstanceGroupsResponse(**args) - def unmarshal_ListInstancePoliciesResponse(data: Any) -> ListInstancePoliciesResponse: if not isinstance(data, dict): raise TypeError( @@ -503,19 +398,14 @@ def unmarshal_ListInstancePoliciesResponse(data: Any) -> ListInstancePoliciesRes args: Dict[str, Any] = {} - field = data.get("policies", None) - if field is not None: - args["policies"] = ( - [unmarshal_InstancePolicy(v) for v in field] if field is not None else None - ) + field = data.get("policies", []) + args["policies"] = [unmarshal_InstancePolicy(v) for v in field] if field is not None else None - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field return ListInstancePoliciesResponse(**args) - def unmarshal_ListInstanceTemplatesResponse(data: Any) -> ListInstanceTemplatesResponse: if not isinstance(data, dict): raise TypeError( @@ -524,21 +414,14 @@ def unmarshal_ListInstanceTemplatesResponse(data: Any) -> ListInstanceTemplatesR args: Dict[str, Any] = {} - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field + field = data.get("total_count", 0) + args["total_count"] = field - field = data.get("instance_templates", None) - if field is not None: - args["instance_templates"] = ( - [unmarshal_InstanceTemplate(v) for v in field] - if field is not None - else None - ) + field = data.get("instance_templates", []) + args["instance_templates"] = [unmarshal_InstanceTemplate(v) for v in field] if field is not None else None return ListInstanceTemplatesResponse(**args) - def marshal_Capacity( request: Capacity, defaults: ProfileDefaults, @@ -547,15 +430,21 @@ def marshal_Capacity( if request.max_replicas is not None: output["max_replicas"] = request.max_replicas + else: + output["max_replicas"] = 0 if request.min_replicas is not None: output["min_replicas"] = request.min_replicas + else: + output["min_replicas"] = 0 if request.cooldown_delay is not None: output["cooldown_delay"] = request.cooldown_delay + else: + output["cooldown_delay"] = None - return output + return output def marshal_Loadbalancer( request: Loadbalancer, @@ -565,15 +454,21 @@ def marshal_Loadbalancer( if request.id is not None: output["id"] = request.id + else: + output["id"] = str() if request.backend_ids is not None: output["backend_ids"] = request.backend_ids + else: + output["backend_ids"] = [] if request.private_network_id is not None: output["private_network_id"] = request.private_network_id + else: + output["private_network_id"] = str() - return output + return output def marshal_CreateInstanceGroupRequest( request: CreateInstanceGroupRequest, @@ -583,24 +478,36 @@ def marshal_CreateInstanceGroupRequest( if request.name is not None: output["name"] = request.name + else: + output["name"] = str() if request.template_id is not None: output["template_id"] = request.template_id + else: + output["template_id"] = str() if request.capacity is not None: output["capacity"] = marshal_Capacity(request.capacity, defaults) + else: + output["capacity"] = str() if request.loadbalancer is not None: output["loadbalancer"] = marshal_Loadbalancer(request.loadbalancer, defaults) + else: + output["loadbalancer"] = str() if request.project_id is not None: output["project_id"] = request.project_id or defaults.default_project_id + else: + output["project_id"] = None if request.tags is not None: output["tags"] = request.tags + else: + output["tags"] = None - return output + return output def marshal_Metric( request: Metric, @@ -608,31 +515,41 @@ def marshal_Metric( ) -> Dict[str, Any]: output: Dict[str, Any] = {} output.update( - resolve_one_of( - [ - OneOfPossibility("managed_metric", request.managed_metric), - OneOfPossibility("cockpit_metric_name", request.cockpit_metric_name), - ] - ), + resolve_one_of([ + OneOfPossibility(param="managed_metric", value=request.managed_metric,marshal_func=marshal_MetricManagedMetric + ), + OneOfPossibility(param="cockpit_metric_name", value=request.cockpit_metric_name,marshal_func=None + ), + ]), ) if request.name is not None: output["name"] = request.name + else: + output["name"] = str() if request.operator is not None: output["operator"] = str(request.operator) + else: + output["operator"] = getattr(MetricOperator, "OPERATOR_UNKNOWN") if request.aggregate is not None: output["aggregate"] = str(request.aggregate) + else: + output["aggregate"] = getattr(MetricAggregate, "AGGREGATE_UNKNOWN") if request.sampling_range_min is not None: output["sampling_range_min"] = request.sampling_range_min + else: + output["sampling_range_min"] = 0 if request.threshold is not None: output["threshold"] = request.threshold + else: + output["threshold"] = 0.0 - return output + return output def marshal_CreateInstancePolicyRequest( request: CreateInstancePolicyRequest, @@ -640,33 +557,44 @@ def marshal_CreateInstancePolicyRequest( ) -> Dict[str, Any]: output: Dict[str, Any] = {} output.update( - resolve_one_of( - [ - OneOfPossibility("metric", request.metric), - ] - ), + resolve_one_of([ + OneOfPossibility(param="metric", value=request.metric,marshal_func=marshal_Metric + ), + ]), ) if request.name is not None: output["name"] = request.name + else: + output["name"] = str() if request.action is not None: output["action"] = str(request.action) + else: + output["action"] = str() if request.type_ is not None: output["type"] = str(request.type_) + else: + output["type"] = str() if request.value is not None: output["value"] = request.value + else: + output["value"] = str() if request.priority is not None: output["priority"] = request.priority + else: + output["priority"] = 0 if request.instance_group_id is not None: output["instance_group_id"] = request.instance_group_id + else: + output["instance_group_id"] = str() - return output + return output def marshal_VolumeInstanceTemplateFromEmpty( request: VolumeInstanceTemplateFromEmpty, @@ -676,9 +604,11 @@ def marshal_VolumeInstanceTemplateFromEmpty( if request.size is not None: output["size"] = request.size + else: + output["size"] = str() - return output + return output def marshal_VolumeInstanceTemplateFromSnapshot( request: VolumeInstanceTemplateFromSnapshot, @@ -688,12 +618,16 @@ def marshal_VolumeInstanceTemplateFromSnapshot( if request.snapshot_id is not None: output["snapshot_id"] = request.snapshot_id + else: + output["snapshot_id"] = str() if request.size is not None: output["size"] = request.size + else: + output["size"] = None - return output + return output def marshal_VolumeInstanceTemplate( request: VolumeInstanceTemplate, @@ -701,35 +635,42 @@ def marshal_VolumeInstanceTemplate( ) -> Dict[str, Any]: output: Dict[str, Any] = {} output.update( - resolve_one_of( - [ - OneOfPossibility("from_empty", request.from_empty), - OneOfPossibility("from_snapshot", request.from_snapshot), - ] - ), + resolve_one_of([ + OneOfPossibility(param="from_empty", value=request.from_empty,marshal_func=marshal_VolumeInstanceTemplateFromEmpty + ), + OneOfPossibility(param="from_snapshot", value=request.from_snapshot,marshal_func=marshal_VolumeInstanceTemplateFromSnapshot + ), + ]), ) output.update( - resolve_one_of( - [ - OneOfPossibility("perf_iops", request.perf_iops), - ] - ), + resolve_one_of([ + OneOfPossibility(param="perf_iops", value=request.perf_iops,marshal_func=None + ), + ]), ) if request.name is not None: output["name"] = request.name + else: + output["name"] = str() if request.tags is not None: output["tags"] = request.tags + else: + output["tags"] = [] if request.boot is not None: output["boot"] = request.boot + else: + output["boot"] = False if request.volume_type is not None: output["volume_type"] = str(request.volume_type) + else: + output["volume_type"] = getattr(VolumeInstanceTemplateVolumeType, "UNKNOWN_VOLUME_TYPE") - return output + return output def marshal_CreateInstanceTemplateRequest( request: CreateInstanceTemplateRequest, @@ -739,45 +680,69 @@ def marshal_CreateInstanceTemplateRequest( if request.commercial_type is not None: output["commercial_type"] = request.commercial_type + else: + output["commercial_type"] = str() if request.volumes is not None: output["volumes"] = { key: marshal_VolumeInstanceTemplate(value, defaults) for key, value in request.volumes.items() } + else: + output["volumes"] = str() if request.image_id is not None: output["image_id"] = request.image_id + else: + output["image_id"] = None if request.tags is not None: output["tags"] = request.tags + else: + output["tags"] = None if request.security_group_id is not None: output["security_group_id"] = request.security_group_id + else: + output["security_group_id"] = None if request.name is not None: output["name"] = request.name + else: + output["name"] = str() if request.placement_group_id is not None: output["placement_group_id"] = request.placement_group_id + else: + output["placement_group_id"] = None if request.public_ips_v4_count is not None: output["public_ips_v4_count"] = request.public_ips_v4_count + else: + output["public_ips_v4_count"] = None if request.public_ips_v6_count is not None: output["public_ips_v6_count"] = request.public_ips_v6_count + else: + output["public_ips_v6_count"] = None if request.project_id is not None: output["project_id"] = request.project_id or defaults.default_project_id + else: + output["project_id"] = None if request.private_network_ids is not None: output["private_network_ids"] = request.private_network_ids + else: + output["private_network_ids"] = None if request.cloud_init is not None: output["cloud_init"] = request.cloud_init + else: + output["cloud_init"] = None - return output + return output def marshal_UpdateInstanceGroupRequestCapacity( request: UpdateInstanceGroupRequestCapacity, @@ -787,15 +752,21 @@ def marshal_UpdateInstanceGroupRequestCapacity( if request.max_replicas is not None: output["max_replicas"] = request.max_replicas + else: + output["max_replicas"] = None if request.min_replicas is not None: output["min_replicas"] = request.min_replicas + else: + output["min_replicas"] = None if request.cooldown_delay is not None: output["cooldown_delay"] = request.cooldown_delay + else: + output["cooldown_delay"] = None - return output + return output def marshal_UpdateInstanceGroupRequestLoadbalancer( request: UpdateInstanceGroupRequestLoadbalancer, @@ -805,9 +776,11 @@ def marshal_UpdateInstanceGroupRequestLoadbalancer( if request.backend_ids is not None: output["backend_ids"] = request.backend_ids + else: + output["backend_ids"] = None - return output + return output def marshal_UpdateInstanceGroupRequest( request: UpdateInstanceGroupRequest, @@ -817,22 +790,26 @@ def marshal_UpdateInstanceGroupRequest( if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.tags is not None: output["tags"] = request.tags + else: + output["tags"] = None if request.capacity is not None: - output["capacity"] = marshal_UpdateInstanceGroupRequestCapacity( - request.capacity, defaults - ) + output["capacity"] = marshal_UpdateInstanceGroupRequestCapacity(request.capacity, defaults) + else: + output["capacity"] = None if request.loadbalancer is not None: - output["loadbalancer"] = marshal_UpdateInstanceGroupRequestLoadbalancer( - request.loadbalancer, defaults - ) + output["loadbalancer"] = marshal_UpdateInstanceGroupRequestLoadbalancer(request.loadbalancer, defaults) + else: + output["loadbalancer"] = None - return output + return output def marshal_UpdateInstancePolicyRequestMetric( request: UpdateInstancePolicyRequestMetric, @@ -840,31 +817,41 @@ def marshal_UpdateInstancePolicyRequestMetric( ) -> Dict[str, Any]: output: Dict[str, Any] = {} output.update( - resolve_one_of( - [ - OneOfPossibility("managed_metric", request.managed_metric), - OneOfPossibility("cockpit_metric_name", request.cockpit_metric_name), - ] - ), + resolve_one_of([ + OneOfPossibility(param="managed_metric", value=request.managed_metric,marshal_func=marshal_UpdateInstancePolicyRequestMetricManagedMetric + ), + OneOfPossibility(param="cockpit_metric_name", value=request.cockpit_metric_name,marshal_func=None + ), + ]), ) if request.operator is not None: output["operator"] = str(request.operator) + else: + output["operator"] = getattr(UpdateInstancePolicyRequestMetricOperator, "OPERATOR_UNKNOWN") if request.aggregate is not None: output["aggregate"] = str(request.aggregate) + else: + output["aggregate"] = getattr(UpdateInstancePolicyRequestMetricAggregate, "AGGREGATE_UNKNOWN") if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.sampling_range_min is not None: output["sampling_range_min"] = request.sampling_range_min + else: + output["sampling_range_min"] = None if request.threshold is not None: output["threshold"] = request.threshold + else: + output["threshold"] = None - return output + return output def marshal_UpdateInstancePolicyRequest( request: UpdateInstancePolicyRequest, @@ -872,30 +859,39 @@ def marshal_UpdateInstancePolicyRequest( ) -> Dict[str, Any]: output: Dict[str, Any] = {} output.update( - resolve_one_of( - [ - OneOfPossibility("metric", request.metric), - ] - ), + resolve_one_of([ + OneOfPossibility(param="metric", value=request.metric,marshal_func=marshal_UpdateInstancePolicyRequestMetric + ), + ]), ) if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.action is not None: output["action"] = str(request.action) + else: + output["action"] = None if request.type_ is not None: output["type"] = str(request.type_) + else: + output["type"] = None if request.value is not None: output["value"] = request.value + else: + output["value"] = None if request.priority is not None: output["priority"] = request.priority + else: + output["priority"] = None - return output + return output def marshal_UpdateInstanceTemplateRequest( request: UpdateInstanceTemplateRequest, @@ -905,38 +901,61 @@ def marshal_UpdateInstanceTemplateRequest( if request.commercial_type is not None: output["commercial_type"] = request.commercial_type + else: + output["commercial_type"] = None if request.image_id is not None: output["image_id"] = request.image_id + else: + output["image_id"] = None if request.volumes is not None: output["volumes"] = { key: marshal_VolumeInstanceTemplate(value, defaults) for key, value in request.volumes.items() } + else: + output["volumes"] = None if request.tags is not None: output["tags"] = request.tags + else: + output["tags"] = None if request.security_group_id is not None: output["security_group_id"] = request.security_group_id + else: + output["security_group_id"] = None if request.placement_group_id is not None: output["placement_group_id"] = request.placement_group_id + else: + output["placement_group_id"] = None if request.public_ips_v4_count is not None: output["public_ips_v4_count"] = request.public_ips_v4_count + else: + output["public_ips_v4_count"] = None if request.public_ips_v6_count is not None: output["public_ips_v6_count"] = request.public_ips_v6_count + else: + output["public_ips_v6_count"] = None if request.name is not None: output["name"] = request.name + else: + output["name"] = None if request.private_network_ids is not None: output["private_network_ids"] = request.private_network_ids + else: + output["private_network_ids"] = None if request.cloud_init is not None: output["cloud_init"] = request.cloud_init + else: + output["cloud_init"] = None + return output diff --git a/scaleway/scaleway/autoscaling/v1alpha1/types.py b/scaleway/scaleway/autoscaling/v1alpha1/types.py index f1ecfd81d..8d45d6259 100644 --- a/scaleway/scaleway/autoscaling/v1alpha1/types.py +++ b/scaleway/scaleway/autoscaling/v1alpha1/types.py @@ -3,18 +3,24 @@ from __future__ import annotations from dataclasses import dataclass +from decimal import Decimal from datetime import datetime from enum import Enum -from typing import Dict, List, Optional +from typing import Any, Dict, List, Optional from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, Zone as ScwZone, ) from scaleway_core.utils import ( StrEnumMeta, ) - class InstanceGroupEventLevel(str, Enum, metaclass=StrEnumMeta): INFO = "info" SUCCESS = "success" @@ -23,7 +29,6 @@ class InstanceGroupEventLevel(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class InstanceGroupEventSource(str, Enum, metaclass=StrEnumMeta): UNKNOWN_SOURCE = "unknown_source" WATCHER = "watcher" @@ -34,7 +39,6 @@ class InstanceGroupEventSource(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class InstancePolicyAction(str, Enum, metaclass=StrEnumMeta): UNKNOWN_ACTION = "unknown_action" SCALE_UP = "scale_up" @@ -43,7 +47,6 @@ class InstancePolicyAction(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class InstancePolicyType(str, Enum, metaclass=StrEnumMeta): UNKNOWN_TYPE = "unknown_type" FLAT_COUNT = "flat_count" @@ -53,7 +56,6 @@ class InstancePolicyType(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class InstanceTemplateStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_STATUS = "unknown_status" READY = "ready" @@ -62,7 +64,6 @@ class InstanceTemplateStatus(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListInstanceGroupEventsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_DESC = "created_at_desc" CREATED_AT_ASC = "created_at_asc" @@ -70,7 +71,6 @@ class ListInstanceGroupEventsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListInstanceGroupsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_DESC = "created_at_desc" CREATED_AT_ASC = "created_at_asc" @@ -78,7 +78,6 @@ class ListInstanceGroupsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListInstancePoliciesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_DESC = "created_at_desc" CREATED_AT_ASC = "created_at_asc" @@ -86,7 +85,6 @@ class ListInstancePoliciesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class ListInstanceTemplatesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_DESC = "created_at_desc" CREATED_AT_ASC = "created_at_asc" @@ -94,7 +92,6 @@ class ListInstanceTemplatesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class MetricAggregate(str, Enum, metaclass=StrEnumMeta): AGGREGATE_UNKNOWN = "aggregate_unknown" AGGREGATE_AVERAGE = "aggregate_average" @@ -105,21 +102,17 @@ class MetricAggregate(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class MetricManagedMetric(str, Enum, metaclass=StrEnumMeta): MANAGED_METRIC_UNKNOWN = "managed_metric_unknown" MANAGED_METRIC_INSTANCE_CPU = "managed_metric_instance_cpu" MANAGED_METRIC_INSTANCE_NETWORK_IN = "managed_metric_instance_network_in" MANAGED_METRIC_INSTANCE_NETWORK_OUT = "managed_metric_instance_network_out" - MANAGED_LOADBALANCER_BACKEND_CONNECTIONS_RATE = ( - "managed_loadbalancer_backend_connections_rate" - ) + MANAGED_LOADBALANCER_BACKEND_CONNECTIONS_RATE = "managed_loadbalancer_backend_connections_rate" MANAGED_LOADBALANCER_BACKEND_THROUGHPUT = "managed_loadbalancer_backend_throughput" def __str__(self) -> str: return str(self.value) - class MetricOperator(str, Enum, metaclass=StrEnumMeta): OPERATOR_UNKNOWN = "operator_unknown" OPERATOR_GREATER_THAN = "operator_greater_than" @@ -128,7 +121,6 @@ class MetricOperator(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - class UpdateInstancePolicyRequestMetricAggregate(str, Enum, metaclass=StrEnumMeta): AGGREGATE_UNKNOWN = "aggregate_unknown" AGGREGATE_AVERAGE = "aggregate_average" @@ -139,21 +131,17 @@ class UpdateInstancePolicyRequestMetricAggregate(str, Enum, metaclass=StrEnumMet def __str__(self) -> str: return str(self.value) - class UpdateInstancePolicyRequestMetricManagedMetric(str, Enum, metaclass=StrEnumMeta): MANAGED_METRIC_UNKNOWN = "managed_metric_unknown" MANAGED_METRIC_INSTANCE_CPU = "managed_metric_instance_cpu" MANAGED_METRIC_INSTANCE_NETWORK_IN = "managed_metric_instance_network_in" MANAGED_METRIC_INSTANCE_NETWORK_OUT = "managed_metric_instance_network_out" - MANAGED_LOADBALANCER_BACKEND_CONNECTIONS_RATE = ( - "managed_loadbalancer_backend_connections_rate" - ) + MANAGED_LOADBALANCER_BACKEND_CONNECTIONS_RATE = "managed_loadbalancer_backend_connections_rate" MANAGED_LOADBALANCER_BACKEND_THROUGHPUT = "managed_loadbalancer_backend_throughput" def __str__(self) -> str: return str(self.value) - class UpdateInstancePolicyRequestMetricOperator(str, Enum, metaclass=StrEnumMeta): OPERATOR_UNKNOWN = "operator_unknown" OPERATOR_GREATER_THAN = "operator_greater_than" @@ -162,7 +150,6 @@ class UpdateInstancePolicyRequestMetricOperator(str, Enum, metaclass=StrEnumMeta def __str__(self) -> str: return str(self.value) - class VolumeInstanceTemplateVolumeType(str, Enum, metaclass=StrEnumMeta): UNKNOWN_VOLUME_TYPE = "unknown_volume_type" L_SSD = "l_ssd" @@ -171,18 +158,17 @@ class VolumeInstanceTemplateVolumeType(str, Enum, metaclass=StrEnumMeta): def __str__(self) -> str: return str(self.value) - @dataclass class VolumeInstanceTemplateFromEmpty: size: int - + @dataclass class VolumeInstanceTemplateFromSnapshot: snapshot_id: str - + size: Optional[int] - + @dataclass class Capacity: @@ -190,17 +176,17 @@ class Capacity: """ Maximum count of Instances for the Instance group. """ - + min_replicas: int """ Minimum count of Instances for the Instance group. """ - + cooldown_delay: Optional[str] """ Time (in seconds) after a scaling action during which requests to carry out a new scaling action will be denied. """ - + @dataclass class Loadbalancer: @@ -208,17 +194,17 @@ class Loadbalancer: """ Load Balancer ID. """ - + backend_ids: List[str] """ Load Balancer backend IDs. """ - + private_network_id: str """ ID of the Private Network attached to the Load Balancer. """ - + @dataclass class Metric: @@ -226,31 +212,31 @@ class Metric: """ Name or description of the metric policy. """ - + operator: MetricOperator """ Operator used when comparing the threshold value of the chosen `metric` to the actual sampled and aggregated value. """ - + aggregate: MetricAggregate """ How the values sampled for the `metric` should be aggregated. """ - + sampling_range_min: int """ Interval of time, in minutes, during which metric is sampled. """ - + threshold: float """ Threshold value to measure the aggregated sampled `metric` value against. Combined with the `operator` field, determines whether a scaling action should be triggered. """ - + managed_metric: Optional[MetricManagedMetric] - + cockpit_metric_name: Optional[str] - + @dataclass class VolumeInstanceTemplate: @@ -258,28 +244,28 @@ class VolumeInstanceTemplate: """ Name of the volume. """ - + tags: List[str] """ List of tags assigned to the volume. """ - + boot: bool """ Force the Instance to boot on this volume. """ - + volume_type: VolumeInstanceTemplateVolumeType """ Type of the volume. """ - + from_empty: Optional[VolumeInstanceTemplateFromEmpty] - + from_snapshot: Optional[VolumeInstanceTemplateFromSnapshot] - + perf_iops: Optional[int] - + @dataclass class InstanceGroupEvent: @@ -287,32 +273,32 @@ class InstanceGroupEvent: """ Instance group event ID. """ - + source: InstanceGroupEventSource """ Log source. """ - + level: InstanceGroupEventLevel """ The severity of the log. """ - + name: str """ Log title. """ - + created_at: Optional[datetime] """ Date and time of the log. """ - + details: Optional[str] """ Full text of the log. """ - + @dataclass class InstanceGroup: @@ -320,52 +306,52 @@ class InstanceGroup: """ Instance group ID. """ - + project_id: str """ Project ID of the Instance group. """ - + name: str """ Name of the Instance group. """ - + tags: List[str] """ Instance group tags. """ - + instance_template_id: str """ Template ID (ID of the Instance template to attach to the Instance group). """ - + capacity: Capacity """ Specification of the minimum and maximum replicas for the Instance group, and the cooldown interval between two scaling events. """ - + loadbalancer: Loadbalancer """ Specification of the Load Balancer linked to the Instance group. """ - + error_messages: List[str] """ Any configuration errors for dependencies (Load Balancer, Private Network, Instance template etc.). """ - + created_at: Optional[datetime] """ Date on which the Instance group was created. """ - + updated_at: Optional[datetime] """ Date on which the Instance group was last updated. """ - + @dataclass class InstancePolicy: @@ -373,39 +359,39 @@ class InstancePolicy: """ Scaling policy ID. """ - + name: str """ Name of scaling policy. """ - + action: InstancePolicyAction """ Action to execute when the metric-based condition is met. """ - + type_: InstancePolicyType """ How to use the number defined in `value` when determining by how many Instances to scale up/down. """ - + value: int """ Number representing the magnitude of the scaling action to take for the Instance group. """ - + priority: int """ Priority of this policy compared to all other scaling policies. The lower the number, the higher the priority (higher priority will be processed sooner in the order). """ - + instance_group_id: str """ Instance group ID related to this policy. """ - + metric: Optional[Metric] - + @dataclass class InstanceTemplate: @@ -413,82 +399,82 @@ class InstanceTemplate: """ ID of Instance template resource. """ - + commercial_type: str """ Name of Instance commercial type. """ - + volumes: Dict[str, VolumeInstanceTemplate] """ Template of Instance volume. """ - + tags: List[str] """ List of tags for the Instance template. """ - + project_id: str """ ID of the Project containing the Instance template resource. """ - + name: str """ Name of Instance template. """ - + private_network_ids: List[str] """ Private Network IDs to attach to the new Instance. """ - + image_id: Optional[str] """ Instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. """ - + security_group_id: Optional[str] """ Instance security group ID (optional). """ - + placement_group_id: Optional[str] """ Instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. """ - + public_ips_v4_count: Optional[int] """ Number of flexible IPv4 addresses to attach to the new Instance. """ - + public_ips_v6_count: Optional[int] """ Number of flexible IPv6 addresses to attach to the new Instance. """ - + status: InstanceTemplateStatus """ Status of Instance template. """ - + cloud_init: Optional[str] """ Cloud-config file must be passed in Base64 format. Cloud-config files are special scripts designed to be run by the cloud-init process. These are generally used for initial configuration on the very first boot of a server. """ - + created_at: Optional[datetime] """ Date on which the Instance template was created. """ - + updated_at: Optional[datetime] """ Date on which the Instance template was last updated. """ - + @dataclass class UpdateInstanceGroupRequestCapacity: @@ -496,17 +482,17 @@ class UpdateInstanceGroupRequestCapacity: """ Maximum count of Instances for the Instance group. """ - + min_replicas: Optional[int] """ Minimum count of Instances for the Instance group. """ - + cooldown_delay: Optional[str] """ Time (in seconds) after a scaling action during which requests to carry out a new scaling action will be denied. """ - + @dataclass class UpdateInstanceGroupRequestLoadbalancer: @@ -514,7 +500,7 @@ class UpdateInstanceGroupRequestLoadbalancer: """ Load Balancer backend IDs. """ - + @dataclass class UpdateInstancePolicyRequestMetric: @@ -522,31 +508,31 @@ class UpdateInstancePolicyRequestMetric: """ Operator used when comparing the threshold value of the chosen `metric` to the actual sampled and aggregated value. """ - + aggregate: UpdateInstancePolicyRequestMetricAggregate """ How the values sampled for the `metric` should be aggregated. """ - + name: Optional[str] """ Name or description of your metric policy. """ - + sampling_range_min: Optional[int] """ Interval of time, in minutes, during which metric is sampled. """ - + threshold: Optional[float] """ Threshold value to measure the aggregated sampled `metric` value against. Combined with the `operator` field, determines whether a scaling action should be triggered. """ - + managed_metric: Optional[UpdateInstancePolicyRequestMetricManagedMetric] - + cockpit_metric_name: Optional[str] - + @dataclass class CreateInstanceGroupRequest: @@ -554,37 +540,37 @@ class CreateInstanceGroupRequest: """ Name of Instance group. """ - + template_id: str """ Template ID (ID of the Instance template to attach to the Instance group). """ - + capacity: Capacity """ Specification of the minimum and maximum replicas for the Instance group, and the cooldown interval between two scaling events. """ - + loadbalancer: Loadbalancer """ Specification of the Load Balancer to link to the Instance group. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + project_id: Optional[str] """ Project ID to filter for, only Instance groups from this Project will be returned. """ - + tags: Optional[List[str]] """ List of tags for the Instance group. """ - + @dataclass class CreateInstancePolicyRequest: @@ -592,39 +578,39 @@ class CreateInstancePolicyRequest: """ Name of the policy. """ - + action: InstancePolicyAction """ Action to execute when the metric-based condition is met. """ - + type_: InstancePolicyType """ How to use the number defined in `value` when determining by how many Instances to scale up/down. """ - + value: int """ Value representing the magnitude of the scaling action to take for the Instance group. Depending on the `type` parameter, this number could represent a total number of Instances in the group, a number of Instances to add, or a percentage to scale the group by. """ - + priority: int """ Priority of this policy compared to all other scaling policies. This determines the processing order. The lower the number, the higher the priority. """ - + instance_group_id: str """ Instance group ID related to this policy. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + metric: Optional[Metric] - + @dataclass class CreateInstanceTemplateRequest: @@ -632,67 +618,67 @@ class CreateInstanceTemplateRequest: """ Zone to target. If none is passed will use default zone from the config. """ - + commercial_type: str """ Name of Instance commercial type. """ - + volumes: Dict[str, VolumeInstanceTemplate] """ Template of Instance volume. """ - + image_id: Optional[str] """ Instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. """ - + tags: Optional[List[str]] """ List of tags for the Instance template. """ - + security_group_id: Optional[str] """ Instance security group ID (optional). """ - + name: str """ Name of Instance template. """ - + placement_group_id: Optional[str] """ Instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. """ - + public_ips_v4_count: Optional[int] """ Number of flexible IPv4 addresses to attach to the new Instance. """ - + public_ips_v6_count: Optional[int] """ Number of flexible IPv6 addresses to attach to the new Instance. """ - + project_id: Optional[str] """ ID of the Project containing the Instance template resource. """ - + private_network_ids: Optional[List[str]] """ Private Network IDs to attach to the new Instance. """ - + cloud_init: Optional[str] """ Cloud-config file must be passed in Base64 format. Cloud-config files are special scripts designed to be run by the cloud-init process. These are generally used for initial configuration on the very first boot of a server. """ - + @dataclass class DeleteInstanceGroupRequest: @@ -700,12 +686,12 @@ class DeleteInstanceGroupRequest: """ ID of the Instance group to delete. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class DeleteInstancePolicyRequest: @@ -713,12 +699,12 @@ class DeleteInstancePolicyRequest: """ ID of the policy to delete. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class DeleteInstanceTemplateRequest: @@ -726,12 +712,12 @@ class DeleteInstanceTemplateRequest: """ ID of the template to delete. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class GetInstanceGroupRequest: @@ -739,12 +725,12 @@ class GetInstanceGroupRequest: """ ID of the requested Instance group. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class GetInstancePolicyRequest: @@ -752,12 +738,12 @@ class GetInstancePolicyRequest: """ Policy ID. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class GetInstanceTemplateRequest: @@ -765,12 +751,12 @@ class GetInstanceTemplateRequest: """ Template ID of the resource. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + @dataclass class ListInstanceGroupEventsRequest: @@ -778,27 +764,27 @@ class ListInstanceGroupEventsRequest: """ List all event logs for the Instance group ID. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + order_by: Optional[ListInstanceGroupEventsRequestOrderBy] """ Sort order of Instance groups in the response. """ - + page: Optional[int] """ Page number to return, from the paginated results. """ - + page_size: Optional[int] """ Number of Instance groups to return per page. """ - + @dataclass class ListInstanceGroupEventsResponse: @@ -806,12 +792,12 @@ class ListInstanceGroupEventsResponse: """ Paginated list of Instance groups. """ - + total_count: int """ Count of all Instance groups matching the requested criteria. """ - + @dataclass class ListInstanceGroupsRequest: @@ -819,22 +805,22 @@ class ListInstanceGroupsRequest: """ Zone to target. If none is passed will use default zone from the config. """ - + order_by: Optional[ListInstanceGroupsRequestOrderBy] """ Sort order of Instance groups in the response. """ - + page: Optional[int] """ Page number to return, from the paginated results. """ - + page_size: Optional[int] """ Number of Instance groups to return per page. """ - + @dataclass class ListInstanceGroupsResponse: @@ -842,12 +828,12 @@ class ListInstanceGroupsResponse: """ Paginated list of Instance groups. """ - + total_count: int """ Count of all Instance groups matching the requested criteria. """ - + @dataclass class ListInstancePoliciesRequest: @@ -855,27 +841,27 @@ class ListInstancePoliciesRequest: """ Instance group ID. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + order_by: Optional[ListInstancePoliciesRequestOrderBy] """ Sort order of Instance groups in the response. """ - + page: Optional[int] """ Page number to return, from the paginated results. """ - + page_size: Optional[int] """ Number of scaling policies to return per page. """ - + @dataclass class ListInstancePoliciesResponse: @@ -883,12 +869,12 @@ class ListInstancePoliciesResponse: """ Paginated list of policies. """ - + total_count: int """ Count of all policies matching the requested criteria. """ - + @dataclass class ListInstanceTemplatesRequest: @@ -896,22 +882,22 @@ class ListInstanceTemplatesRequest: """ Zone to target. If none is passed will use default zone from the config. """ - + order_by: Optional[ListInstanceTemplatesRequestOrderBy] """ Sort order of Instance groups in the response. """ - + page: Optional[int] """ Page number to return, from the paginated results. """ - + page_size: Optional[int] """ Number of Instance groups to return per page. """ - + @dataclass class ListInstanceTemplatesResponse: @@ -919,12 +905,12 @@ class ListInstanceTemplatesResponse: """ Count of all templates matching the requested criteria. """ - + instance_templates: List[InstanceTemplate] """ Paginated list of Instance templates. """ - + @dataclass class UpdateInstanceGroupRequest: @@ -932,32 +918,32 @@ class UpdateInstanceGroupRequest: """ Instance group ID to update. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + name: Optional[str] """ Name of Instance group. """ - + tags: Optional[List[str]] """ List of tags for the Load Balancer. """ - + capacity: Optional[UpdateInstanceGroupRequestCapacity] """ Specification of the minimum and maximum replicas for the Instance group, and the cooldown interval between two scaling events. """ - + loadbalancer: Optional[UpdateInstanceGroupRequestLoadbalancer] """ Specification of the Load Balancer to link to the Instance group. """ - + @dataclass class UpdateInstancePolicyRequest: @@ -965,39 +951,39 @@ class UpdateInstancePolicyRequest: """ Policy ID to update. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + name: Optional[str] """ Policy name to update. """ - + action: Optional[InstancePolicyAction] """ Action to update (action to execute when the metric-based condition is met). """ - + type_: Optional[InstancePolicyType] """ Type to update (how to use the number defined in `value` when determining by how many Instances to scale up/down). """ - + value: Optional[int] """ Value to update (number representing the magnitude of the scaling action to take for the Instance group). """ - + priority: Optional[int] """ Priority to update (priority of this policy compared to all other scaling policies. The lower the number, the higher the priority). """ - + metric: Optional[UpdateInstancePolicyRequestMetric] - + @dataclass class UpdateInstanceTemplateRequest: @@ -1005,63 +991,64 @@ class UpdateInstanceTemplateRequest: """ Template ID of the resource. """ - + zone: Optional[ScwZone] """ Zone to target. If none is passed will use default zone from the config. """ - + commercial_type: Optional[str] """ Name of Instance commercial type. """ - + image_id: Optional[str] """ Instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. """ - + volumes: Optional[Dict[str, VolumeInstanceTemplate]] """ Template of Instance volume. """ - + tags: Optional[List[str]] """ List of tags for the Instance template. """ - + security_group_id: Optional[str] """ Instance security group ID (optional). """ - + placement_group_id: Optional[str] """ Instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. """ - + public_ips_v4_count: Optional[int] """ Number of flexible IPv4 addresses to attach to the new Instance. """ - + public_ips_v6_count: Optional[int] """ Number of flexible IPv6 addresses to attach to the new Instance. """ - + name: Optional[str] """ Name of Instance template. """ - + private_network_ids: Optional[List[str]] """ Private Network IDs to attach to the new Instance. """ - + cloud_init: Optional[str] """ Cloud-config file must be passed in Base64 format. Cloud-config files are special scripts designed to be run by the cloud-init process. These are generally used for initial configuration on the very first boot of a server. """ + diff --git a/scaleway/scaleway/baremetal/v1/api.py b/scaleway/scaleway/baremetal/v1/api.py index d9b73a500..dcba4c6fa 100644 --- a/scaleway/scaleway/baremetal/v1/api.py +++ b/scaleway/scaleway/baremetal/v1/api.py @@ -2,59 +2,133 @@ # If you have any remark or suggestion do not hesitate to open an issue. from datetime import datetime -from typing import List, Optional +from typing import Any, Awaitable, Dict, List, Optional, Union from scaleway_core.api import API from scaleway_core.bridge import ( + Money, + Region as ScwRegion, + ScwFile, + ServiceInfo, + TimeSeries, + TimeSeriesPoint, Zone as ScwZone, + marshal_Money, + unmarshal_Money, + marshal_ScwFile, + unmarshal_ScwFile, + unmarshal_ServiceInfo, + marshal_TimeSeries, + unmarshal_TimeSeries, ) from scaleway_core.utils import ( + OneOfPossibility, WaitForOptions, + project_or_organization_id, + random_name, + resolve_one_of, validate_path_param, fetch_all_pages, wait_for_resource, ) from .types import ( + IPReverseStatus, + IPVersion, ListServerEventsRequestOrderBy, ListServerPrivateNetworksRequestOrderBy, ListServersRequestOrderBy, ListSettingsRequestOrderBy, + OfferStock, OfferSubscriptionPeriod, + SchemaFilesystemFormat, + SchemaPartitionLabel, + SchemaPoolType, + SchemaRAIDLevel, ServerBootType, + ServerInstallStatus, + ServerOptionOptionStatus, + ServerPingStatus, + ServerPrivateNetworkStatus, + ServerStatus, + SettingType, AddOptionServerRequest, BMCAccess, + CPU, + CertificationOption, CreateServerRequest, CreateServerRequestInstall, + DeleteOptionServerRequest, + DeleteServerRequest, + Disk, + GPU, + GetBMCAccessRequest, + GetDefaultPartitioningSchemaRequest, + GetOSRequest, + GetOfferRequest, + GetOptionRequest, + GetServerMetricsRequest, GetServerMetricsResponse, + GetServerRequest, IP, InstallServerRequest, + LicenseOption, + ListOSRequest, ListOSResponse, + ListOffersRequest, ListOffersResponse, + ListOptionsRequest, ListOptionsResponse, + ListServerEventsRequest, ListServerEventsResponse, ListServerPrivateNetworksResponse, + ListServersRequest, ListServersResponse, + ListSettingsRequest, ListSettingsResponse, + Memory, + MigrateServerToMonthlyOfferRequest, OS, + OSOSField, Offer, + OfferOptionOffer, Option, + PersistentMemory, PrivateNetworkApiAddServerPrivateNetworkRequest, + PrivateNetworkApiDeleteServerPrivateNetworkRequest, + PrivateNetworkApiListServerPrivateNetworksRequest, PrivateNetworkApiSetServerPrivateNetworksRequest, + PrivateNetworkOption, + PublicBandwidthOption, + RaidController, RebootServerRequest, + RemoteAccessOption, Schema, + SchemaDisk, + SchemaFilesystem, + SchemaPartition, + SchemaPool, + SchemaRAID, + SchemaZFS, Server, ServerEvent, + ServerInstall, + ServerOption, ServerPrivateNetwork, + ServerRescueServer, SetServerPrivateNetworksResponse, Setting, StartBMCAccessRequest, StartServerRequest, + StopBMCAccessRequest, + StopServerRequest, UpdateIPRequest, UpdateServerRequest, UpdateSettingRequest, ValidatePartitioningSchemaRequest, ) from .content import ( + SERVER_INSTALL_TRANSIENT_STATUSES, + SERVER_PRIVATE_NETWORK_TRANSIENT_STATUSES, SERVER_TRANSIENT_STATUSES, ) from .marshalling import ( @@ -90,12 +164,10 @@ marshal_ValidatePartitioningSchemaRequest, ) - class BaremetalV1API(API): """ This API allows you to manage your Elastic Metal servers. """ - def list_servers( self, *, @@ -124,15 +196,15 @@ def list_servers( :param project_id: Project ID to filter for. :param option_id: Option ID to filter for. :return: :class:`ListServersResponse ` - + Usage: :: - + result = api.list_servers() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/servers", @@ -140,8 +212,7 @@ def list_servers( "name": name, "option_id": option_id, "order_by": order_by, - "organization_id": organization_id - or self.client.default_organization_id, + "organization_id": organization_id or self.client.default_organization_id, "page": page, "page_size": page_size or self.client.default_page_size, "project_id": project_id or self.client.default_project_id, @@ -152,7 +223,7 @@ def list_servers( self._throw_on_error(res) return unmarshal_ListServersResponse(res.json()) - + def list_servers_all( self, *, @@ -181,14 +252,14 @@ def list_servers_all( :param project_id: Project ID to filter for. :param option_id: Option ID to filter for. :return: :class:`List[Server] ` - + Usage: :: - + result = api.list_servers_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListServersResponse, key="servers", fetcher=self.list_servers, @@ -205,7 +276,7 @@ def list_servers_all( "option_id": option_id, }, ) - + def get_server( self, *, @@ -218,18 +289,18 @@ def get_server( :param server_id: ID of the server. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.get_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}", @@ -237,7 +308,7 @@ def get_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def wait_for_server( self, *, @@ -251,10 +322,10 @@ def wait_for_server( :param server_id: ID of the server. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.get_server( server_id="example", ) @@ -274,7 +345,7 @@ def wait_for_server( "zone": zone, }, ) - + def create_server( self, *, @@ -303,19 +374,19 @@ def create_server( :param install: Object describing the configuration details of the OS installation on the server. :param option_ids: IDs of options to enable on server. :return: :class:`Server ` - + Usage: :: - + result = api.create_server( offer_id="example", name="example", description="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers", @@ -337,7 +408,7 @@ def create_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def update_server( self, *, @@ -356,18 +427,18 @@ def update_server( :param description: Description associated with the server, max 255 characters, not updated if null. :param tags: Tags associated with the server, not updated if null. :return: :class:`Server ` - + Usage: :: - + result = api.update_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "PATCH", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}", @@ -385,7 +456,7 @@ def update_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def install_server( self, *, @@ -414,10 +485,10 @@ def install_server( :param service_password: Password used for the service to install. :param partitioning_schema: Partitioning schema. :return: :class:`Server ` - + Usage: :: - + result = api.install_server( server_id="example", os_id="example", @@ -425,10 +496,10 @@ def install_server( ssh_key_ids=[], ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/install", @@ -451,7 +522,7 @@ def install_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def get_server_metrics( self, *, @@ -464,18 +535,18 @@ def get_server_metrics( :param server_id: Server ID to get the metrics. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`GetServerMetricsResponse ` - + Usage: :: - + result = api.get_server_metrics( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/metrics", @@ -483,7 +554,7 @@ def get_server_metrics( self._throw_on_error(res) return unmarshal_GetServerMetricsResponse(res.json()) - + def delete_server( self, *, @@ -496,18 +567,18 @@ def delete_server( :param server_id: ID of the server to delete. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.delete_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "DELETE", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}", @@ -515,7 +586,7 @@ def delete_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def reboot_server( self, *, @@ -530,18 +601,18 @@ def reboot_server( :param zone: Zone to target. If none is passed will use default zone from the config. :param boot_type: The type of boot. :return: :class:`Server ` - + Usage: :: - + result = api.reboot_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/reboot", @@ -557,7 +628,7 @@ def reboot_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def start_server( self, *, @@ -572,18 +643,18 @@ def start_server( :param zone: Zone to target. If none is passed will use default zone from the config. :param boot_type: The type of boot. :return: :class:`Server ` - + Usage: :: - + result = api.start_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/start", @@ -599,7 +670,7 @@ def start_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def stop_server( self, *, @@ -612,18 +683,18 @@ def stop_server( :param server_id: ID of the server to stop. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.stop_server( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/stop", @@ -632,7 +703,7 @@ def stop_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def list_server_events( self, *, @@ -651,18 +722,18 @@ def list_server_events( :param page_size: Number of server events per page. :param order_by: Order of the server events. :return: :class:`ListServerEventsResponse ` - + Usage: :: - + result = api.list_server_events( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/events", @@ -675,7 +746,7 @@ def list_server_events( self._throw_on_error(res) return unmarshal_ListServerEventsResponse(res.json()) - + def list_server_events_all( self, *, @@ -694,16 +765,16 @@ def list_server_events_all( :param page_size: Number of server events per page. :param order_by: Order of the server events. :return: :class:`List[ServerEvent] ` - + Usage: :: - + result = api.list_server_events_all( server_id="example", ) """ - return fetch_all_pages( + return fetch_all_pages( type=ListServerEventsResponse, key="events", fetcher=self.list_server_events, @@ -715,7 +786,7 @@ def list_server_events_all( "order_by": order_by, }, ) - + def get_default_partitioning_schema( self, *, @@ -730,18 +801,18 @@ def get_default_partitioning_schema( :param os_id: ID of the OS. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Schema ` - + Usage: :: - + result = api.get_default_partitioning_schema( offer_id="example", os_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/partitioning-schemas/default", @@ -753,7 +824,7 @@ def get_default_partitioning_schema( self._throw_on_error(res) return unmarshal_Schema(res.json()) - + def validate_partitioning_schema( self, *, @@ -769,18 +840,18 @@ def validate_partitioning_schema( :param os_id: OS ID. :param zone: Zone to target. If none is passed will use default zone from the config. :param partitioning_schema: Partitioning schema. - + Usage: :: - + result = api.validate_partitioning_schema( offer_id="example", os_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/partitioning-schemas/validate", @@ -796,7 +867,6 @@ def validate_partitioning_schema( ) self._throw_on_error(res) - def start_bmc_access( self, *, @@ -814,19 +884,19 @@ def start_bmc_access( :param ip: The IP authorized to connect to the server. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`BMCAccess ` - + Usage: :: - + result = api.start_bmc_access( server_id="example", ip="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/bmc-access", @@ -842,7 +912,7 @@ def start_bmc_access( self._throw_on_error(res) return unmarshal_BMCAccess(res.json()) - + def get_bmc_access( self, *, @@ -855,18 +925,18 @@ def get_bmc_access( :param server_id: ID of the server. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`BMCAccess ` - + Usage: :: - + result = api.get_bmc_access( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/bmc-access", @@ -874,7 +944,7 @@ def get_bmc_access( self._throw_on_error(res) return unmarshal_BMCAccess(res.json()) - + def stop_bmc_access( self, *, @@ -886,25 +956,24 @@ def stop_bmc_access( Stop BMC (Baseboard Management Controller) access associated with the ID. :param server_id: ID of the server. :param zone: Zone to target. If none is passed will use default zone from the config. - + Usage: :: - + result = api.stop_bmc_access( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "DELETE", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/bmc-access", ) self._throw_on_error(res) - def update_ip( self, *, @@ -921,20 +990,20 @@ def update_ip( :param zone: Zone to target. If none is passed will use default zone from the config. :param reverse: New reverse IP to update, not updated if null. :return: :class:`IP ` - + Usage: :: - + result = api.update_ip( server_id="example", ip_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) param_ip_id = validate_path_param("ip_id", ip_id) - + res = self._request( "PATCH", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/ips/{param_ip_id}", @@ -951,7 +1020,7 @@ def update_ip( self._throw_on_error(res) return unmarshal_IP(res.json()) - + def add_option_server( self, *, @@ -968,20 +1037,20 @@ def add_option_server( :param zone: Zone to target. If none is passed will use default zone from the config. :param expires_at: Auto expire the option after this date. :return: :class:`Server ` - + Usage: :: - + result = api.add_option_server( server_id="example", option_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) param_option_id = validate_path_param("option_id", option_id) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/options/{param_option_id}", @@ -998,7 +1067,7 @@ def add_option_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def delete_option_server( self, *, @@ -1013,20 +1082,20 @@ def delete_option_server( :param option_id: ID of the option to delete. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.delete_option_server( server_id="example", option_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) param_option_id = validate_path_param("option_id", option_id) - + res = self._request( "DELETE", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/options/{param_option_id}", @@ -1034,7 +1103,7 @@ def delete_option_server( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def migrate_server_to_monthly_offer( self, *, @@ -1047,18 +1116,18 @@ def migrate_server_to_monthly_offer( :param server_id: ID of the server. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Server ` - + Usage: :: - + result = api.migrate_server_to_monthly_offer( server_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - + res = self._request( "POST", f"/baremetal/v1/zones/{param_zone}/servers/{param_server_id}/migrate-offer-monthly", @@ -1066,7 +1135,7 @@ def migrate_server_to_monthly_offer( self._throw_on_error(res) return unmarshal_Server(res.json()) - + def list_offers( self, *, @@ -1085,15 +1154,15 @@ def list_offers( :param subscription_period: Subscription period type to filter offers by. :param name: Offer name to filter offers by. :return: :class:`ListOffersResponse ` - + Usage: :: - + result = api.list_offers() """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/offers", @@ -1107,7 +1176,7 @@ def list_offers( self._throw_on_error(res) return unmarshal_ListOffersResponse(res.json()) - + def list_offers_all( self, *, @@ -1126,14 +1195,14 @@ def list_offers_all( :param subscription_period: Subscription period type to filter offers by. :param name: Offer name to filter offers by. :return: :class:`List[Offer] ` - + Usage: :: - + result = api.list_offers_all() """ - return fetch_all_pages( + return fetch_all_pages( type=ListOffersResponse, key="offers", fetcher=self.list_offers, @@ -1145,7 +1214,7 @@ def list_offers_all( "name": name, }, ) - + def get_offer( self, *, @@ -1158,18 +1227,18 @@ def get_offer( :param offer_id: ID of the researched Offer. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Offer ` - + Usage: :: - + result = api.get_offer( offer_id="example", ) """ - + param_zone = validate_path_param("zone", zone or self.client.default_zone) param_offer_id = validate_path_param("offer_id", offer_id) - + res = self._request( "GET", f"/baremetal/v1/zones/{param_zone}/offers/{param_offer_id}", @@ -1177,7 +1246,7 @@ def get_offer( self._throw_on_error(res) return unmarshal_Offer(res.json()) - + def get_option( self, *, @@ -1190,18 +1259,18 @@ def get_option( :param option_id: ID of the option. :param zone: Zone to target. If none is passed will use default zone from the config. :return: :class:`Option