From 36f791b505a5068ed0caeff1188b6a55d3a30937 Mon Sep 17 00:00:00 2001 From: Anurag Sharma Date: Mon, 26 Aug 2024 09:36:16 +0530 Subject: [PATCH] Ocean ECS --- CHANGELOG.md | 8 + README.md | 6 +- docs/README.md | 6 +- docs/clients/ocean/ocean_ecs_client.md | 457 +++++++++++ docs/models/ocean/azure.md | 14 + docs/models/ocean/ecs.md | 860 +++++++++++++++++++++ pydocmd.yml | 4 + requirements.txt | 2 +- setup.py | 7 +- spotinst_sdk2/__init__.py | 2 +- spotinst_sdk2/clients/ocean/__init__.py | 219 +++--- spotinst_sdk2/models/ocean/ecs/__init__.py | 379 ++++----- spotinst_sdk2/version.py | 2 +- 13 files changed, 1613 insertions(+), 353 deletions(-) create mode 100644 docs/clients/ocean/ocean_ecs_client.md create mode 100644 docs/models/ocean/ecs.md diff --git a/CHANGELOG.md b/CHANGELOG.md index a73ad517..76556bd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [3.14.0] - 2024-08-26 +### Added +- Added support for Ocean ECS. + +## [3.13.0] - 2024-08-23 +### Added +- Added `SuspensionHours` model for Ocean AKS. + ## [3.12.0] - 2024-08-21 ### Fixed - Updated new fields for ocean Automatic Rightsizing APIs (beta release. For internal use only). diff --git a/README.md b/README.md index f4594de8..84aa09d0 100755 --- a/README.md +++ b/README.md @@ -166,15 +166,19 @@ Take note you can create more than one client with the session. The currently su - `session.client("setup_azure")` - `session.client("setup_gcp")` - `session.client("elastigroup_aws")` -- `session.client("elastigroup_azure")` - `session.client("elastigroup_azure_v3")` - `session.client("elastigroup_gcp")` - `session.client("mcs")` - `session.client("mrScaler_aws")` - `session.client("ocean_aws")` +- `session.client("ocean_azure")` +- `session.client("ocean_gcp")` +- `session.client("ocean_ecs")` +- `session.client("ocean_rightsizing")` - `session.client("subscription")` - `session.client("managed_instance_aws")` - `session.client("stateful_node_azure")` +- `session.client("functions")` A full list of endpoints and clients can be found in the documentation [here](./docs/clients/). diff --git a/docs/README.md b/docs/README.md index f4594de8..84aa09d0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -166,15 +166,19 @@ Take note you can create more than one client with the session. The currently su - `session.client("setup_azure")` - `session.client("setup_gcp")` - `session.client("elastigroup_aws")` -- `session.client("elastigroup_azure")` - `session.client("elastigroup_azure_v3")` - `session.client("elastigroup_gcp")` - `session.client("mcs")` - `session.client("mrScaler_aws")` - `session.client("ocean_aws")` +- `session.client("ocean_azure")` +- `session.client("ocean_gcp")` +- `session.client("ocean_ecs")` +- `session.client("ocean_rightsizing")` - `session.client("subscription")` - `session.client("managed_instance_aws")` - `session.client("stateful_node_azure")` +- `session.client("functions")` A full list of endpoints and clients can be found in the documentation [here](./docs/clients/). diff --git a/docs/clients/ocean/ocean_ecs_client.md b/docs/clients/ocean/ocean_ecs_client.md new file mode 100644 index 00000000..6c3493a2 --- /dev/null +++ b/docs/clients/ocean/ocean_ecs_client.md @@ -0,0 +1,457 @@ +

OceanEcsClient

+ +```python +OceanEcsClient(self, + session=None, + print_output=True, + log_level=None, + user_agent=None, + timeout=None) +``` + +

get_all_ocean_clusters

+ +```python +OceanEcsClient.get_all_ocean_clusters() +``` + +Get the configurations for all Ocean ECS clusters in the specified account. + +__Returns__ + +`(Object)`: Ocean ECS API response + +

create_ocean_cluster

+ +```python +OceanEcsClient.create_ocean_cluster(ocean: Ocean) +``` + +Create an Ocean ECS Cluster + +__Arguments__ + +- __ocean (Ocean)__: Ocean ECS Object + +__Returns__ + +`(Object)`: Ocean ECS API response + +

get_ocean_cluster

+ +```python +OceanEcsClient.get_ocean_cluster(ocean_id: str) +``` + +Get the configuration for a specified Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster + +__Returns__ + +`(Object)`: Ocean API response + +

update_ocean_cluster

+ +```python +OceanEcsClient.update_ocean_cluster(ocean_id: str, ocean: Ocean) +``` + +Update an existing Ocean Cluster + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __ocean (Ocean)__: Ocean object + +__Returns__ + +`(Object)`: Ocean API response + +

delete_ocean_cluster

+ +```python +OceanEcsClient.delete_ocean_cluster(ocean_id: str) +``` + +Delete a specified Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster + +__Returns__ + +`(Object)`: Ocean API response + +

import_ocean_cluster

+ +```python +OceanEcsClient.import_ocean_cluster( + ecs_cluster_name: str, import_cluster_config: ImportClusterConfig) +``` + +Create an Ocean ECS Cluster + +__Arguments__ + +- __ecs_cluster_name (String)__: Name of the existing ECS Cluster to import +- __import_cluster_config (ImportClusterConfig)__: Import Cluster Object + +__Returns__ + +`(Object)`: Ocean ECS API response + +

get_elastilog

+ +```python +OceanEcsClient.get_elastilog(ocean_id: str, + from_date: str, + to_date: str, + severity: str = None, + resource_id: str = None, + limit: int = None) +``` + +Get the log of an Ocean Cluster. + +__Arguments__ + +- __ocean_id (String)__: Ocean cluster identifier +- __to_date (String)__: end date value +- __from_date (String)__: beginning date value +- __severity (String) (Optional)__: Log level severity +- __resource_id (String) (Optional)__: specific resource identifier +- __limit(int) (Optional)__: Maximum number of lines to extract in a response + +__Returns__ + +`(Object)`: Ocean Get Log API response + +

instance_types_filters_simulation

+ +```python +OceanEcsClient.instance_types_filters_simulation( + ocean_id: str, filters: InstanceTypesFilters) +``` + +Returns all instances types that match the given filters. +These instance types will be used if the cluster is configured with these filters. + +__Arguments__ + +- __ocean_id (String)__: Id of the Ocean Cluster +- __filters (InstanceTypesFilters)__: List of filters + +__Returns__ + +`(Object)`: Ocean Instance Type Simultion response + +

get_allowed_instance_types

+ +```python +OceanEcsClient.get_allowed_instance_types(ocean_id: str) +``` + +Return the list of the allowed Ocean cluster instance types. + +__Arguments__ + +- __ocean_id (String)__: Ocean cluster identifier + +__Returns__ + +`(Object)`: Ocean Allowed Instance Types response + +

upgrade_elastigroup_to_ocean

+ +```python +OceanEcsClient.upgrade_elastigroup_to_ocean(group_id: str) +``` + +Upgrade an Elastigroup with ECS integration into Ocean for ECS cluster. + +__Arguments__ + +- __group_id (String)__: Elastigroup ID + +__Returns__ + +`(Object)`: Ocean ECS API response + +

initiate_roll

+ +```python +OceanEcsClient.initiate_roll(ocean_id: str, roll_config: RollConfig) +``` + +Initiate Cluster Rolls + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __roll_config (RollConfig)__: Cluster Roll / Roll with Instance Ids/ Roll with VNG Ids + +__Returns__ + +`(Object)`: Cluster Roll API response + +

list_rolls

+ +```python +OceanEcsClient.list_rolls(ocean_id: str) +``` + +List rolls of an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster + +__Returns__ + +`(Object)`: List of Cluster Roll API response + +

update_roll

+ +```python +OceanEcsClient.update_roll(ocean_id: str, roll_id: str, status: str) +``` + +Update a roll of an Ocean cluster. +Performing the request will stop the next batch in a roll. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __roll_id (String)__: Ocean cluster roll identifier +- __status (String)__: update roll status request + +__Returns__ + +`(Object)`: Cluster Roll API response + +

get_roll

+ +```python +OceanEcsClient.get_roll(ocean_id: str, roll_id: str) +``` + +Get status for a roll of an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __roll_id (String)__: Ocean cluster roll identifier + +__Returns__ + +`(Object)`: Cluster Roll API response + +

get_cluster_container_instances

+ +```python +OceanEcsClient.get_cluster_container_instances(ocean_id: str, + instance_id: str = None, + launch_spec_id: str = None + ) +``` + +Get container instances data of an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __instance_id (String)__: Instance identifier +- __launch_spec_id (String)__: Ocean cluster VNG identifier. + +__Returns__ + +`(Object)`: Ocean Aws Container Instances Data Response + +

detach_instances

+ +```python +OceanEcsClient.detach_instances( + ocean_id: str, detach_configuration: DetachInstancesConfig) +``` + +Detach instances from your Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __detach_configuration (DetachInstancesConfig)__: Detach instances request + +__Returns__ + +`(Object)`: Detach Instance response + +

create_virtual_node_group

+ +```python +OceanEcsClient.create_virtual_node_group(vng: VirtualNodeGroup) +``` + +Create a new Ocean ECS virtual node group in the specified account. + +__Arguments__ + +- __vng (VirtualNodeGroup)__: VirtualNodeGroup Object + +__Returns__ + +`(Object)`: Ocean Virtual Node Group API response + +

get_all_virtual_node_groups

+ +```python +OceanEcsClient.get_all_virtual_node_groups(ocean_id: str) +``` + +Get all VNGs for the specified Ocean cluster. + +__Returns__ + +`(Object)`: Ocean Virtual Node Group API response + +

delete_virtual_node_group

+ +```python +OceanEcsClient.delete_virtual_node_group( + vng_id: str, delete_container_instances: bool = None) +``` + +Delete a specified virtual node group in an Ocean cluster. + +__Arguments__ + +- __vng_id (String)__: Ocean cluster Virtual Node Group identifier. +- __delete_container_instances (Bool)__: When set to "true", all instances belonging to the deleted VNG will be drained, detached, and terminated. + +__Returns__ + +`(Object)`: Ocean Virtual Node Group Delete response + +

