From b5cef9fd65afea7aeadaa5b3e7af82080b85b05f Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Mon, 14 Oct 2024 09:03:24 +0000 Subject: [PATCH] feat: update generated APIs --- .../iam/v1alpha1/marshalling.py | 28 ++- .../scaleway_async/iam/v1alpha1/types.py | 5 + .../scaleway_async/instance/v1/__init__.py | 8 - .../scaleway_async/instance/v1/api.py | 152 +----------- .../scaleway_async/instance/v1/marshalling.py | 126 +++------- .../scaleway_async/instance/v1/types.py | 106 +-------- .../instance/v1/types_private.py | 5 - .../scaleway_async/jobs/v1alpha1/__init__.py | 22 ++ .../scaleway_async/jobs/v1alpha1/api.py | 221 ++++++++++++++++++ .../jobs/v1alpha1/marshalling.py | 177 ++++++++++++++ .../scaleway_async/jobs/v1alpha1/types.py | 116 +++++++++ scaleway/scaleway/iam/v1alpha1/marshalling.py | 28 ++- scaleway/scaleway/iam/v1alpha1/types.py | 5 + scaleway/scaleway/instance/v1/__init__.py | 8 - scaleway/scaleway/instance/v1/api.py | 152 +----------- scaleway/scaleway/instance/v1/marshalling.py | 126 +++------- scaleway/scaleway/instance/v1/types.py | 106 +-------- .../scaleway/instance/v1/types_private.py | 5 - scaleway/scaleway/jobs/v1alpha1/__init__.py | 22 ++ scaleway/scaleway/jobs/v1alpha1/api.py | 221 ++++++++++++++++++ .../scaleway/jobs/v1alpha1/marshalling.py | 177 ++++++++++++++ scaleway/scaleway/jobs/v1alpha1/types.py | 116 +++++++++ 22 files changed, 1202 insertions(+), 730 deletions(-) diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py index 51868f293..e64f626ff 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/marshalling.py @@ -126,18 +126,6 @@ def unmarshal_APIKey(data: Any) -> APIKey: if field is not None: args["default_project_id"] = field - field = data.get("editable", None) - if field is not None: - args["editable"] = field - - field = data.get("managed", None) - if field is not None: - args["managed"] = field - - field = data.get("creation_ip", None) - if field is not None: - args["creation_ip"] = field - field = data.get("secret_key", None) if field is not None: args["secret_key"] = field @@ -150,6 +138,22 @@ def unmarshal_APIKey(data: Any) -> APIKey: else: args["application_id"] = None + field = data.get("editable", None) + if field is not None: + args["editable"] = field + + field = data.get("deletable", None) + if field is not None: + args["deletable"] = field + + field = data.get("managed", None) + if field is not None: + args["managed"] = field + + field = data.get("creation_ip", None) + if field is not None: + args["creation_ip"] = field + field = data.get("user_id", None) if field is not None: args["user_id"] = field diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index f8ce6abc9..1a7e65e2b 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -287,6 +287,11 @@ class APIKey: Defines whether or not the API key is editable. """ + deletable: bool + """ + Defines whether or not the API key is deletable. + """ + managed: bool """ Defines whether or not the API key is managed. diff --git a/scaleway-async/scaleway_async/instance/v1/__init__.py b/scaleway-async/scaleway_async/instance/v1/__init__.py index 8f2320f26..a5563e97a 100644 --- a/scaleway-async/scaleway_async/instance/v1/__init__.py +++ b/scaleway-async/scaleway_async/instance/v1/__init__.py @@ -111,8 +111,6 @@ from .types import DetachServerVolumeResponse from .types import ExportSnapshotRequest from .types import ExportSnapshotResponse -from .types import GetBootscriptRequest -from .types import GetBootscriptResponse from .types import GetDashboardRequest from .types import GetDashboardResponse from .types import GetImageRequest @@ -137,8 +135,6 @@ from .types import GetSnapshotResponse from .types import GetVolumeRequest from .types import GetVolumeResponse -from .types import ListBootscriptsRequest -from .types import ListBootscriptsResponse from .types import ListDefaultSecurityGroupRulesRequest from .types import ListImagesRequest from .types import ListImagesResponse @@ -310,8 +306,6 @@ "DetachServerVolumeResponse", "ExportSnapshotRequest", "ExportSnapshotResponse", - "GetBootscriptRequest", - "GetBootscriptResponse", "GetDashboardRequest", "GetDashboardResponse", "GetImageRequest", @@ -336,8 +330,6 @@ "GetSnapshotResponse", "GetVolumeRequest", "GetVolumeResponse", - "ListBootscriptsRequest", - "ListBootscriptsResponse", "ListDefaultSecurityGroupRulesRequest", "ListImagesRequest", "ListImagesResponse", diff --git a/scaleway-async/scaleway_async/instance/v1/api.py b/scaleway-async/scaleway_async/instance/v1/api.py index 6f9816084..8aa5e54e2 100644 --- a/scaleway-async/scaleway_async/instance/v1/api.py +++ b/scaleway-async/scaleway_async/instance/v1/api.py @@ -68,7 +68,6 @@ DetachServerVolumeResponse, ExportSnapshotRequest, ExportSnapshotResponse, - GetBootscriptResponse, GetDashboardResponse, GetImageResponse, GetIpResponse, @@ -83,7 +82,6 @@ GetVolumeResponse, Image, Ip, - ListBootscriptsResponse, ListImagesResponse, ListIpsResponse, ListPlacementGroupsResponse, @@ -163,7 +161,6 @@ unmarshal_CreateVolumeResponse, unmarshal_DetachServerVolumeResponse, unmarshal_ExportSnapshotResponse, - unmarshal_GetBootscriptResponse, unmarshal_GetDashboardResponse, unmarshal_GetImageResponse, unmarshal_GetIpResponse, @@ -176,7 +173,6 @@ unmarshal_GetServerTypesAvailabilityResponse, unmarshal_GetSnapshotResponse, unmarshal_GetVolumeResponse, - unmarshal_ListBootscriptsResponse, unmarshal_ListImagesResponse, unmarshal_ListIpsResponse, unmarshal_ListPlacementGroupsResponse, @@ -522,7 +518,6 @@ async def _create_server( public_ip: Optional[str] = None, public_ips: Optional[List[str]] = None, boot_type: Optional[BootType] = None, - bootscript: Optional[str] = None, organization: Optional[str] = None, project: Optional[str] = None, tags: Optional[List[str]] = None, @@ -545,7 +540,6 @@ async def _create_server( :param public_ip: ID of the reserved IP to attach to the Instance. :param public_ips: A list of reserved IP IDs to attach to the Instance. :param boot_type: Boot type to use. - :param bootscript: Bootscript ID to use when `boot_type` is set to `bootscript`. :param organization: Instance Organization ID. One-Of ('project_identifier'): at most one of 'project', 'organization' could be set. :param project: Instance Project ID. @@ -583,7 +577,6 @@ async def _create_server( public_ip=public_ip, public_ips=public_ips, boot_type=boot_type, - bootscript=bootscript, tags=tags, security_group=security_group, placement_group=placement_group, @@ -667,11 +660,9 @@ async def _set_server( id: str, name: str, commercial_type: str, - organization: Optional[str] = None, dynamic_ip_required: bool, hostname: str, - protected: bool, - state_detail: str, + organization: Optional[str] = None, project: Optional[str] = None, allowed_actions: Optional[List[ServerAction]] = None, tags: Optional[List[str]] = None, @@ -679,6 +670,7 @@ async def _set_server( routed_ip_enabled: Optional[bool] = None, enable_ipv6: Optional[bool] = None, image: Optional[Image] = None, + protected: bool, private_ip: Optional[str] = None, public_ip: Optional[ServerIp] = None, public_ips: Optional[List[ServerIp]] = None, @@ -686,8 +678,8 @@ async def _set_server( state: Optional[ServerState] = None, location: Optional[ServerLocation] = None, ipv6: Optional[ServerIpv6] = None, - bootscript: Optional[Bootscript] = None, boot_type: Optional[BootType] = None, + state_detail: str, volumes: Optional[Dict[str, Volume]] = None, security_group: Optional[SecurityGroupSummary] = None, maintenances: Optional[List[ServerMaintenance]] = None, @@ -701,11 +693,9 @@ async def _set_server( :param id: Instance unique ID. :param name: Instance name. :param commercial_type: Instance commercial type (eg. GP1-M). - :param organization: Instance Organization ID. :param dynamic_ip_required: True if a dynamic IPv4 is required. :param hostname: Instance host name. - :param protected: Instance protection option is activated. - :param state_detail: Instance state_detail. + :param organization: Instance Organization ID. :param project: Instance Project ID. :param allowed_actions: Provide a list of allowed actions on the server. :param tags: Tags associated with the Instance. @@ -713,6 +703,7 @@ async def _set_server( :param routed_ip_enabled: True to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False). :param enable_ipv6: True if IPv6 is enabled (deprecated and always `False` when `routed_ip_enabled` is `True`). :param image: Provide information on the Instance image. + :param protected: Instance protection option is activated. :param private_ip: Instance private IP address (deprecated and always `null` when `routed_ip_enabled` is `True`). :param public_ip: Information about the public IP (deprecated in favor of `public_ips`). :param public_ips: Information about all the public IPs attached to the server. @@ -720,8 +711,8 @@ async def _set_server( :param state: Instance state. :param location: Instance location. :param ipv6: Instance IPv6 address (deprecated when `routed_ip_enabled` is `True`). - :param bootscript: Instance bootscript. :param boot_type: Instance boot type. + :param state_detail: Instance state_detail. :param volumes: Instance volumes. :param security_group: Instance security group. :param maintenances: Instance planned maintenances. @@ -776,7 +767,6 @@ async def _set_server( state=state, location=location, ipv6=ipv6, - bootscript=bootscript, boot_type=boot_type, volumes=volumes, security_group=security_group, @@ -802,7 +792,6 @@ async def _update_server( boot_type: Optional[BootType] = None, tags: Optional[List[str]] = None, volumes: Optional[Dict[str, VolumeServerTemplate]] = None, - bootscript: Optional[str] = None, dynamic_ip_required: Optional[bool] = None, routed_ip_enabled: Optional[bool] = None, public_ips: Optional[List[str]] = None, @@ -823,7 +812,6 @@ async def _update_server( :param boot_type: :param tags: Tags of the Instance. :param volumes: - :param bootscript: :param dynamic_ip_required: :param routed_ip_enabled: True to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False). :param public_ips: A list of reserved IP IDs to attach to the Instance. @@ -862,7 +850,6 @@ async def _update_server( boot_type=boot_type, tags=tags, volumes=volumes, - bootscript=bootscript, dynamic_ip_required=dynamic_ip_required, routed_ip_enabled=routed_ip_enabled, public_ips=public_ips, @@ -1270,7 +1257,6 @@ async def create_image( arch: Arch, zone: Optional[Zone] = None, name: Optional[str] = None, - default_bootscript: Optional[str] = None, extra_volumes: Optional[Dict[str, VolumeTemplate]] = None, organization: Optional[str] = None, project: Optional[str] = None, @@ -1284,7 +1270,6 @@ async def create_image( :param arch: Architecture of the image. :param zone: Zone to target. If none is passed will use default zone from the config. :param name: Name of the image. - :param default_bootscript: Default bootscript of the image. :param extra_volumes: Additional volumes of the image. :param organization: Organization ID of the image. One-Of ('project_identifier'): at most one of 'project', 'organization' could be set. @@ -1314,7 +1299,6 @@ async def create_image( arch=arch, zone=zone, name=name or random_name(prefix="img"), - default_bootscript=default_bootscript, extra_volumes=extra_volumes, tags=tags, public=public, @@ -3940,130 +3924,6 @@ async def delete_private_nic( self._throw_on_error(res) - async def list_bootscripts( - self, - *, - zone: Optional[Zone] = None, - arch: Optional[str] = None, - title: Optional[str] = None, - default: Optional[bool] = None, - public: Optional[bool] = None, - per_page: Optional[int] = None, - page: Optional[int] = None, - ) -> ListBootscriptsResponse: - """ - List bootscripts. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param arch: - :param title: - :param default: - :param public: - :param per_page: - :param page: - :return: :class:`ListBootscriptsResponse ` - :deprecated - - Usage: - :: - - result = await api.list_bootscripts() - """ - - param_zone = validate_path_param("zone", zone or self.client.default_zone) - - res = self._request( - "GET", - f"/instance/v1/zones/{param_zone}/bootscripts", - params={ - "arch": arch, - "default": default, - "page": page, - "per_page": per_page or self.client.default_page_size, - "public": public, - "title": title, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListBootscriptsResponse(res.json()) - - async def list_bootscripts_all( - self, - *, - zone: Optional[Zone] = None, - arch: Optional[str] = None, - title: Optional[str] = None, - default: Optional[bool] = None, - public: Optional[bool] = None, - per_page: Optional[int] = None, - page: Optional[int] = None, - ) -> List[Bootscript]: - """ - List bootscripts. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param arch: - :param title: - :param default: - :param public: - :param per_page: - :param page: - :return: :class:`List[Bootscript] ` - :deprecated - - Usage: - :: - - result = await api.list_bootscripts_all() - """ - - return await fetch_all_pages_async( - type=ListBootscriptsResponse, - key="bootscripts", - fetcher=self.list_bootscripts, - args={ - "zone": zone, - "arch": arch, - "title": title, - "default": default, - "public": public, - "per_page": per_page, - "page": page, - }, - ) - - async def get_bootscript( - self, - *, - bootscript_id: str, - zone: Optional[Zone] = None, - ) -> GetBootscriptResponse: - """ - Get bootscripts. - Get details of a bootscript with the specified ID. - :param bootscript_id: - :param zone: Zone to target. If none is passed will use default zone from the config. - :return: :class:`GetBootscriptResponse ` - :deprecated - - Usage: - :: - - result = await api.get_bootscript( - bootscript_id="example", - ) - """ - - param_zone = validate_path_param("zone", zone or self.client.default_zone) - param_bootscript_id = validate_path_param("bootscript_id", bootscript_id) - - res = self._request( - "GET", - f"/instance/v1/zones/{param_zone}/bootscripts/{param_bootscript_id}", - ) - - self._throw_on_error(res) - return unmarshal_GetBootscriptResponse(res.json()) - async def get_dashboard( self, *, diff --git a/scaleway-async/scaleway_async/instance/v1/marshalling.py b/scaleway-async/scaleway_async/instance/v1/marshalling.py index 128b20744..2fb081f97 100644 --- a/scaleway-async/scaleway_async/instance/v1/marshalling.py +++ b/scaleway-async/scaleway_async/instance/v1/marshalling.py @@ -55,7 +55,6 @@ CreateVolumeResponse, DetachServerVolumeResponse, ExportSnapshotResponse, - GetBootscriptResponse, Dashboard, GetDashboardResponse, GetImageResponse, @@ -71,7 +70,6 @@ GetServerTypesAvailabilityResponse, GetSnapshotResponse, GetVolumeResponse, - ListBootscriptsResponse, ListImagesResponse, ListIpsResponse, ListPlacementGroupsResponse, @@ -208,6 +206,10 @@ def unmarshal_Bootscript(data: Any) -> Bootscript: args: Dict[str, Any] = {} + field = data.get("architecture", None) + if field is not None: + args["architecture"] = field + field = data.get("bootcmdargs", None) if field is not None: args["bootcmdargs"] = field @@ -236,10 +238,6 @@ def unmarshal_Bootscript(data: Any) -> Bootscript: if field is not None: args["organization"] = field - field = data.get("project", None) - if field is not None: - args["project"] = field - field = data.get("public", None) if field is not None: args["public"] = field @@ -248,9 +246,9 @@ def unmarshal_Bootscript(data: Any) -> Bootscript: if field is not None: args["title"] = field - field = data.get("architecture", None) + field = data.get("project", None) if field is not None: - args["architecture"] = field + args["project"] = field field = data.get("zone", None) if field is not None: @@ -829,6 +827,22 @@ def unmarshal_Server(data: Any) -> Server: else None ) + field = data.get("maintenances", None) + if field is not None: + args["maintenances"] = ( + [unmarshal_ServerMaintenance(v) for v in field] + if field is not None + else None + ) + + field = data.get("state_detail", None) + if field is not None: + args["state_detail"] = field + + field = data.get("arch", None) + if field is not None: + args["arch"] = field + field = data.get("modification_date", None) if field is not None: args["modification_date"] = ( @@ -849,27 +863,17 @@ def unmarshal_Server(data: Any) -> Server: else: args["ipv6"] = None - field = data.get("bootscript", None) + field = data.get("security_group", None) if field is not None: - args["bootscript"] = unmarshal_Bootscript(field) + args["security_group"] = unmarshal_SecurityGroupSummary(field) else: - args["bootscript"] = None - - field = data.get("maintenances", None) - if field is not None: - args["maintenances"] = ( - [unmarshal_ServerMaintenance(v) for v in field] - if field is not None - else None - ) - - field = data.get("state_detail", None) - if field is not None: - args["state_detail"] = field + args["security_group"] = None - field = data.get("arch", None) + field = data.get("placement_group", None) if field is not None: - args["arch"] = field + args["placement_group"] = unmarshal_PlacementGroup(field) + else: + args["placement_group"] = None field = data.get("private_nics", None) if field is not None: @@ -881,18 +885,6 @@ def unmarshal_Server(data: Any) -> Server: if field is not None: args["zone"] = field - field = data.get("security_group", None) - if field is not None: - args["security_group"] = unmarshal_SecurityGroupSummary(field) - else: - args["security_group"] = None - - field = data.get("placement_group", None) - if field is not None: - args["placement_group"] = unmarshal_PlacementGroup(field) - else: - args["placement_group"] = None - field = data.get("admin_password_encryption_ssh_key_id", None) if field is not None: args["admin_password_encryption_ssh_key_id"] = field @@ -1476,23 +1468,6 @@ def unmarshal_ExportSnapshotResponse(data: Any) -> ExportSnapshotResponse: return ExportSnapshotResponse(**args) -def unmarshal_GetBootscriptResponse(data: Any) -> GetBootscriptResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'GetBootscriptResponse' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("bootscript", None) - if field is not None: - args["bootscript"] = unmarshal_Bootscript(field) - else: - args["bootscript"] = None - - return GetBootscriptResponse(**args) - - def unmarshal_Dashboard(data: Any) -> Dashboard: if not isinstance(data, dict): raise TypeError( @@ -1823,27 +1798,6 @@ def unmarshal_GetVolumeResponse(data: Any) -> GetVolumeResponse: return GetVolumeResponse(**args) -def unmarshal_ListBootscriptsResponse(data: Any) -> ListBootscriptsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListBootscriptsResponse' 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("bootscripts", None) - if field is not None: - args["bootscripts"] = ( - [unmarshal_Bootscript(v) for v in field] if field is not None else None - ) - - return ListBootscriptsResponse(**args) - - def unmarshal_ListImagesResponse(data: Any) -> ListImagesResponse: if not isinstance(data, dict): raise TypeError( @@ -2825,9 +2779,6 @@ def marshal_CreateImageRequest( if request.name is not None: output["name"] = request.name - if request.default_bootscript is not None: - output["default_bootscript"] = request.default_bootscript - if request.extra_volumes is not None: output["extra_volumes"] = { key: marshal_VolumeTemplate(value, defaults) @@ -3102,9 +3053,6 @@ def marshal_CreateServerRequest( if request.boot_type is not None: output["boot_type"] = str(request.boot_type) - if request.bootscript is not None: - output["bootscript"] = request.bootscript - if request.tags is not None: output["tags"] = request.tags @@ -3304,6 +3252,9 @@ def marshal_Bootscript( ) -> Dict[str, Any]: output: Dict[str, Any] = {} + if request.architecture is not None: + output["architecture"] = str(request.architecture) + if request.bootcmdargs is not None: output["bootcmdargs"] = request.bootcmdargs @@ -3327,17 +3278,14 @@ def marshal_Bootscript( request.organization or defaults.default_organization_id ) - if request.project is not None: - output["project"] = request.project or defaults.default_project_id - if request.public is not None: output["public"] = request.public if request.title is not None: output["title"] = request.title - if request.architecture is not None: - output["architecture"] = str(request.architecture) + if request.project is not None: + output["project"] = request.project or defaults.default_project_id if request.zone is not None: output["zone"] = request.zone or defaults.default_zone @@ -3773,9 +3721,6 @@ def marshal_UpdateServerRequest( for key, value in request.volumes.items() } - if request.bootscript is not None: - output["bootscript"] = request.bootscript - if request.dynamic_ip_required is not None: output["dynamic_ip_required"] = request.dynamic_ip_required @@ -4247,9 +4192,6 @@ def marshal__SetServerRequest( if request.ipv6 is not None: output["ipv6"] = marshal_ServerIpv6(request.ipv6, defaults) - if request.bootscript is not None: - output["bootscript"] = marshal_Bootscript(request.bootscript, defaults) - if request.boot_type is not None: output["boot_type"] = str(request.boot_type) diff --git a/scaleway-async/scaleway_async/instance/v1/types.py b/scaleway-async/scaleway_async/instance/v1/types.py index 185efdfda..a31a50b14 100644 --- a/scaleway-async/scaleway_async/instance/v1/types.py +++ b/scaleway-async/scaleway_async/instance/v1/types.py @@ -308,64 +308,31 @@ class ServerSummary: @dataclass class Bootscript: + architecture: Arch + bootcmdargs: str - """ - Bootscript arguments. - """ default: bool - """ - Display if the bootscript is the default bootscript (if no other boot option is configured). - """ dtb: str - """ - Provide information regarding a Device Tree Binary (DTB) for use with C1 servers. - """ id: str - """ - Bootscript ID. - """ initrd: str - """ - Initrd (initial ramdisk) configuration. - """ kernel: str - """ - Instance kernel version. - """ organization: str - """ - Bootscript Organization ID. - """ - - project: str - """ - Bootscript Project ID. - """ public: bool - """ - Provide information if the bootscript is public. - """ title: str - """ - Bootscript title. - """ - architecture: Arch - """ - Bootscript architecture. - """ + project: str zone: Zone """ - Zone in which the bootscript is located. + Zone to target. If none is passed will use default zone from the config. """ @@ -912,11 +879,6 @@ class Server: Instance IPv6 address (deprecated when `routed_ip_enabled` is `True`). """ - bootscript: Optional[Bootscript] - """ - Instance bootscript. - """ - maintenances: List[ServerMaintenance] """ Instance planned maintenance. @@ -1562,11 +1524,6 @@ class CreateImageRequest: Name of the image. """ - default_bootscript: Optional[str] - """ - Default bootscript of the image. - """ - extra_volumes: Optional[Dict[str, VolumeTemplate]] """ Additional volumes of the image. @@ -1858,11 +1815,6 @@ class CreateServerRequest: Boot type to use. """ - bootscript: Optional[str] - """ - Bootscript ID to use when `boot_type` is set to `bootscript`. - """ - tags: Optional[List[str]] """ Instance tags. @@ -2165,21 +2117,6 @@ class ExportSnapshotResponse: task: Optional[Task] -@dataclass -class GetBootscriptRequest: - bootscript_id: str - - zone: Optional[Zone] - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetBootscriptResponse: - bootscript: Optional[Bootscript] - - @dataclass class GetDashboardRequest: zone: Optional[Zone] @@ -2412,39 +2349,6 @@ class GetVolumeResponse: volume: Optional[Volume] -@dataclass -class ListBootscriptsRequest: - zone: Optional[Zone] - """ - Zone to target. If none is passed will use default zone from the config. - """ - - arch: Optional[str] - - title: Optional[str] - - default: Optional[bool] - - public: Optional[bool] - - per_page: Optional[int] - - page: Optional[int] - - -@dataclass -class ListBootscriptsResponse: - total_count: int - """ - Total number of bootscripts. - """ - - bootscripts: List[Bootscript] - """ - List of bootscripts. - """ - - @dataclass class ListDefaultSecurityGroupRulesRequest: zone: Optional[Zone] @@ -3509,8 +3413,6 @@ class UpdateServerRequest: volumes: Optional[Dict[str, VolumeServerTemplate]] - bootscript: Optional[str] - dynamic_ip_required: Optional[bool] routed_ip_enabled: Optional[bool] diff --git a/scaleway-async/scaleway_async/instance/v1/types_private.py b/scaleway-async/scaleway_async/instance/v1/types_private.py index 26165b3d2..517b22f86 100644 --- a/scaleway-async/scaleway_async/instance/v1/types_private.py +++ b/scaleway-async/scaleway_async/instance/v1/types_private.py @@ -22,7 +22,6 @@ SnapshotState, VolumeVolumeType, ServerSummary, - Bootscript, Volume, Image, PlacementGroup, @@ -236,10 +235,6 @@ class _SetServerRequest: """ Instance IPv6 address (deprecated when `routed_ip_enabled` is `True`). """ - bootscript: Optional[Bootscript] - """ - Instance bootscript. - """ boot_type: Optional[BootType] """ Instance boot type. diff --git a/scaleway-async/scaleway_async/jobs/v1alpha1/__init__.py b/scaleway-async/scaleway_async/jobs/v1alpha1/__init__.py index 04ecb8c68..91ec71677 100644 --- a/scaleway-async/scaleway_async/jobs/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/jobs/v1alpha1/__init__.py @@ -4,16 +4,26 @@ from .content import JOB_RUN_TRANSIENT_STATUSES from .types import ListJobDefinitionsRequestOrderBy from .types import ListJobRunsRequestOrderBy +from .types import SecretEnvVar +from .types import SecretFile from .types import CronSchedule from .types import CreateJobDefinitionRequestCronScheduleConfig +from .types import CreateJobDefinitionSecretsRequestSecretConfig +from .types import Secret from .types import JobDefinition from .types import JobRun from .types import Resource from .types import UpdateJobDefinitionRequestCronScheduleConfig from .types import CreateJobDefinitionRequest +from .types import CreateJobDefinitionSecretsRequest +from .types import CreateJobDefinitionSecretsResponse from .types import DeleteJobDefinitionRequest +from .types import DeleteJobDefinitionSecretRequest from .types import GetJobDefinitionRequest +from .types import GetJobDefinitionSecretRequest from .types import GetJobRunRequest +from .types import ListJobDefinitionSecretsRequest +from .types import ListJobDefinitionSecretsResponse from .types import ListJobDefinitionsRequest from .types import ListJobDefinitionsResponse from .types import ListJobRunsRequest @@ -24,6 +34,7 @@ from .types import StartJobDefinitionResponse from .types import StopJobRunRequest from .types import UpdateJobDefinitionRequest +from .types import UpdateJobDefinitionSecretRequest from .api import JobsV1Alpha1API __all__ = [ @@ -31,16 +42,26 @@ "JOB_RUN_TRANSIENT_STATUSES", "ListJobDefinitionsRequestOrderBy", "ListJobRunsRequestOrderBy", + "SecretEnvVar", + "SecretFile", "CronSchedule", "CreateJobDefinitionRequestCronScheduleConfig", + "CreateJobDefinitionSecretsRequestSecretConfig", + "Secret", "JobDefinition", "JobRun", "Resource", "UpdateJobDefinitionRequestCronScheduleConfig", "CreateJobDefinitionRequest", + "CreateJobDefinitionSecretsRequest", + "CreateJobDefinitionSecretsResponse", "DeleteJobDefinitionRequest", + "DeleteJobDefinitionSecretRequest", "GetJobDefinitionRequest", + "GetJobDefinitionSecretRequest", "GetJobRunRequest", + "ListJobDefinitionSecretsRequest", + "ListJobDefinitionSecretsResponse", "ListJobDefinitionsRequest", "ListJobDefinitionsResponse", "ListJobRunsRequest", @@ -51,5 +72,6 @@ "StartJobDefinitionResponse", "StopJobRunRequest", "UpdateJobDefinitionRequest", + "UpdateJobDefinitionSecretRequest", "JobsV1Alpha1API", ] diff --git a/scaleway-async/scaleway_async/jobs/v1alpha1/api.py b/scaleway-async/scaleway_async/jobs/v1alpha1/api.py index a3b9090c4..a402596fa 100644 --- a/scaleway-async/scaleway_async/jobs/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/jobs/v1alpha1/api.py @@ -17,26 +17,37 @@ ListJobRunsRequestOrderBy, CreateJobDefinitionRequest, CreateJobDefinitionRequestCronScheduleConfig, + CreateJobDefinitionSecretsRequest, + CreateJobDefinitionSecretsRequestSecretConfig, + CreateJobDefinitionSecretsResponse, JobDefinition, JobRun, + ListJobDefinitionSecretsResponse, ListJobDefinitionsResponse, ListJobRunsResponse, ListJobsResourcesResponse, + Secret, StartJobDefinitionRequest, StartJobDefinitionResponse, UpdateJobDefinitionRequest, UpdateJobDefinitionRequestCronScheduleConfig, + UpdateJobDefinitionSecretRequest, ) from .marshalling import ( + unmarshal_Secret, unmarshal_JobDefinition, unmarshal_JobRun, + unmarshal_CreateJobDefinitionSecretsResponse, + unmarshal_ListJobDefinitionSecretsResponse, unmarshal_ListJobDefinitionsResponse, unmarshal_ListJobRunsResponse, unmarshal_ListJobsResourcesResponse, unmarshal_StartJobDefinitionResponse, marshal_CreateJobDefinitionRequest, + marshal_CreateJobDefinitionSecretsRequest, marshal_StartJobDefinitionRequest, marshal_UpdateJobDefinitionRequest, + marshal_UpdateJobDefinitionSecretRequest, ) @@ -395,6 +406,216 @@ async def start_job_definition( self._throw_on_error(res) return unmarshal_StartJobDefinitionResponse(res.json()) + async def create_job_definition_secrets( + self, + *, + job_definition_id: str, + secrets: List[CreateJobDefinitionSecretsRequestSecretConfig], + region: Optional[Region] = None, + ) -> CreateJobDefinitionSecretsResponse: + """ + :param job_definition_id: UUID of the job definition to get. + :param secrets: Secrets to inject into the job. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`CreateJobDefinitionSecretsResponse ` + + Usage: + :: + + result = await api.create_job_definition_secrets( + job_definition_id="example", + secrets=[], + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + + res = self._request( + "POST", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets", + body=marshal_CreateJobDefinitionSecretsRequest( + CreateJobDefinitionSecretsRequest( + job_definition_id=job_definition_id, + secrets=secrets, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CreateJobDefinitionSecretsResponse(res.json()) + + async def get_job_definition_secret( + self, + *, + job_definition_id: str, + secret_id: str, + region: Optional[Region] = None, + ) -> Secret: + """ + :param job_definition_id: + :param secret_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Secret ` + + Usage: + :: + + result = await api.get_job_definition_secret( + job_definition_id="example", + secret_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + param_secret_id = validate_path_param("secret_id", secret_id) + + res = self._request( + "GET", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets/{param_secret_id}", + ) + + self._throw_on_error(res) + return unmarshal_Secret(res.json()) + + async def list_job_definition_secrets( + self, + *, + job_definition_id: str, + region: Optional[Region] = None, + ) -> ListJobDefinitionSecretsResponse: + """ + :param job_definition_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ListJobDefinitionSecretsResponse ` + + Usage: + :: + + result = await api.list_job_definition_secrets( + job_definition_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + + res = self._request( + "GET", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets", + ) + + self._throw_on_error(res) + return unmarshal_ListJobDefinitionSecretsResponse(res.json()) + + async def update_job_definition_secret( + self, + *, + job_definition_id: str, + secret_id: str, + region: Optional[Region] = None, + secret_manager_version: Optional[str] = None, + path: Optional[str] = None, + env_var_name: Optional[str] = None, + ) -> Secret: + """ + :param job_definition_id: + :param secret_id: + :param region: Region to target. If none is passed will use default region from the config. + :param secret_manager_version: + :param path: + One-Of ('secret_config'): at most one of 'path', 'env_var_name' could be set. + :param env_var_name: + One-Of ('secret_config'): at most one of 'path', 'env_var_name' could be set. + :return: :class:`Secret ` + + Usage: + :: + + result = await api.update_job_definition_secret( + job_definition_id="example", + secret_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + param_secret_id = validate_path_param("secret_id", secret_id) + + res = self._request( + "PATCH", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets/{param_secret_id}", + body=marshal_UpdateJobDefinitionSecretRequest( + UpdateJobDefinitionSecretRequest( + job_definition_id=job_definition_id, + secret_id=secret_id, + region=region, + secret_manager_version=secret_manager_version, + path=path, + env_var_name=env_var_name, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Secret(res.json()) + + async def delete_job_definition_secret( + self, + *, + job_definition_id: str, + secret_id: str, + region: Optional[Region] = None, + ) -> None: + """ + :param job_definition_id: + :param secret_id: + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_job_definition_secret( + job_definition_id="example", + secret_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + param_secret_id = validate_path_param("secret_id", secret_id) + + res = self._request( + "DELETE", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets/{param_secret_id}", + ) + + self._throw_on_error(res) + async def get_job_run( self, *, diff --git a/scaleway-async/scaleway_async/jobs/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/jobs/v1alpha1/marshalling.py index 0d63fb1c5..649c6a891 100644 --- a/scaleway-async/scaleway_async/jobs/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/jobs/v1alpha1/marshalling.py @@ -5,10 +5,19 @@ from dateutil import parser from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) from .types import ( + SecretEnvVar, + SecretFile, + Secret, CronSchedule, JobDefinition, JobRun, + CreateJobDefinitionSecretsResponse, + ListJobDefinitionSecretsResponse, ListJobDefinitionsResponse, ListJobRunsResponse, Resource, @@ -16,12 +25,80 @@ StartJobDefinitionResponse, CreateJobDefinitionRequestCronScheduleConfig, CreateJobDefinitionRequest, + CreateJobDefinitionSecretsRequestSecretConfig, + CreateJobDefinitionSecretsRequest, StartJobDefinitionRequest, UpdateJobDefinitionRequestCronScheduleConfig, UpdateJobDefinitionRequest, + UpdateJobDefinitionSecretRequest, ) +def unmarshal_SecretEnvVar(data: Any) -> SecretEnvVar: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SecretEnvVar' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + return SecretEnvVar(**args) + + +def unmarshal_SecretFile(data: Any) -> SecretFile: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SecretFile' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("path", None) + if field is not None: + args["path"] = field + + return SecretFile(**args) + + +def unmarshal_Secret(data: Any) -> Secret: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Secret' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secret_id", None) + if field is not None: + args["secret_id"] = field + + field = data.get("secret_manager_id", None) + if field is not None: + args["secret_manager_id"] = field + + field = data.get("secret_manager_version", None) + if field is not None: + args["secret_manager_version"] = field + + field = data.get("file", None) + if field is not None: + args["file"] = unmarshal_SecretFile(field) + else: + args["file"] = None + + field = data.get("env_var", None) + if field is not None: + args["env_var"] = unmarshal_SecretEnvVar(field) + else: + args["env_var"] = None + + return Secret(**args) + + def unmarshal_CronSchedule(data: Any) -> CronSchedule: if not isinstance(data, dict): raise TypeError( @@ -209,6 +286,48 @@ def unmarshal_JobRun(data: Any) -> JobRun: return JobRun(**args) +def unmarshal_CreateJobDefinitionSecretsResponse( + data: Any, +) -> CreateJobDefinitionSecretsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CreateJobDefinitionSecretsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secrets", None) + if field is not None: + args["secrets"] = ( + [unmarshal_Secret(v) for v in field] if field is not None else None + ) + + return CreateJobDefinitionSecretsResponse(**args) + + +def unmarshal_ListJobDefinitionSecretsResponse( + data: Any, +) -> ListJobDefinitionSecretsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListJobDefinitionSecretsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secrets", None) + if field is not None: + args["secrets"] = ( + [unmarshal_Secret(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 + + return ListJobDefinitionSecretsResponse(**args) + + def unmarshal_ListJobDefinitionsResponse(data: Any) -> ListJobDefinitionsResponse: if not isinstance(data, dict): raise TypeError( @@ -365,6 +484,44 @@ def marshal_CreateJobDefinitionRequest( return output +def marshal_CreateJobDefinitionSecretsRequestSecretConfig( + request: CreateJobDefinitionSecretsRequestSecretConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("path", request.path), + OneOfPossibility("env_var_name", request.env_var_name), + ] + ), + ) + + if request.secret_manager_id is not None: + output["secret_manager_id"] = request.secret_manager_id + + if request.secret_manager_version is not None: + output["secret_manager_version"] = request.secret_manager_version + + return output + + +def marshal_CreateJobDefinitionSecretsRequest( + request: CreateJobDefinitionSecretsRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.secrets is not None: + output["secrets"] = [ + marshal_CreateJobDefinitionSecretsRequestSecretConfig(item, defaults) + for item in request.secrets + ] + + return output + + def marshal_StartJobDefinitionRequest( request: StartJobDefinitionRequest, defaults: ProfileDefaults, @@ -437,3 +594,23 @@ def marshal_UpdateJobDefinitionRequest( ) return output + + +def marshal_UpdateJobDefinitionSecretRequest( + request: UpdateJobDefinitionSecretRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("path", request.path), + OneOfPossibility("env_var_name", request.env_var_name), + ] + ), + ) + + if request.secret_manager_version is not None: + output["secret_manager_version"] = request.secret_manager_version + + return output diff --git a/scaleway-async/scaleway_async/jobs/v1alpha1/types.py b/scaleway-async/scaleway_async/jobs/v1alpha1/types.py index 3e9dad045..b1ae41e00 100644 --- a/scaleway-async/scaleway_async/jobs/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/jobs/v1alpha1/types.py @@ -45,6 +45,16 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class SecretEnvVar: + name: str + + +@dataclass +class SecretFile: + path: str + + @dataclass class CronSchedule: schedule: str @@ -65,6 +75,30 @@ class CreateJobDefinitionRequestCronScheduleConfig: timezone: str +@dataclass +class CreateJobDefinitionSecretsRequestSecretConfig: + secret_manager_id: str + + secret_manager_version: str + + path: Optional[str] + + env_var_name: Optional[str] + + +@dataclass +class Secret: + secret_id: str + + secret_manager_id: str + + secret_manager_version: str + + file: Optional[SecretFile] + + env_var: Optional[SecretEnvVar] + + @dataclass class JobDefinition: id: str @@ -216,6 +250,29 @@ class CreateJobDefinitionRequest: """ +@dataclass +class CreateJobDefinitionSecretsRequest: + job_definition_id: str + """ + UUID of the job definition to get. + """ + + secrets: List[CreateJobDefinitionSecretsRequestSecretConfig] + """ + Secrets to inject into the job. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class CreateJobDefinitionSecretsResponse: + secrets: List[Secret] + + @dataclass class DeleteJobDefinitionRequest: job_definition_id: str @@ -229,6 +286,18 @@ class DeleteJobDefinitionRequest: """ +@dataclass +class DeleteJobDefinitionSecretRequest: + job_definition_id: str + + secret_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class GetJobDefinitionRequest: job_definition_id: str @@ -242,6 +311,18 @@ class GetJobDefinitionRequest: """ +@dataclass +class GetJobDefinitionSecretRequest: + job_definition_id: str + + secret_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class GetJobRunRequest: job_run_id: str @@ -255,6 +336,23 @@ class GetJobRunRequest: """ +@dataclass +class ListJobDefinitionSecretsRequest: + job_definition_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListJobDefinitionSecretsResponse: + secrets: List[Secret] + + total_count: int + + @dataclass class ListJobDefinitionsRequest: region: Optional[Region] @@ -424,3 +522,21 @@ class UpdateJobDefinitionRequest: """ cron_schedule: Optional[UpdateJobDefinitionRequestCronScheduleConfig] + + +@dataclass +class UpdateJobDefinitionSecretRequest: + job_definition_id: str + + secret_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + secret_manager_version: Optional[str] + + path: Optional[str] + + env_var_name: Optional[str] diff --git a/scaleway/scaleway/iam/v1alpha1/marshalling.py b/scaleway/scaleway/iam/v1alpha1/marshalling.py index 51868f293..e64f626ff 100644 --- a/scaleway/scaleway/iam/v1alpha1/marshalling.py +++ b/scaleway/scaleway/iam/v1alpha1/marshalling.py @@ -126,18 +126,6 @@ def unmarshal_APIKey(data: Any) -> APIKey: if field is not None: args["default_project_id"] = field - field = data.get("editable", None) - if field is not None: - args["editable"] = field - - field = data.get("managed", None) - if field is not None: - args["managed"] = field - - field = data.get("creation_ip", None) - if field is not None: - args["creation_ip"] = field - field = data.get("secret_key", None) if field is not None: args["secret_key"] = field @@ -150,6 +138,22 @@ def unmarshal_APIKey(data: Any) -> APIKey: else: args["application_id"] = None + field = data.get("editable", None) + if field is not None: + args["editable"] = field + + field = data.get("deletable", None) + if field is not None: + args["deletable"] = field + + field = data.get("managed", None) + if field is not None: + args["managed"] = field + + field = data.get("creation_ip", None) + if field is not None: + args["creation_ip"] = field + field = data.get("user_id", None) if field is not None: args["user_id"] = field diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index f8ce6abc9..1a7e65e2b 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -287,6 +287,11 @@ class APIKey: Defines whether or not the API key is editable. """ + deletable: bool + """ + Defines whether or not the API key is deletable. + """ + managed: bool """ Defines whether or not the API key is managed. diff --git a/scaleway/scaleway/instance/v1/__init__.py b/scaleway/scaleway/instance/v1/__init__.py index 8f2320f26..a5563e97a 100644 --- a/scaleway/scaleway/instance/v1/__init__.py +++ b/scaleway/scaleway/instance/v1/__init__.py @@ -111,8 +111,6 @@ from .types import DetachServerVolumeResponse from .types import ExportSnapshotRequest from .types import ExportSnapshotResponse -from .types import GetBootscriptRequest -from .types import GetBootscriptResponse from .types import GetDashboardRequest from .types import GetDashboardResponse from .types import GetImageRequest @@ -137,8 +135,6 @@ from .types import GetSnapshotResponse from .types import GetVolumeRequest from .types import GetVolumeResponse -from .types import ListBootscriptsRequest -from .types import ListBootscriptsResponse from .types import ListDefaultSecurityGroupRulesRequest from .types import ListImagesRequest from .types import ListImagesResponse @@ -310,8 +306,6 @@ "DetachServerVolumeResponse", "ExportSnapshotRequest", "ExportSnapshotResponse", - "GetBootscriptRequest", - "GetBootscriptResponse", "GetDashboardRequest", "GetDashboardResponse", "GetImageRequest", @@ -336,8 +330,6 @@ "GetSnapshotResponse", "GetVolumeRequest", "GetVolumeResponse", - "ListBootscriptsRequest", - "ListBootscriptsResponse", "ListDefaultSecurityGroupRulesRequest", "ListImagesRequest", "ListImagesResponse", diff --git a/scaleway/scaleway/instance/v1/api.py b/scaleway/scaleway/instance/v1/api.py index c59291c20..47b0545b4 100644 --- a/scaleway/scaleway/instance/v1/api.py +++ b/scaleway/scaleway/instance/v1/api.py @@ -68,7 +68,6 @@ DetachServerVolumeResponse, ExportSnapshotRequest, ExportSnapshotResponse, - GetBootscriptResponse, GetDashboardResponse, GetImageResponse, GetIpResponse, @@ -83,7 +82,6 @@ GetVolumeResponse, Image, Ip, - ListBootscriptsResponse, ListImagesResponse, ListIpsResponse, ListPlacementGroupsResponse, @@ -163,7 +161,6 @@ unmarshal_CreateVolumeResponse, unmarshal_DetachServerVolumeResponse, unmarshal_ExportSnapshotResponse, - unmarshal_GetBootscriptResponse, unmarshal_GetDashboardResponse, unmarshal_GetImageResponse, unmarshal_GetIpResponse, @@ -176,7 +173,6 @@ unmarshal_GetServerTypesAvailabilityResponse, unmarshal_GetSnapshotResponse, unmarshal_GetVolumeResponse, - unmarshal_ListBootscriptsResponse, unmarshal_ListImagesResponse, unmarshal_ListIpsResponse, unmarshal_ListPlacementGroupsResponse, @@ -522,7 +518,6 @@ def _create_server( public_ip: Optional[str] = None, public_ips: Optional[List[str]] = None, boot_type: Optional[BootType] = None, - bootscript: Optional[str] = None, organization: Optional[str] = None, project: Optional[str] = None, tags: Optional[List[str]] = None, @@ -545,7 +540,6 @@ def _create_server( :param public_ip: ID of the reserved IP to attach to the Instance. :param public_ips: A list of reserved IP IDs to attach to the Instance. :param boot_type: Boot type to use. - :param bootscript: Bootscript ID to use when `boot_type` is set to `bootscript`. :param organization: Instance Organization ID. One-Of ('project_identifier'): at most one of 'project', 'organization' could be set. :param project: Instance Project ID. @@ -583,7 +577,6 @@ def _create_server( public_ip=public_ip, public_ips=public_ips, boot_type=boot_type, - bootscript=bootscript, tags=tags, security_group=security_group, placement_group=placement_group, @@ -667,11 +660,9 @@ def _set_server( id: str, name: str, commercial_type: str, - organization: Optional[str] = None, dynamic_ip_required: bool, hostname: str, - protected: bool, - state_detail: str, + organization: Optional[str] = None, project: Optional[str] = None, allowed_actions: Optional[List[ServerAction]] = None, tags: Optional[List[str]] = None, @@ -679,6 +670,7 @@ def _set_server( routed_ip_enabled: Optional[bool] = None, enable_ipv6: Optional[bool] = None, image: Optional[Image] = None, + protected: bool, private_ip: Optional[str] = None, public_ip: Optional[ServerIp] = None, public_ips: Optional[List[ServerIp]] = None, @@ -686,8 +678,8 @@ def _set_server( state: Optional[ServerState] = None, location: Optional[ServerLocation] = None, ipv6: Optional[ServerIpv6] = None, - bootscript: Optional[Bootscript] = None, boot_type: Optional[BootType] = None, + state_detail: str, volumes: Optional[Dict[str, Volume]] = None, security_group: Optional[SecurityGroupSummary] = None, maintenances: Optional[List[ServerMaintenance]] = None, @@ -701,11 +693,9 @@ def _set_server( :param id: Instance unique ID. :param name: Instance name. :param commercial_type: Instance commercial type (eg. GP1-M). - :param organization: Instance Organization ID. :param dynamic_ip_required: True if a dynamic IPv4 is required. :param hostname: Instance host name. - :param protected: Instance protection option is activated. - :param state_detail: Instance state_detail. + :param organization: Instance Organization ID. :param project: Instance Project ID. :param allowed_actions: Provide a list of allowed actions on the server. :param tags: Tags associated with the Instance. @@ -713,6 +703,7 @@ def _set_server( :param routed_ip_enabled: True to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False). :param enable_ipv6: True if IPv6 is enabled (deprecated and always `False` when `routed_ip_enabled` is `True`). :param image: Provide information on the Instance image. + :param protected: Instance protection option is activated. :param private_ip: Instance private IP address (deprecated and always `null` when `routed_ip_enabled` is `True`). :param public_ip: Information about the public IP (deprecated in favor of `public_ips`). :param public_ips: Information about all the public IPs attached to the server. @@ -720,8 +711,8 @@ def _set_server( :param state: Instance state. :param location: Instance location. :param ipv6: Instance IPv6 address (deprecated when `routed_ip_enabled` is `True`). - :param bootscript: Instance bootscript. :param boot_type: Instance boot type. + :param state_detail: Instance state_detail. :param volumes: Instance volumes. :param security_group: Instance security group. :param maintenances: Instance planned maintenances. @@ -776,7 +767,6 @@ def _set_server( state=state, location=location, ipv6=ipv6, - bootscript=bootscript, boot_type=boot_type, volumes=volumes, security_group=security_group, @@ -802,7 +792,6 @@ def _update_server( boot_type: Optional[BootType] = None, tags: Optional[List[str]] = None, volumes: Optional[Dict[str, VolumeServerTemplate]] = None, - bootscript: Optional[str] = None, dynamic_ip_required: Optional[bool] = None, routed_ip_enabled: Optional[bool] = None, public_ips: Optional[List[str]] = None, @@ -823,7 +812,6 @@ def _update_server( :param boot_type: :param tags: Tags of the Instance. :param volumes: - :param bootscript: :param dynamic_ip_required: :param routed_ip_enabled: True to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False). :param public_ips: A list of reserved IP IDs to attach to the Instance. @@ -862,7 +850,6 @@ def _update_server( boot_type=boot_type, tags=tags, volumes=volumes, - bootscript=bootscript, dynamic_ip_required=dynamic_ip_required, routed_ip_enabled=routed_ip_enabled, public_ips=public_ips, @@ -1270,7 +1257,6 @@ def create_image( arch: Arch, zone: Optional[Zone] = None, name: Optional[str] = None, - default_bootscript: Optional[str] = None, extra_volumes: Optional[Dict[str, VolumeTemplate]] = None, organization: Optional[str] = None, project: Optional[str] = None, @@ -1284,7 +1270,6 @@ def create_image( :param arch: Architecture of the image. :param zone: Zone to target. If none is passed will use default zone from the config. :param name: Name of the image. - :param default_bootscript: Default bootscript of the image. :param extra_volumes: Additional volumes of the image. :param organization: Organization ID of the image. One-Of ('project_identifier'): at most one of 'project', 'organization' could be set. @@ -1314,7 +1299,6 @@ def create_image( arch=arch, zone=zone, name=name or random_name(prefix="img"), - default_bootscript=default_bootscript, extra_volumes=extra_volumes, tags=tags, public=public, @@ -3940,130 +3924,6 @@ def delete_private_nic( self._throw_on_error(res) - def list_bootscripts( - self, - *, - zone: Optional[Zone] = None, - arch: Optional[str] = None, - title: Optional[str] = None, - default: Optional[bool] = None, - public: Optional[bool] = None, - per_page: Optional[int] = None, - page: Optional[int] = None, - ) -> ListBootscriptsResponse: - """ - List bootscripts. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param arch: - :param title: - :param default: - :param public: - :param per_page: - :param page: - :return: :class:`ListBootscriptsResponse ` - :deprecated - - Usage: - :: - - result = api.list_bootscripts() - """ - - param_zone = validate_path_param("zone", zone or self.client.default_zone) - - res = self._request( - "GET", - f"/instance/v1/zones/{param_zone}/bootscripts", - params={ - "arch": arch, - "default": default, - "page": page, - "per_page": per_page or self.client.default_page_size, - "public": public, - "title": title, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListBootscriptsResponse(res.json()) - - def list_bootscripts_all( - self, - *, - zone: Optional[Zone] = None, - arch: Optional[str] = None, - title: Optional[str] = None, - default: Optional[bool] = None, - public: Optional[bool] = None, - per_page: Optional[int] = None, - page: Optional[int] = None, - ) -> List[Bootscript]: - """ - List bootscripts. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param arch: - :param title: - :param default: - :param public: - :param per_page: - :param page: - :return: :class:`List[Bootscript] ` - :deprecated - - Usage: - :: - - result = api.list_bootscripts_all() - """ - - return fetch_all_pages( - type=ListBootscriptsResponse, - key="bootscripts", - fetcher=self.list_bootscripts, - args={ - "zone": zone, - "arch": arch, - "title": title, - "default": default, - "public": public, - "per_page": per_page, - "page": page, - }, - ) - - def get_bootscript( - self, - *, - bootscript_id: str, - zone: Optional[Zone] = None, - ) -> GetBootscriptResponse: - """ - Get bootscripts. - Get details of a bootscript with the specified ID. - :param bootscript_id: - :param zone: Zone to target. If none is passed will use default zone from the config. - :return: :class:`GetBootscriptResponse ` - :deprecated - - Usage: - :: - - result = api.get_bootscript( - bootscript_id="example", - ) - """ - - param_zone = validate_path_param("zone", zone or self.client.default_zone) - param_bootscript_id = validate_path_param("bootscript_id", bootscript_id) - - res = self._request( - "GET", - f"/instance/v1/zones/{param_zone}/bootscripts/{param_bootscript_id}", - ) - - self._throw_on_error(res) - return unmarshal_GetBootscriptResponse(res.json()) - def get_dashboard( self, *, diff --git a/scaleway/scaleway/instance/v1/marshalling.py b/scaleway/scaleway/instance/v1/marshalling.py index 128b20744..2fb081f97 100644 --- a/scaleway/scaleway/instance/v1/marshalling.py +++ b/scaleway/scaleway/instance/v1/marshalling.py @@ -55,7 +55,6 @@ CreateVolumeResponse, DetachServerVolumeResponse, ExportSnapshotResponse, - GetBootscriptResponse, Dashboard, GetDashboardResponse, GetImageResponse, @@ -71,7 +70,6 @@ GetServerTypesAvailabilityResponse, GetSnapshotResponse, GetVolumeResponse, - ListBootscriptsResponse, ListImagesResponse, ListIpsResponse, ListPlacementGroupsResponse, @@ -208,6 +206,10 @@ def unmarshal_Bootscript(data: Any) -> Bootscript: args: Dict[str, Any] = {} + field = data.get("architecture", None) + if field is not None: + args["architecture"] = field + field = data.get("bootcmdargs", None) if field is not None: args["bootcmdargs"] = field @@ -236,10 +238,6 @@ def unmarshal_Bootscript(data: Any) -> Bootscript: if field is not None: args["organization"] = field - field = data.get("project", None) - if field is not None: - args["project"] = field - field = data.get("public", None) if field is not None: args["public"] = field @@ -248,9 +246,9 @@ def unmarshal_Bootscript(data: Any) -> Bootscript: if field is not None: args["title"] = field - field = data.get("architecture", None) + field = data.get("project", None) if field is not None: - args["architecture"] = field + args["project"] = field field = data.get("zone", None) if field is not None: @@ -829,6 +827,22 @@ def unmarshal_Server(data: Any) -> Server: else None ) + field = data.get("maintenances", None) + if field is not None: + args["maintenances"] = ( + [unmarshal_ServerMaintenance(v) for v in field] + if field is not None + else None + ) + + field = data.get("state_detail", None) + if field is not None: + args["state_detail"] = field + + field = data.get("arch", None) + if field is not None: + args["arch"] = field + field = data.get("modification_date", None) if field is not None: args["modification_date"] = ( @@ -849,27 +863,17 @@ def unmarshal_Server(data: Any) -> Server: else: args["ipv6"] = None - field = data.get("bootscript", None) + field = data.get("security_group", None) if field is not None: - args["bootscript"] = unmarshal_Bootscript(field) + args["security_group"] = unmarshal_SecurityGroupSummary(field) else: - args["bootscript"] = None - - field = data.get("maintenances", None) - if field is not None: - args["maintenances"] = ( - [unmarshal_ServerMaintenance(v) for v in field] - if field is not None - else None - ) - - field = data.get("state_detail", None) - if field is not None: - args["state_detail"] = field + args["security_group"] = None - field = data.get("arch", None) + field = data.get("placement_group", None) if field is not None: - args["arch"] = field + args["placement_group"] = unmarshal_PlacementGroup(field) + else: + args["placement_group"] = None field = data.get("private_nics", None) if field is not None: @@ -881,18 +885,6 @@ def unmarshal_Server(data: Any) -> Server: if field is not None: args["zone"] = field - field = data.get("security_group", None) - if field is not None: - args["security_group"] = unmarshal_SecurityGroupSummary(field) - else: - args["security_group"] = None - - field = data.get("placement_group", None) - if field is not None: - args["placement_group"] = unmarshal_PlacementGroup(field) - else: - args["placement_group"] = None - field = data.get("admin_password_encryption_ssh_key_id", None) if field is not None: args["admin_password_encryption_ssh_key_id"] = field @@ -1476,23 +1468,6 @@ def unmarshal_ExportSnapshotResponse(data: Any) -> ExportSnapshotResponse: return ExportSnapshotResponse(**args) -def unmarshal_GetBootscriptResponse(data: Any) -> GetBootscriptResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'GetBootscriptResponse' failed as data isn't a dictionary." - ) - - args: Dict[str, Any] = {} - - field = data.get("bootscript", None) - if field is not None: - args["bootscript"] = unmarshal_Bootscript(field) - else: - args["bootscript"] = None - - return GetBootscriptResponse(**args) - - def unmarshal_Dashboard(data: Any) -> Dashboard: if not isinstance(data, dict): raise TypeError( @@ -1823,27 +1798,6 @@ def unmarshal_GetVolumeResponse(data: Any) -> GetVolumeResponse: return GetVolumeResponse(**args) -def unmarshal_ListBootscriptsResponse(data: Any) -> ListBootscriptsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListBootscriptsResponse' 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("bootscripts", None) - if field is not None: - args["bootscripts"] = ( - [unmarshal_Bootscript(v) for v in field] if field is not None else None - ) - - return ListBootscriptsResponse(**args) - - def unmarshal_ListImagesResponse(data: Any) -> ListImagesResponse: if not isinstance(data, dict): raise TypeError( @@ -2825,9 +2779,6 @@ def marshal_CreateImageRequest( if request.name is not None: output["name"] = request.name - if request.default_bootscript is not None: - output["default_bootscript"] = request.default_bootscript - if request.extra_volumes is not None: output["extra_volumes"] = { key: marshal_VolumeTemplate(value, defaults) @@ -3102,9 +3053,6 @@ def marshal_CreateServerRequest( if request.boot_type is not None: output["boot_type"] = str(request.boot_type) - if request.bootscript is not None: - output["bootscript"] = request.bootscript - if request.tags is not None: output["tags"] = request.tags @@ -3304,6 +3252,9 @@ def marshal_Bootscript( ) -> Dict[str, Any]: output: Dict[str, Any] = {} + if request.architecture is not None: + output["architecture"] = str(request.architecture) + if request.bootcmdargs is not None: output["bootcmdargs"] = request.bootcmdargs @@ -3327,17 +3278,14 @@ def marshal_Bootscript( request.organization or defaults.default_organization_id ) - if request.project is not None: - output["project"] = request.project or defaults.default_project_id - if request.public is not None: output["public"] = request.public if request.title is not None: output["title"] = request.title - if request.architecture is not None: - output["architecture"] = str(request.architecture) + if request.project is not None: + output["project"] = request.project or defaults.default_project_id if request.zone is not None: output["zone"] = request.zone or defaults.default_zone @@ -3773,9 +3721,6 @@ def marshal_UpdateServerRequest( for key, value in request.volumes.items() } - if request.bootscript is not None: - output["bootscript"] = request.bootscript - if request.dynamic_ip_required is not None: output["dynamic_ip_required"] = request.dynamic_ip_required @@ -4247,9 +4192,6 @@ def marshal__SetServerRequest( if request.ipv6 is not None: output["ipv6"] = marshal_ServerIpv6(request.ipv6, defaults) - if request.bootscript is not None: - output["bootscript"] = marshal_Bootscript(request.bootscript, defaults) - if request.boot_type is not None: output["boot_type"] = str(request.boot_type) diff --git a/scaleway/scaleway/instance/v1/types.py b/scaleway/scaleway/instance/v1/types.py index 185efdfda..a31a50b14 100644 --- a/scaleway/scaleway/instance/v1/types.py +++ b/scaleway/scaleway/instance/v1/types.py @@ -308,64 +308,31 @@ class ServerSummary: @dataclass class Bootscript: + architecture: Arch + bootcmdargs: str - """ - Bootscript arguments. - """ default: bool - """ - Display if the bootscript is the default bootscript (if no other boot option is configured). - """ dtb: str - """ - Provide information regarding a Device Tree Binary (DTB) for use with C1 servers. - """ id: str - """ - Bootscript ID. - """ initrd: str - """ - Initrd (initial ramdisk) configuration. - """ kernel: str - """ - Instance kernel version. - """ organization: str - """ - Bootscript Organization ID. - """ - - project: str - """ - Bootscript Project ID. - """ public: bool - """ - Provide information if the bootscript is public. - """ title: str - """ - Bootscript title. - """ - architecture: Arch - """ - Bootscript architecture. - """ + project: str zone: Zone """ - Zone in which the bootscript is located. + Zone to target. If none is passed will use default zone from the config. """ @@ -912,11 +879,6 @@ class Server: Instance IPv6 address (deprecated when `routed_ip_enabled` is `True`). """ - bootscript: Optional[Bootscript] - """ - Instance bootscript. - """ - maintenances: List[ServerMaintenance] """ Instance planned maintenance. @@ -1562,11 +1524,6 @@ class CreateImageRequest: Name of the image. """ - default_bootscript: Optional[str] - """ - Default bootscript of the image. - """ - extra_volumes: Optional[Dict[str, VolumeTemplate]] """ Additional volumes of the image. @@ -1858,11 +1815,6 @@ class CreateServerRequest: Boot type to use. """ - bootscript: Optional[str] - """ - Bootscript ID to use when `boot_type` is set to `bootscript`. - """ - tags: Optional[List[str]] """ Instance tags. @@ -2165,21 +2117,6 @@ class ExportSnapshotResponse: task: Optional[Task] -@dataclass -class GetBootscriptRequest: - bootscript_id: str - - zone: Optional[Zone] - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetBootscriptResponse: - bootscript: Optional[Bootscript] - - @dataclass class GetDashboardRequest: zone: Optional[Zone] @@ -2412,39 +2349,6 @@ class GetVolumeResponse: volume: Optional[Volume] -@dataclass -class ListBootscriptsRequest: - zone: Optional[Zone] - """ - Zone to target. If none is passed will use default zone from the config. - """ - - arch: Optional[str] - - title: Optional[str] - - default: Optional[bool] - - public: Optional[bool] - - per_page: Optional[int] - - page: Optional[int] - - -@dataclass -class ListBootscriptsResponse: - total_count: int - """ - Total number of bootscripts. - """ - - bootscripts: List[Bootscript] - """ - List of bootscripts. - """ - - @dataclass class ListDefaultSecurityGroupRulesRequest: zone: Optional[Zone] @@ -3509,8 +3413,6 @@ class UpdateServerRequest: volumes: Optional[Dict[str, VolumeServerTemplate]] - bootscript: Optional[str] - dynamic_ip_required: Optional[bool] routed_ip_enabled: Optional[bool] diff --git a/scaleway/scaleway/instance/v1/types_private.py b/scaleway/scaleway/instance/v1/types_private.py index 26165b3d2..517b22f86 100644 --- a/scaleway/scaleway/instance/v1/types_private.py +++ b/scaleway/scaleway/instance/v1/types_private.py @@ -22,7 +22,6 @@ SnapshotState, VolumeVolumeType, ServerSummary, - Bootscript, Volume, Image, PlacementGroup, @@ -236,10 +235,6 @@ class _SetServerRequest: """ Instance IPv6 address (deprecated when `routed_ip_enabled` is `True`). """ - bootscript: Optional[Bootscript] - """ - Instance bootscript. - """ boot_type: Optional[BootType] """ Instance boot type. diff --git a/scaleway/scaleway/jobs/v1alpha1/__init__.py b/scaleway/scaleway/jobs/v1alpha1/__init__.py index 04ecb8c68..91ec71677 100644 --- a/scaleway/scaleway/jobs/v1alpha1/__init__.py +++ b/scaleway/scaleway/jobs/v1alpha1/__init__.py @@ -4,16 +4,26 @@ from .content import JOB_RUN_TRANSIENT_STATUSES from .types import ListJobDefinitionsRequestOrderBy from .types import ListJobRunsRequestOrderBy +from .types import SecretEnvVar +from .types import SecretFile from .types import CronSchedule from .types import CreateJobDefinitionRequestCronScheduleConfig +from .types import CreateJobDefinitionSecretsRequestSecretConfig +from .types import Secret from .types import JobDefinition from .types import JobRun from .types import Resource from .types import UpdateJobDefinitionRequestCronScheduleConfig from .types import CreateJobDefinitionRequest +from .types import CreateJobDefinitionSecretsRequest +from .types import CreateJobDefinitionSecretsResponse from .types import DeleteJobDefinitionRequest +from .types import DeleteJobDefinitionSecretRequest from .types import GetJobDefinitionRequest +from .types import GetJobDefinitionSecretRequest from .types import GetJobRunRequest +from .types import ListJobDefinitionSecretsRequest +from .types import ListJobDefinitionSecretsResponse from .types import ListJobDefinitionsRequest from .types import ListJobDefinitionsResponse from .types import ListJobRunsRequest @@ -24,6 +34,7 @@ from .types import StartJobDefinitionResponse from .types import StopJobRunRequest from .types import UpdateJobDefinitionRequest +from .types import UpdateJobDefinitionSecretRequest from .api import JobsV1Alpha1API __all__ = [ @@ -31,16 +42,26 @@ "JOB_RUN_TRANSIENT_STATUSES", "ListJobDefinitionsRequestOrderBy", "ListJobRunsRequestOrderBy", + "SecretEnvVar", + "SecretFile", "CronSchedule", "CreateJobDefinitionRequestCronScheduleConfig", + "CreateJobDefinitionSecretsRequestSecretConfig", + "Secret", "JobDefinition", "JobRun", "Resource", "UpdateJobDefinitionRequestCronScheduleConfig", "CreateJobDefinitionRequest", + "CreateJobDefinitionSecretsRequest", + "CreateJobDefinitionSecretsResponse", "DeleteJobDefinitionRequest", + "DeleteJobDefinitionSecretRequest", "GetJobDefinitionRequest", + "GetJobDefinitionSecretRequest", "GetJobRunRequest", + "ListJobDefinitionSecretsRequest", + "ListJobDefinitionSecretsResponse", "ListJobDefinitionsRequest", "ListJobDefinitionsResponse", "ListJobRunsRequest", @@ -51,5 +72,6 @@ "StartJobDefinitionResponse", "StopJobRunRequest", "UpdateJobDefinitionRequest", + "UpdateJobDefinitionSecretRequest", "JobsV1Alpha1API", ] diff --git a/scaleway/scaleway/jobs/v1alpha1/api.py b/scaleway/scaleway/jobs/v1alpha1/api.py index 6c2ab413c..e3944ad03 100644 --- a/scaleway/scaleway/jobs/v1alpha1/api.py +++ b/scaleway/scaleway/jobs/v1alpha1/api.py @@ -17,26 +17,37 @@ ListJobRunsRequestOrderBy, CreateJobDefinitionRequest, CreateJobDefinitionRequestCronScheduleConfig, + CreateJobDefinitionSecretsRequest, + CreateJobDefinitionSecretsRequestSecretConfig, + CreateJobDefinitionSecretsResponse, JobDefinition, JobRun, + ListJobDefinitionSecretsResponse, ListJobDefinitionsResponse, ListJobRunsResponse, ListJobsResourcesResponse, + Secret, StartJobDefinitionRequest, StartJobDefinitionResponse, UpdateJobDefinitionRequest, UpdateJobDefinitionRequestCronScheduleConfig, + UpdateJobDefinitionSecretRequest, ) from .marshalling import ( + unmarshal_Secret, unmarshal_JobDefinition, unmarshal_JobRun, + unmarshal_CreateJobDefinitionSecretsResponse, + unmarshal_ListJobDefinitionSecretsResponse, unmarshal_ListJobDefinitionsResponse, unmarshal_ListJobRunsResponse, unmarshal_ListJobsResourcesResponse, unmarshal_StartJobDefinitionResponse, marshal_CreateJobDefinitionRequest, + marshal_CreateJobDefinitionSecretsRequest, marshal_StartJobDefinitionRequest, marshal_UpdateJobDefinitionRequest, + marshal_UpdateJobDefinitionSecretRequest, ) @@ -395,6 +406,216 @@ def start_job_definition( self._throw_on_error(res) return unmarshal_StartJobDefinitionResponse(res.json()) + def create_job_definition_secrets( + self, + *, + job_definition_id: str, + secrets: List[CreateJobDefinitionSecretsRequestSecretConfig], + region: Optional[Region] = None, + ) -> CreateJobDefinitionSecretsResponse: + """ + :param job_definition_id: UUID of the job definition to get. + :param secrets: Secrets to inject into the job. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`CreateJobDefinitionSecretsResponse ` + + Usage: + :: + + result = api.create_job_definition_secrets( + job_definition_id="example", + secrets=[], + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + + res = self._request( + "POST", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets", + body=marshal_CreateJobDefinitionSecretsRequest( + CreateJobDefinitionSecretsRequest( + job_definition_id=job_definition_id, + secrets=secrets, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CreateJobDefinitionSecretsResponse(res.json()) + + def get_job_definition_secret( + self, + *, + job_definition_id: str, + secret_id: str, + region: Optional[Region] = None, + ) -> Secret: + """ + :param job_definition_id: + :param secret_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Secret ` + + Usage: + :: + + result = api.get_job_definition_secret( + job_definition_id="example", + secret_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + param_secret_id = validate_path_param("secret_id", secret_id) + + res = self._request( + "GET", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets/{param_secret_id}", + ) + + self._throw_on_error(res) + return unmarshal_Secret(res.json()) + + def list_job_definition_secrets( + self, + *, + job_definition_id: str, + region: Optional[Region] = None, + ) -> ListJobDefinitionSecretsResponse: + """ + :param job_definition_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ListJobDefinitionSecretsResponse ` + + Usage: + :: + + result = api.list_job_definition_secrets( + job_definition_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + + res = self._request( + "GET", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets", + ) + + self._throw_on_error(res) + return unmarshal_ListJobDefinitionSecretsResponse(res.json()) + + def update_job_definition_secret( + self, + *, + job_definition_id: str, + secret_id: str, + region: Optional[Region] = None, + secret_manager_version: Optional[str] = None, + path: Optional[str] = None, + env_var_name: Optional[str] = None, + ) -> Secret: + """ + :param job_definition_id: + :param secret_id: + :param region: Region to target. If none is passed will use default region from the config. + :param secret_manager_version: + :param path: + One-Of ('secret_config'): at most one of 'path', 'env_var_name' could be set. + :param env_var_name: + One-Of ('secret_config'): at most one of 'path', 'env_var_name' could be set. + :return: :class:`Secret ` + + Usage: + :: + + result = api.update_job_definition_secret( + job_definition_id="example", + secret_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + param_secret_id = validate_path_param("secret_id", secret_id) + + res = self._request( + "PATCH", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets/{param_secret_id}", + body=marshal_UpdateJobDefinitionSecretRequest( + UpdateJobDefinitionSecretRequest( + job_definition_id=job_definition_id, + secret_id=secret_id, + region=region, + secret_manager_version=secret_manager_version, + path=path, + env_var_name=env_var_name, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Secret(res.json()) + + def delete_job_definition_secret( + self, + *, + job_definition_id: str, + secret_id: str, + region: Optional[Region] = None, + ) -> None: + """ + :param job_definition_id: + :param secret_id: + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_job_definition_secret( + job_definition_id="example", + secret_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_job_definition_id = validate_path_param( + "job_definition_id", job_definition_id + ) + param_secret_id = validate_path_param("secret_id", secret_id) + + res = self._request( + "DELETE", + f"/serverless-jobs/v1alpha1/regions/{param_region}/job-definitions/{param_job_definition_id}/secrets/{param_secret_id}", + ) + + self._throw_on_error(res) + def get_job_run( self, *, diff --git a/scaleway/scaleway/jobs/v1alpha1/marshalling.py b/scaleway/scaleway/jobs/v1alpha1/marshalling.py index 0d63fb1c5..649c6a891 100644 --- a/scaleway/scaleway/jobs/v1alpha1/marshalling.py +++ b/scaleway/scaleway/jobs/v1alpha1/marshalling.py @@ -5,10 +5,19 @@ from dateutil import parser from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) from .types import ( + SecretEnvVar, + SecretFile, + Secret, CronSchedule, JobDefinition, JobRun, + CreateJobDefinitionSecretsResponse, + ListJobDefinitionSecretsResponse, ListJobDefinitionsResponse, ListJobRunsResponse, Resource, @@ -16,12 +25,80 @@ StartJobDefinitionResponse, CreateJobDefinitionRequestCronScheduleConfig, CreateJobDefinitionRequest, + CreateJobDefinitionSecretsRequestSecretConfig, + CreateJobDefinitionSecretsRequest, StartJobDefinitionRequest, UpdateJobDefinitionRequestCronScheduleConfig, UpdateJobDefinitionRequest, + UpdateJobDefinitionSecretRequest, ) +def unmarshal_SecretEnvVar(data: Any) -> SecretEnvVar: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SecretEnvVar' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + + return SecretEnvVar(**args) + + +def unmarshal_SecretFile(data: Any) -> SecretFile: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SecretFile' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("path", None) + if field is not None: + args["path"] = field + + return SecretFile(**args) + + +def unmarshal_Secret(data: Any) -> Secret: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Secret' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secret_id", None) + if field is not None: + args["secret_id"] = field + + field = data.get("secret_manager_id", None) + if field is not None: + args["secret_manager_id"] = field + + field = data.get("secret_manager_version", None) + if field is not None: + args["secret_manager_version"] = field + + field = data.get("file", None) + if field is not None: + args["file"] = unmarshal_SecretFile(field) + else: + args["file"] = None + + field = data.get("env_var", None) + if field is not None: + args["env_var"] = unmarshal_SecretEnvVar(field) + else: + args["env_var"] = None + + return Secret(**args) + + def unmarshal_CronSchedule(data: Any) -> CronSchedule: if not isinstance(data, dict): raise TypeError( @@ -209,6 +286,48 @@ def unmarshal_JobRun(data: Any) -> JobRun: return JobRun(**args) +def unmarshal_CreateJobDefinitionSecretsResponse( + data: Any, +) -> CreateJobDefinitionSecretsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CreateJobDefinitionSecretsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secrets", None) + if field is not None: + args["secrets"] = ( + [unmarshal_Secret(v) for v in field] if field is not None else None + ) + + return CreateJobDefinitionSecretsResponse(**args) + + +def unmarshal_ListJobDefinitionSecretsResponse( + data: Any, +) -> ListJobDefinitionSecretsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListJobDefinitionSecretsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("secrets", None) + if field is not None: + args["secrets"] = ( + [unmarshal_Secret(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 + + return ListJobDefinitionSecretsResponse(**args) + + def unmarshal_ListJobDefinitionsResponse(data: Any) -> ListJobDefinitionsResponse: if not isinstance(data, dict): raise TypeError( @@ -365,6 +484,44 @@ def marshal_CreateJobDefinitionRequest( return output +def marshal_CreateJobDefinitionSecretsRequestSecretConfig( + request: CreateJobDefinitionSecretsRequestSecretConfig, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("path", request.path), + OneOfPossibility("env_var_name", request.env_var_name), + ] + ), + ) + + if request.secret_manager_id is not None: + output["secret_manager_id"] = request.secret_manager_id + + if request.secret_manager_version is not None: + output["secret_manager_version"] = request.secret_manager_version + + return output + + +def marshal_CreateJobDefinitionSecretsRequest( + request: CreateJobDefinitionSecretsRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.secrets is not None: + output["secrets"] = [ + marshal_CreateJobDefinitionSecretsRequestSecretConfig(item, defaults) + for item in request.secrets + ] + + return output + + def marshal_StartJobDefinitionRequest( request: StartJobDefinitionRequest, defaults: ProfileDefaults, @@ -437,3 +594,23 @@ def marshal_UpdateJobDefinitionRequest( ) return output + + +def marshal_UpdateJobDefinitionSecretRequest( + request: UpdateJobDefinitionSecretRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("path", request.path), + OneOfPossibility("env_var_name", request.env_var_name), + ] + ), + ) + + if request.secret_manager_version is not None: + output["secret_manager_version"] = request.secret_manager_version + + return output diff --git a/scaleway/scaleway/jobs/v1alpha1/types.py b/scaleway/scaleway/jobs/v1alpha1/types.py index 3e9dad045..b1ae41e00 100644 --- a/scaleway/scaleway/jobs/v1alpha1/types.py +++ b/scaleway/scaleway/jobs/v1alpha1/types.py @@ -45,6 +45,16 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class SecretEnvVar: + name: str + + +@dataclass +class SecretFile: + path: str + + @dataclass class CronSchedule: schedule: str @@ -65,6 +75,30 @@ class CreateJobDefinitionRequestCronScheduleConfig: timezone: str +@dataclass +class CreateJobDefinitionSecretsRequestSecretConfig: + secret_manager_id: str + + secret_manager_version: str + + path: Optional[str] + + env_var_name: Optional[str] + + +@dataclass +class Secret: + secret_id: str + + secret_manager_id: str + + secret_manager_version: str + + file: Optional[SecretFile] + + env_var: Optional[SecretEnvVar] + + @dataclass class JobDefinition: id: str @@ -216,6 +250,29 @@ class CreateJobDefinitionRequest: """ +@dataclass +class CreateJobDefinitionSecretsRequest: + job_definition_id: str + """ + UUID of the job definition to get. + """ + + secrets: List[CreateJobDefinitionSecretsRequestSecretConfig] + """ + Secrets to inject into the job. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class CreateJobDefinitionSecretsResponse: + secrets: List[Secret] + + @dataclass class DeleteJobDefinitionRequest: job_definition_id: str @@ -229,6 +286,18 @@ class DeleteJobDefinitionRequest: """ +@dataclass +class DeleteJobDefinitionSecretRequest: + job_definition_id: str + + secret_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class GetJobDefinitionRequest: job_definition_id: str @@ -242,6 +311,18 @@ class GetJobDefinitionRequest: """ +@dataclass +class GetJobDefinitionSecretRequest: + job_definition_id: str + + secret_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class GetJobRunRequest: job_run_id: str @@ -255,6 +336,23 @@ class GetJobRunRequest: """ +@dataclass +class ListJobDefinitionSecretsRequest: + job_definition_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListJobDefinitionSecretsResponse: + secrets: List[Secret] + + total_count: int + + @dataclass class ListJobDefinitionsRequest: region: Optional[Region] @@ -424,3 +522,21 @@ class UpdateJobDefinitionRequest: """ cron_schedule: Optional[UpdateJobDefinitionRequestCronScheduleConfig] + + +@dataclass +class UpdateJobDefinitionSecretRequest: + job_definition_id: str + + secret_id: str + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + secret_manager_version: Optional[str] + + path: Optional[str] + + env_var_name: Optional[str]