From 87848fbecbe7527ae14917150b1679f321f10ce8 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Tue, 18 Aug 2026 14:30:27 +0000 Subject: [PATCH] feat(serverless_jobs): add reason application_not_started to job run --- .../autoscaling/v1alpha1/__init__.py | 105 -- .../autoscaling/v1alpha1/api.py | 939 -------------- .../autoscaling/v1alpha1/marshalling.py | 1107 ----------------- .../autoscaling/v1alpha1/types.py | 1093 ---------------- .../scaleway_async/jobs/v1alpha2/types.py | 1 + .../scaleway/autoscaling/v1alpha1/__init__.py | 105 -- scaleway/scaleway/autoscaling/v1alpha1/api.py | 939 -------------- .../autoscaling/v1alpha1/marshalling.py | 1107 ----------------- .../scaleway/autoscaling/v1alpha1/types.py | 1093 ---------------- scaleway/scaleway/jobs/v1alpha2/types.py | 1 + 10 files changed, 2 insertions(+), 6488 deletions(-) delete mode 100644 scaleway-async/scaleway_async/autoscaling/v1alpha1/__init__.py delete mode 100644 scaleway-async/scaleway_async/autoscaling/v1alpha1/api.py delete mode 100644 scaleway-async/scaleway_async/autoscaling/v1alpha1/marshalling.py delete mode 100644 scaleway-async/scaleway_async/autoscaling/v1alpha1/types.py delete mode 100644 scaleway/scaleway/autoscaling/v1alpha1/__init__.py delete mode 100644 scaleway/scaleway/autoscaling/v1alpha1/api.py delete mode 100644 scaleway/scaleway/autoscaling/v1alpha1/marshalling.py delete mode 100644 scaleway/scaleway/autoscaling/v1alpha1/types.py diff --git a/scaleway-async/scaleway_async/autoscaling/v1alpha1/__init__.py b/scaleway-async/scaleway_async/autoscaling/v1alpha1/__init__.py deleted file mode 100644 index 67bcfcbe7..000000000 --- a/scaleway-async/scaleway_async/autoscaling/v1alpha1/__init__.py +++ /dev/null @@ -1,105 +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 InstanceGroupEventLevel -from .types import InstanceGroupEventSource -from .types import InstancePolicyAction -from .types import InstancePolicyType -from .types import InstanceTemplateStatus -from .types import ListInstanceGroupEventsRequestOrderBy -from .types import ListInstanceGroupsRequestOrderBy -from .types import ListInstancePoliciesRequestOrderBy -from .types import ListInstanceTemplatesRequestOrderBy -from .types import MetricAggregate -from .types import MetricManagedMetric -from .types import MetricOperator -from .types import UpdateInstancePolicyRequestMetricAggregate -from .types import UpdateInstancePolicyRequestMetricManagedMetric -from .types import UpdateInstancePolicyRequestMetricOperator -from .types import VolumeInstanceTemplateVolumeType -from .types import VolumeInstanceTemplateFromEmpty -from .types import VolumeInstanceTemplateFromSnapshot -from .types import Capacity -from .types import Loadbalancer -from .types import Metric -from .types import VolumeInstanceTemplate -from .types import InstanceGroupEvent -from .types import InstanceGroup -from .types import InstancePolicy -from .types import InstanceTemplate -from .types import UpdateInstanceGroupRequestCapacity -from .types import UpdateInstanceGroupRequestLoadbalancer -from .types import UpdateInstancePolicyRequestMetric -from .types import CreateInstanceGroupRequest -from .types import CreateInstancePolicyRequest -from .types import CreateInstanceTemplateRequest -from .types import DeleteInstanceGroupRequest -from .types import DeleteInstancePolicyRequest -from .types import DeleteInstanceTemplateRequest -from .types import GetInstanceGroupRequest -from .types import GetInstancePolicyRequest -from .types import GetInstanceTemplateRequest -from .types import ListInstanceGroupEventsRequest -from .types import ListInstanceGroupEventsResponse -from .types import ListInstanceGroupsRequest -from .types import ListInstanceGroupsResponse -from .types import ListInstancePoliciesRequest -from .types import ListInstancePoliciesResponse -from .types import ListInstanceTemplatesRequest -from .types import ListInstanceTemplatesResponse -from .types import UpdateInstanceGroupRequest -from .types import UpdateInstancePolicyRequest -from .types import UpdateInstanceTemplateRequest -from .api import AutoscalingV1Alpha1API - -__all__ = [ - "InstanceGroupEventLevel", - "InstanceGroupEventSource", - "InstancePolicyAction", - "InstancePolicyType", - "InstanceTemplateStatus", - "ListInstanceGroupEventsRequestOrderBy", - "ListInstanceGroupsRequestOrderBy", - "ListInstancePoliciesRequestOrderBy", - "ListInstanceTemplatesRequestOrderBy", - "MetricAggregate", - "MetricManagedMetric", - "MetricOperator", - "UpdateInstancePolicyRequestMetricAggregate", - "UpdateInstancePolicyRequestMetricManagedMetric", - "UpdateInstancePolicyRequestMetricOperator", - "VolumeInstanceTemplateVolumeType", - "VolumeInstanceTemplateFromEmpty", - "VolumeInstanceTemplateFromSnapshot", - "Capacity", - "Loadbalancer", - "Metric", - "VolumeInstanceTemplate", - "InstanceGroupEvent", - "InstanceGroup", - "InstancePolicy", - "InstanceTemplate", - "UpdateInstanceGroupRequestCapacity", - "UpdateInstanceGroupRequestLoadbalancer", - "UpdateInstancePolicyRequestMetric", - "CreateInstanceGroupRequest", - "CreateInstancePolicyRequest", - "CreateInstanceTemplateRequest", - "DeleteInstanceGroupRequest", - "DeleteInstancePolicyRequest", - "DeleteInstanceTemplateRequest", - "GetInstanceGroupRequest", - "GetInstancePolicyRequest", - "GetInstanceTemplateRequest", - "ListInstanceGroupEventsRequest", - "ListInstanceGroupEventsResponse", - "ListInstanceGroupsRequest", - "ListInstanceGroupsResponse", - "ListInstancePoliciesRequest", - "ListInstancePoliciesResponse", - "ListInstanceTemplatesRequest", - "ListInstanceTemplatesResponse", - "UpdateInstanceGroupRequest", - "UpdateInstancePolicyRequest", - "UpdateInstanceTemplateRequest", - "AutoscalingV1Alpha1API", -] diff --git a/scaleway-async/scaleway_async/autoscaling/v1alpha1/api.py b/scaleway-async/scaleway_async/autoscaling/v1alpha1/api.py deleted file mode 100644 index 8db810cad..000000000 --- a/scaleway-async/scaleway_async/autoscaling/v1alpha1/api.py +++ /dev/null @@ -1,939 +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 Optional - -from scaleway_core.api import API -from scaleway_core.bridge import ( - Zone as ScwZone, -) -from scaleway_core.utils import ( - validate_path_param, - fetch_all_pages_async, -) -from .types import ( - InstancePolicyAction, - InstancePolicyType, - ListInstanceGroupEventsRequestOrderBy, - ListInstanceGroupsRequestOrderBy, - ListInstancePoliciesRequestOrderBy, - ListInstanceTemplatesRequestOrderBy, - Capacity, - CreateInstanceGroupRequest, - CreateInstancePolicyRequest, - CreateInstanceTemplateRequest, - InstanceGroup, - InstanceGroupEvent, - InstancePolicy, - InstanceTemplate, - ListInstanceGroupEventsResponse, - ListInstanceGroupsResponse, - ListInstancePoliciesResponse, - ListInstanceTemplatesResponse, - Loadbalancer, - Metric, - UpdateInstanceGroupRequest, - UpdateInstanceGroupRequestCapacity, - UpdateInstanceGroupRequestLoadbalancer, - UpdateInstancePolicyRequest, - UpdateInstancePolicyRequestMetric, - UpdateInstanceTemplateRequest, - VolumeInstanceTemplate, -) -from .marshalling import ( - unmarshal_InstanceGroup, - unmarshal_InstancePolicy, - unmarshal_InstanceTemplate, - unmarshal_ListInstanceGroupEventsResponse, - unmarshal_ListInstanceGroupsResponse, - unmarshal_ListInstancePoliciesResponse, - unmarshal_ListInstanceTemplatesResponse, - marshal_CreateInstanceGroupRequest, - marshal_CreateInstancePolicyRequest, - marshal_CreateInstanceTemplateRequest, - marshal_UpdateInstanceGroupRequest, - marshal_UpdateInstancePolicyRequest, - marshal_UpdateInstanceTemplateRequest, -) - - -class AutoscalingV1Alpha1API(API): - """ """ - - async def get_instance_group( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - ) -> InstanceGroup: - """ - Get Instance group. - Retrieve information about an existing Instance group, specified by its `instance_group_id`. Its full details, including errors, are returned in the response object. - :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 = await 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 - ) - - res = self._request( - "GET", - f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", - ) - - self._throw_on_error(res) - return unmarshal_InstanceGroup(res.json()) - - async def create_instance_group( - self, - *, - name: str, - template_id: str, - capacity: Capacity, - loadbalancer: Loadbalancer, - zone: Optional[ScwZone] = None, - project_id: Optional[str] = None, - tags: Optional[list[str]] = None, - ) -> InstanceGroup: - """ - Create Instance group. - Create a new Instance group. You must specify a `template_id`, capacity and Load Balancer object. - :param name: Name of Instance group. - :param template_id: Template ID (ID of the Instance template to attach to the 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. - :param zone: Zone to target. If none is passed will use default zone from the config. - :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 = await api.create_instance_group( - name="example", - template_id="example", - capacity=Capacity(), - 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", - body=marshal_CreateInstanceGroupRequest( - CreateInstanceGroupRequest( - name=name, - template_id=template_id, - capacity=capacity, - loadbalancer=loadbalancer, - zone=zone, - project_id=project_id, - tags=tags, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceGroup(res.json()) - - async def list_instance_groups( - self, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstanceGroupsResponse: - """ - List Instance groups. - List all Instance groups, for a Scaleway Organization or Scaleway Project. By default, the Instance groups returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await 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", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstanceGroupsResponse(res.json()) - - async def list_instance_groups_all( - self, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstanceGroup]: - """ - List Instance groups. - List all Instance groups, for a Scaleway Organization or Scaleway Project. By default, the Instance groups returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await api.list_instance_groups_all() - """ - - return await fetch_all_pages_async( - type=ListInstanceGroupsResponse, - key="instance_groups", - fetcher=self.list_instance_groups, - args={ - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) - - async def update_instance_group( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - name: Optional[str] = None, - tags: Optional[list[str]] = None, - capacity: Optional[UpdateInstanceGroupRequestCapacity] = None, - loadbalancer: Optional[UpdateInstanceGroupRequestLoadbalancer] = None, - ) -> InstanceGroup: - """ - Update Instance group. - Update the parameters of an existing Instance group, specified by its `instance_group_id`. - :param instance_group_id: Instance group ID to update. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param name: Name of Instance group. - :param tags: List of tags for the Load Balancer. - :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 = await 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 - ) - - res = self._request( - "PATCH", - f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", - body=marshal_UpdateInstanceGroupRequest( - UpdateInstanceGroupRequest( - instance_group_id=instance_group_id, - zone=zone, - name=name, - tags=tags, - capacity=capacity, - loadbalancer=loadbalancer, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceGroup(res.json()) - - async def delete_instance_group( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - ) -> None: - """ - 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 = await 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 - ) - - res = self._request( - "DELETE", - f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", - ) - - self._throw_on_error(res) - - async def create_instance_template( - self, - *, - zone: Optional[ScwZone] = None, - commercial_type: str, - volumes: dict[str, VolumeInstanceTemplate], - image_id: Optional[str] = None, - tags: Optional[list[str]] = None, - security_group_id: Optional[str] = None, - name: str, - placement_group_id: Optional[str] = None, - public_ips_v4_count: Optional[int] = None, - public_ips_v6_count: Optional[int] = None, - project_id: Optional[str] = None, - private_network_ids: Optional[list[str]] = None, - cloud_init: Optional[str] = None, - ) -> InstanceTemplate: - """ - Create Instance template. - Create a new Instance template. This specifies the details of the Instance (commercial type, zone, image, volumes etc.) that will be in the Instance group. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param commercial_type: Name of Instance commercial type. - :param volumes: Template of Instance volume. - :param image_id: Instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. - :param tags: List of tags for the Instance template. - :param security_group_id: Instance security group ID (optional). - :param name: Name of Instance template. - :param placement_group_id: Instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. - :param public_ips_v4_count: Number of flexible IPv4 addresses to attach to the new Instance. - :param public_ips_v6_count: Number of flexible IPv6 addresses to attach to the new Instance. - :param project_id: ID of the Project containing the Instance template resource. - :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 = await 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", - body=marshal_CreateInstanceTemplateRequest( - CreateInstanceTemplateRequest( - zone=zone, - commercial_type=commercial_type, - volumes=volumes, - image_id=image_id, - tags=tags, - security_group_id=security_group_id, - name=name, - placement_group_id=placement_group_id, - public_ips_v4_count=public_ips_v4_count, - public_ips_v6_count=public_ips_v6_count, - project_id=project_id, - private_network_ids=private_network_ids, - cloud_init=cloud_init, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceTemplate(res.json()) - - async def update_instance_template( - self, - *, - template_id: str, - zone: Optional[ScwZone] = None, - commercial_type: Optional[str] = None, - image_id: Optional[str] = None, - volumes: Optional[dict[str, VolumeInstanceTemplate]] = None, - tags: Optional[list[str]] = None, - security_group_id: Optional[str] = None, - placement_group_id: Optional[str] = None, - public_ips_v4_count: Optional[int] = None, - public_ips_v6_count: Optional[int] = None, - name: Optional[str] = None, - private_network_ids: Optional[list[str]] = None, - cloud_init: Optional[str] = None, - ) -> InstanceTemplate: - """ - Update Instance template. - Update an Instance template, such as its commercial offer type, image or volume 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. - :param commercial_type: Name of Instance commercial type. - :param image_id: Instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. - :param volumes: Template of Instance volume. - :param tags: List of tags for the Instance template. - :param security_group_id: Instance security group ID (optional). - :param placement_group_id: Instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. - :param public_ips_v4_count: Number of flexible IPv4 addresses to attach to the new Instance. - :param public_ips_v6_count: Number of flexible IPv6 addresses to attach to the new Instance. - :param name: Name of 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 = await 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}", - body=marshal_UpdateInstanceTemplateRequest( - UpdateInstanceTemplateRequest( - template_id=template_id, - zone=zone, - commercial_type=commercial_type, - image_id=image_id, - volumes=volumes, - tags=tags, - security_group_id=security_group_id, - placement_group_id=placement_group_id, - public_ips_v4_count=public_ips_v4_count, - public_ips_v6_count=public_ips_v6_count, - name=name, - private_network_ids=private_network_ids, - cloud_init=cloud_init, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceTemplate(res.json()) - - async def get_instance_template( - self, - *, - template_id: str, - zone: Optional[ScwZone] = None, - ) -> InstanceTemplate: - """ - Get Instance template. - Get an existing Instance template from its `template_id`. - :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 = await 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}", - ) - - self._throw_on_error(res) - return unmarshal_InstanceTemplate(res.json()) - - async def delete_instance_template( - self, - *, - template_id: str, - zone: Optional[ScwZone] = None, - ) -> None: - """ - 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 = await 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) - - async def list_instance_templates( - self, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceTemplatesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstanceTemplatesResponse: - """ - List Instance templates. - List all Instance templates, for a Scaleway Organization or Scaleway Project. By default, the Instance templates returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await 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", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstanceTemplatesResponse(res.json()) - - async def list_instance_templates_all( - self, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceTemplatesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstanceTemplate]: - """ - List Instance templates. - List all Instance templates, for a Scaleway Organization or Scaleway Project. By default, the Instance templates returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await api.list_instance_templates_all() - """ - - return await fetch_all_pages_async( - type=ListInstanceTemplatesResponse, - key="instance_templates", - fetcher=self.list_instance_templates, - args={ - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) - - async def create_instance_policy( - self, - *, - name: str, - action: InstancePolicyAction, - type_: InstancePolicyType, - value: int, - priority: int, - instance_group_id: str, - zone: Optional[ScwZone] = None, - metric: Optional[Metric] = None, - ) -> InstancePolicy: - """ - Create scaling policy. - Create a new scaling policy. You must specify a `policy_id`, capacity and Load Balancer object. - :param name: Name of the policy. - :param action: Action to execute when the metric-based condition is met. - :param type_: How to use the number defined in `value` when determining by how many Instances to scale up/down. - :param value: 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. - :param priority: Priority of this policy compared to all other scaling policies. This determines the processing order. The lower the number, the higher the priority. - :param instance_group_id: Instance group ID related to this policy. - :param zone: Zone to target. If none is passed will use default zone from the config. - :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 = await api.create_instance_policy( - name="example", - action=InstancePolicyAction.unknown_action, - type=InstancePolicyType.unknown_type, - value=1, - priority=1, - 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", - body=marshal_CreateInstancePolicyRequest( - CreateInstancePolicyRequest( - name=name, - action=action, - type_=type_, - value=value, - priority=priority, - instance_group_id=instance_group_id, - zone=zone, - metric=metric, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstancePolicy(res.json()) - - async def update_instance_policy( - self, - *, - policy_id: str, - zone: Optional[ScwZone] = None, - name: Optional[str] = None, - metric: Optional[UpdateInstancePolicyRequestMetric] = None, - action: Optional[InstancePolicyAction] = None, - type_: Optional[InstancePolicyType] = None, - value: Optional[int] = None, - priority: Optional[int] = None, - ) -> InstancePolicy: - """ - Update scaling policy. - Update the parameters of an existing scaling policy, specified by its `policy_id`. - :param policy_id: Policy ID to update. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param name: Policy name to update. - :param metric: Metric specification to update (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. - :param action: Action to update (action to execute when the metric-based condition is met). - :param type_: Type to update (how to use the number defined in `value` when determining by how many Instances to scale up/down). - :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 = await 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}", - body=marshal_UpdateInstancePolicyRequest( - UpdateInstancePolicyRequest( - policy_id=policy_id, - zone=zone, - name=name, - action=action, - type_=type_, - value=value, - priority=priority, - metric=metric, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstancePolicy(res.json()) - - async def list_instance_policies( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstancePoliciesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstancePoliciesResponse: - """ - List scaling policies. - List all scaling policies, for a Scaleway Organization or Scaleway Project. By default, the policies returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param instance_group_id: Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await 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", - params={ - "instance_group_id": instance_group_id, - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstancePoliciesResponse(res.json()) - - async def list_instance_policies_all( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstancePoliciesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstancePolicy]: - """ - List scaling policies. - List all scaling policies, for a Scaleway Organization or Scaleway Project. By default, the policies returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param instance_group_id: Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await api.list_instance_policies_all( - instance_group_id="example", - ) - """ - - return await fetch_all_pages_async( - type=ListInstancePoliciesResponse, - key="policies", - fetcher=self.list_instance_policies, - args={ - "instance_group_id": instance_group_id, - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) - - async def get_instance_policy( - self, - *, - policy_id: str, - zone: Optional[ScwZone] = None, - ) -> InstancePolicy: - """ - Get scaling policy. - Retrieve information about an existing scaling policy, specified by its `policy_id`. Its full details are returned in the response object. - :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 = await 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}", - ) - - self._throw_on_error(res) - return unmarshal_InstancePolicy(res.json()) - - async def delete_instance_policy( - self, - *, - policy_id: str, - zone: Optional[ScwZone] = None, - ) -> None: - """ - Delete scaling 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 = await 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) - - async def list_instance_group_events( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupEventsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstanceGroupEventsResponse: - """ - List events. - List all events for a given Instance group. By default, the events are ordered by creation date in descending order, though this can be modified via the `order_by` field. - :param instance_group_id: List all event logs for the Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await 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 - ) - - res = self._request( - "GET", - f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}/events", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstanceGroupEventsResponse(res.json()) - - async def list_instance_group_events_all( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupEventsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstanceGroupEvent]: - """ - List events. - List all events for a given Instance group. By default, the events are ordered by creation date in descending order, though this can be modified via the `order_by` field. - :param instance_group_id: List all event logs for the Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 = await api.list_instance_group_events_all( - instance_group_id="example", - ) - """ - - return await fetch_all_pages_async( - type=ListInstanceGroupEventsResponse, - key="instance_events", - fetcher=self.list_instance_group_events, - args={ - "instance_group_id": instance_group_id, - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) diff --git a/scaleway-async/scaleway_async/autoscaling/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/autoscaling/v1alpha1/marshalling.py deleted file mode 100644 index 37c7f0860..000000000 --- a/scaleway-async/scaleway_async/autoscaling/v1alpha1/marshalling.py +++ /dev/null @@ -1,1107 +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 -from dateutil import parser - -from scaleway_core.profile import ProfileDefaults -from scaleway_core.utils import ( - OneOfPossibility, - resolve_one_of, -) -from .types import ( - InstanceGroupEventLevel, - InstanceGroupEventSource, - InstancePolicyAction, - InstancePolicyType, - InstanceTemplateStatus, - MetricAggregate, - MetricManagedMetric, - MetricOperator, - VolumeInstanceTemplateVolumeType, - Capacity, - Loadbalancer, - InstanceGroup, - Metric, - InstancePolicy, - VolumeInstanceTemplateFromEmpty, - VolumeInstanceTemplateFromSnapshot, - VolumeInstanceTemplate, - InstanceTemplate, - InstanceGroupEvent, - ListInstanceGroupEventsResponse, - ListInstanceGroupsResponse, - ListInstancePoliciesResponse, - ListInstanceTemplatesResponse, - CreateInstanceGroupRequest, - CreateInstancePolicyRequest, - CreateInstanceTemplateRequest, - UpdateInstanceGroupRequestCapacity, - UpdateInstanceGroupRequestLoadbalancer, - UpdateInstanceGroupRequest, - UpdateInstancePolicyRequestMetric, - UpdateInstancePolicyRequest, - UpdateInstanceTemplateRequest, -) - - -def unmarshal_Capacity(data: Any) -> Capacity: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Capacity' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("max_replicas", None) - if field is not None: - args["max_replicas"] = field - else: - args["max_replicas"] = 0 - - field = data.get("min_replicas", None) - if field is not None: - args["min_replicas"] = field - else: - args["min_replicas"] = 0 - - field = data.get("cooldown_delay", None) - if field is not None: - args["cooldown_delay"] = field - else: - args["cooldown_delay"] = None - - return Capacity(**args) - - -def unmarshal_Loadbalancer(data: Any) -> Loadbalancer: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Loadbalancer' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("backend_ids", None) - if field is not None: - args["backend_ids"] = field - else: - args["backend_ids"] = [] - - field = data.get("private_network_id", None) - if field is not None: - args["private_network_id"] = field - else: - args["private_network_id"] = None - - return Loadbalancer(**args) - - -def unmarshal_InstanceGroup(data: Any) -> InstanceGroup: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstanceGroup' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field - else: - args["project_id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("tags", None) - if field is not None: - args["tags"] = field - else: - args["tags"] = [] - - field = data.get("instance_template_id", None) - if field is not None: - args["instance_template_id"] = field - else: - args["instance_template_id"] = None - - field = data.get("capacity", None) - if field is not None: - args["capacity"] = unmarshal_Capacity(field) - else: - args["capacity"] = None - - field = data.get("loadbalancer", None) - if field is not None: - args["loadbalancer"] = unmarshal_Loadbalancer(field) - else: - args["loadbalancer"] = None - - field = data.get("error_messages", None) - if field is not None: - args["error_messages"] = field - else: - args["error_messages"] = [] - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - else: - args["zone"] = None - - field = data.get("created_at", None) - if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["created_at"] = None - - field = data.get("updated_at", None) - if field is not None: - args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["updated_at"] = None - - return InstanceGroup(**args) - - -def unmarshal_Metric(data: Any) -> Metric: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Metric' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("operator", None) - if field is not None: - args["operator"] = field - else: - args["operator"] = MetricOperator.OPERATOR_UNKNOWN - - field = data.get("aggregate", None) - if field is not None: - args["aggregate"] = field - else: - args["aggregate"] = MetricAggregate.AGGREGATE_UNKNOWN - - field = data.get("sampling_range_min", None) - if field is not None: - args["sampling_range_min"] = field - else: - args["sampling_range_min"] = 0 - - field = data.get("threshold", None) - if field is not None: - args["threshold"] = field - else: - args["threshold"] = 0.0 - - field = data.get("managed_metric", None) - if field is not None: - args["managed_metric"] = field - else: - args["managed_metric"] = MetricManagedMetric.MANAGED_METRIC_UNKNOWN - - field = data.get("cockpit_metric_name", None) - if field is not None: - args["cockpit_metric_name"] = field - else: - args["cockpit_metric_name"] = None - - return Metric(**args) - - -def unmarshal_InstancePolicy(data: Any) -> InstancePolicy: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstancePolicy' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("action", None) - if field is not None: - args["action"] = field - else: - args["action"] = InstancePolicyAction.UNKNOWN_ACTION - - field = data.get("type", None) - if field is not None: - args["type_"] = field - else: - args["type_"] = InstancePolicyType.UNKNOWN_TYPE - - field = data.get("value", None) - if field is not None: - args["value"] = field - else: - args["value"] = 0 - - field = data.get("priority", None) - if field is not None: - args["priority"] = field - else: - args["priority"] = 0 - - field = data.get("instance_group_id", None) - if field is not None: - args["instance_group_id"] = field - else: - args["instance_group_id"] = None - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - else: - args["zone"] = None - - field = data.get("metric", None) - if field is not None: - args["metric"] = unmarshal_Metric(field) - else: - args["metric"] = None - - return InstancePolicy(**args) - - -def unmarshal_VolumeInstanceTemplateFromEmpty( - data: Any, -) -> VolumeInstanceTemplateFromEmpty: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'VolumeInstanceTemplateFromEmpty' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("size", None) - if field is not None: - args["size"] = field - else: - args["size"] = None - - return VolumeInstanceTemplateFromEmpty(**args) - - -def unmarshal_VolumeInstanceTemplateFromSnapshot( - data: Any, -) -> VolumeInstanceTemplateFromSnapshot: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'VolumeInstanceTemplateFromSnapshot' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("snapshot_id", None) - if field is not None: - args["snapshot_id"] = field - else: - args["snapshot_id"] = None - - field = data.get("size", None) - if field is not None: - args["size"] = field - else: - args["size"] = None - - return VolumeInstanceTemplateFromSnapshot(**args) - - -def unmarshal_VolumeInstanceTemplate(data: Any) -> VolumeInstanceTemplate: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'VolumeInstanceTemplate' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("tags", None) - if field is not None: - args["tags"] = field - else: - args["tags"] = [] - - field = data.get("boot", None) - if field is not None: - args["boot"] = field - else: - args["boot"] = False - - field = data.get("volume_type", None) - if field is not None: - args["volume_type"] = field - else: - args["volume_type"] = VolumeInstanceTemplateVolumeType.UNKNOWN_VOLUME_TYPE - - field = data.get("perf_iops", None) - if field is not None: - args["perf_iops"] = field - else: - args["perf_iops"] = None - - field = data.get("from_empty", None) - if field is not None: - args["from_empty"] = unmarshal_VolumeInstanceTemplateFromEmpty(field) - else: - args["from_empty"] = None - - field = data.get("from_snapshot", None) - if field is not None: - args["from_snapshot"] = unmarshal_VolumeInstanceTemplateFromSnapshot(field) - else: - args["from_snapshot"] = None - - return VolumeInstanceTemplate(**args) - - -def unmarshal_InstanceTemplate(data: Any) -> InstanceTemplate: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstanceTemplate' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("commercial_type", None) - if field is not None: - args["commercial_type"] = field - else: - args["commercial_type"] = None - - 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 - ) - else: - args["volumes"] = {} - - field = data.get("tags", None) - if field is not None: - args["tags"] = field - else: - args["tags"] = [] - - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field - else: - args["project_id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("private_network_ids", None) - if field is not None: - args["private_network_ids"] = field - else: - args["private_network_ids"] = [] - - field = data.get("image_id", None) - if field is not None: - args["image_id"] = field - else: - args["image_id"] = None - - field = data.get("security_group_id", None) - if field is not None: - args["security_group_id"] = field - else: - args["security_group_id"] = None - - field = data.get("placement_group_id", None) - if field is not None: - args["placement_group_id"] = field - else: - args["placement_group_id"] = None - - 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"] = 0 - - 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"] = 0 - - field = data.get("status", None) - if field is not None: - args["status"] = field - else: - args["status"] = InstanceTemplateStatus.UNKNOWN_STATUS - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - else: - args["zone"] = None - - field = data.get("cloud_init", None) - if field is not None: - args["cloud_init"] = field - else: - args["cloud_init"] = None - - field = data.get("created_at", None) - if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["created_at"] = None - - field = data.get("updated_at", None) - if field is not None: - args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["updated_at"] = None - - return InstanceTemplate(**args) - - -def unmarshal_InstanceGroupEvent(data: Any) -> InstanceGroupEvent: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstanceGroupEvent' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("source", None) - if field is not None: - args["source"] = field - else: - args["source"] = InstanceGroupEventSource.UNKNOWN_SOURCE - - field = data.get("level", None) - if field is not None: - args["level"] = field - else: - args["level"] = InstanceGroupEventLevel.INFO - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("created_at", None) - if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["created_at"] = None - - field = data.get("details", None) - if field is not None: - args["details"] = field - else: - args["details"] = None - - return InstanceGroupEvent(**args) - - -def unmarshal_ListInstanceGroupEventsResponse( - data: Any, -) -> ListInstanceGroupEventsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstanceGroupEventsResponse' failed as data isn't a dictionary." - ) - - 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 - ) - else: - args["instance_events"] = [] - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - else: - args["total_count"] = 0 - - return ListInstanceGroupEventsResponse(**args) - - -def unmarshal_ListInstanceGroupsResponse(data: Any) -> ListInstanceGroupsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstanceGroupsResponse' failed as data isn't a dictionary." - ) - - 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 - ) - else: - args["instance_groups"] = [] - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - else: - args["total_count"] = 0 - - return ListInstanceGroupsResponse(**args) - - -def unmarshal_ListInstancePoliciesResponse(data: Any) -> ListInstancePoliciesResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstancePoliciesResponse' failed as data isn't a dictionary." - ) - - 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 - ) - else: - args["policies"] = [] - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - else: - args["total_count"] = 0 - - return ListInstancePoliciesResponse(**args) - - -def unmarshal_ListInstanceTemplatesResponse(data: Any) -> ListInstanceTemplatesResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstanceTemplatesResponse' 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 - else: - args["total_count"] = 0 - - 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 - ) - else: - args["instance_templates"] = [] - - return ListInstanceTemplatesResponse(**args) - - -def marshal_Capacity( - request: Capacity, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.max_replicas is not None: - output["max_replicas"] = request.max_replicas - - if request.min_replicas is not None: - output["min_replicas"] = request.min_replicas - - if request.cooldown_delay is not None: - output["cooldown_delay"] = request.cooldown_delay - - return output - - -def marshal_Loadbalancer( - request: Loadbalancer, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.id is not None: - output["id"] = request.id - - if request.backend_ids is not None: - output["backend_ids"] = request.backend_ids - - if request.private_network_id is not None: - output["private_network_id"] = request.private_network_id - - return output - - -def marshal_CreateInstanceGroupRequest( - request: CreateInstanceGroupRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.name is not None: - output["name"] = request.name - - if request.template_id is not None: - output["template_id"] = request.template_id - - if request.capacity is not None: - output["capacity"] = marshal_Capacity(request.capacity, defaults) - - if request.loadbalancer is not None: - output["loadbalancer"] = marshal_Loadbalancer(request.loadbalancer, defaults) - - if request.project_id is not None: - output["project_id"] = request.project_id - else: - output["project_id"] = defaults.default_project_id - - if request.tags is not None: - output["tags"] = request.tags - - return output - - -def marshal_Metric( - request: Metric, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="managed_metric", - value=request.managed_metric, - marshal_func=None, - ), - OneOfPossibility( - param="cockpit_metric_name", - value=request.cockpit_metric_name, - marshal_func=None, - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.operator is not None: - output["operator"] = request.operator - - if request.aggregate is not None: - output["aggregate"] = request.aggregate - - if request.sampling_range_min is not None: - output["sampling_range_min"] = request.sampling_range_min - - if request.threshold is not None: - output["threshold"] = request.threshold - - return output - - -def marshal_CreateInstancePolicyRequest( - request: CreateInstancePolicyRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="metric", value=request.metric, marshal_func=marshal_Metric - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.action is not None: - output["action"] = request.action - - if request.type_ is not None: - output["type"] = request.type_ - - if request.value is not None: - output["value"] = request.value - - if request.priority is not None: - output["priority"] = request.priority - - if request.instance_group_id is not None: - output["instance_group_id"] = request.instance_group_id - - return output - - -def marshal_VolumeInstanceTemplateFromEmpty( - request: VolumeInstanceTemplateFromEmpty, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.size is not None: - output["size"] = request.size - - return output - - -def marshal_VolumeInstanceTemplateFromSnapshot( - request: VolumeInstanceTemplateFromSnapshot, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.snapshot_id is not None: - output["snapshot_id"] = request.snapshot_id - - if request.size is not None: - output["size"] = request.size - - return output - - -def marshal_VolumeInstanceTemplate( - request: VolumeInstanceTemplate, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - 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( - param="perf_iops", value=request.perf_iops, marshal_func=None - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.tags is not None: - output["tags"] = request.tags - - if request.boot is not None: - output["boot"] = request.boot - - if request.volume_type is not None: - output["volume_type"] = request.volume_type - - return output - - -def marshal_CreateInstanceTemplateRequest( - request: CreateInstanceTemplateRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.commercial_type is not None: - output["commercial_type"] = request.commercial_type - - if request.volumes is not None: - output["volumes"] = { - key: marshal_VolumeInstanceTemplate(value, defaults) - for key, value in request.volumes.items() - } - - if request.image_id is not None: - output["image_id"] = request.image_id - - if request.tags is not None: - output["tags"] = request.tags - - if request.security_group_id is not None: - output["security_group_id"] = request.security_group_id - - if request.name is not None: - output["name"] = request.name - - if request.placement_group_id is not None: - output["placement_group_id"] = request.placement_group_id - - if request.public_ips_v4_count is not None: - output["public_ips_v4_count"] = request.public_ips_v4_count - - if request.public_ips_v6_count is not None: - output["public_ips_v6_count"] = request.public_ips_v6_count - - if request.project_id is not None: - output["project_id"] = request.project_id - else: - output["project_id"] = defaults.default_project_id - - if request.private_network_ids is not None: - output["private_network_ids"] = request.private_network_ids - - if request.cloud_init is not None: - output["cloud_init"] = request.cloud_init - - return output - - -def marshal_UpdateInstanceGroupRequestCapacity( - request: UpdateInstanceGroupRequestCapacity, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.max_replicas is not None: - output["max_replicas"] = request.max_replicas - - if request.min_replicas is not None: - output["min_replicas"] = request.min_replicas - - if request.cooldown_delay is not None: - output["cooldown_delay"] = request.cooldown_delay - - return output - - -def marshal_UpdateInstanceGroupRequestLoadbalancer( - request: UpdateInstanceGroupRequestLoadbalancer, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.backend_ids is not None: - output["backend_ids"] = request.backend_ids - - return output - - -def marshal_UpdateInstanceGroupRequest( - request: UpdateInstanceGroupRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.name is not None: - output["name"] = request.name - - if request.tags is not None: - output["tags"] = request.tags - - if request.capacity is not None: - output["capacity"] = marshal_UpdateInstanceGroupRequestCapacity( - request.capacity, defaults - ) - - if request.loadbalancer is not None: - output["loadbalancer"] = marshal_UpdateInstanceGroupRequestLoadbalancer( - request.loadbalancer, defaults - ) - - return output - - -def marshal_UpdateInstancePolicyRequestMetric( - request: UpdateInstancePolicyRequestMetric, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="managed_metric", - value=request.managed_metric, - marshal_func=None, - ), - OneOfPossibility( - param="cockpit_metric_name", - value=request.cockpit_metric_name, - marshal_func=None, - ), - ] - ), - ) - - if request.operator is not None: - output["operator"] = request.operator - - if request.aggregate is not None: - output["aggregate"] = request.aggregate - - if request.name is not None: - output["name"] = request.name - - if request.sampling_range_min is not None: - output["sampling_range_min"] = request.sampling_range_min - - if request.threshold is not None: - output["threshold"] = request.threshold - - return output - - -def marshal_UpdateInstancePolicyRequest( - request: UpdateInstancePolicyRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="metric", - value=request.metric, - marshal_func=marshal_UpdateInstancePolicyRequestMetric, - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.action is not None: - output["action"] = request.action - - if request.type_ is not None: - output["type"] = request.type_ - - if request.value is not None: - output["value"] = request.value - - if request.priority is not None: - output["priority"] = request.priority - - return output - - -def marshal_UpdateInstanceTemplateRequest( - request: UpdateInstanceTemplateRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.commercial_type is not None: - output["commercial_type"] = request.commercial_type - - if request.image_id is not None: - output["image_id"] = request.image_id - - if request.volumes is not None: - output["volumes"] = { - key: marshal_VolumeInstanceTemplate(value, defaults) - for key, value in request.volumes.items() - } - - if request.tags is not None: - output["tags"] = request.tags - - if request.security_group_id is not None: - output["security_group_id"] = request.security_group_id - - if request.placement_group_id is not None: - output["placement_group_id"] = request.placement_group_id - - if request.public_ips_v4_count is not None: - output["public_ips_v4_count"] = request.public_ips_v4_count - - if request.public_ips_v6_count is not None: - output["public_ips_v6_count"] = request.public_ips_v6_count - - if request.name is not None: - output["name"] = request.name - - if request.private_network_ids is not None: - output["private_network_ids"] = request.private_network_ids - - if request.cloud_init is not None: - output["cloud_init"] = request.cloud_init - - return output diff --git a/scaleway-async/scaleway_async/autoscaling/v1alpha1/types.py b/scaleway-async/scaleway_async/autoscaling/v1alpha1/types.py deleted file mode 100644 index 58bbb50fd..000000000 --- a/scaleway-async/scaleway_async/autoscaling/v1alpha1/types.py +++ /dev/null @@ -1,1093 +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, field -from datetime import datetime -from enum import Enum -from typing import Optional - -from scaleway_core.bridge import ( - Zone as ScwZone, -) -from scaleway_core.utils import ( - StrEnumMeta, -) - - -class InstanceGroupEventLevel(str, Enum, metaclass=StrEnumMeta): - INFO = "info" - SUCCESS = "success" - ERROR = "error" - - def __str__(self) -> str: - return str(self.value) - - -class InstanceGroupEventSource(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_SOURCE = "unknown_source" - WATCHER = "watcher" - SCALER = "scaler" - INSTANCE_MANAGER = "instance_manager" - SUPERVISOR = "supervisor" - - def __str__(self) -> str: - return str(self.value) - - -class InstancePolicyAction(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_ACTION = "unknown_action" - SCALE_UP = "scale_up" - SCALE_DOWN = "scale_down" - - def __str__(self) -> str: - return str(self.value) - - -class InstancePolicyType(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_TYPE = "unknown_type" - FLAT_COUNT = "flat_count" - PERCENT_OF_TOTAL_GROUP = "percent_of_total_group" - SET_TOTAL_GROUP = "set_total_group" - - def __str__(self) -> str: - return str(self.value) - - -class InstanceTemplateStatus(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_STATUS = "unknown_status" - READY = "ready" - ERROR = "error" - - 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" - - 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" - - 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" - - 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" - - def __str__(self) -> str: - return str(self.value) - - -class MetricAggregate(str, Enum, metaclass=StrEnumMeta): - AGGREGATE_UNKNOWN = "aggregate_unknown" - AGGREGATE_AVERAGE = "aggregate_average" - AGGREGATE_MAX = "aggregate_max" - AGGREGATE_MIN = "aggregate_min" - AGGREGATE_SUM = "aggregate_sum" - - 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_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" - OPERATOR_LESS_THAN = "operator_less_than" - - def __str__(self) -> str: - return str(self.value) - - -class UpdateInstancePolicyRequestMetricAggregate(str, Enum, metaclass=StrEnumMeta): - AGGREGATE_UNKNOWN = "aggregate_unknown" - AGGREGATE_AVERAGE = "aggregate_average" - AGGREGATE_MAX = "aggregate_max" - AGGREGATE_MIN = "aggregate_min" - AGGREGATE_SUM = "aggregate_sum" - - 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_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" - OPERATOR_LESS_THAN = "operator_less_than" - - def __str__(self) -> str: - return str(self.value) - - -class VolumeInstanceTemplateVolumeType(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_VOLUME_TYPE = "unknown_volume_type" - L_SSD = "l_ssd" - SBS = "sbs" - - def __str__(self) -> str: - return str(self.value) - - -@dataclass -class VolumeInstanceTemplateFromEmpty: - size: int - - -@dataclass -class VolumeInstanceTemplateFromSnapshot: - snapshot_id: str - size: Optional[int] = None - - -@dataclass -class Capacity: - max_replicas: int - """ - Maximum count of Instances for the Instance group. - """ - - min_replicas: int - """ - Minimum count of Instances for the Instance group. - """ - - cooldown_delay: Optional[str] = None - """ - Time (in seconds) after a scaling action during which requests to carry out a new scaling action will be denied. - """ - - -@dataclass -class Loadbalancer: - id: str - """ - 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: - name: str - """ - 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] = ( - MetricManagedMetric.MANAGED_METRIC_UNKNOWN - ) - - cockpit_metric_name: Optional[str] = None - - -@dataclass -class VolumeInstanceTemplate: - name: str - """ - 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] = None - - from_snapshot: Optional[VolumeInstanceTemplateFromSnapshot] = None - - perf_iops: Optional[int] = None - - -@dataclass -class InstanceGroupEvent: - id: str - """ - Instance group event ID. - """ - - source: InstanceGroupEventSource - """ - Log source. - """ - - level: InstanceGroupEventLevel - """ - The severity of the log. - """ - - name: str - """ - Log title. - """ - - created_at: Optional[datetime] = None - """ - Date and time of the log. - """ - - details: Optional[str] = None - """ - Full text of the log. - """ - - -@dataclass -class InstanceGroup: - id: str - """ - 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.). - """ - - zone: ScwZone - """ - Zone for this resource. - """ - - created_at: Optional[datetime] = None - """ - Date on which the Instance group was created. - """ - - updated_at: Optional[datetime] = None - """ - Date on which the Instance group was last updated. - """ - - -@dataclass -class InstancePolicy: - id: str - """ - 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. - """ - - zone: ScwZone - """ - Zone for this resource. - """ - - metric: Optional[Metric] = None - - -@dataclass -class InstanceTemplate: - id: str - """ - 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. - """ - - status: InstanceTemplateStatus - """ - Status of Instance template. - """ - - zone: ScwZone - """ - Zone for this resource. - """ - - image_id: Optional[str] = None - """ - 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] = None - """ - Instance security group ID (optional). - """ - - placement_group_id: Optional[str] = None - """ - 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] = 0 - """ - Number of flexible IPv4 addresses to attach to the new Instance. - """ - - public_ips_v6_count: Optional[int] = 0 - """ - Number of flexible IPv6 addresses to attach to the new Instance. - """ - - cloud_init: Optional[str] = None - """ - 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] = None - """ - Date on which the Instance template was created. - """ - - updated_at: Optional[datetime] = None - """ - Date on which the Instance template was last updated. - """ - - -@dataclass -class UpdateInstanceGroupRequestCapacity: - max_replicas: Optional[int] = 0 - """ - Maximum count of Instances for the Instance group. - """ - - min_replicas: Optional[int] = 0 - """ - Minimum count of Instances for the Instance group. - """ - - cooldown_delay: Optional[str] = None - """ - Time (in seconds) after a scaling action during which requests to carry out a new scaling action will be denied. - """ - - -@dataclass -class UpdateInstanceGroupRequestLoadbalancer: - backend_ids: Optional[list[str]] = field(default_factory=list) - """ - Load Balancer backend IDs. - """ - - -@dataclass -class UpdateInstancePolicyRequestMetric: - operator: UpdateInstancePolicyRequestMetricOperator - """ - 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] = None - """ - Name or description of your metric policy. - """ - - sampling_range_min: Optional[int] = 0 - """ - Interval of time, in minutes, during which metric is sampled. - """ - - threshold: Optional[float] = 0.0 - """ - 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] = ( - UpdateInstancePolicyRequestMetricManagedMetric.MANAGED_METRIC_UNKNOWN - ) - - cockpit_metric_name: Optional[str] = None - - -@dataclass -class CreateInstanceGroupRequest: - name: str - """ - 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] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - project_id: Optional[str] = None - """ - Project ID to filter for, only Instance groups from this Project will be returned. - """ - - tags: Optional[list[str]] = field(default_factory=list) - """ - List of tags for the Instance group. - """ - - -@dataclass -class CreateInstancePolicyRequest: - name: str - """ - 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] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - metric: Optional[Metric] = None - - -@dataclass -class CreateInstanceTemplateRequest: - commercial_type: str - """ - Name of Instance commercial type. - """ - - volumes: dict[str, VolumeInstanceTemplate] - """ - Template of Instance volume. - """ - - name: str - """ - Name of Instance template. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - image_id: Optional[str] = None - """ - 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]] = field(default_factory=list) - """ - List of tags for the Instance template. - """ - - security_group_id: Optional[str] = None - """ - Instance security group ID (optional). - """ - - placement_group_id: Optional[str] = None - """ - 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] = 0 - """ - Number of flexible IPv4 addresses to attach to the new Instance. - """ - - public_ips_v6_count: Optional[int] = 0 - """ - Number of flexible IPv6 addresses to attach to the new Instance. - """ - - project_id: Optional[str] = None - """ - ID of the Project containing the Instance template resource. - """ - - private_network_ids: Optional[list[str]] = field(default_factory=list) - """ - Private Network IDs to attach to the new Instance. - """ - - cloud_init: Optional[str] = None - """ - 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: - instance_group_id: str - """ - ID of the Instance group to delete. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class DeleteInstancePolicyRequest: - policy_id: str - """ - ID of the policy to delete. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class DeleteInstanceTemplateRequest: - template_id: str - """ - ID of the template to delete. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetInstanceGroupRequest: - instance_group_id: str - """ - ID of the requested Instance group. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetInstancePolicyRequest: - policy_id: str - """ - Policy ID. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetInstanceTemplateRequest: - template_id: str - """ - Template ID of the resource. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class ListInstanceGroupEventsRequest: - instance_group_id: str - """ - List all event logs for the Instance group ID. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstanceGroupEventsRequestOrderBy] = ( - ListInstanceGroupEventsRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of Instance groups to return per page. - """ - - -@dataclass -class ListInstanceGroupEventsResponse: - instance_events: list[InstanceGroupEvent] - """ - Paginated list of Instance groups. - """ - - total_count: int - """ - Count of all Instance groups matching the requested criteria. - """ - - -@dataclass -class ListInstanceGroupsRequest: - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstanceGroupsRequestOrderBy] = ( - ListInstanceGroupsRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of Instance groups to return per page. - """ - - -@dataclass -class ListInstanceGroupsResponse: - instance_groups: list[InstanceGroup] - """ - Paginated list of Instance groups. - """ - - total_count: int - """ - Count of all Instance groups matching the requested criteria. - """ - - -@dataclass -class ListInstancePoliciesRequest: - instance_group_id: str - """ - Instance group ID. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstancePoliciesRequestOrderBy] = ( - ListInstancePoliciesRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of scaling policies to return per page. - """ - - -@dataclass -class ListInstancePoliciesResponse: - policies: list[InstancePolicy] - """ - Paginated list of policies. - """ - - total_count: int - """ - Count of all policies matching the requested criteria. - """ - - -@dataclass -class ListInstanceTemplatesRequest: - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstanceTemplatesRequestOrderBy] = ( - ListInstanceTemplatesRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of Instance groups to return per page. - """ - - -@dataclass -class ListInstanceTemplatesResponse: - total_count: int - """ - Count of all templates matching the requested criteria. - """ - - instance_templates: list[InstanceTemplate] - """ - Paginated list of Instance templates. - """ - - -@dataclass -class UpdateInstanceGroupRequest: - instance_group_id: str - """ - Instance group ID to update. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - name: Optional[str] = None - """ - Name of Instance group. - """ - - tags: Optional[list[str]] = field(default_factory=list) - """ - List of tags for the Load Balancer. - """ - - capacity: Optional[UpdateInstanceGroupRequestCapacity] = None - """ - Specification of the minimum and maximum replicas for the Instance group, and the cooldown interval between two scaling events. - """ - - loadbalancer: Optional[UpdateInstanceGroupRequestLoadbalancer] = None - """ - Specification of the Load Balancer to link to the Instance group. - """ - - -@dataclass -class UpdateInstancePolicyRequest: - policy_id: str - """ - Policy ID to update. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - name: Optional[str] = None - """ - Policy name to update. - """ - - action: Optional[InstancePolicyAction] = InstancePolicyAction.UNKNOWN_ACTION - """ - Action to update (action to execute when the metric-based condition is met). - """ - - type_: Optional[InstancePolicyType] = InstancePolicyType.UNKNOWN_TYPE - """ - Type to update (how to use the number defined in `value` when determining by how many Instances to scale up/down). - """ - - value: Optional[int] = 0 - """ - Value to update (number representing the magnitude of the scaling action to take for the Instance group). - """ - - priority: Optional[int] = 0 - """ - Priority to update (priority of this policy compared to all other scaling policies. The lower the number, the higher the priority). - """ - - metric: Optional[UpdateInstancePolicyRequestMetric] = None - - -@dataclass -class UpdateInstanceTemplateRequest: - template_id: str - """ - Template ID of the resource. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - commercial_type: Optional[str] = None - """ - Name of Instance commercial type. - """ - - image_id: Optional[str] = None - """ - 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]] = field(default_factory=dict) - """ - Template of Instance volume. - """ - - tags: Optional[list[str]] = field(default_factory=list) - """ - List of tags for the Instance template. - """ - - security_group_id: Optional[str] = None - """ - Instance security group ID (optional). - """ - - placement_group_id: Optional[str] = None - """ - 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] = 0 - """ - Number of flexible IPv4 addresses to attach to the new Instance. - """ - - public_ips_v6_count: Optional[int] = 0 - """ - Number of flexible IPv6 addresses to attach to the new Instance. - """ - - name: Optional[str] = None - """ - Name of Instance template. - """ - - private_network_ids: Optional[list[str]] = field(default_factory=list) - """ - Private Network IDs to attach to the new Instance. - """ - - cloud_init: Optional[str] = None - """ - 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-async/scaleway_async/jobs/v1alpha2/types.py b/scaleway-async/scaleway_async/jobs/v1alpha2/types.py index 478b5c25f..5254160d1 100644 --- a/scaleway-async/scaleway_async/jobs/v1alpha2/types.py +++ b/scaleway-async/scaleway_async/jobs/v1alpha2/types.py @@ -29,6 +29,7 @@ class JobRunReason(str, Enum, metaclass=StrEnumMeta): SECRET_DISABLED = "secret_disabled" SECRET_NOT_FOUND = "secret_not_found" QUOTA_EXCEEDED = "quota_exceeded" + APPLICATION_NOT_STARTED = "application_not_started" def __str__(self) -> str: return str(self.value) diff --git a/scaleway/scaleway/autoscaling/v1alpha1/__init__.py b/scaleway/scaleway/autoscaling/v1alpha1/__init__.py deleted file mode 100644 index 67bcfcbe7..000000000 --- a/scaleway/scaleway/autoscaling/v1alpha1/__init__.py +++ /dev/null @@ -1,105 +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 InstanceGroupEventLevel -from .types import InstanceGroupEventSource -from .types import InstancePolicyAction -from .types import InstancePolicyType -from .types import InstanceTemplateStatus -from .types import ListInstanceGroupEventsRequestOrderBy -from .types import ListInstanceGroupsRequestOrderBy -from .types import ListInstancePoliciesRequestOrderBy -from .types import ListInstanceTemplatesRequestOrderBy -from .types import MetricAggregate -from .types import MetricManagedMetric -from .types import MetricOperator -from .types import UpdateInstancePolicyRequestMetricAggregate -from .types import UpdateInstancePolicyRequestMetricManagedMetric -from .types import UpdateInstancePolicyRequestMetricOperator -from .types import VolumeInstanceTemplateVolumeType -from .types import VolumeInstanceTemplateFromEmpty -from .types import VolumeInstanceTemplateFromSnapshot -from .types import Capacity -from .types import Loadbalancer -from .types import Metric -from .types import VolumeInstanceTemplate -from .types import InstanceGroupEvent -from .types import InstanceGroup -from .types import InstancePolicy -from .types import InstanceTemplate -from .types import UpdateInstanceGroupRequestCapacity -from .types import UpdateInstanceGroupRequestLoadbalancer -from .types import UpdateInstancePolicyRequestMetric -from .types import CreateInstanceGroupRequest -from .types import CreateInstancePolicyRequest -from .types import CreateInstanceTemplateRequest -from .types import DeleteInstanceGroupRequest -from .types import DeleteInstancePolicyRequest -from .types import DeleteInstanceTemplateRequest -from .types import GetInstanceGroupRequest -from .types import GetInstancePolicyRequest -from .types import GetInstanceTemplateRequest -from .types import ListInstanceGroupEventsRequest -from .types import ListInstanceGroupEventsResponse -from .types import ListInstanceGroupsRequest -from .types import ListInstanceGroupsResponse -from .types import ListInstancePoliciesRequest -from .types import ListInstancePoliciesResponse -from .types import ListInstanceTemplatesRequest -from .types import ListInstanceTemplatesResponse -from .types import UpdateInstanceGroupRequest -from .types import UpdateInstancePolicyRequest -from .types import UpdateInstanceTemplateRequest -from .api import AutoscalingV1Alpha1API - -__all__ = [ - "InstanceGroupEventLevel", - "InstanceGroupEventSource", - "InstancePolicyAction", - "InstancePolicyType", - "InstanceTemplateStatus", - "ListInstanceGroupEventsRequestOrderBy", - "ListInstanceGroupsRequestOrderBy", - "ListInstancePoliciesRequestOrderBy", - "ListInstanceTemplatesRequestOrderBy", - "MetricAggregate", - "MetricManagedMetric", - "MetricOperator", - "UpdateInstancePolicyRequestMetricAggregate", - "UpdateInstancePolicyRequestMetricManagedMetric", - "UpdateInstancePolicyRequestMetricOperator", - "VolumeInstanceTemplateVolumeType", - "VolumeInstanceTemplateFromEmpty", - "VolumeInstanceTemplateFromSnapshot", - "Capacity", - "Loadbalancer", - "Metric", - "VolumeInstanceTemplate", - "InstanceGroupEvent", - "InstanceGroup", - "InstancePolicy", - "InstanceTemplate", - "UpdateInstanceGroupRequestCapacity", - "UpdateInstanceGroupRequestLoadbalancer", - "UpdateInstancePolicyRequestMetric", - "CreateInstanceGroupRequest", - "CreateInstancePolicyRequest", - "CreateInstanceTemplateRequest", - "DeleteInstanceGroupRequest", - "DeleteInstancePolicyRequest", - "DeleteInstanceTemplateRequest", - "GetInstanceGroupRequest", - "GetInstancePolicyRequest", - "GetInstanceTemplateRequest", - "ListInstanceGroupEventsRequest", - "ListInstanceGroupEventsResponse", - "ListInstanceGroupsRequest", - "ListInstanceGroupsResponse", - "ListInstancePoliciesRequest", - "ListInstancePoliciesResponse", - "ListInstanceTemplatesRequest", - "ListInstanceTemplatesResponse", - "UpdateInstanceGroupRequest", - "UpdateInstancePolicyRequest", - "UpdateInstanceTemplateRequest", - "AutoscalingV1Alpha1API", -] diff --git a/scaleway/scaleway/autoscaling/v1alpha1/api.py b/scaleway/scaleway/autoscaling/v1alpha1/api.py deleted file mode 100644 index 42c941b2d..000000000 --- a/scaleway/scaleway/autoscaling/v1alpha1/api.py +++ /dev/null @@ -1,939 +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 Optional - -from scaleway_core.api import API -from scaleway_core.bridge import ( - Zone as ScwZone, -) -from scaleway_core.utils import ( - validate_path_param, - fetch_all_pages, -) -from .types import ( - InstancePolicyAction, - InstancePolicyType, - ListInstanceGroupEventsRequestOrderBy, - ListInstanceGroupsRequestOrderBy, - ListInstancePoliciesRequestOrderBy, - ListInstanceTemplatesRequestOrderBy, - Capacity, - CreateInstanceGroupRequest, - CreateInstancePolicyRequest, - CreateInstanceTemplateRequest, - InstanceGroup, - InstanceGroupEvent, - InstancePolicy, - InstanceTemplate, - ListInstanceGroupEventsResponse, - ListInstanceGroupsResponse, - ListInstancePoliciesResponse, - ListInstanceTemplatesResponse, - Loadbalancer, - Metric, - UpdateInstanceGroupRequest, - UpdateInstanceGroupRequestCapacity, - UpdateInstanceGroupRequestLoadbalancer, - UpdateInstancePolicyRequest, - UpdateInstancePolicyRequestMetric, - UpdateInstanceTemplateRequest, - VolumeInstanceTemplate, -) -from .marshalling import ( - unmarshal_InstanceGroup, - unmarshal_InstancePolicy, - unmarshal_InstanceTemplate, - unmarshal_ListInstanceGroupEventsResponse, - unmarshal_ListInstanceGroupsResponse, - unmarshal_ListInstancePoliciesResponse, - unmarshal_ListInstanceTemplatesResponse, - marshal_CreateInstanceGroupRequest, - marshal_CreateInstancePolicyRequest, - marshal_CreateInstanceTemplateRequest, - marshal_UpdateInstanceGroupRequest, - marshal_UpdateInstancePolicyRequest, - marshal_UpdateInstanceTemplateRequest, -) - - -class AutoscalingV1Alpha1API(API): - """ """ - - def get_instance_group( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - ) -> InstanceGroup: - """ - Get Instance group. - Retrieve information about an existing Instance group, specified by its `instance_group_id`. Its full details, including errors, are returned in the response object. - :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 - ) - - res = self._request( - "GET", - f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", - ) - - self._throw_on_error(res) - return unmarshal_InstanceGroup(res.json()) - - def create_instance_group( - self, - *, - name: str, - template_id: str, - capacity: Capacity, - loadbalancer: Loadbalancer, - zone: Optional[ScwZone] = None, - project_id: Optional[str] = None, - tags: Optional[list[str]] = None, - ) -> InstanceGroup: - """ - Create Instance group. - Create a new Instance group. You must specify a `template_id`, capacity and Load Balancer object. - :param name: Name of Instance group. - :param template_id: Template ID (ID of the Instance template to attach to the 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. - :param zone: Zone to target. If none is passed will use default zone from the config. - :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", - capacity=Capacity(), - 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", - body=marshal_CreateInstanceGroupRequest( - CreateInstanceGroupRequest( - name=name, - template_id=template_id, - capacity=capacity, - loadbalancer=loadbalancer, - zone=zone, - project_id=project_id, - tags=tags, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceGroup(res.json()) - - def list_instance_groups( - self, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstanceGroupsResponse: - """ - List Instance groups. - List all Instance groups, for a Scaleway Organization or Scaleway Project. By default, the Instance groups returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstanceGroupsResponse(res.json()) - - def list_instance_groups_all( - self, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstanceGroup]: - """ - List Instance groups. - List all Instance groups, for a Scaleway Organization or Scaleway Project. By default, the Instance groups returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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( - type=ListInstanceGroupsResponse, - key="instance_groups", - fetcher=self.list_instance_groups, - args={ - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) - - def update_instance_group( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - name: Optional[str] = None, - tags: Optional[list[str]] = None, - capacity: Optional[UpdateInstanceGroupRequestCapacity] = None, - loadbalancer: Optional[UpdateInstanceGroupRequestLoadbalancer] = None, - ) -> InstanceGroup: - """ - Update Instance group. - Update the parameters of an existing Instance group, specified by its `instance_group_id`. - :param instance_group_id: Instance group ID to update. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param name: Name of Instance group. - :param tags: List of tags for the Load Balancer. - :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 - ) - - res = self._request( - "PATCH", - f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}", - body=marshal_UpdateInstanceGroupRequest( - UpdateInstanceGroupRequest( - instance_group_id=instance_group_id, - zone=zone, - name=name, - tags=tags, - capacity=capacity, - loadbalancer=loadbalancer, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceGroup(res.json()) - - def delete_instance_group( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - ) -> None: - """ - 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 - ) - - 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, - *, - zone: Optional[ScwZone] = None, - commercial_type: str, - volumes: dict[str, VolumeInstanceTemplate], - image_id: Optional[str] = None, - tags: Optional[list[str]] = None, - security_group_id: Optional[str] = None, - name: str, - placement_group_id: Optional[str] = None, - public_ips_v4_count: Optional[int] = None, - public_ips_v6_count: Optional[int] = None, - project_id: Optional[str] = None, - private_network_ids: Optional[list[str]] = None, - cloud_init: Optional[str] = None, - ) -> InstanceTemplate: - """ - Create Instance template. - Create a new Instance template. This specifies the details of the Instance (commercial type, zone, image, volumes etc.) that will be in the Instance group. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param commercial_type: Name of Instance commercial type. - :param volumes: Template of Instance volume. - :param image_id: Instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. - :param tags: List of tags for the Instance template. - :param security_group_id: Instance security group ID (optional). - :param name: Name of Instance template. - :param placement_group_id: Instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. - :param public_ips_v4_count: Number of flexible IPv4 addresses to attach to the new Instance. - :param public_ips_v6_count: Number of flexible IPv6 addresses to attach to the new Instance. - :param project_id: ID of the Project containing the Instance template resource. - :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", - body=marshal_CreateInstanceTemplateRequest( - CreateInstanceTemplateRequest( - zone=zone, - commercial_type=commercial_type, - volumes=volumes, - image_id=image_id, - tags=tags, - security_group_id=security_group_id, - name=name, - placement_group_id=placement_group_id, - public_ips_v4_count=public_ips_v4_count, - public_ips_v6_count=public_ips_v6_count, - project_id=project_id, - private_network_ids=private_network_ids, - cloud_init=cloud_init, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceTemplate(res.json()) - - def update_instance_template( - self, - *, - template_id: str, - zone: Optional[ScwZone] = None, - commercial_type: Optional[str] = None, - image_id: Optional[str] = None, - volumes: Optional[dict[str, VolumeInstanceTemplate]] = None, - tags: Optional[list[str]] = None, - security_group_id: Optional[str] = None, - placement_group_id: Optional[str] = None, - public_ips_v4_count: Optional[int] = None, - public_ips_v6_count: Optional[int] = None, - name: Optional[str] = None, - private_network_ids: Optional[list[str]] = None, - cloud_init: Optional[str] = None, - ) -> InstanceTemplate: - """ - Update Instance template. - Update an Instance template, such as its commercial offer type, image or volume 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. - :param commercial_type: Name of Instance commercial type. - :param image_id: Instance image ID. Can be an ID of a marketplace or personal image. This image must be compatible with `volume` and `commercial_type` template. - :param volumes: Template of Instance volume. - :param tags: List of tags for the Instance template. - :param security_group_id: Instance security group ID (optional). - :param placement_group_id: Instance placement group ID. This is optional, but it is highly recommended to set a preference for Instance location within Availability Zone. - :param public_ips_v4_count: Number of flexible IPv4 addresses to attach to the new Instance. - :param public_ips_v6_count: Number of flexible IPv6 addresses to attach to the new Instance. - :param name: Name of 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}", - body=marshal_UpdateInstanceTemplateRequest( - UpdateInstanceTemplateRequest( - template_id=template_id, - zone=zone, - commercial_type=commercial_type, - image_id=image_id, - volumes=volumes, - tags=tags, - security_group_id=security_group_id, - placement_group_id=placement_group_id, - public_ips_v4_count=public_ips_v4_count, - public_ips_v6_count=public_ips_v6_count, - name=name, - private_network_ids=private_network_ids, - cloud_init=cloud_init, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstanceTemplate(res.json()) - - def get_instance_template( - self, - *, - template_id: str, - zone: Optional[ScwZone] = None, - ) -> InstanceTemplate: - """ - Get Instance template. - Get an existing Instance template from its `template_id`. - :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}", - ) - - self._throw_on_error(res) - return unmarshal_InstanceTemplate(res.json()) - - def delete_instance_template( - self, - *, - template_id: str, - zone: Optional[ScwZone] = None, - ) -> None: - """ - 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, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceTemplatesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstanceTemplatesResponse: - """ - List Instance templates. - List all Instance templates, for a Scaleway Organization or Scaleway Project. By default, the Instance templates returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstanceTemplatesResponse(res.json()) - - def list_instance_templates_all( - self, - *, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceTemplatesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstanceTemplate]: - """ - List Instance templates. - List all Instance templates, for a Scaleway Organization or Scaleway Project. By default, the Instance templates returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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( - type=ListInstanceTemplatesResponse, - key="instance_templates", - fetcher=self.list_instance_templates, - args={ - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) - - def create_instance_policy( - self, - *, - name: str, - action: InstancePolicyAction, - type_: InstancePolicyType, - value: int, - priority: int, - instance_group_id: str, - zone: Optional[ScwZone] = None, - metric: Optional[Metric] = None, - ) -> InstancePolicy: - """ - Create scaling policy. - Create a new scaling policy. You must specify a `policy_id`, capacity and Load Balancer object. - :param name: Name of the policy. - :param action: Action to execute when the metric-based condition is met. - :param type_: How to use the number defined in `value` when determining by how many Instances to scale up/down. - :param value: 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. - :param priority: Priority of this policy compared to all other scaling policies. This determines the processing order. The lower the number, the higher the priority. - :param instance_group_id: Instance group ID related to this policy. - :param zone: Zone to target. If none is passed will use default zone from the config. - :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, - type=InstancePolicyType.unknown_type, - value=1, - priority=1, - 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", - body=marshal_CreateInstancePolicyRequest( - CreateInstancePolicyRequest( - name=name, - action=action, - type_=type_, - value=value, - priority=priority, - instance_group_id=instance_group_id, - zone=zone, - metric=metric, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstancePolicy(res.json()) - - def update_instance_policy( - self, - *, - policy_id: str, - zone: Optional[ScwZone] = None, - name: Optional[str] = None, - metric: Optional[UpdateInstancePolicyRequestMetric] = None, - action: Optional[InstancePolicyAction] = None, - type_: Optional[InstancePolicyType] = None, - value: Optional[int] = None, - priority: Optional[int] = None, - ) -> InstancePolicy: - """ - Update scaling policy. - Update the parameters of an existing scaling policy, specified by its `policy_id`. - :param policy_id: Policy ID to update. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param name: Policy name to update. - :param metric: Metric specification to update (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. - :param action: Action to update (action to execute when the metric-based condition is met). - :param type_: Type to update (how to use the number defined in `value` when determining by how many Instances to scale up/down). - :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}", - body=marshal_UpdateInstancePolicyRequest( - UpdateInstancePolicyRequest( - policy_id=policy_id, - zone=zone, - name=name, - action=action, - type_=type_, - value=value, - priority=priority, - metric=metric, - ), - self.client, - ), - ) - - self._throw_on_error(res) - return unmarshal_InstancePolicy(res.json()) - - def list_instance_policies( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstancePoliciesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstancePoliciesResponse: - """ - List scaling policies. - List all scaling policies, for a Scaleway Organization or Scaleway Project. By default, the policies returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param instance_group_id: Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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", - params={ - "instance_group_id": instance_group_id, - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstancePoliciesResponse(res.json()) - - def list_instance_policies_all( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstancePoliciesRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstancePolicy]: - """ - List scaling policies. - List all scaling policies, for a Scaleway Organization or Scaleway Project. By default, the policies returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field. - :param instance_group_id: Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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( - type=ListInstancePoliciesResponse, - key="policies", - fetcher=self.list_instance_policies, - args={ - "instance_group_id": instance_group_id, - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) - - def get_instance_policy( - self, - *, - policy_id: str, - zone: Optional[ScwZone] = None, - ) -> InstancePolicy: - """ - Get scaling policy. - Retrieve information about an existing scaling policy, specified by its `policy_id`. Its full details are returned in the response object. - :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}", - ) - - self._throw_on_error(res) - return unmarshal_InstancePolicy(res.json()) - - def delete_instance_policy( - self, - *, - policy_id: str, - zone: Optional[ScwZone] = None, - ) -> None: - """ - Delete scaling 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, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupEventsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> ListInstanceGroupEventsResponse: - """ - List events. - List all events for a given Instance group. By default, the events are ordered by creation date in descending order, though this can be modified via the `order_by` field. - :param instance_group_id: List all event logs for the Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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 - ) - - res = self._request( - "GET", - f"/autoscaling/v1alpha1/zones/{param_zone}/instance-groups/{param_instance_group_id}/events", - params={ - "order_by": order_by, - "page": page, - "page_size": page_size or self.client.default_page_size, - }, - ) - - self._throw_on_error(res) - return unmarshal_ListInstanceGroupEventsResponse(res.json()) - - def list_instance_group_events_all( - self, - *, - instance_group_id: str, - zone: Optional[ScwZone] = None, - order_by: Optional[ListInstanceGroupEventsRequestOrderBy] = None, - page: Optional[int] = None, - page_size: Optional[int] = None, - ) -> list[InstanceGroupEvent]: - """ - List events. - List all events for a given Instance group. By default, the events are ordered by creation date in descending order, though this can be modified via the `order_by` field. - :param instance_group_id: List all event logs for the Instance group ID. - :param zone: Zone to target. If none is passed will use default zone from the config. - :param order_by: Sort order of Instance groups in the response. - :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( - type=ListInstanceGroupEventsResponse, - key="instance_events", - fetcher=self.list_instance_group_events, - args={ - "instance_group_id": instance_group_id, - "zone": zone, - "order_by": order_by, - "page": page, - "page_size": page_size, - }, - ) diff --git a/scaleway/scaleway/autoscaling/v1alpha1/marshalling.py b/scaleway/scaleway/autoscaling/v1alpha1/marshalling.py deleted file mode 100644 index 37c7f0860..000000000 --- a/scaleway/scaleway/autoscaling/v1alpha1/marshalling.py +++ /dev/null @@ -1,1107 +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 -from dateutil import parser - -from scaleway_core.profile import ProfileDefaults -from scaleway_core.utils import ( - OneOfPossibility, - resolve_one_of, -) -from .types import ( - InstanceGroupEventLevel, - InstanceGroupEventSource, - InstancePolicyAction, - InstancePolicyType, - InstanceTemplateStatus, - MetricAggregate, - MetricManagedMetric, - MetricOperator, - VolumeInstanceTemplateVolumeType, - Capacity, - Loadbalancer, - InstanceGroup, - Metric, - InstancePolicy, - VolumeInstanceTemplateFromEmpty, - VolumeInstanceTemplateFromSnapshot, - VolumeInstanceTemplate, - InstanceTemplate, - InstanceGroupEvent, - ListInstanceGroupEventsResponse, - ListInstanceGroupsResponse, - ListInstancePoliciesResponse, - ListInstanceTemplatesResponse, - CreateInstanceGroupRequest, - CreateInstancePolicyRequest, - CreateInstanceTemplateRequest, - UpdateInstanceGroupRequestCapacity, - UpdateInstanceGroupRequestLoadbalancer, - UpdateInstanceGroupRequest, - UpdateInstancePolicyRequestMetric, - UpdateInstancePolicyRequest, - UpdateInstanceTemplateRequest, -) - - -def unmarshal_Capacity(data: Any) -> Capacity: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Capacity' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("max_replicas", None) - if field is not None: - args["max_replicas"] = field - else: - args["max_replicas"] = 0 - - field = data.get("min_replicas", None) - if field is not None: - args["min_replicas"] = field - else: - args["min_replicas"] = 0 - - field = data.get("cooldown_delay", None) - if field is not None: - args["cooldown_delay"] = field - else: - args["cooldown_delay"] = None - - return Capacity(**args) - - -def unmarshal_Loadbalancer(data: Any) -> Loadbalancer: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Loadbalancer' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("backend_ids", None) - if field is not None: - args["backend_ids"] = field - else: - args["backend_ids"] = [] - - field = data.get("private_network_id", None) - if field is not None: - args["private_network_id"] = field - else: - args["private_network_id"] = None - - return Loadbalancer(**args) - - -def unmarshal_InstanceGroup(data: Any) -> InstanceGroup: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstanceGroup' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field - else: - args["project_id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("tags", None) - if field is not None: - args["tags"] = field - else: - args["tags"] = [] - - field = data.get("instance_template_id", None) - if field is not None: - args["instance_template_id"] = field - else: - args["instance_template_id"] = None - - field = data.get("capacity", None) - if field is not None: - args["capacity"] = unmarshal_Capacity(field) - else: - args["capacity"] = None - - field = data.get("loadbalancer", None) - if field is not None: - args["loadbalancer"] = unmarshal_Loadbalancer(field) - else: - args["loadbalancer"] = None - - field = data.get("error_messages", None) - if field is not None: - args["error_messages"] = field - else: - args["error_messages"] = [] - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - else: - args["zone"] = None - - field = data.get("created_at", None) - if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["created_at"] = None - - field = data.get("updated_at", None) - if field is not None: - args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["updated_at"] = None - - return InstanceGroup(**args) - - -def unmarshal_Metric(data: Any) -> Metric: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'Metric' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("operator", None) - if field is not None: - args["operator"] = field - else: - args["operator"] = MetricOperator.OPERATOR_UNKNOWN - - field = data.get("aggregate", None) - if field is not None: - args["aggregate"] = field - else: - args["aggregate"] = MetricAggregate.AGGREGATE_UNKNOWN - - field = data.get("sampling_range_min", None) - if field is not None: - args["sampling_range_min"] = field - else: - args["sampling_range_min"] = 0 - - field = data.get("threshold", None) - if field is not None: - args["threshold"] = field - else: - args["threshold"] = 0.0 - - field = data.get("managed_metric", None) - if field is not None: - args["managed_metric"] = field - else: - args["managed_metric"] = MetricManagedMetric.MANAGED_METRIC_UNKNOWN - - field = data.get("cockpit_metric_name", None) - if field is not None: - args["cockpit_metric_name"] = field - else: - args["cockpit_metric_name"] = None - - return Metric(**args) - - -def unmarshal_InstancePolicy(data: Any) -> InstancePolicy: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstancePolicy' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("action", None) - if field is not None: - args["action"] = field - else: - args["action"] = InstancePolicyAction.UNKNOWN_ACTION - - field = data.get("type", None) - if field is not None: - args["type_"] = field - else: - args["type_"] = InstancePolicyType.UNKNOWN_TYPE - - field = data.get("value", None) - if field is not None: - args["value"] = field - else: - args["value"] = 0 - - field = data.get("priority", None) - if field is not None: - args["priority"] = field - else: - args["priority"] = 0 - - field = data.get("instance_group_id", None) - if field is not None: - args["instance_group_id"] = field - else: - args["instance_group_id"] = None - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - else: - args["zone"] = None - - field = data.get("metric", None) - if field is not None: - args["metric"] = unmarshal_Metric(field) - else: - args["metric"] = None - - return InstancePolicy(**args) - - -def unmarshal_VolumeInstanceTemplateFromEmpty( - data: Any, -) -> VolumeInstanceTemplateFromEmpty: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'VolumeInstanceTemplateFromEmpty' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("size", None) - if field is not None: - args["size"] = field - else: - args["size"] = None - - return VolumeInstanceTemplateFromEmpty(**args) - - -def unmarshal_VolumeInstanceTemplateFromSnapshot( - data: Any, -) -> VolumeInstanceTemplateFromSnapshot: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'VolumeInstanceTemplateFromSnapshot' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("snapshot_id", None) - if field is not None: - args["snapshot_id"] = field - else: - args["snapshot_id"] = None - - field = data.get("size", None) - if field is not None: - args["size"] = field - else: - args["size"] = None - - return VolumeInstanceTemplateFromSnapshot(**args) - - -def unmarshal_VolumeInstanceTemplate(data: Any) -> VolumeInstanceTemplate: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'VolumeInstanceTemplate' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("tags", None) - if field is not None: - args["tags"] = field - else: - args["tags"] = [] - - field = data.get("boot", None) - if field is not None: - args["boot"] = field - else: - args["boot"] = False - - field = data.get("volume_type", None) - if field is not None: - args["volume_type"] = field - else: - args["volume_type"] = VolumeInstanceTemplateVolumeType.UNKNOWN_VOLUME_TYPE - - field = data.get("perf_iops", None) - if field is not None: - args["perf_iops"] = field - else: - args["perf_iops"] = None - - field = data.get("from_empty", None) - if field is not None: - args["from_empty"] = unmarshal_VolumeInstanceTemplateFromEmpty(field) - else: - args["from_empty"] = None - - field = data.get("from_snapshot", None) - if field is not None: - args["from_snapshot"] = unmarshal_VolumeInstanceTemplateFromSnapshot(field) - else: - args["from_snapshot"] = None - - return VolumeInstanceTemplate(**args) - - -def unmarshal_InstanceTemplate(data: Any) -> InstanceTemplate: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstanceTemplate' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("commercial_type", None) - if field is not None: - args["commercial_type"] = field - else: - args["commercial_type"] = None - - 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 - ) - else: - args["volumes"] = {} - - field = data.get("tags", None) - if field is not None: - args["tags"] = field - else: - args["tags"] = [] - - field = data.get("project_id", None) - if field is not None: - args["project_id"] = field - else: - args["project_id"] = None - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("private_network_ids", None) - if field is not None: - args["private_network_ids"] = field - else: - args["private_network_ids"] = [] - - field = data.get("image_id", None) - if field is not None: - args["image_id"] = field - else: - args["image_id"] = None - - field = data.get("security_group_id", None) - if field is not None: - args["security_group_id"] = field - else: - args["security_group_id"] = None - - field = data.get("placement_group_id", None) - if field is not None: - args["placement_group_id"] = field - else: - args["placement_group_id"] = None - - 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"] = 0 - - 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"] = 0 - - field = data.get("status", None) - if field is not None: - args["status"] = field - else: - args["status"] = InstanceTemplateStatus.UNKNOWN_STATUS - - field = data.get("zone", None) - if field is not None: - args["zone"] = field - else: - args["zone"] = None - - field = data.get("cloud_init", None) - if field is not None: - args["cloud_init"] = field - else: - args["cloud_init"] = None - - field = data.get("created_at", None) - if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["created_at"] = None - - field = data.get("updated_at", None) - if field is not None: - args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["updated_at"] = None - - return InstanceTemplate(**args) - - -def unmarshal_InstanceGroupEvent(data: Any) -> InstanceGroupEvent: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'InstanceGroupEvent' failed as data isn't a dictionary." - ) - - args: dict[str, Any] = {} - - field = data.get("id", None) - if field is not None: - args["id"] = field - else: - args["id"] = None - - field = data.get("source", None) - if field is not None: - args["source"] = field - else: - args["source"] = InstanceGroupEventSource.UNKNOWN_SOURCE - - field = data.get("level", None) - if field is not None: - args["level"] = field - else: - args["level"] = InstanceGroupEventLevel.INFO - - field = data.get("name", None) - if field is not None: - args["name"] = field - else: - args["name"] = None - - field = data.get("created_at", None) - if field is not None: - args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field - else: - args["created_at"] = None - - field = data.get("details", None) - if field is not None: - args["details"] = field - else: - args["details"] = None - - return InstanceGroupEvent(**args) - - -def unmarshal_ListInstanceGroupEventsResponse( - data: Any, -) -> ListInstanceGroupEventsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstanceGroupEventsResponse' failed as data isn't a dictionary." - ) - - 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 - ) - else: - args["instance_events"] = [] - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - else: - args["total_count"] = 0 - - return ListInstanceGroupEventsResponse(**args) - - -def unmarshal_ListInstanceGroupsResponse(data: Any) -> ListInstanceGroupsResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstanceGroupsResponse' failed as data isn't a dictionary." - ) - - 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 - ) - else: - args["instance_groups"] = [] - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - else: - args["total_count"] = 0 - - return ListInstanceGroupsResponse(**args) - - -def unmarshal_ListInstancePoliciesResponse(data: Any) -> ListInstancePoliciesResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstancePoliciesResponse' failed as data isn't a dictionary." - ) - - 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 - ) - else: - args["policies"] = [] - - field = data.get("total_count", None) - if field is not None: - args["total_count"] = field - else: - args["total_count"] = 0 - - return ListInstancePoliciesResponse(**args) - - -def unmarshal_ListInstanceTemplatesResponse(data: Any) -> ListInstanceTemplatesResponse: - if not isinstance(data, dict): - raise TypeError( - "Unmarshalling the type 'ListInstanceTemplatesResponse' 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 - else: - args["total_count"] = 0 - - 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 - ) - else: - args["instance_templates"] = [] - - return ListInstanceTemplatesResponse(**args) - - -def marshal_Capacity( - request: Capacity, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.max_replicas is not None: - output["max_replicas"] = request.max_replicas - - if request.min_replicas is not None: - output["min_replicas"] = request.min_replicas - - if request.cooldown_delay is not None: - output["cooldown_delay"] = request.cooldown_delay - - return output - - -def marshal_Loadbalancer( - request: Loadbalancer, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.id is not None: - output["id"] = request.id - - if request.backend_ids is not None: - output["backend_ids"] = request.backend_ids - - if request.private_network_id is not None: - output["private_network_id"] = request.private_network_id - - return output - - -def marshal_CreateInstanceGroupRequest( - request: CreateInstanceGroupRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.name is not None: - output["name"] = request.name - - if request.template_id is not None: - output["template_id"] = request.template_id - - if request.capacity is not None: - output["capacity"] = marshal_Capacity(request.capacity, defaults) - - if request.loadbalancer is not None: - output["loadbalancer"] = marshal_Loadbalancer(request.loadbalancer, defaults) - - if request.project_id is not None: - output["project_id"] = request.project_id - else: - output["project_id"] = defaults.default_project_id - - if request.tags is not None: - output["tags"] = request.tags - - return output - - -def marshal_Metric( - request: Metric, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="managed_metric", - value=request.managed_metric, - marshal_func=None, - ), - OneOfPossibility( - param="cockpit_metric_name", - value=request.cockpit_metric_name, - marshal_func=None, - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.operator is not None: - output["operator"] = request.operator - - if request.aggregate is not None: - output["aggregate"] = request.aggregate - - if request.sampling_range_min is not None: - output["sampling_range_min"] = request.sampling_range_min - - if request.threshold is not None: - output["threshold"] = request.threshold - - return output - - -def marshal_CreateInstancePolicyRequest( - request: CreateInstancePolicyRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="metric", value=request.metric, marshal_func=marshal_Metric - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.action is not None: - output["action"] = request.action - - if request.type_ is not None: - output["type"] = request.type_ - - if request.value is not None: - output["value"] = request.value - - if request.priority is not None: - output["priority"] = request.priority - - if request.instance_group_id is not None: - output["instance_group_id"] = request.instance_group_id - - return output - - -def marshal_VolumeInstanceTemplateFromEmpty( - request: VolumeInstanceTemplateFromEmpty, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.size is not None: - output["size"] = request.size - - return output - - -def marshal_VolumeInstanceTemplateFromSnapshot( - request: VolumeInstanceTemplateFromSnapshot, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.snapshot_id is not None: - output["snapshot_id"] = request.snapshot_id - - if request.size is not None: - output["size"] = request.size - - return output - - -def marshal_VolumeInstanceTemplate( - request: VolumeInstanceTemplate, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - 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( - param="perf_iops", value=request.perf_iops, marshal_func=None - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.tags is not None: - output["tags"] = request.tags - - if request.boot is not None: - output["boot"] = request.boot - - if request.volume_type is not None: - output["volume_type"] = request.volume_type - - return output - - -def marshal_CreateInstanceTemplateRequest( - request: CreateInstanceTemplateRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.commercial_type is not None: - output["commercial_type"] = request.commercial_type - - if request.volumes is not None: - output["volumes"] = { - key: marshal_VolumeInstanceTemplate(value, defaults) - for key, value in request.volumes.items() - } - - if request.image_id is not None: - output["image_id"] = request.image_id - - if request.tags is not None: - output["tags"] = request.tags - - if request.security_group_id is not None: - output["security_group_id"] = request.security_group_id - - if request.name is not None: - output["name"] = request.name - - if request.placement_group_id is not None: - output["placement_group_id"] = request.placement_group_id - - if request.public_ips_v4_count is not None: - output["public_ips_v4_count"] = request.public_ips_v4_count - - if request.public_ips_v6_count is not None: - output["public_ips_v6_count"] = request.public_ips_v6_count - - if request.project_id is not None: - output["project_id"] = request.project_id - else: - output["project_id"] = defaults.default_project_id - - if request.private_network_ids is not None: - output["private_network_ids"] = request.private_network_ids - - if request.cloud_init is not None: - output["cloud_init"] = request.cloud_init - - return output - - -def marshal_UpdateInstanceGroupRequestCapacity( - request: UpdateInstanceGroupRequestCapacity, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.max_replicas is not None: - output["max_replicas"] = request.max_replicas - - if request.min_replicas is not None: - output["min_replicas"] = request.min_replicas - - if request.cooldown_delay is not None: - output["cooldown_delay"] = request.cooldown_delay - - return output - - -def marshal_UpdateInstanceGroupRequestLoadbalancer( - request: UpdateInstanceGroupRequestLoadbalancer, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.backend_ids is not None: - output["backend_ids"] = request.backend_ids - - return output - - -def marshal_UpdateInstanceGroupRequest( - request: UpdateInstanceGroupRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.name is not None: - output["name"] = request.name - - if request.tags is not None: - output["tags"] = request.tags - - if request.capacity is not None: - output["capacity"] = marshal_UpdateInstanceGroupRequestCapacity( - request.capacity, defaults - ) - - if request.loadbalancer is not None: - output["loadbalancer"] = marshal_UpdateInstanceGroupRequestLoadbalancer( - request.loadbalancer, defaults - ) - - return output - - -def marshal_UpdateInstancePolicyRequestMetric( - request: UpdateInstancePolicyRequestMetric, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="managed_metric", - value=request.managed_metric, - marshal_func=None, - ), - OneOfPossibility( - param="cockpit_metric_name", - value=request.cockpit_metric_name, - marshal_func=None, - ), - ] - ), - ) - - if request.operator is not None: - output["operator"] = request.operator - - if request.aggregate is not None: - output["aggregate"] = request.aggregate - - if request.name is not None: - output["name"] = request.name - - if request.sampling_range_min is not None: - output["sampling_range_min"] = request.sampling_range_min - - if request.threshold is not None: - output["threshold"] = request.threshold - - return output - - -def marshal_UpdateInstancePolicyRequest( - request: UpdateInstancePolicyRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - output.update( - resolve_one_of( - [ - OneOfPossibility( - param="metric", - value=request.metric, - marshal_func=marshal_UpdateInstancePolicyRequestMetric, - ), - ] - ), - ) - - if request.name is not None: - output["name"] = request.name - - if request.action is not None: - output["action"] = request.action - - if request.type_ is not None: - output["type"] = request.type_ - - if request.value is not None: - output["value"] = request.value - - if request.priority is not None: - output["priority"] = request.priority - - return output - - -def marshal_UpdateInstanceTemplateRequest( - request: UpdateInstanceTemplateRequest, - defaults: ProfileDefaults, -) -> dict[str, Any]: - output: dict[str, Any] = {} - - if request.commercial_type is not None: - output["commercial_type"] = request.commercial_type - - if request.image_id is not None: - output["image_id"] = request.image_id - - if request.volumes is not None: - output["volumes"] = { - key: marshal_VolumeInstanceTemplate(value, defaults) - for key, value in request.volumes.items() - } - - if request.tags is not None: - output["tags"] = request.tags - - if request.security_group_id is not None: - output["security_group_id"] = request.security_group_id - - if request.placement_group_id is not None: - output["placement_group_id"] = request.placement_group_id - - if request.public_ips_v4_count is not None: - output["public_ips_v4_count"] = request.public_ips_v4_count - - if request.public_ips_v6_count is not None: - output["public_ips_v6_count"] = request.public_ips_v6_count - - if request.name is not None: - output["name"] = request.name - - if request.private_network_ids is not None: - output["private_network_ids"] = request.private_network_ids - - if request.cloud_init is not None: - output["cloud_init"] = request.cloud_init - - return output diff --git a/scaleway/scaleway/autoscaling/v1alpha1/types.py b/scaleway/scaleway/autoscaling/v1alpha1/types.py deleted file mode 100644 index 58bbb50fd..000000000 --- a/scaleway/scaleway/autoscaling/v1alpha1/types.py +++ /dev/null @@ -1,1093 +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, field -from datetime import datetime -from enum import Enum -from typing import Optional - -from scaleway_core.bridge import ( - Zone as ScwZone, -) -from scaleway_core.utils import ( - StrEnumMeta, -) - - -class InstanceGroupEventLevel(str, Enum, metaclass=StrEnumMeta): - INFO = "info" - SUCCESS = "success" - ERROR = "error" - - def __str__(self) -> str: - return str(self.value) - - -class InstanceGroupEventSource(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_SOURCE = "unknown_source" - WATCHER = "watcher" - SCALER = "scaler" - INSTANCE_MANAGER = "instance_manager" - SUPERVISOR = "supervisor" - - def __str__(self) -> str: - return str(self.value) - - -class InstancePolicyAction(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_ACTION = "unknown_action" - SCALE_UP = "scale_up" - SCALE_DOWN = "scale_down" - - def __str__(self) -> str: - return str(self.value) - - -class InstancePolicyType(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_TYPE = "unknown_type" - FLAT_COUNT = "flat_count" - PERCENT_OF_TOTAL_GROUP = "percent_of_total_group" - SET_TOTAL_GROUP = "set_total_group" - - def __str__(self) -> str: - return str(self.value) - - -class InstanceTemplateStatus(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_STATUS = "unknown_status" - READY = "ready" - ERROR = "error" - - 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" - - 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" - - 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" - - 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" - - def __str__(self) -> str: - return str(self.value) - - -class MetricAggregate(str, Enum, metaclass=StrEnumMeta): - AGGREGATE_UNKNOWN = "aggregate_unknown" - AGGREGATE_AVERAGE = "aggregate_average" - AGGREGATE_MAX = "aggregate_max" - AGGREGATE_MIN = "aggregate_min" - AGGREGATE_SUM = "aggregate_sum" - - 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_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" - OPERATOR_LESS_THAN = "operator_less_than" - - def __str__(self) -> str: - return str(self.value) - - -class UpdateInstancePolicyRequestMetricAggregate(str, Enum, metaclass=StrEnumMeta): - AGGREGATE_UNKNOWN = "aggregate_unknown" - AGGREGATE_AVERAGE = "aggregate_average" - AGGREGATE_MAX = "aggregate_max" - AGGREGATE_MIN = "aggregate_min" - AGGREGATE_SUM = "aggregate_sum" - - 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_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" - OPERATOR_LESS_THAN = "operator_less_than" - - def __str__(self) -> str: - return str(self.value) - - -class VolumeInstanceTemplateVolumeType(str, Enum, metaclass=StrEnumMeta): - UNKNOWN_VOLUME_TYPE = "unknown_volume_type" - L_SSD = "l_ssd" - SBS = "sbs" - - def __str__(self) -> str: - return str(self.value) - - -@dataclass -class VolumeInstanceTemplateFromEmpty: - size: int - - -@dataclass -class VolumeInstanceTemplateFromSnapshot: - snapshot_id: str - size: Optional[int] = None - - -@dataclass -class Capacity: - max_replicas: int - """ - Maximum count of Instances for the Instance group. - """ - - min_replicas: int - """ - Minimum count of Instances for the Instance group. - """ - - cooldown_delay: Optional[str] = None - """ - Time (in seconds) after a scaling action during which requests to carry out a new scaling action will be denied. - """ - - -@dataclass -class Loadbalancer: - id: str - """ - 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: - name: str - """ - 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] = ( - MetricManagedMetric.MANAGED_METRIC_UNKNOWN - ) - - cockpit_metric_name: Optional[str] = None - - -@dataclass -class VolumeInstanceTemplate: - name: str - """ - 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] = None - - from_snapshot: Optional[VolumeInstanceTemplateFromSnapshot] = None - - perf_iops: Optional[int] = None - - -@dataclass -class InstanceGroupEvent: - id: str - """ - Instance group event ID. - """ - - source: InstanceGroupEventSource - """ - Log source. - """ - - level: InstanceGroupEventLevel - """ - The severity of the log. - """ - - name: str - """ - Log title. - """ - - created_at: Optional[datetime] = None - """ - Date and time of the log. - """ - - details: Optional[str] = None - """ - Full text of the log. - """ - - -@dataclass -class InstanceGroup: - id: str - """ - 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.). - """ - - zone: ScwZone - """ - Zone for this resource. - """ - - created_at: Optional[datetime] = None - """ - Date on which the Instance group was created. - """ - - updated_at: Optional[datetime] = None - """ - Date on which the Instance group was last updated. - """ - - -@dataclass -class InstancePolicy: - id: str - """ - 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. - """ - - zone: ScwZone - """ - Zone for this resource. - """ - - metric: Optional[Metric] = None - - -@dataclass -class InstanceTemplate: - id: str - """ - 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. - """ - - status: InstanceTemplateStatus - """ - Status of Instance template. - """ - - zone: ScwZone - """ - Zone for this resource. - """ - - image_id: Optional[str] = None - """ - 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] = None - """ - Instance security group ID (optional). - """ - - placement_group_id: Optional[str] = None - """ - 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] = 0 - """ - Number of flexible IPv4 addresses to attach to the new Instance. - """ - - public_ips_v6_count: Optional[int] = 0 - """ - Number of flexible IPv6 addresses to attach to the new Instance. - """ - - cloud_init: Optional[str] = None - """ - 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] = None - """ - Date on which the Instance template was created. - """ - - updated_at: Optional[datetime] = None - """ - Date on which the Instance template was last updated. - """ - - -@dataclass -class UpdateInstanceGroupRequestCapacity: - max_replicas: Optional[int] = 0 - """ - Maximum count of Instances for the Instance group. - """ - - min_replicas: Optional[int] = 0 - """ - Minimum count of Instances for the Instance group. - """ - - cooldown_delay: Optional[str] = None - """ - Time (in seconds) after a scaling action during which requests to carry out a new scaling action will be denied. - """ - - -@dataclass -class UpdateInstanceGroupRequestLoadbalancer: - backend_ids: Optional[list[str]] = field(default_factory=list) - """ - Load Balancer backend IDs. - """ - - -@dataclass -class UpdateInstancePolicyRequestMetric: - operator: UpdateInstancePolicyRequestMetricOperator - """ - 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] = None - """ - Name or description of your metric policy. - """ - - sampling_range_min: Optional[int] = 0 - """ - Interval of time, in minutes, during which metric is sampled. - """ - - threshold: Optional[float] = 0.0 - """ - 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] = ( - UpdateInstancePolicyRequestMetricManagedMetric.MANAGED_METRIC_UNKNOWN - ) - - cockpit_metric_name: Optional[str] = None - - -@dataclass -class CreateInstanceGroupRequest: - name: str - """ - 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] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - project_id: Optional[str] = None - """ - Project ID to filter for, only Instance groups from this Project will be returned. - """ - - tags: Optional[list[str]] = field(default_factory=list) - """ - List of tags for the Instance group. - """ - - -@dataclass -class CreateInstancePolicyRequest: - name: str - """ - 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] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - metric: Optional[Metric] = None - - -@dataclass -class CreateInstanceTemplateRequest: - commercial_type: str - """ - Name of Instance commercial type. - """ - - volumes: dict[str, VolumeInstanceTemplate] - """ - Template of Instance volume. - """ - - name: str - """ - Name of Instance template. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - image_id: Optional[str] = None - """ - 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]] = field(default_factory=list) - """ - List of tags for the Instance template. - """ - - security_group_id: Optional[str] = None - """ - Instance security group ID (optional). - """ - - placement_group_id: Optional[str] = None - """ - 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] = 0 - """ - Number of flexible IPv4 addresses to attach to the new Instance. - """ - - public_ips_v6_count: Optional[int] = 0 - """ - Number of flexible IPv6 addresses to attach to the new Instance. - """ - - project_id: Optional[str] = None - """ - ID of the Project containing the Instance template resource. - """ - - private_network_ids: Optional[list[str]] = field(default_factory=list) - """ - Private Network IDs to attach to the new Instance. - """ - - cloud_init: Optional[str] = None - """ - 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: - instance_group_id: str - """ - ID of the Instance group to delete. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class DeleteInstancePolicyRequest: - policy_id: str - """ - ID of the policy to delete. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class DeleteInstanceTemplateRequest: - template_id: str - """ - ID of the template to delete. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetInstanceGroupRequest: - instance_group_id: str - """ - ID of the requested Instance group. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetInstancePolicyRequest: - policy_id: str - """ - Policy ID. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class GetInstanceTemplateRequest: - template_id: str - """ - Template ID of the resource. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - -@dataclass -class ListInstanceGroupEventsRequest: - instance_group_id: str - """ - List all event logs for the Instance group ID. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstanceGroupEventsRequestOrderBy] = ( - ListInstanceGroupEventsRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of Instance groups to return per page. - """ - - -@dataclass -class ListInstanceGroupEventsResponse: - instance_events: list[InstanceGroupEvent] - """ - Paginated list of Instance groups. - """ - - total_count: int - """ - Count of all Instance groups matching the requested criteria. - """ - - -@dataclass -class ListInstanceGroupsRequest: - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstanceGroupsRequestOrderBy] = ( - ListInstanceGroupsRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of Instance groups to return per page. - """ - - -@dataclass -class ListInstanceGroupsResponse: - instance_groups: list[InstanceGroup] - """ - Paginated list of Instance groups. - """ - - total_count: int - """ - Count of all Instance groups matching the requested criteria. - """ - - -@dataclass -class ListInstancePoliciesRequest: - instance_group_id: str - """ - Instance group ID. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstancePoliciesRequestOrderBy] = ( - ListInstancePoliciesRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of scaling policies to return per page. - """ - - -@dataclass -class ListInstancePoliciesResponse: - policies: list[InstancePolicy] - """ - Paginated list of policies. - """ - - total_count: int - """ - Count of all policies matching the requested criteria. - """ - - -@dataclass -class ListInstanceTemplatesRequest: - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - order_by: Optional[ListInstanceTemplatesRequestOrderBy] = ( - ListInstanceTemplatesRequestOrderBy.CREATED_AT_DESC - ) - """ - Sort order of Instance groups in the response. - """ - - page: Optional[int] = 0 - """ - Page number to return, from the paginated results. - """ - - page_size: Optional[int] = 0 - """ - Number of Instance groups to return per page. - """ - - -@dataclass -class ListInstanceTemplatesResponse: - total_count: int - """ - Count of all templates matching the requested criteria. - """ - - instance_templates: list[InstanceTemplate] - """ - Paginated list of Instance templates. - """ - - -@dataclass -class UpdateInstanceGroupRequest: - instance_group_id: str - """ - Instance group ID to update. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - name: Optional[str] = None - """ - Name of Instance group. - """ - - tags: Optional[list[str]] = field(default_factory=list) - """ - List of tags for the Load Balancer. - """ - - capacity: Optional[UpdateInstanceGroupRequestCapacity] = None - """ - Specification of the minimum and maximum replicas for the Instance group, and the cooldown interval between two scaling events. - """ - - loadbalancer: Optional[UpdateInstanceGroupRequestLoadbalancer] = None - """ - Specification of the Load Balancer to link to the Instance group. - """ - - -@dataclass -class UpdateInstancePolicyRequest: - policy_id: str - """ - Policy ID to update. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - name: Optional[str] = None - """ - Policy name to update. - """ - - action: Optional[InstancePolicyAction] = InstancePolicyAction.UNKNOWN_ACTION - """ - Action to update (action to execute when the metric-based condition is met). - """ - - type_: Optional[InstancePolicyType] = InstancePolicyType.UNKNOWN_TYPE - """ - Type to update (how to use the number defined in `value` when determining by how many Instances to scale up/down). - """ - - value: Optional[int] = 0 - """ - Value to update (number representing the magnitude of the scaling action to take for the Instance group). - """ - - priority: Optional[int] = 0 - """ - Priority to update (priority of this policy compared to all other scaling policies. The lower the number, the higher the priority). - """ - - metric: Optional[UpdateInstancePolicyRequestMetric] = None - - -@dataclass -class UpdateInstanceTemplateRequest: - template_id: str - """ - Template ID of the resource. - """ - - zone: Optional[ScwZone] = None - """ - Zone to target. If none is passed will use default zone from the config. - """ - - commercial_type: Optional[str] = None - """ - Name of Instance commercial type. - """ - - image_id: Optional[str] = None - """ - 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]] = field(default_factory=dict) - """ - Template of Instance volume. - """ - - tags: Optional[list[str]] = field(default_factory=list) - """ - List of tags for the Instance template. - """ - - security_group_id: Optional[str] = None - """ - Instance security group ID (optional). - """ - - placement_group_id: Optional[str] = None - """ - 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] = 0 - """ - Number of flexible IPv4 addresses to attach to the new Instance. - """ - - public_ips_v6_count: Optional[int] = 0 - """ - Number of flexible IPv6 addresses to attach to the new Instance. - """ - - name: Optional[str] = None - """ - Name of Instance template. - """ - - private_network_ids: Optional[list[str]] = field(default_factory=list) - """ - Private Network IDs to attach to the new Instance. - """ - - cloud_init: Optional[str] = None - """ - 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/jobs/v1alpha2/types.py b/scaleway/scaleway/jobs/v1alpha2/types.py index 478b5c25f..5254160d1 100644 --- a/scaleway/scaleway/jobs/v1alpha2/types.py +++ b/scaleway/scaleway/jobs/v1alpha2/types.py @@ -29,6 +29,7 @@ class JobRunReason(str, Enum, metaclass=StrEnumMeta): SECRET_DISABLED = "secret_disabled" SECRET_NOT_FOUND = "secret_not_found" QUOTA_EXCEEDED = "quota_exceeded" + APPLICATION_NOT_STARTED = "application_not_started" def __str__(self) -> str: return str(self.value)