update_virtual_node_group

+ +```python +OceanEcsClient.update_virtual_node_group(vng_id: str, + vng: VirtualNodeGroup) +``` + +Update specified VNG for an Ocean cluster. + +__Arguments__ + +- __vng_id (String)__: ID of the Ocean Virtual Node Group +- __vng (VirtualNodeGroup)__: VirtualNodeGroup Object + +__Returns__ + +`(Object)`: Ocean Virtual Node Group API response + +

get_virtual_node_group

+ +```python +OceanEcsClient.get_virtual_node_group(vng_id: str) +``` + +Get a specified VNG for an Ocean cluster. + +__Arguments__ + +- __vng_id (String)__: Ocean cluster Virtual Node Group identifier. + +__Returns__ + +`(Object)`: Ocean Virtual Node Group API response + +

import_fargate_to_existing_ocean_cluster

+ +```python +OceanEcsClient.import_fargate_to_existing_ocean_cluster( + ocean_id: str, + import_fargate_existing: ImportFargateToExistingOceanCluster) +``` + +Import a Fargate service into an existing Ocean ECS cluster. + +__Arguments__ + +- __ocean_id (String)__: Ocean cluster Identifier +- __import_fargate_existing (Object)__: ImportFargateToExistingOceanCluster Object + +__Returns__ + +`(Object)`: Ocean ECS Fargate Response + +

get_fargate_services_discovery

+ +```python +OceanEcsClient.get_fargate_services_discovery(ocean_id: str) +``` + +Get existing Fargate services in the ECS cluster. + +__Arguments__ + +- __ocean_id (String)__: Ocean cluster identifier + +__Returns__ + +`(Object)`: Ocean ECS Fargate Response + +

get_fargate_migration_status

+ +```python +OceanEcsClient.get_fargate_migration_status(ocean_id: str) +``` + +Get the status of a Fargate service import. + +__Arguments__ + +- __ocean_id (String)__: Ocean cluster identifier + +__Returns__ + +`(Object)`: Ocean ECS Fargate Response + +

import_fargate_to_new_ocean_cluster

+ +```python +OceanEcsClient.import_fargate_to_new_ocean_cluster( + import_fargate_new: ImportFargateToNewOceanCluster) +``` + +Import a Fargate service into a new Ocean ECS cluster. + +__Arguments__ + +- __ocean_id (String)__: Ocean cluster Identifier +- __import_fargate_new (Object)__: ImportFargateToNewOceanCluster Object + +__Returns__ + +`(Object)`: Ocean ECS Fargate Response + +

launch_instances_in_vng

+ +```python +OceanEcsClient.launch_instances_in_vng(vng_id: str, amount: int) +``` + +Launch container instances in virtual node group. + +__Arguments__ + +- __vng_id (String)__: Ocean cluster Virtual Node Group identifier. +- __amount (int)__: The number of nodes to launch. + +__Returns__ + +`(Object)`: Ocean Virtual Node Group Launch API response + diff --git a/docs/models/ocean/azure.md b/docs/models/ocean/azure.md index 0f47d9a5..9c56b376 100644 --- a/docs/models/ocean/azure.md +++ b/docs/models/ocean/azure.md @@ -873,3 +873,17 @@ __Arguments__ - __node_names_to_detach__: List[str] - __ocean_id__: str +

RightSizingFilter

+ +```python +RightSizingFilter( + self, + attribute: Attribute = 'd3043820717d74d9a17694c176d39733', + namespaces: typing.List[str] = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __attribute__: Attribute +- __namespaces__: List[str] + diff --git a/docs/models/ocean/ecs.md b/docs/models/ocean/ecs.md new file mode 100644 index 00000000..5623e2ca --- /dev/null +++ b/docs/models/ocean/ecs.md @@ -0,0 +1,860 @@ +

spotinst_sdk2.models.ocean.ecs

+ + +

Down

+ +```python +Down( + self, + evaluation_periods: int = 'd3043820717d74d9a17694c176d39733', + max_scale_down_percentage: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __evaluation_periods__: int +- __max_scale_down_percentage__: int + +

Headroom

+ +```python +Headroom(self, + cpu_per_unit: int = 'd3043820717d74d9a17694c176d39733', + memory_per_unit: int = 'd3043820717d74d9a17694c176d39733', + num_of_units: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __cpu_per_unit__: int +- __memory_per_unit__: int +- __num_of_units__: int + +

ResourceLimits

+ +```python +ResourceLimits(self, + max_memory_gib: int = 'd3043820717d74d9a17694c176d39733', + max_v_cpu: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __max_memory_gib__: int +- __max_v_cpu__: int + +

AutoScaler

+ +```python +AutoScaler( + self, + auto_headroom_percentage: int = 'd3043820717d74d9a17694c176d39733', + cooldown: int = 'd3043820717d74d9a17694c176d39733', + down: Down = 'd3043820717d74d9a17694c176d39733', + enable_automatic_and_manual_headroom: + bool = 'd3043820717d74d9a17694c176d39733', + headroom: Headroom = 'd3043820717d74d9a17694c176d39733', + is_auto_config: bool = 'd3043820717d74d9a17694c176d39733', + is_enabled: bool = 'd3043820717d74d9a17694c176d39733', + resource_limits: ResourceLimits = 'd3043820717d74d9a17694c176d39733', + should_scale_down_non_service_tasks: + bool = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __auto_headroom_percentage__: int +- __cooldown__: int +- __down__: Down +- __enable_automatic_and_manual_headroom__: bool +- __headroom__: Headroom +- __is_auto_config__: bool +- __is_enabled__: bool +- __resource_limits__: ResourceLimits +- __should_scale_down_non_service_tasks__: bool + +

Capacity

+ +```python +Capacity(self, + maximum: int = 'd3043820717d74d9a17694c176d39733', + minimum: int = 'd3043820717d74d9a17694c176d39733', + target: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __maximum__: int +- __minimum__: int +- __target__: int + +

Architecture

+ +```python +Architecture(cls, value, names=None, *, module, qualname, type, start) +``` +An enumeration. +

arm64

+ + +

i386

+ + +

x86_64

+ + +

Category

+ +```python +Category(cls, value, names=None, *, module, qualname, type, start) +``` +An enumeration. +

accelerated_computing

+ + +

compute_optimized

+ + +

general_purpose

+ + +

memory_optimized

+ + +

storage_optimized

+ + +

DiskType

+ +```python +DiskType(cls, value, names=None, *, module, qualname, type, start) +``` +An enumeration. +

ebs

+ + +

hdd

+ + +

nvme

+ + +

ssd

+ + +

Hypervisor

+ +```python +Hypervisor(cls, value, names=None, *, module, qualname, type, start) +``` +An enumeration. +

nitro

+ + +

xen

+ + +

RootDeviceType

+ +```python +RootDeviceType(cls, value, names=None, *, module, qualname, type, start) +``` +An enumeration. +

ebs

+ + +

instance_store

+ + +

VirtualizationType

+ +```python +VirtualizationType(cls, + value, + names=None, + *, + module, + qualname, + type, + start) +``` +An enumeration. +

hvm

+ + +

paravirtual

+ + +

InstanceTypesFilters

+ +```python +InstanceTypesFilters( + self, + min_vcpu: int = 'd3043820717d74d9a17694c176d39733', + max_vcpu: int = 'd3043820717d74d9a17694c176d39733', + min_memory_gi_b: float = 'd3043820717d74d9a17694c176d39733', + max_memory_gi_b: float = 'd3043820717d74d9a17694c176d39733', + min_gpu: int = 'd3043820717d74d9a17694c176d39733', + max_gpu: int = 'd3043820717d74d9a17694c176d39733', + include_families: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + exclude_families: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + exclude_metal: bool = 'd3043820717d74d9a17694c176d39733', + is_ena_supported: bool = 'd3043820717d74d9a17694c176d39733', + architectures: + typing.List[spotinst_sdk2.models.ocean.ecs.Architecture] = 'd3043820717d74d9a17694c176d39733', + virtualization_types: + typing.List[spotinst_sdk2.models.ocean.ecs.VirtualizationType] = 'd3043820717d74d9a17694c176d39733', + categories: + typing.List[spotinst_sdk2.models.ocean.ecs.Category] = 'd3043820717d74d9a17694c176d39733', + min_enis: int = 'd3043820717d74d9a17694c176d39733', + disk_types: + typing.List[spotinst_sdk2.models.ocean.ecs.DiskType] = 'd3043820717d74d9a17694c176d39733', + hypervisor: + typing.List[spotinst_sdk2.models.ocean.ecs.Hypervisor] = 'd3043820717d74d9a17694c176d39733', + root_device_types: + typing.List[spotinst_sdk2.models.ocean.ecs.RootDeviceType] = 'd3043820717d74d9a17694c176d39733', + min_network_performance: int = 'd3043820717d74d9a17694c176d39733', + max_network_performance: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __min_vcpu__: int +- __max_vcpu__: int +- __min_memory_gi_b__: float +- __max_memory_gi_b__: float +- __min_gpu__: int +- __max_gpu__: int +- __include_families__: List[str] +- __exclude_families__: List[str] +- __exclude_metal__: bool +- __is_ena_supported__: bool +- __architectures__: List[Architecture] +- __virtualization_types__: List[VirtualizationType] +- __categories__: List[Category] +- __min_enis__: int +- __disk_types__: List[DiskType] +- __hypervisor__: List[Hypervisor] +- __root_device_types__: List[RootDeviceType] +- __min_network_performance__: int +- __max_network_performance__: int + +

InstanceTypes

+ +```python +InstanceTypes( + self, + blacklist: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + filters: InstanceTypesFilters = 'd3043820717d74d9a17694c176d39733', + whitelist: typing.List[str] = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __blacklist__: List[str] +- __filters__: InstanceTypesFilters +- __whitelist__: List[str] + +

DynamicVolumeSize

+ +```python +DynamicVolumeSize( + self, + base_size: int = 'd3043820717d74d9a17694c176d39733', + resource: str = 'd3043820717d74d9a17694c176d39733', + size_per_resource_unit: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __base_size__: int +- __resource__: str +- __size_per_resource_unit__: int + +

EBS

+ +```python +EBS(self, + delete_on_termination: bool = 'd3043820717d74d9a17694c176d39733', + dynamic_volume_size: + DynamicVolumeSize = 'd3043820717d74d9a17694c176d39733', + encrypted: bool = 'd3043820717d74d9a17694c176d39733', + iops: int = 'd3043820717d74d9a17694c176d39733', + kms_key_id: str = 'd3043820717d74d9a17694c176d39733', + snapshot_id: str = 'd3043820717d74d9a17694c176d39733', + throughput: int = 'd3043820717d74d9a17694c176d39733', + volume_size: int = 'd3043820717d74d9a17694c176d39733', + volume_type: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __delete_on_termination__: bool +- __dynamic_volume_size__: DynamicVolumeSize +- __encrypted__: bool +- __iops__: int +- __kms_key_id__: str +- __snapshot_id__: str +- __throughput__: int +- __volume_size__: int +- __volume_type__: str + +

BlockDeviceMapping

+ +```python +BlockDeviceMapping(self, + device_name: str = 'd3043820717d74d9a17694c176d39733', + ebs: EBS = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __device_name__: str +- __ebs__: EBS + +

IamInstanceProfile

+ +```python +IamInstanceProfile(self, arn: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __arn__: str + +

HttpEndpoint

+ +```python +HttpEndpoint(cls, value, names=None, *, module, qualname, type, start) +``` +An enumeration. +

disabled

+ + +

enabled

+ + +

HttpTokens

+ +```python +HttpTokens(cls, value, names=None, *, module, qualname, type, start) +``` +An enumeration. +

optional

+ + +

required

+ + +

InstanceMetadataOptions

+ +```python +InstanceMetadataOptions( + self, + http_endpoint: HttpEndpoint = 'd3043820717d74d9a17694c176d39733', + http_put_response_hop_limit: int = 'd3043820717d74d9a17694c176d39733', + http_tokens: HttpTokens = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __http_endpoint__: HttpEndpoint +- __http_put_response_hop_limit__: int +- __http_tokens__: HttpTokens + +

Tag

+ +```python +Tag(self, + tag_key: str = 'd3043820717d74d9a17694c176d39733', + tag_value: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __tag_key__: str +- __tag_value__: str + +

LaunchSpecification

+ +```python +LaunchSpecification( + self, + associate_ipv6_address: bool = 'd3043820717d74d9a17694c176d39733', + associate_public_ip_address: bool = 'd3043820717d74d9a17694c176d39733', + block_device_mappings: + typing.List[spotinst_sdk2.models.ocean.ecs.BlockDeviceMapping] = 'd3043820717d74d9a17694c176d39733', + ebs_optimized: bool = 'd3043820717d74d9a17694c176d39733', + iam_instance_profile: + IamInstanceProfile = 'd3043820717d74d9a17694c176d39733', + image_id: str = 'd3043820717d74d9a17694c176d39733', + instance_metadata_options: + InstanceMetadataOptions = 'd3043820717d74d9a17694c176d39733', + monitoring: bool = 'd3043820717d74d9a17694c176d39733', + security_group_ids: + typing.List[str] = 'd3043820717d74d9a17694c176d39733', + tags: + typing.List[spotinst_sdk2.models.ocean.ecs.Tag] = 'd3043820717d74d9a17694c176d39733', + use_as_template_only: bool = 'd3043820717d74d9a17694c176d39733', + user_data: str = 'd3043820717d74d9a17694c176d39733', + key_pair: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __associate_ipv6_address__: bool +- __associate_public_ip_address__: bool +- __block_device_mappings__: List[BlockDeviceMapping] +- __ebs_optimized__: bool +- __iam_instance_profile__: IamInstanceProfile +- __image_id__: str +- __instance_metadata_options__: InstanceMetadataOptions +- __monitoring__: bool +- __security_group_ids__: List[str] +- __tags__: List[Tag] +- __use_as_template_only__: bool +- __user_data__: str +- __key_pair__: str + +

OptimizeImages

+ +```python +OptimizeImages( + self, + perform_at: str = 'd3043820717d74d9a17694c176d39733', + should_optimize_ecs_ami: bool = 'd3043820717d74d9a17694c176d39733', + time_windows: typing.List[str] = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __perform_at__: str +- __should_optimize_ecs_ami__: bool +- __time_windows__: List[str] + +

Compute

+ +```python +Compute( + self, + instance_types: InstanceTypes = 'd3043820717d74d9a17694c176d39733', + launch_specification: + LaunchSpecification = 'd3043820717d74d9a17694c176d39733', + optimize_images: OptimizeImages = 'd3043820717d74d9a17694c176d39733', + subnet_ids: typing.List[str] = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __instance_types__: InstanceTypes +- __launch_specification__: LaunchSpecification +- __optimize_images__: OptimizeImages +- __subnet_ids__: List[str] + +

S3Bucket

+ +```python +S3Bucket(self, id: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __id__: str + +

LoggingConfiguration

+ +```python +LoggingConfiguration(self, + s3: S3Bucket = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __s3__: S3Bucket + +

Logging

+ +```python +Logging( + self, + export: LoggingConfiguration = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __export__: LoggingConfiguration + +

ShutdownHours

+ +```python +ShutdownHours( + self, + is_enabled: bool = 'd3043820717d74d9a17694c176d39733', + time_windows: typing.List[str] = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __is_enabled__: bool +- __time_windows__: List[str] + +

ClusterRoll

+ +```python +ClusterRoll( + self, + batch_min_healthy_percentage: int = 'd3043820717d74d9a17694c176d39733', + batch_size_percentage: int = 'd3043820717d74d9a17694c176d39733', + comment: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __batch_min_healthy_percentage__: int +- __batch_size_percentage__: int +- __comment__: str + +

Parameters

+ +```python +Parameters(self, + cluster_roll: ClusterRoll = 'd3043820717d74d9a17694c176d39733' + ) +``` + +__Arguments__ + +- __cluster_roll__: ClusterRoll + +

SchedulingTask

+ +```python +SchedulingTask( + self, + cron_expression: str = 'd3043820717d74d9a17694c176d39733', + is_enabled: bool = 'd3043820717d74d9a17694c176d39733', + parameters: Parameters = 'd3043820717d74d9a17694c176d39733', + task_type: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __cron_expression__: str +- __is_enabled__: bool +- __parameters__: Parameters +- __task_type__: str + +

Scheduling

+ +```python +Scheduling( + self, + shutdown_hours: ShutdownHours = 'd3043820717d74d9a17694c176d39733', + tasks: + typing.List[spotinst_sdk2.models.ocean.ecs.SchedulingTask] = 'd3043820717d74d9a17694c176d39733' +) +``` + +__Arguments__ + +- __shutdown_hours__: ShutdownHours +- __tasks__: List[SchedulingTask] + +

AvailabilityVsCost

+ +```python +AvailabilityVsCost(cls, + value, + names=None, + *, + module, + qualname, + type, + start) +``` +An enumeration. +

balanced

+ + +

cheapest

+ + +

cost_oriented

+ + +

ClusterOrientation

+ +```python +ClusterOrientation( + self, + availability_vs_cost: + AvailabilityVsCost = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __availability_vs_cost__: AvailabilityVsCost + +

Strategy

+ +```python +Strategy( + self, + cluster_orientation: + ClusterOrientation = 'd3043820717d74d9a17694c176d39733', + draining_timeout: int = 'd3043820717d74d9a17694c176d39733', + fallback_to_od: bool = 'd3043820717d74d9a17694c176d39733', + spot_percentage: int = 'd3043820717d74d9a17694c176d39733', + utilize_commitments: bool = 'd3043820717d74d9a17694c176d39733', + utilize_reserved_instances: bool = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __cluster_orientation__: ClusterOrientation +- __draining_timeout__: int +- __fallback_to_od__: bool +- __spot_percentage__: int +- __utilize_commitments__: bool +- __utilize_reserved_instances__: bool + +

Ocean

+ +```python +Ocean(self, + auto_scaler: AutoScaler = 'd3043820717d74d9a17694c176d39733', + capacity: Capacity = 'd3043820717d74d9a17694c176d39733', + cluster_name: str = 'd3043820717d74d9a17694c176d39733', + compute: Compute = 'd3043820717d74d9a17694c176d39733', + logging: Logging = 'd3043820717d74d9a17694c176d39733', + name: str = 'd3043820717d74d9a17694c176d39733', + region: str = 'd3043820717d74d9a17694c176d39733', + scheduling: Scheduling = 'd3043820717d74d9a17694c176d39733', + strategy: Strategy = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __auto_scaler__: AutoScaler +- __capacity__: Capacity +- __cluster_name__: str +- __compute__: Compute +- __logging__: Logging +- __name__: str +- __region__: str +- __scheduling__: Scheduling +- __strategy__: Strategy + +

ImportClusterConfig

+ +```python +ImportClusterConfig( + self, + instance_id: str = 'd3043820717d74d9a17694c176d39733', + name: str = 'd3043820717d74d9a17694c176d39733', + region: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __instance_id__: str +- __name__: str +- __region__: str + +

RollConfig

+ +```python +RollConfig( + self, + batch_min_healthy_percentage: int = 'd3043820717d74d9a17694c176d39733', + batch_size_percentage: int = 'd3043820717d74d9a17694c176d39733', + comment: str = 'd3043820717d74d9a17694c176d39733', + launch_spec_ids: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + instance_ids: typing.List[str] = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __batch_min_healthy_percentage__: int +- __batch_size_percentage__: int +- __comment__: str +- __instance_ids__: List[str] +- __launch_spec_ids__: List[str] + +

DetachInstancesConfig

+ +```python +DetachInstancesConfig( + self, + instances_to_detach: + typing.List[str] = 'd3043820717d74d9a17694c176d39733', + should_decrement_target_capacity: + bool = 'd3043820717d74d9a17694c176d39733', + should_terminate_instances: bool = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __instances_to_detach__: List[str] +- __should_decrement_target_capacity__: bool +- __should_terminate_instances__: bool + +

Attribute

+ +```python +Attribute(self, + key: str = 'd3043820717d74d9a17694c176d39733', + value: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __key__: str +- __value__: str + +

AutoScale

+ +```python +AutoScale( + self, + headrooms: + typing.List[spotinst_sdk2.models.ocean.ecs.Headroom] = 'd3043820717d74d9a17694c176d39733' +) +``` + +__Arguments__ + +- __headrooms__: List[Headrooms] + +

Image

+ +```python +Image(self, id: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __id__: str + +

VngTask

+ +```python +VngTask( + self, + config: + typing.List[spotinst_sdk2.models.ocean.ecs.Headroom] = 'd3043820717d74d9a17694c176d39733', + cron_expression: str = 'd3043820717d74d9a17694c176d39733', + is_enabled: bool = 'd3043820717d74d9a17694c176d39733', + task_type: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __config__: List[Headroom] +- __cron_expression__: str +- __is_enabled__: bool +- __task_type__: str + +

VngScheduling

+ +```python +VngScheduling( + self, tasks: typing.List[spotinst_sdk2.models.ocean.ecs.VngTask]) +``` + +__Arguments__ + +- __tasks__: List[VngTask] + +

VirtualNodeGroup

+ +```python +VirtualNodeGroup( + self, + attributes: + typing.List[spotinst_sdk2.models.ocean.ecs.Attribute] = 'd3043820717d74d9a17694c176d39733', + auto_scale: AutoScale = 'd3043820717d74d9a17694c176d39733', + block_device_mappings: + typing.List[spotinst_sdk2.models.ocean.ecs.BlockDeviceMapping] = 'd3043820717d74d9a17694c176d39733', + iam_instance_profile: + IamInstanceProfile = 'd3043820717d74d9a17694c176d39733', + image_id: str = 'd3043820717d74d9a17694c176d39733', + images: + typing.List[spotinst_sdk2.models.ocean.ecs.Image] = 'd3043820717d74d9a17694c176d39733', + instance_metadata_options: + InstanceMetadataOptions = 'd3043820717d74d9a17694c176d39733', + instance_types: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + name: str = 'd3043820717d74d9a17694c176d39733', + ocean_id: str = 'd3043820717d74d9a17694c176d39733', + preferred_spot_types: + typing.List[str] = 'd3043820717d74d9a17694c176d39733', + restrict_scale_down: bool = 'd3043820717d74d9a17694c176d39733', + scheduling: VngScheduling = 'd3043820717d74d9a17694c176d39733', + security_group_ids: + typing.List[str] = 'd3043820717d74d9a17694c176d39733', + strategy: Strategy = 'd3043820717d74d9a17694c176d39733', + subnet_ids: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + tags: + typing.List[spotinst_sdk2.models.ocean.ecs.Tag] = 'd3043820717d74d9a17694c176d39733', + user_data: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __attributes__: List[Attribute] +- __auto_scale__: AutoScale +- __block_device_mappings__: List[BlockDeviceMapping] +- __iam_instance_profile__: IamInstanceProfile +- __image_id__: str +- __images__: List[Image] +- __instance_metadata_options__: InstanceMetadataOptions +- __instance_types__: List[str] +- __name__: str +- __ocean_id__: str +- __preferred_spot_types__: List[str] +- __restrict_scale_down__: bool +- __scheduling__: VngScheduling +- __security_group_ids__: List[str] +- __strategy__: Strategy +- __subnet_ids__: List[str] +- __tags__: List[Tag] +- __user_data__: str + +

ImportFargateToExistingOceanCluster

+ +```python +ImportFargateToExistingOceanCluster( + self, + services: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + simple_new_service_names: bool = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __services__: List[str] +- __simple_new_service_names__: bool + +

ImportFargateToNewOceanCluster

+ +```python +ImportFargateToNewOceanCluster( + self, + ecs_cluster_name: str = 'd3043820717d74d9a17694c176d39733', + key_pair: str = 'd3043820717d74d9a17694c176d39733', + ocean_cluster_name: str = 'd3043820717d74d9a17694c176d39733', + region: str = 'd3043820717d74d9a17694c176d39733', + services: typing.List[str] = 'd3043820717d74d9a17694c176d39733', + tags: + typing.List[spotinst_sdk2.models.ocean.ecs.Tag] = 'd3043820717d74d9a17694c176d39733' +) +``` + +__Arguments__ + +- __ecs_cluster_name__: str +- __key_pair__: str +- __ocean_cluster_name__: str +- __region__: str +- __services__: List[str] +- __tags__: List[Tag] + diff --git a/pydocmd.yml b/pydocmd.yml index 9614b28b..0a724792 100755 --- a/pydocmd.yml +++ b/pydocmd.yml @@ -25,6 +25,8 @@ generate: - spotinst_sdk2.clients.ocean.OceanAzureClient++ - clients/ocean/ocean_gcp_client.md: - spotinst_sdk2.clients.ocean.OceanGcpClient++ + - clients/ocean/ocean_ecs_client.md: + - spotinst_sdk2.clients.ocean.OceanEcsClient++ # - clients/ocean/ocean_rightsizing_client.md: # - spotinst_sdk2.clients.ocean.OceanRightSizingClient++ - clients/ocean_cd/ocean_cd_client.md: @@ -59,6 +61,8 @@ generate: - spotinst_sdk2.models.ocean.azure++ - models/ocean/gcp.md: - spotinst_sdk2.models.ocean.gcp++ + - models/ocean/ecs.md: + - spotinst_sdk2.models.ocean.ecs++ # - models/ocean/rightsizing.md: # - spotinst_sdk2.models.ocean.rightsizing++ - models/ocean_cd.md: diff --git a/requirements.txt b/requirements.txt index 889a46c8..963d9d84 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ PyYaml==6.0.2 requests==2.32.3 -pydoc-markdown==2.1.3 +pydoc-markdown==4.8.2 mock==5.1.0 pytest==8.3.2 \ No newline at end of file diff --git a/setup.py b/setup.py index 6bda306f..8c10d512 100755 --- a/setup.py +++ b/setup.py @@ -23,8 +23,8 @@ name='spotinst-sdk2', version=version['__version__'], - # start from Python 3.6 - python_requires='>=3.6.0', + # start from Python 3.7 + python_requires='>=3.7.0', description='A Python SDK for Spotinst', long_description=long_description, long_description_content_type='text/markdown', @@ -44,11 +44,11 @@ 'Intended Audience :: Developers', 'Topic :: Software Development :: Libraries :: Python Modules', 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', ], keywords='spotinst spot instances aws azure ec2 cloud infrastructure development elastigroup', @@ -82,6 +82,7 @@ "spotinst_sdk2.models.ocean.aws", "spotinst_sdk2.models.ocean.azure", "spotinst_sdk2.models.ocean.gcp", + "spotinst_sdk2.models.ocean.ecs", "spotinst_sdk2.models.ocean.rightsizing", "spotinst_sdk2.models.ocean_cd", "spotinst_sdk2.models.ocean_cd", diff --git a/spotinst_sdk2/__init__.py b/spotinst_sdk2/__init__.py index 2587613b..d5334e54 100644 --- a/spotinst_sdk2/__init__.py +++ b/spotinst_sdk2/__init__.py @@ -57,7 +57,7 @@ def client(self, service, print_output=True, log_level=None, user_agent=None, ti user_agent=user_agent, timeout=timeout), "ocean_gcp": OceanGcpClient(session=self.session, print_output=print_output, log_level=log_level, user_agent=user_agent, timeout=timeout), - "ocean_ecs": OceanECSClient(session=self.session, print_output=print_output, log_level=log_level, + "ocean_ecs": OceanEcsClient(session=self.session, print_output=print_output, log_level=log_level, user_agent=user_agent, timeout=timeout), "ocean_rightsizing": OceanRightSizingClient(session=self.session, print_output=print_output, log_level=log_level, user_agent=user_agent, timeout=timeout), diff --git a/spotinst_sdk2/clients/ocean/__init__.py b/spotinst_sdk2/clients/ocean/__init__.py index aff0f72a..cd769c2b 100644 --- a/spotinst_sdk2/clients/ocean/__init__.py +++ b/spotinst_sdk2/clients/ocean/__init__.py @@ -145,7 +145,7 @@ def fetch_rightsizing_recommendations(self, ocean_id: str, group_response = self.send_post( body=body_json, url=self.__base_ocean_cluster_url + - "/" + ocean_id + "/rightSizing/suggestion", + "/" + ocean_id + "/rightSizing/suggestion", entity_name='ocean') formatted_response = self.convert_json( @@ -401,7 +401,7 @@ def instance_types_filter_simulation(self, ocean_id: str, aggregated_costs_response = self.send_post( body=body_json, url=self.__base_ocean_cluster_url + "/" + - ocean_id + "/instanceTypeFiltersSimulation", + ocean_id + "/instanceTypeFiltersSimulation", entity_name='ocean') formatted_response = self.convert_json( @@ -473,7 +473,7 @@ def launch_nodes_in_vng(self, ocean_launch_spec_id: str, amount: int): response = self.send_put( body=body_json, url=self.__base_ocean_launchspec_url + "/" + - ocean_launch_spec_id + "/launchNodes", + ocean_launch_spec_id + "/launchNodes", entity_name='ocean (Cluster Roll)') formatted_response = self.convert_json( @@ -794,7 +794,7 @@ def instance_types_filter_simulation_for_vng(self, launch_spec_id: str, aggregated_costs_response = self.send_post( body=body_json, url=self.__base_ocean_launchspec_url + "/" + - launch_spec_id + "/instanceTypeFiltersSimulation", + launch_spec_id + "/instanceTypeFiltersSimulation", entity_name='ocean_instance_type_filters_simulation_for_vng') formatted_response = self.convert_json( @@ -854,7 +854,7 @@ def allowed_instance_types_by_filters_for_vng(self, launch_spec_id: str): """ response = self.send_get( url=self.__base_ocean_launchspec_url + "/" + - launch_spec_id + "/allowedInstanceTypesByFilters", + launch_spec_id + "/allowedInstanceTypesByFilters", entity_name="ocean_aws_allowed_instance_types_by_filters_for_vng" ) @@ -986,7 +986,8 @@ def stop_migration(self, ocean_id: str, migration_id: str, migration: aws_ocean. response = self.send_put( body=body_json, - url=self.__base_ocean_cluster_url + "/" + ocean_id + "/migration/" + migration_id, + url=self.__base_ocean_cluster_url + "/" + + ocean_id + "/migration/" + migration_id, entity_name="ocean_aws_migration", ) @@ -1008,7 +1009,8 @@ def get_migration_status(self, ocean_id: str, migration_id: str): """ response = self.send_get( - url=self.__base_ocean_cluster_url + "/" + ocean_id + "/migration/" + migration_id, + url=self.__base_ocean_cluster_url + "/" + + ocean_id + "/migration/" + migration_id, entity_name="ocean_aws_migration" ) @@ -1079,7 +1081,7 @@ def get_extended_resource_definition(self, ocean_extended_resource_definition_id response = self.send_get( url=self.__base_ocean_extended_resource_definition_url + - "/" + ocean_extended_resource_definition_id, + "/" + ocean_extended_resource_definition_id, entity_name='ocean_aws_extended_resource_defintion' ) @@ -1132,7 +1134,7 @@ def update_extended_resource_definition(self, ocean_extended_resource_definition response = self.send_put( body=body_json, url=self.__base_ocean_extended_resource_definition_url + - "/" + ocean_extended_resource_definition_id, + "/" + ocean_extended_resource_definition_id, entity_name='ocean_extended_resource_defintion') formatted_response = self.convert_json( @@ -1153,7 +1155,7 @@ def delete_extended_resource_definition(self, ocean_extended_resource_definition """ return self.send_delete( url=self.__base_ocean_extended_resource_definition_url + - "/" + ocean_extended_resource_definition_id, + "/" + ocean_extended_resource_definition_id, entity_name='ocean_extended_resource_defintion') # endregion @@ -1576,7 +1578,7 @@ def stop_roll(self, ocean_id: str, roll_id: str): """ response = self.send_put( url=self.__base_ocean_cluster_url + "/" + - ocean_id + "/roll/" + roll_id + "/stop", + ocean_id + "/roll/" + roll_id + "/stop", entity_name="ocean (Cluster Roll)" ) @@ -1653,7 +1655,7 @@ def stop_migration(self, ocean_id: str, migration_id: str): response = self.send_put( url=self.__base_ocean_cluster_url + "/" + - ocean_id + "/migration/" + migration_id + "/stop", + ocean_id + "/migration/" + migration_id + "/stop", entity_name="ocean_azure_migration", ) @@ -1676,7 +1678,7 @@ def get_migration(self, ocean_id: str, migration_id: str): response = self.send_get( url=self.__base_ocean_cluster_url + "/" + - ocean_id + "/migration/" + migration_id, + ocean_id + "/migration/" + migration_id, entity_name="ocean_azure_migration" ) @@ -2044,7 +2046,7 @@ def get_rightsizing_recommendations(self, ocean_id: str, filter: gcp_ocean.Right group_response = self.send_post( body=body_json, url=self.__base_ocean_cluster_url + - "/" + ocean_id + "/rightSizing/suggestion", + "/" + ocean_id + "/rightSizing/suggestion", entity_name='ocean') formatted_response = self.convert_json( @@ -2109,7 +2111,7 @@ def get_aggregated_summary_costs(self, ocean_id: str, aggregated_cluster_costs: aggregated_summary_costs_response = self.send_post( body=body_json, url=self.__base_ocean_cluster_url + "/" + - ocean_id + "/aggregatedCosts/summary", + ocean_id + "/aggregatedCosts/summary", entity_name='ocean (aggregated summary costs)') formatted_response = self.convert_json( @@ -2484,7 +2486,7 @@ def launch_nodes_in_vng(self, ocean_launch_spec_id: str, amount: int): response = self.send_put( body=body_json, url=self.__base_ocean_launchspec_url + "/" + - ocean_launch_spec_id + "/launchNodes", + ocean_launch_spec_id + "/launchNodes", entity_name='ocean (Cluster Roll)') formatted_response = self.convert_json( @@ -2774,17 +2776,19 @@ def get_ocean_right_sizing_recommendations(self, ocean_id: str, cluster_resource # endRegion -# region OceanECS -class OceanECSClient(Client): - __base_ocean_url = "/ocean/aws/ecs/cluster/" +# region OceanEcs + + +class OceanEcsClient(Client): + __base_ocean_url = "/ocean/aws/ecs/cluster" __base_launch_spec_url = "/ocean/aws/ecs/launchSpec" def get_all_ocean_clusters(self): """ - Get the configurations for all Ocean clusters in the specified account. + Get the configurations for all Ocean ECS clusters in the specified account. # Returns - (Object): Ocean ECS Api response + (Object): Ocean ECS API response """ response = self.send_get( @@ -2894,17 +2898,19 @@ def delete_ocean_cluster(self, ocean_id: str): entity_name="ocean ecs" ) - def import_ocean_cluster(self, ecs_cluster_nameocean: str, import_cluster: ecs_ocean.ImportCluster): + def import_ocean_cluster(self, ecs_cluster_name: str, import_cluster_config: ecs_ocean.ImportClusterConfig): """ Create an Ocean ECS Cluster # Arguments - ocean (Ocean): Ocean ECS Object + ecs_cluster_name (String): Name of the existing ECS Cluster to import + import_cluster_config (ImportClusterConfig): Import Cluster Object # Returns (Object): Ocean ECS API response """ - ocean = ecs_ocean.ImportClusterRequest(import_cluster) + ocean = ecs_ocean.ImportClusterRequest( + import_cluster_config=import_cluster_config) excluded_missing_dict = self.exclude_missing( json.loads(ocean.toJSON())) @@ -2916,7 +2922,7 @@ def import_ocean_cluster(self, ecs_cluster_nameocean: str, import_cluster: ecs_o response = self.send_post( body=body_json, - url=self.__base_ocean_url + "/" + ecs_cluster_nameocean, + url=self.__base_ocean_url + "/" + ecs_cluster_name + "/import", entity_name='ocean ecs') formatted_response = self.convert_json(response, @@ -2930,10 +2936,11 @@ def get_elastilog(self, ocean_id: str, from_date: str, to_date: str, severity: s Get the log of an Ocean Cluster. # Arguments + ocean_id (String): Ocean cluster identifier to_date (String): end date value from_date (String): beginning date value - severity(String) (Optional): Log level severity - resource_id(String) (Optional): specific resource identifier + severity (String) (Optional): Log level severity + resource_id (String) (Optional): specific resource identifier limit(int) (Optional): Maximum number of lines to extract in a response # Returns @@ -2944,34 +2951,13 @@ def get_elastilog(self, ocean_id: str, from_date: str, to_date: str, severity: s resourceId=resource_id, limit=limit) result = self.send_get( - url=geturl, entity_name='ocean_ecs_log', query_params=query_params) + url=geturl, entity_name='ocean ecs', query_params=query_params) formatted_response = self.convert_json( result, self.camel_to_underscore) return formatted_response["response"]["items"] - def get_rightsizing_recommendations(self, ocean_id: str): - """ - Get right-sizing recommendations for an Ocean cluster. - - # Arguments - ocean_id (String): Id of the Ocean Cluster - - # Returns - (Object): Ocean API response - """ - - group_response = self.send_get( - url=self.__base_ocean_url + - "/" + ocean_id + "/rightSizing/suggestion", - entity_name='ocean ecs') - - formatted_response = self.convert_json( - group_response, self.camel_to_underscore) - - return formatted_response["response"]["items"] - def instance_types_filters_simulation(self, ocean_id: str, filters: ecs_ocean.InstanceTypesFilters): """ Returns all instances types that match the given filters. @@ -2997,8 +2983,8 @@ def instance_types_filters_simulation(self, ocean_id: str, filters: ecs_ocean.In group_response = self.send_post( body=body_json, url=self.__base_ocean_url + - "/" + ocean_id + "/instanceTypeFiltersSimulation", - entity_name='ocean ecs instance type filter') + "/" + ocean_id + "/instanceTypeFiltersSimulation", + entity_name='ocean ecs') formatted_response = self.convert_json( group_response, self.camel_to_underscore) @@ -3017,7 +3003,7 @@ def get_allowed_instance_types(self, ocean_id: str): """ response = self.send_get( url=self.__base_ocean_url + "/" + ocean_id + "/allowedInstanceTypes", - entity_name="ocean ecs allowed instance types" + entity_name="ocean ecs" ) formatted_response = self.convert_json( @@ -3035,27 +3021,31 @@ def upgrade_elastigroup_to_ocean(self, group_id: str): # Returns (Object): Ocean ECS API response """ - response = self.send_post( + query_params = dict(groupId=group_id) + + response = self.send_post_with_params( url=self.__base_ocean_url + "/import", - entity_name='ocean ecs') + entity_name='ocean ecs', + body=None, + user_query_params=query_params) formatted_response = self.convert_json(response, self.camel_to_underscore) return formatted_response["response"]["items"][0] - def initiate_roll(self, ocean_id: str, cluster_roll: ecs_ocean.Roll): + def initiate_roll(self, ocean_id: str, roll_config: ecs_ocean.RollConfig): """ Initiate Cluster Rolls # Arguments ocean_id (String): ID of the Ocean Cluster - cluster_roll (Roll): Cluster Roll / Roll with Instance Ids/ Launch specification Ids + roll_config (RollConfig): Cluster Roll / Roll with Instance Ids/ Roll with VNG Ids # Returns (Object): Cluster Roll API response """ - roll_request = ecs_ocean.ClusterRollInitiateRequest(cluster_roll) + roll_request = ecs_ocean.ClusterRollInitiateRequest(roll_config) excluded_missing_dict = self.exclude_missing( json.loads(roll_request.toJSON())) @@ -3149,40 +3139,45 @@ def get_roll(self, ocean_id: str, roll_id: str): return formatted_response["response"]["items"][0] - def get_cluster_container_instances(self, ocean_id: str, instance_id: str, launch_spec_id: str): + def get_cluster_container_instances(self, ocean_id: str, instance_id: str = None, launch_spec_id: str = None): """ Get container instances data of an Ocean cluster. # Arguments ocean_id (String): ID of the Ocean Cluster instance_id (String): Instance identifier - launch_spec_id (String): Ocean launch spec identifier + launch_spec_id (String): Ocean cluster VNG identifier. # Returns (Object): Ocean Aws Container Instances Data Response """ + query_params = dict(instanceId=instance_id, + launchSpecId=launch_spec_id) + response = self.send_get( url=self.__base_ocean_url + "/" + ocean_id + "/containerInstances", + query_params=query_params, entity_name="ocean ecs instances" ) formatted_response = self.convert_json( response, self.camel_to_underscore) - return formatted_response["response"]["items"][0] + return formatted_response["response"]["items"] - def detach_instances(self, ocean_id: str, detach_instance: ecs_ocean.DetachInstances): + def detach_instances(self, ocean_id: str, detach_configuration: ecs_ocean.DetachInstancesConfig): """ Detach instances from your Ocean cluster. # Arguments ocean_id (String): ID of the Ocean Cluster - detach_instance (DetachInstances): Detach instances request + detach_configuration (DetachInstancesConfig): Detach instances request # Returns (Object): Detach Instance response """ - request = ecs_ocean.DetachInstancesRequest(detach_instance) + request = ecs_ocean.DetachInstancesRequest( + detach_config=detach_configuration) excluded_missing_dict = self.exclude_missing( json.loads(request.toJSON())) @@ -3210,7 +3205,7 @@ def create_virtual_node_group(self, vng: ecs_ocean.VirtualNodeGroup): vng (VirtualNodeGroup): VirtualNodeGroup Object # Returns - (Object): Ocean Launch Spec response + (Object): Ocean Virtual Node Group API response """ ocean = ecs_ocean.VNGRequest(vng) @@ -3234,15 +3229,15 @@ def create_virtual_node_group(self, vng: ecs_ocean.VirtualNodeGroup): def get_all_virtual_node_groups(self, ocean_id: str): """ - Get all the custom VNGs for all Ocean clusters in the specified account. + Get all VNGs for the specified Ocean cluster. # Returns - (Object): Ocean VNG API response + (Object): Ocean Virtual Node Group API response """ response = self.send_get( url=self.__base_launch_spec_url, - entity_name="ocean_gcp_vng", + entity_name="ocean ecs vng", query_params=dict(oceanId=ocean_id) ) @@ -3257,27 +3252,28 @@ def delete_virtual_node_group(self, vng_id: str, delete_container_instances: boo # Arguments vng_id (String): Ocean cluster Virtual Node Group identifier. - delete_container_instances (Bool): When set to "true", all instances belonging to the deleted launch specification will be drained, detached, and terminated. + delete_container_instances (Bool): When set to "true", all instances belonging to the deleted VNG will be drained, detached, and terminated. # Returns - (Object): Ocean Launch Specification Delete response + (Object): Ocean Virtual Node Group Delete response """ return self.send_delete_with_params( url=self.__base_launch_spec_url + "/" + vng_id, entity_name="ocean ecs vng", - user_query_params=dict(deleteContainerInstances=delete_container_instances) + user_query_params=dict( + deleteContainerInstances=delete_container_instances) ) def update_virtual_node_group(self, vng_id: str, vng: ecs_ocean.VirtualNodeGroup): """ - Get a specific custom launch configuration for an Ocean cluster in the specified account. + Update specified VNG for an Ocean cluster. # Arguments vng_id (String): ID of the Ocean Virtual Node Group - ocean (Ocean): Ocean object + vng (VirtualNodeGroup): VirtualNodeGroup Object # Returns - (Object): Ocean Launch Spec response + (Object): Ocean Virtual Node Group API response """ ocean = ecs_ocean.VNGRequest(vng) @@ -3300,18 +3296,18 @@ def update_virtual_node_group(self, vng_id: str, vng: ecs_ocean.VirtualNodeGroup return formatted_response["response"]["items"][0] - def get_virtual_node_group(self, ocean_launch_spec_id: str): + def get_virtual_node_group(self, vng_id: str): """ - Get a specific custom launch configuration for an Ocean cluster in the specified account. + Get a specified VNG for an Ocean cluster. # Arguments - ocean_launch_spec_id (String): Ocean cluster launch specification identifier + vng_id (String): Ocean cluster Virtual Node Group identifier. # Returns - (Object): Ocean Allowed Instance Types response + (Object): Ocean Virtual Node Group API response """ response = self.send_get( - url=self.__base_launch_spec_url + "/" + ocean_launch_spec_id, + url=self.__base_launch_spec_url + "/" + vng_id, entity_name="ocean ecs vng" ) @@ -3326,13 +3322,14 @@ def import_fargate_to_existing_ocean_cluster(self, ocean_id: str, Import a Fargate service into an existing Ocean ECS cluster. # Arguments - ocean_id(String): Ocean cluster Identifier - import_fargate_existing(Object): ImportFargateToExistingOceanCluster Object + ocean_id (String): Ocean cluster Identifier + import_fargate_existing (Object): ImportFargateToExistingOceanCluster Object # Returns (Object): Ocean ECS Fargate Response """ - ocean = ecs_ocean.ImportFargateToExistingOceanClusterRequest(import_fargate_existing) + ocean = ecs_ocean.ImportFargateToExistingOceanClusterRequest( + import_config=import_fargate_existing) excluded_missing_dict = self.exclude_missing( json.loads(ocean.toJSON())) @@ -3363,7 +3360,8 @@ def get_fargate_services_discovery(self, ocean_id: str): (Object): Ocean ECS Fargate Response """ response = self.send_get( - url=self.__base_ocean_url + ocean_id + "/fargateMigration/serviceDiscovery", + url=self.__base_ocean_url + "/" + ocean_id + + "/fargateMigration/serviceDiscovery", entity_name="ocean ecs fargate" ) @@ -3383,7 +3381,7 @@ def get_fargate_migration_status(self, ocean_id: str): (Object): Ocean ECS Fargate Response """ response = self.send_get( - url=self.__base_ocean_url + ocean_id + "/fargateMigration/status", + url=self.__base_ocean_url + "/" + ocean_id + "/fargateMigration/status", entity_name="ocean ecs fargate" ) @@ -3392,19 +3390,19 @@ def get_fargate_migration_status(self, ocean_id: str): return formatted_response["response"]["items"] - def import_fargate_to_new_ocean_cluster(self, ocean_id: str, - import_fargate_new: ecs_ocean.ImportFargateToNewOceanCluster): + def import_fargate_to_new_ocean_cluster(self, import_fargate_new: ecs_ocean.ImportFargateToNewOceanCluster): """ Import a Fargate service into a new Ocean ECS cluster. # Arguments - ocean_id(String): Ocean cluster Identifier - import_fargate_new(Object): ImportFargateToNewOceanCluster Object + ocean_id (String): Ocean cluster Identifier + import_fargate_new (Object): ImportFargateToNewOceanCluster Object # Returns (Object): Ocean ECS Fargate Response """ - ocean = ecs_ocean.ImportFargateToNewOceanClusterRequest(import_fargate_new) + ocean = ecs_ocean.ImportFargateToNewOceanClusterRequest( + import_config=import_fargate_new) excluded_missing_dict = self.exclude_missing( json.loads(ocean.toJSON())) @@ -3424,45 +3422,12 @@ def import_fargate_to_new_ocean_cluster(self, ocean_id: str, return formatted_response["response"]["items"] - def get_ecs_cluster_aggregated_costs(self, ocean_id: str, - aggregated_cluster_costs: ecs_ocean.AggregatedClusterCosts): - """ - Provides Ecs cluster resource usage and costs over a time interval which can be grouped and/or filtered by AWS tag - - # Arguments - ocean_id (String): ID of the Ocean Cluster - aggregated_cluster_costs (AggregatedClusterCosts): Aggregated Cluster Costs request - - # Returns - (Object): Aggregated Cluster Costs API response - """ - aggregated_cluster_costs_request = ecs_ocean.AggregatedClusterCostRequest( - aggregated_cluster_costs) - - excluded_missing_dict = self.exclude_missing( - json.loads(aggregated_cluster_costs_request.toJSON())) - - formatted_missing_dict = self.convert_json_with_list_of_lists( - excluded_missing_dict, self.underscore_to_camel) - - body_json = json.dumps(formatted_missing_dict) - - aggregated_costs_response = self.send_post( - body=body_json, - url=self.__base_ocean_url + "/" + ocean_id + "/aggregatedCosts", - entity_name='ocean ecs(aggregated cluster costs)') - - formatted_response = self.convert_json( - aggregated_costs_response, self.camel_to_underscore) - - return formatted_response["response"]["items"][0] - - def launch_instances_in_vng(self, ocean_launch_spec_id: str, amount: int): + def launch_instances_in_vng(self, vng_id: str, amount: int): """ Launch container instances in virtual node group. # Arguments - ocean_launch_spec_id (String): Ocean cluster launch specification identifier. + vng_id (String): Ocean cluster Virtual Node Group identifier. amount (int): The number of nodes to launch. # Returns @@ -3480,11 +3445,13 @@ def launch_instances_in_vng(self, ocean_launch_spec_id: str, amount: int): response = self.send_put( body=body_json, - url=self.__base_launch_spec_url + "/" + ocean_launch_spec_id + "/launchContainerInstances", - entity_name='ocean vng launch instances') + url=self.__base_launch_spec_url + "/" + + vng_id + "/launchContainerInstances", + entity_name='ocean ecs vng') formatted_response = self.convert_json( response, self.camel_to_underscore) return formatted_response["response"]["items"][0] -# endregion \ No newline at end of file + +# endregion diff --git a/spotinst_sdk2/models/ocean/ecs/__init__.py b/spotinst_sdk2/models/ocean/ecs/__init__.py index dae0e2a9..915bd637 100644 --- a/spotinst_sdk2/models/ocean/ecs/__init__.py +++ b/spotinst_sdk2/models/ocean/ecs/__init__.py @@ -9,13 +9,14 @@ class Down: """ # Arguments evaluation_periods: int - maxScale_down_percentage: int + max_scale_down_percentage: int """ + def __init__(self, evaluation_periods: int = none, - maxScale_down_percentage: int = none): + max_scale_down_percentage: int = none): self.evaluation_periods = evaluation_periods - self.maxScale_down_percentage = maxScale_down_percentage + self.max_scale_down_percentage = max_scale_down_percentage class Headroom: @@ -25,6 +26,7 @@ class Headroom: memory_per_unit: int num_of_units: int """ + def __init__(self, cpu_per_unit: int = none, memory_per_unit: int = none, @@ -38,13 +40,14 @@ class ResourceLimits: """ # Arguments max_memory_gib: int - max_vcpu: int + max_v_cpu: int """ + def __init__(self, max_memory_gib: int = none, - max_vcpu: int = none): + max_v_cpu: int = none): self.max_memory_gib = max_memory_gib - self.max_vcpu = max_vcpu + self.max_v_cpu = max_v_cpu class AutoScaler: @@ -60,6 +63,7 @@ class AutoScaler: resource_limits: ResourceLimits should_scale_down_non_service_tasks: bool """ + def __init__(self, auto_headroom_percentage: int = none, cooldown: int = none, @@ -81,37 +85,30 @@ def __init__(self, self.should_scale_down_non_service_tasks = should_scale_down_non_service_tasks -class Unit(Enum): - weight = "weight" - instance = "instance" - - class Capacity: """ # Arguments maximum: int minimum: int target: int - unit: Unit """ + def __init__(self, maximum: int = none, minimum: int = none, - target: int = none, - unit: Unit = none): + target: int = none): self.maximum = maximum self.minimum = minimum self.target = target - self.unit = unit -class Architectures(Enum): +class Architecture(Enum): i386 = "i386" x86_64 = "x86_64" arm64 = "arm64" -class Categories(Enum): +class Category(Enum): accelerated_computing = "Accelerated_computing" compute_optimized = "Compute_optimized" general_purpose = "General_purpose" @@ -119,7 +116,7 @@ class Categories(Enum): storage_optimized = "Storage_optimized" -class DiskTypes(Enum): +class DiskType(Enum): nvme = "NVMe" ebs = "EBS" ssd = "SSD" @@ -131,67 +128,79 @@ class Hypervisor(Enum): xen = "xen" -class RootDeviceTypes(Enum): +class RootDeviceType(Enum): ebs = "ebs" instance_store = "instance-store" -class VirtualizationTypes(Enum): +class VirtualizationType(Enum): hvm = "hvm" paravirtual = "paravirtual" class InstanceTypesFilters: """ - architectures: List[Architectures] - categories: List[Categories] - disk_types: List[DiskTypes] + # Arguments + min_vcpu: int + max_vcpu: int + min_memory_gi_b: float + max_memory_gi_b: float + min_gpu: int + max_gpu: int + include_families: List[str] exclude_families: List[str] exclude_metal: bool - hypervisor: List[Hypervisor] - include_families: List[str] is_ena_supported: bool - max_gpu: int - max_memory_gi_b: float - max_network_performance: int - max_vcpu: int + architectures: List[Architecture] + virtualization_types: List[VirtualizationType] + categories: List[Category] min_enis: int - min_gpu: int - min_memory_gi_b: float + disk_types: List[DiskType] + hypervisor: List[Hypervisor] + root_device_types: List[RootDeviceType] min_network_performance: int - min_vcpu: int - root_device_types: List[RootDeviceTypes] - virtualization_types: List[VirtualizationTypes] + max_network_performance: int """ + def __init__(self, - architectures: List[Architectures] = none, - categories: List[Categories] = none, - disk_types: List[DiskTypes] = none, + min_vcpu: int = none, + max_vcpu: int = none, + min_memory_gi_b: float = none, + max_memory_gi_b: float = none, + min_gpu: int = none, + max_gpu: int = none, + include_families: List[str] = none, exclude_families: List[str] = none, exclude_metal: bool = none, - hypervisor: List[Hypervisor] = none, - include_families: List[str] = none, is_ena_supported: bool = none, - max_gpu: int = none, - min_memory_gi_b: float = none, + architectures: List[Architecture] = none, + virtualization_types: List[VirtualizationType] = none, + categories: List[Category] = none, + min_enis: int = none, + disk_types: List[DiskType] = none, + hypervisor: List[Hypervisor] = none, + root_device_types: List[RootDeviceType] = none, min_network_performance: int = none, - min_vcpu: int = none, - root_device_types: List[RootDeviceTypes] = none, - virtualization_types: List[VirtualizationTypes] = none): + max_network_performance: int = none): + self.min_vcpu = min_vcpu + self.max_vcpu = max_vcpu + self.min_memory_gi_b = min_memory_gi_b + self.max_memory_gi_b = max_memory_gi_b + self.min_gpu = min_gpu + self.max_gpu = max_gpu + self.include_families = include_families + self.exclude_families = exclude_families + self.exclude_metal = exclude_metal + self.is_ena_supported = is_ena_supported self.architectures = architectures + self.virtualization_types = virtualization_types self.categories = categories + self.min_enis = min_enis self.disk_types = disk_types - self.exclude_families = exclude_families - self.exclude_metal = exclude_metal self.hypervisor = hypervisor - self.include_families = include_families - self.is_ena_supported = is_ena_supported - self.max_gpu= max_gpu - self.min_memory_gi_b = min_memory_gi_b - self.min_network_performance = min_network_performance - self.min_vcpu = min_vcpu self.root_device_types = root_device_types - self.virtualization_types = virtualization_types + self.min_network_performance = min_network_performance + self.max_network_performance = max_network_performance class InstanceTypes: @@ -201,6 +210,7 @@ class InstanceTypes: filters: InstanceTypesFilters whitelist: List[str] """ + def __init__(self, blacklist: List[str] = none, filters: InstanceTypesFilters = none, @@ -217,6 +227,7 @@ class DynamicVolumeSize: resource: str size_per_resource_unit: int """ + def __init__(self, base_size: int = none, resource: str = none, @@ -239,6 +250,7 @@ class EBS: volume_size: int volume_type: str """ + def __init__(self, delete_on_termination: bool = none, dynamic_volume_size: DynamicVolumeSize = none, @@ -260,12 +272,13 @@ def __init__(self, self.volume_type = volume_type -class BlockDeviceMappings: +class BlockDeviceMapping: """ # Arguments device_name: str ebs: EBS """ + def __init__(self, device_name: str = none, ebs: EBS = none): @@ -278,6 +291,7 @@ class IamInstanceProfile: # Arguments arn: str """ + def __init__(self, arn: str = none): self.arn = arn @@ -300,6 +314,7 @@ class InstanceMetadataOptions: http_put_response_hop_limit: int http_tokens: HttpTokens """ + def __init__(self, http_endpoint: HttpEndpoint = none, http_put_response_hop_limit: int = none, @@ -309,12 +324,13 @@ def __init__(self, self.http_tokens = http_tokens -class Tags: +class Tag: """ # Arguments tag_key: str tag_value: str """ + def __init__(self, tag_key: str = none, tag_value: str = none): @@ -327,30 +343,33 @@ class LaunchSpecification: # Arguments associate_ipv6_address: bool associate_public_ip_address: bool - block_device_mappings: List[BlockDeviceMappings] + block_device_mappings: List[BlockDeviceMapping] ebs_optimized: bool iam_instance_profile: IamInstanceProfile image_id: str instance_metadata_options: InstanceMetadataOptions monitoring: bool security_group_ids: List[str] - tags: List[Tags] + tags: List[Tag] use_as_template_only: bool user_data: str + key_pair: str """ + def __init__(self, associate_ipv6_address: bool = none, associate_public_ip_address: bool = none, - block_device_mappings: List[BlockDeviceMappings] = none, + block_device_mappings: List[BlockDeviceMapping] = none, ebs_optimized: bool = none, iam_instance_profile: IamInstanceProfile = none, image_id: str = none, instance_metadata_options: InstanceMetadataOptions = none, monitoring: bool = none, security_group_ids: List[str] = none, - tags: List[Tags] = none, + tags: List[Tag] = none, use_as_template_only: bool = none, - user_data: str = none): + user_data: str = none, + key_pair: str = none): self.associate_ipv6_address = associate_ipv6_address self.associate_public_ip_address = associate_public_ip_address self.block_device_mappings = block_device_mappings @@ -363,6 +382,7 @@ def __init__(self, self.tags = tags self.use_as_template_only = use_as_template_only self.user_data = user_data + self.key_pair = key_pair class OptimizeImages: @@ -372,6 +392,7 @@ class OptimizeImages: should_optimize_ecs_ami: bool time_windows: List[str] """ + def __init__(self, perform_at: str = none, should_optimize_ecs_ami: bool = none, @@ -389,6 +410,7 @@ class Compute: optimize_images: OptimizeImages subnet_ids: List[str] """ + def __init__(self, instance_types: InstanceTypes = none, launch_specification: LaunchSpecification = none, @@ -400,33 +422,36 @@ def __init__(self, self.subnet_ids = subnet_ids -class S3: +class S3Bucket: """ # Arguments id: str """ + def __init__(self, id: str = none): self.id = id -class Export: +class LoggingConfiguration: """ # Arguments - s3: S3 + s3: S3Bucket """ + def __init__(self, - s3: S3 = none): + s3: S3Bucket = none): self.s3 = s3 class Logging: """ # Arguments - export: Export + export: LoggingConfiguration """ + def __init__(self, - export: Export = none): + export: LoggingConfiguration = none): self.export = export @@ -436,6 +461,7 @@ class ShutdownHours: is_enabled: bool time_windows: List[str] """ + def __init__(self, is_enabled: bool = none, time_windows: List[str] = none): @@ -450,6 +476,7 @@ class ClusterRoll: batch_size_percentage: int comment: str """ + def __init__(self, batch_min_healthy_percentage: int = none, batch_size_percentage: int = none, @@ -464,12 +491,13 @@ class Parameters: # Arguments cluster_roll: ClusterRoll """ + def __init__(self, cluster_roll: ClusterRoll = none): self.cluster_roll = cluster_roll -class Tasks: +class SchedulingTask: """ # Arguments cron_expression: str @@ -477,6 +505,7 @@ class Tasks: parameters: Parameters task_type: str """ + def __init__(self, cron_expression: str = none, is_enabled: bool = none, @@ -492,18 +521,20 @@ class Scheduling: """ # Arguments shutdown_hours: ShutdownHours - tasks: List[Tasks] + tasks: List[SchedulingTask] """ + def __init__(self, shutdown_hours: ShutdownHours = none, - tasks: List[Tasks] = none): + tasks: List[SchedulingTask] = none): self.shutdown_hours = shutdown_hours self.tasks = tasks class AvailabilityVsCost(Enum): - cost_oriented = "CostOriented" + cost_oriented = "costOriented" balanced = "balanced" + cheapest = "cheapest" class ClusterOrientation: @@ -511,6 +542,7 @@ class ClusterOrientation: # Arguments availability_vs_cost: AvailabilityVsCost """ + def __init__(self, availability_vs_cost: AvailabilityVsCost = none): self.availability_vs_cost = availability_vs_cost @@ -526,6 +558,7 @@ class Strategy: utilize_commitments: bool utilize_reserved_instances: bool """ + def __init__(self, cluster_orientation: ClusterOrientation = none, draining_timeout: int = none, @@ -554,6 +587,7 @@ class Ocean: scheduling: Scheduling strategy: Strategy """ + def __init__(self, auto_scaler: AutoScaler = none, capacity: Capacity = none, @@ -584,13 +618,14 @@ def toJSON(self): sort_keys=True, indent=4) -class ImportCluster: +class ImportClusterConfig: """ # Arguments instance_id: str name: str region: str """ + def __init__(self, instance_id: str = none, name: str = none, @@ -601,10 +636,10 @@ def __init__(self, class ImportClusterRequest: - def __init__(self, import_cluster: ImportCluster): - self.region = import_cluster.region - self.name = import_cluster.name - self.instance_id = import_cluster.instance_id + def __init__(self, import_cluster_config: ImportClusterConfig): + self.region = import_cluster_config.region + self.name = import_cluster_config.name + self.instance_id = import_cluster_config.instance_id def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, @@ -620,7 +655,7 @@ def toJSON(self): sort_keys=True, indent=4) -class Roll: +class RollConfig: """ # Arguments batch_min_healthy_percentage: int @@ -645,8 +680,8 @@ def __init__( class ClusterRollInitiateRequest: - def __init__(self, roll: Roll = none): - self.roll = roll + def __init__(self, roll_config: RollConfig = none): + self.roll = roll_config def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, @@ -662,7 +697,7 @@ def toJSON(self): sort_keys=True, indent=4) -class DetachInstances: +class DetachInstancesConfig: """ # Arguments instances_to_detach: List[str] @@ -681,22 +716,23 @@ def __init__( class DetachInstancesRequest: - def __init__(self, detachInstances: DetachInstances): - self.instances_to_detach = detachInstances.instances_to_detach - self.should_decrement_target_capacity = detachInstances.should_decrement_target_capacity - self.should_terminate_instances = detachInstances.should_terminate_instances + def __init__(self, detach_config: DetachInstancesConfig): + self.instances_to_detach = detach_config.instances_to_detach + self.should_decrement_target_capacity = detach_config.should_decrement_target_capacity + self.should_terminate_instances = detach_config.should_terminate_instances def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) -class Attributes: +class Attribute: """ # Arguments key: str value: str """ + def __init__(self, key: str = none, value: str = none): @@ -709,22 +745,24 @@ class AutoScale: # Arguments headrooms: List[Headrooms] """ + def __init__(self, headrooms: List[Headroom] = none): self.headrooms = headrooms -class Images: +class Image: """ # Arguments id: str """ + def __init__(self, id: str = none): self.id = id -class VngTasks: +class VngTask: """ # Arguments config: List[Headroom] @@ -732,6 +770,7 @@ class VngTasks: is_enabled: bool task_type: str """ + def __init__(self, config: List[Headroom] = none, cron_expression: str = none, @@ -746,22 +785,23 @@ def __init__(self, class VngScheduling: """ # Arguments - tasks: List[VngTasks] + tasks: List[VngTask] """ + def __init__(self, - tasks: List[VngTasks]): + tasks: List[VngTask]): self.tasks = tasks class VirtualNodeGroup: """ # Arguments - attributes: List[Attributes] + attributes: List[Attribute] auto_scale: AutoScale - block_device_mappings: List[BlockDeviceMappings] - iam_instance_profile: List[str] + block_device_mappings: List[BlockDeviceMapping] + iam_instance_profile: IamInstanceProfile image_id: str - images: List[Images] + images: List[Image] instance_metadata_options: InstanceMetadataOptions instance_types: List[str] name: str @@ -772,16 +812,17 @@ class VirtualNodeGroup: security_group_ids: List[str] strategy: Strategy subnet_ids: List[str] - tags: List[Tags] + tags: List[Tag] user_data: str """ + def __init__(self, - attributes: List[Attributes] = none, + attributes: List[Attribute] = none, auto_scale: AutoScale = none, - block_device_mappings: List[BlockDeviceMappings] = none, - iam_instance_profile: List[str] = none, + block_device_mappings: List[BlockDeviceMapping] = none, + iam_instance_profile: IamInstanceProfile = none, image_id: str = none, - images: List[Images] = none, + images: List[Image] = none, instance_metadata_options: InstanceMetadataOptions = none, instance_types: List[str] = none, name: str = none, @@ -792,7 +833,7 @@ def __init__(self, security_group_ids: List[str] = none, strategy: Strategy = none, subnet_ids: List[str] = none, - tags: List[Tags] = none, + tags: List[Tag] = none, user_data: str = none): self.attributes = attributes self.auto_scale = auto_scale @@ -829,6 +870,7 @@ class ImportFargateToExistingOceanCluster: services: List[str] simple_new_service_names: bool """ + def __init__(self, services: List[str] = none, simple_new_service_names: bool = none): @@ -837,9 +879,9 @@ def __init__(self, class ImportFargateToExistingOceanClusterRequest: - def __init__(self, import_fargate_to_cluster: ImportFargateToExistingOceanCluster): - self.services = import_fargate_to_cluster.services - self.simple_new_service_names = import_fargate_to_cluster.simple_new_service_names + def __init__(self, import_config: ImportFargateToExistingOceanCluster): + self.services = import_config.services + self.simple_new_service_names = import_config.simple_new_service_names def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, @@ -854,15 +896,16 @@ class ImportFargateToNewOceanCluster: ocean_cluster_name: str region: str services: List[str] - tags: List[Tags] - """ - def __int__(self, - ecs_cluster_name: str = none, - key_pair: str = none, - ocean_cluster_name: str = none, - region: str = none, - services: List[str] = none, - tags: List[Tags] = none): + tags: List[Tag] + """ + + def __init__(self, + ecs_cluster_name: str = none, + key_pair: str = none, + ocean_cluster_name: str = none, + region: str = none, + services: List[str] = none, + tags: List[Tag] = none): self.ecs_cluster_name = ecs_cluster_name self.key_pair = key_pair self.ocean_cluster_name = ocean_cluster_name @@ -872,115 +915,13 @@ def __int__(self, class ImportFargateToNewOceanClusterRequest: - def __init__(self, import_fargate_to_cluster: ImportFargateToNewOceanCluster): - self.ecs_cluster_name = import_fargate_to_cluster.ecs_cluster_name - self.key_pair = import_fargate_to_cluster.key_pair - self.ocean_cluster_name = import_fargate_to_cluster.ocean_cluster_name - self.region = import_fargate_to_cluster.region - self.services = import_fargate_to_cluster.services - self.tags = import_fargate_to_cluster.tags - - def toJSON(self): - return json.dumps(self, default=lambda o: o.__dict__, - sort_keys=True, indent=4) - - -class Operator(Enum): - equals = "equals" - not_equals = "notEquals" - exists = "exists" - does_not_exist = "doesNotExist" - - -class Attribute: - """ - # Arguments - key: str - operator: Operator - value: str - """ - - def __init__( - self, - key: str = none, - operator: Operator = none, - value: str = none): - self.key = key - self.operator = operator - self.value = value - - -class AllMatch: - """ - # Arguments - all_matches: List[Attribute] - """ - - def __init__( - self, - all_matches: List[Attribute] = none): - self.all_matches = all_matches - - -class Conditions: - """ - # Arguments - any_match: List[AllMatch] - """ - - def __init__( - self, - any_match: List[AllMatch] = none): - self.any_match = any_match - - -class Filter: - """ - # Arguments - conditions: Conditions - """ - - def __init__( - self, - conditions: Conditions = none): - self.conditions = conditions - - -class GroupBy(Enum): - namespace = "namespace" - namespace_label = "namespace.label.${labelKey}" - resource_label = "resource.label.${labelKey}" - namespace_annotation = "namespace.annotation.${annotationKey}" - resource_annotation = "resource.annotation.${annotationKey}" - - -class AggregatedClusterCosts: - """ - # Arguments - end_time: str - aggregated_filter: Filter - group_by: GroupBy - start_time: str - """ - - def __init__( - self, - end_time: str = none, - aggregated_filter: Filter = none, - group_by: GroupBy = GroupBy.namespace.value, - start_time: str = none): - self.end_time = end_time - self.aggregated_filter = aggregated_filter - self.group_by = group_by - self.start_time = start_time - - -class AggregatedClusterCostRequest: - def __init__(self, aggregated_cluster_costs: AggregatedClusterCosts = none): - self.end_time = aggregated_cluster_costs.end_time - self.start_time = aggregated_cluster_costs.start_time - self.group_by = aggregated_cluster_costs.group_by - self.filter = aggregated_cluster_costs.aggregated_filter + def __init__(self, import_config: ImportFargateToNewOceanCluster): + self.ecs_cluster_name = import_config.ecs_cluster_name + self.key_pair = import_config.key_pair + self.ocean_cluster_name = import_config.ocean_cluster_name + self.region = import_config.region + self.services = import_config.services + self.tags = import_config.tags def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, diff --git a/spotinst_sdk2/version.py b/spotinst_sdk2/version.py index 8576e6e6..6e9b3ce4 100644 --- a/spotinst_sdk2/version.py +++ b/spotinst_sdk2/version.py @@ -1 +1 @@ -__version__ = '3.13.0' +__version__ = '3.14.0'