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 old mode 100755 new mode 100644 index 764e2190..d5334e54 --- a/spotinst_sdk2/__init__.py +++ b/spotinst_sdk2/__init__.py @@ -57,6 +57,8 @@ 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, + 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), "oceancd": OceanCDClient(session=self.session, print_output=print_output, log_level=log_level, diff --git a/spotinst_sdk2/clients/ocean/__init__.py b/spotinst_sdk2/clients/ocean/__init__.py index 20815d2b..cd769c2b 100644 --- a/spotinst_sdk2/clients/ocean/__init__.py +++ b/spotinst_sdk2/clients/ocean/__init__.py @@ -5,6 +5,7 @@ import spotinst_sdk2.models.ocean.aws as aws_ocean import spotinst_sdk2.models.ocean.azure as azure_ocean import spotinst_sdk2.models.ocean.gcp as gcp_ocean +import spotinst_sdk2.models.ocean.ecs as ecs_ocean import spotinst_sdk2.models.ocean.rightsizing as right_sizing_ocean # region AWS @@ -118,7 +119,8 @@ def get_all_ocean_sizing(self, ocean_id: str, namespace: str): return formatted_response["response"]["items"] - def fetch_rightsizing_recommendations(self, ocean_id: str, filter: aws_ocean.RightSizingRecommendationFilter = None): + def fetch_rightsizing_recommendations(self, ocean_id: str, + filter: aws_ocean.RightSizingRecommendationFilter = None): """ Get right-sizing recommendations for an Ocean cluster and filter them according to namespace or label. @@ -506,7 +508,8 @@ def fetch_elastilog(self, ocean_id, from_date, to_date, severity=None, resource_ return formatted_response["response"]["items"] - def import_asg_to_ocean_cluster(self, auto_scaling_group_name, region, import_asg_to_ocean_cluster: aws_ocean.ImportASGToOceanCluster): + def import_asg_to_ocean_cluster(self, auto_scaling_group_name, region, + import_asg_to_ocean_cluster: aws_ocean.ImportASGToOceanCluster): """ Create an Ocean configuration according to an AWS autoscaling group (ASG) configuration. @@ -722,7 +725,7 @@ def update_elastigroup_to_ocean(self, group_id: str): response = self.send_post_with_params( body=None, - url=self.__base_ocean_cluster_url+"/import", + url=self.__base_ocean_cluster_url + "/import", entity_name='ocean_aws_update_eg_to_ocean', user_query_params=query_params) @@ -799,7 +802,8 @@ def instance_types_filter_simulation_for_vng(self, launch_spec_id: str, return formatted_response["response"]["items"][0] - def import_asg_to_ocean_vng(self, auto_scaling_group_name, ocean_id: str, import_asg_to_ocean_launch_spec: aws_ocean.ImportASGToOceanVNG): + def import_asg_to_ocean_vng(self, auto_scaling_group_name, ocean_id: str, + import_asg_to_ocean_launch_spec: aws_ocean.ImportASGToOceanVNG): """ Returns an Ocean Virtual Node Group (VNG) configuration in a given AWS autoscaling group (ASG). The returned value ("Imported VNG") can then be used as input to the Create Virtual Node Group API in order to create an actual VNG in your Ocean cluster. @@ -859,7 +863,9 @@ def allowed_instance_types_by_filters_for_vng(self, launch_spec_id: str): return formatted_response["response"]["items"][0] - def import_eks_cluster_node_group_to_ocean_vng(self, eks_cluster_name: str, eks_node_group_name: str, import_eks_node_group_to_ocean_launch_spec: aws_ocean.ImportEKSNodeGroupToOceanVNG, ocean_id: str = None, region: str = None): + def import_eks_cluster_node_group_to_ocean_vng(self, eks_cluster_name: str, eks_node_group_name: str, + import_eks_node_group_to_ocean_launch_spec: aws_ocean.ImportEKSNodeGroupToOceanVNG, + ocean_id: str = None, region: str = None): """ Returns an Ocean Virtual Node Group (VNG) configuration based on a given AWS EKS Cluster Node Group. The returned value ("Imported VNG") can then be used as input to the Create Virtual Node Group API in order to create an actual VNG in your Ocean cluster. @@ -923,7 +929,7 @@ def create_migration(self, ocean_id: str, migration: aws_ocean.Migration): response = self.send_post( body=body_json, - url=self.__base_ocean_cluster_url+"/"+ocean_id+"/migration", + url=self.__base_ocean_cluster_url + "/" + ocean_id + "/migration", entity_name='ocean_aws_migration') formatted_response = self.convert_json(response, @@ -945,7 +951,7 @@ def get_migration_discovery(self, ocean_id: str, should_fetch_pods: bool): query_params = dict(shouldFetchPods=should_fetch_pods) response = self.send_get( - url=self.__base_ocean_cluster_url+"/"+ocean_id+"/migration/discovery", + url=self.__base_ocean_cluster_url + "/" + ocean_id + "/migration/discovery", entity_name="ocean_aws_migration", query_params=query_params ) @@ -980,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", ) @@ -1002,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" ) @@ -1020,7 +1028,7 @@ def get_all_migrations_summary(self, ocean_id: str = None): """ response = self.send_get( - url=self.__base_ocean_cluster_url+"/"+ocean_id+"/migration", + url=self.__base_ocean_cluster_url + "/" + ocean_id + "/migration", entity_name="ocean_aws_migration", ) @@ -1073,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' ) @@ -1100,7 +1108,8 @@ def get_all_extended_resource_definitions(self): return formatted_response["response"]["items"] - def update_extended_resource_definition(self, ocean_extended_resource_definition_id: str, extended_resource_definition: aws_ocean.ExtendedResourceDefinition): + def update_extended_resource_definition(self, ocean_extended_resource_definition_id: str, + extended_resource_definition: aws_ocean.ExtendedResourceDefinition): """ Only the mapping parameter is updatable for extended resource definition @@ -1286,7 +1295,7 @@ def import_cluster_configuration(self, aks_cluster_name: str, resource_group_nam response = self.send_post_with_params( body=None, - url=self.__base_ocean_cluster_url+"/aks/import", + url=self.__base_ocean_cluster_url + "/aks/import", entity_name='ocean_aks', user_query_params=dict(aksClusterName=aks_cluster_name, resourceGroupName=resource_group_name)) @@ -1422,7 +1431,7 @@ def import_vng_configuration(self, node_pool_name: str, ocean_id: str): response = self.send_post_with_params( body=None, - url=self.__base_ocean_vng_url+"/import", + url=self.__base_ocean_vng_url + "/import", entity_name='ocean_aks', user_query_params=dict(nodePoolName=node_pool_name, oceanId=ocean_id)) @@ -1454,7 +1463,7 @@ def launch_new_nodes(self, node_config: azure_ocean.LaunchNewNodes): response = self.send_put( body=body_json, - url=self.__base_ocean_cluster_url+"/launchNewNodes", + url=self.__base_ocean_cluster_url + "/launchNewNodes", entity_name='ocean_aks') formatted_response = self.convert_json(response, @@ -2439,7 +2448,8 @@ def import_gke_cluster_to_ocean(self, cluster_name: str, location: str, geturl = self.__base_ocean_cluster_url + "/gke/import" query_params = dict( - clusterName=cluster_name, includeLaunchSpecs=include_launchSpecs, location=location, nodePoolName=node_pool_name) + clusterName=cluster_name, includeLaunchSpecs=include_launchSpecs, location=location, + nodePoolName=node_pool_name) result = self.send_post_with_params( body=body_json, @@ -2765,3 +2775,683 @@ def get_ocean_right_sizing_recommendations(self, ocean_id: str, cluster_resource return formatted_response["response"]["items"] # endRegion + +# 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 ECS clusters in the specified account. + + # Returns + (Object): Ocean ECS API response + """ + + response = self.send_get( + url=self.__base_ocean_url, + entity_name="ocean ecs" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"] + + def create_ocean_cluster(self, ocean: ecs_ocean.Ocean): + """ + Create an Ocean ECS Cluster + + # Arguments + ocean (Ocean): Ocean ECS Object + + # Returns + (Object): Ocean ECS API response + """ + ocean = ecs_ocean.OceanRequest(ocean) + + excluded_missing_dict = self.exclude_missing( + json.loads(ocean.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_post( + body=body_json, + url=self.__base_ocean_url, + entity_name='ocean ecs') + + formatted_response = self.convert_json(response, + self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def get_ocean_cluster(self, 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 + """ + response = self.send_get( + url=self.__base_ocean_url + "/" + ocean_id, + entity_name="ocean ecs" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def update_ocean_cluster(self, ocean_id: str, ocean: ecs_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 + """ + ocean = ecs_ocean.OceanRequest(ocean) + + excluded_missing_dict = self.exclude_missing( + json.loads(ocean.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_put( + body=body_json, + url=self.__base_ocean_url + "/" + ocean_id, + entity_name='ocean ecs') + + formatted_response = self.convert_json( + response, + self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def delete_ocean_cluster(self, ocean_id: str): + """ + Delete a specified Ocean cluster. + + # Arguments + ocean_id (String): ID of the Ocean Cluster + + # Returns + (Object): Ocean API response + """ + return self.send_delete( + url=self.__base_ocean_url + "/" + ocean_id, + entity_name="ocean ecs" + ) + + def import_ocean_cluster(self, ecs_cluster_name: str, import_cluster_config: ecs_ocean.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 + """ + ocean = ecs_ocean.ImportClusterRequest( + import_cluster_config=import_cluster_config) + + excluded_missing_dict = self.exclude_missing( + json.loads(ocean.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_post( + body=body_json, + url=self.__base_ocean_url + "/" + ecs_cluster_name + "/import", + entity_name='ocean ecs') + + formatted_response = self.convert_json(response, + self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def get_elastilog(self, 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 + """ + geturl = self.__base_ocean_url + "/" + ocean_id + "/log" + query_params = dict(toDate=to_date, fromDate=from_date, severity=severity, + resourceId=resource_id, limit=limit) + + result = self.send_get( + 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 instance_types_filters_simulation(self, ocean_id: str, filters: ecs_ocean.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 + """ + request = ecs_ocean.InstanceTypesFilterRequest(filters) + + excluded_missing_dict = self.exclude_missing( + json.loads(request.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + group_response = self.send_post( + body=body_json, + url=self.__base_ocean_url + + "/" + ocean_id + "/instanceTypeFiltersSimulation", + entity_name='ocean ecs') + + formatted_response = self.convert_json( + group_response, self.camel_to_underscore) + + return formatted_response["response"]["items"] + + def get_allowed_instance_types(self, 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 + """ + response = self.send_get( + url=self.__base_ocean_url + "/" + ocean_id + "/allowedInstanceTypes", + entity_name="ocean ecs" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"] + + def upgrade_elastigroup_to_ocean(self, 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 + """ + query_params = dict(groupId=group_id) + + response = self.send_post_with_params( + url=self.__base_ocean_url + "/import", + 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, roll_config: ecs_ocean.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 + """ + roll_request = ecs_ocean.ClusterRollInitiateRequest(roll_config) + + excluded_missing_dict = self.exclude_missing( + json.loads(roll_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) + + rolls_response = self.send_post( + body=body_json, + url=self.__base_ocean_url + "/" + ocean_id + "/roll", + entity_name='ocean ecs (Cluster Roll)') + + formatted_response = self.convert_json( + rolls_response, self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def list_rolls(self, 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 + """ + response = self.send_get( + url=self.__base_ocean_url + "/" + ocean_id + "/roll", + entity_name="ocean ecs (Cluster Roll)" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"] + + def update_roll(self, 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 + """ + update_roll_request = ecs_ocean.ClusterRollUpdateRequest(status) + + excluded_missing_dict = self.exclude_missing( + json.loads(update_roll_request.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_put( + body=body_json, + url=self.__base_ocean_url + "/" + ocean_id + "/roll/" + roll_id, + entity_name='ocean ecs (Cluster Roll)') + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def get_roll(self, 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 + """ + response = self.send_get( + url=self.__base_ocean_url + "/" + ocean_id + "/roll/" + roll_id, + entity_name="ocean ecs (Cluster Roll)" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + 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 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"] + + 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_configuration (DetachInstancesConfig): Detach instances request + + # Returns + (Object): Detach Instance response + """ + request = ecs_ocean.DetachInstancesRequest( + detach_config=detach_configuration) + + excluded_missing_dict = self.exclude_missing( + json.loads(request.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_put( + body=body_json, + url=self.__base_ocean_url + "/" + ocean_id + "/detachInstances", + entity_name='ocean ecs detach instances') + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def create_virtual_node_group(self, vng: ecs_ocean.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 + """ + ocean = ecs_ocean.VNGRequest(vng) + + excluded_missing_dict = self.exclude_missing( + json.loads(ocean.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_post( + body=body_json, + url=self.__base_launch_spec_url, + entity_name='ocean ecs vng') + + formatted_response = self.convert_json(response, + self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def get_all_virtual_node_groups(self, ocean_id: str): + """ + Get all VNGs for the specified Ocean cluster. + + # Returns + (Object): Ocean Virtual Node Group API response + """ + + response = self.send_get( + url=self.__base_launch_spec_url, + entity_name="ocean ecs vng", + query_params=dict(oceanId=ocean_id) + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"] + + def delete_virtual_node_group(self, 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 + """ + 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) + ) + + def update_virtual_node_group(self, vng_id: str, vng: ecs_ocean.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 + """ + ocean = ecs_ocean.VNGRequest(vng) + + excluded_missing_dict = self.exclude_missing( + json.loads(ocean.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_put( + body=body_json, + url=self.__base_launch_spec_url + "/" + vng_id, + entity_name='ocean ecs vng') + + formatted_response = self.convert_json( + response, + self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def get_virtual_node_group(self, 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 + """ + response = self.send_get( + url=self.__base_launch_spec_url + "/" + vng_id, + entity_name="ocean ecs vng" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def import_fargate_to_existing_ocean_cluster(self, ocean_id: str, + import_fargate_existing: ecs_ocean.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 + """ + ocean = ecs_ocean.ImportFargateToExistingOceanClusterRequest( + import_config=import_fargate_existing) + + excluded_missing_dict = self.exclude_missing( + json.loads(ocean.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_post( + body=body_json, + url=self.__base_ocean_url + ocean_id + "/fargateMigration", + entity_name='ocean ecs fargate') + + formatted_response = self.convert_json(response, + self.camel_to_underscore) + + return formatted_response["response"]["items"][0] + + def get_fargate_services_discovery(self, ocean_id: str): + """ + Get existing Fargate services in the ECS cluster. + + # Arguments + ocean_id (String): Ocean cluster identifier + + # Returns + (Object): Ocean ECS Fargate Response + """ + response = self.send_get( + url=self.__base_ocean_url + "/" + ocean_id + + "/fargateMigration/serviceDiscovery", + entity_name="ocean ecs fargate" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"] + + def get_fargate_migration_status(self, ocean_id: str): + """ + Get the status of a Fargate service import. + + # Arguments + ocean_id (String): Ocean cluster identifier + + # Returns + (Object): Ocean ECS Fargate Response + """ + response = self.send_get( + url=self.__base_ocean_url + "/" + ocean_id + "/fargateMigration/status", + entity_name="ocean ecs fargate" + ) + + formatted_response = self.convert_json( + response, self.camel_to_underscore) + + return formatted_response["response"]["items"] + + 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 + + # Returns + (Object): Ocean ECS Fargate Response + """ + ocean = ecs_ocean.ImportFargateToNewOceanClusterRequest( + import_config=import_fargate_new) + + excluded_missing_dict = self.exclude_missing( + json.loads(ocean.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_post( + body=body_json, + url=self.__base_ocean_url + "/fargate/import", + entity_name='ocean ecs fargate') + + formatted_response = self.convert_json(response, + self.camel_to_underscore) + + return formatted_response["response"]["items"] + + def launch_instances_in_vng(self, 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 + """ + launch_node_request = ecs_ocean.LaunchInstancesRequest(amount) + + excluded_missing_dict = self.exclude_missing( + json.loads(launch_node_request.toJSON())) + + formatted_missing_dict = self.convert_json( + excluded_missing_dict, self.underscore_to_camel) + + body_json = json.dumps(formatted_missing_dict) + + response = self.send_put( + body=body_json, + 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 diff --git a/spotinst_sdk2/models/ocean/azure/__init__.py b/spotinst_sdk2/models/ocean/azure/__init__.py index e004aca7..56ccc511 100644 --- a/spotinst_sdk2/models/ocean/azure/__init__.py +++ b/spotinst_sdk2/models/ocean/azure/__init__.py @@ -917,7 +917,6 @@ class DetachNodes: node_names_to_detach: List[str] ocean_id: str """ - def __init__(self, node_names_to_detach: List[str] = none, ocean_id: str = none): @@ -933,3 +932,25 @@ def __init__(self, detach_nodes_obj: DetachNodes): def toJSON(self): return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) + + +class RightSizingFilter: + """ + # Arguments + attribute: Attribute + namespaces: List[str] + """ + def __init__(self, + attribute: Attribute = none, + namespaces: List[str] = none): + self.attribute = attribute + self.namespaces = namespaces + + +class FetchRightSizingRequest: + def __init__(self, filter: RightSizingFilter): + self.filter = filter + + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) diff --git a/spotinst_sdk2/models/ocean/ecs/__init__.py b/spotinst_sdk2/models/ocean/ecs/__init__.py new file mode 100644 index 00000000..915bd637 --- /dev/null +++ b/spotinst_sdk2/models/ocean/ecs/__init__.py @@ -0,0 +1,937 @@ +import json +from enum import Enum +from typing import List + +none = "d3043820717d74d9a17694c176d39733" + + +class Down: + """ + # Arguments + evaluation_periods: int + max_scale_down_percentage: int + """ + + def __init__(self, + evaluation_periods: int = none, + max_scale_down_percentage: int = none): + self.evaluation_periods = evaluation_periods + self.max_scale_down_percentage = max_scale_down_percentage + + +class Headroom: + """ + # Arguments + cpu_per_unit: int + memory_per_unit: int + num_of_units: int + """ + + def __init__(self, + cpu_per_unit: int = none, + memory_per_unit: int = none, + num_of_units: int = none): + self.cpu_per_unit = cpu_per_unit + self.memory_per_unit = memory_per_unit + self.num_of_units = num_of_units + + +class ResourceLimits: + """ + # Arguments + max_memory_gib: int + max_v_cpu: int + """ + + def __init__(self, + max_memory_gib: int = none, + max_v_cpu: int = none): + self.max_memory_gib = max_memory_gib + self.max_v_cpu = max_v_cpu + + +class AutoScaler: + """ + # 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 + """ + + def __init__(self, + auto_headroom_percentage: int = none, + cooldown: int = none, + down: Down = none, + enable_automatic_and_manual_headroom: bool = none, + headroom: Headroom = none, + is_auto_config: bool = none, + is_enabled: bool = none, + resource_limits: ResourceLimits = none, + should_scale_down_non_service_tasks: bool = none): + self.auto_headroom_percentage = auto_headroom_percentage + self.cooldown = cooldown + self.down = down + self.enable_automatic_and_manual_headroom = enable_automatic_and_manual_headroom + self.headroom = headroom + self.is_auto_config = is_auto_config + self.is_enabled = is_enabled + self.resource_limits = resource_limits + self.should_scale_down_non_service_tasks = should_scale_down_non_service_tasks + + +class Capacity: + """ + # Arguments + maximum: int + minimum: int + target: int + """ + + def __init__(self, + maximum: int = none, + minimum: int = none, + target: int = none): + self.maximum = maximum + self.minimum = minimum + self.target = target + + +class Architecture(Enum): + i386 = "i386" + x86_64 = "x86_64" + arm64 = "arm64" + + +class Category(Enum): + accelerated_computing = "Accelerated_computing" + compute_optimized = "Compute_optimized" + general_purpose = "General_purpose" + memory_optimized = "Memory_optimized" + storage_optimized = "Storage_optimized" + + +class DiskType(Enum): + nvme = "NVMe" + ebs = "EBS" + ssd = "SSD" + hdd = "HDD" + + +class Hypervisor(Enum): + nitro = "nitro" + xen = "xen" + + +class RootDeviceType(Enum): + ebs = "ebs" + instance_store = "instance-store" + + +class VirtualizationType(Enum): + hvm = "hvm" + paravirtual = "paravirtual" + + +class InstanceTypesFilters: + """ + # 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 + """ + + def __init__(self, + 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, + is_ena_supported: bool = 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, + 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.hypervisor = hypervisor + self.root_device_types = root_device_types + self.min_network_performance = min_network_performance + self.max_network_performance = max_network_performance + + +class InstanceTypes: + """ + # Arguments + blacklist: List[str] + filters: InstanceTypesFilters + whitelist: List[str] + """ + + def __init__(self, + blacklist: List[str] = none, + filters: InstanceTypesFilters = none, + whitelist: List[str] = none): + self.blacklist = blacklist + self.filters = filters + self.whitelist = whitelist + + +class DynamicVolumeSize: + """ + # Arguments + base_size: int + resource: str + size_per_resource_unit: int + """ + + def __init__(self, + base_size: int = none, + resource: str = none, + size_per_resource_unit: int = none): + self.base_size = base_size + self.resource = resource + self.size_per_resource_unit = size_per_resource_unit + + +class EBS: + """ + # 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 + """ + + def __init__(self, + delete_on_termination: bool = none, + dynamic_volume_size: DynamicVolumeSize = none, + encrypted: bool = none, + iops: int = none, + kms_key_id: str = none, + snapshot_id: str = none, + throughput: int = none, + volume_size: int = none, + volume_type: str = none): + self.delete_on_termination = delete_on_termination + self.dynamic_volume_size = dynamic_volume_size + self.encrypted = encrypted + self.iops = iops + self.kms_key_id = kms_key_id + self.snapshot_id = snapshot_id + self.throughput = throughput + self.volume_size = volume_size + self.volume_type = volume_type + + +class BlockDeviceMapping: + """ + # Arguments + device_name: str + ebs: EBS + """ + + def __init__(self, + device_name: str = none, + ebs: EBS = none): + self.device_name = device_name + self.ebs = ebs + + +class IamInstanceProfile: + """ + # Arguments + arn: str + """ + + def __init__(self, + arn: str = none): + self.arn = arn + + +class HttpEndpoint(Enum): + disabled = "disabled" + enabled = "enabled" + + +class HttpTokens(Enum): + optional = "optional" + required = "required" + + +class InstanceMetadataOptions: + """ + # Arguments + http_endpoint: HttpEndpoint + http_put_response_hop_limit: int + http_tokens: HttpTokens + """ + + def __init__(self, + http_endpoint: HttpEndpoint = none, + http_put_response_hop_limit: int = none, + http_tokens: HttpTokens = none): + self.http_endpoint = http_endpoint + self.http_put_response_hop_limit = http_put_response_hop_limit + self.http_tokens = http_tokens + + +class Tag: + """ + # Arguments + tag_key: str + tag_value: str + """ + + def __init__(self, + tag_key: str = none, + tag_value: str = none): + self.tag_key = tag_key + self.tag_value = tag_value + + +class LaunchSpecification: + """ + # 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 + """ + + def __init__(self, + associate_ipv6_address: bool = none, + associate_public_ip_address: bool = 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[Tag] = none, + use_as_template_only: bool = 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 + self.ebs_optimized = ebs_optimized + self.iam_instance_profile = iam_instance_profile + self.image_id = image_id + self.instance_metadata_options = instance_metadata_options + self.monitoring = monitoring + self.security_group_ids = security_group_ids + self.tags = tags + self.use_as_template_only = use_as_template_only + self.user_data = user_data + self.key_pair = key_pair + + +class OptimizeImages: + """ + # Arguments + perform_at: str + should_optimize_ecs_ami: bool + time_windows: List[str] + """ + + def __init__(self, + perform_at: str = none, + should_optimize_ecs_ami: bool = none, + time_windows: List[str] = none): + self.perform_at = perform_at + self.should_optimize_ecs_ami = should_optimize_ecs_ami + self.time_windows = time_windows + + +class Compute: + """ + # Arguments + instance_types: InstanceTypes + launch_specification: LaunchSpecification + optimize_images: OptimizeImages + subnet_ids: List[str] + """ + + def __init__(self, + instance_types: InstanceTypes = none, + launch_specification: LaunchSpecification = none, + optimize_images: OptimizeImages = none, + subnet_ids: List[str] = none): + self.instance_types = instance_types + self.launch_specification = launch_specification + self.optimize_images = optimize_images + self.subnet_ids = subnet_ids + + +class S3Bucket: + """ + # Arguments + id: str + """ + + def __init__(self, + id: str = none): + self.id = id + + +class LoggingConfiguration: + """ + # Arguments + s3: S3Bucket + """ + + def __init__(self, + s3: S3Bucket = none): + self.s3 = s3 + + +class Logging: + """ + # Arguments + export: LoggingConfiguration + """ + + def __init__(self, + export: LoggingConfiguration = none): + self.export = export + + +class ShutdownHours: + """ + # Arguments + is_enabled: bool + time_windows: List[str] + """ + + def __init__(self, + is_enabled: bool = none, + time_windows: List[str] = none): + self.is_enabled = is_enabled + self.time_windows = time_windows + + +class ClusterRoll: + """ + # Arguments + batch_min_healthy_percentage: int + batch_size_percentage: int + comment: str + """ + + def __init__(self, + batch_min_healthy_percentage: int = none, + batch_size_percentage: int = none, + comment: str = none): + self.batch_min_healthy_percentage = batch_min_healthy_percentage + self.batch_size_percentage = batch_size_percentage + self.comment = comment + + +class Parameters: + """ + # Arguments + cluster_roll: ClusterRoll + """ + + def __init__(self, + cluster_roll: ClusterRoll = none): + self.cluster_roll = cluster_roll + + +class SchedulingTask: + """ + # Arguments + cron_expression: str + is_enabled: bool + parameters: Parameters + task_type: str + """ + + def __init__(self, + cron_expression: str = none, + is_enabled: bool = none, + parameters: Parameters = none, + task_type: str = none): + self.cron_expression = cron_expression + self.is_enabled = is_enabled + self.parameters = parameters + self.task_type = task_type + + +class Scheduling: + """ + # Arguments + shutdown_hours: ShutdownHours + tasks: List[SchedulingTask] + """ + + def __init__(self, + shutdown_hours: ShutdownHours = none, + tasks: List[SchedulingTask] = none): + self.shutdown_hours = shutdown_hours + self.tasks = tasks + + +class AvailabilityVsCost(Enum): + cost_oriented = "costOriented" + balanced = "balanced" + cheapest = "cheapest" + + +class ClusterOrientation: + """ + # Arguments + availability_vs_cost: AvailabilityVsCost + """ + + def __init__(self, + availability_vs_cost: AvailabilityVsCost = none): + self.availability_vs_cost = availability_vs_cost + + +class Strategy: + """ + # Arguments + cluster_orientation: ClusterOrientation + draining_timeout: int + fallback_to_od: bool + spot_percentage: int + utilize_commitments: bool + utilize_reserved_instances: bool + """ + + def __init__(self, + cluster_orientation: ClusterOrientation = none, + draining_timeout: int = none, + fallback_to_od: bool = none, + spot_percentage: int = none, + utilize_commitments: bool = none, + utilize_reserved_instances: bool = none): + self.cluster_orientation = cluster_orientation + self.draining_timeout = draining_timeout + self.fallback_to_od = fallback_to_od + self.spot_percentage = spot_percentage + self.utilize_commitments = utilize_commitments + self.utilize_reserved_instances = utilize_reserved_instances + + +class Ocean: + """ + # Arguments + auto_scaler: AutoScaler + capacity: Capacity + cluster_name: str + compute: Compute + logging: Logging + name: str + region: str + scheduling: Scheduling + strategy: Strategy + """ + + def __init__(self, + auto_scaler: AutoScaler = none, + capacity: Capacity = none, + cluster_name: str = none, + compute: Compute = none, + logging: Logging = none, + name: str = none, + region: str = none, + scheduling: Scheduling = none, + strategy: Strategy = none): + self.auto_scaler = auto_scaler + self.capacity = capacity + self.cluster_name = cluster_name + self.compute = compute + self.logging = logging + self.name = name + self.region = region + self.scheduling = scheduling + self.strategy = strategy + + +class OceanRequest: + def __init__(self, ocean: Ocean): + self.cluster = ocean + + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) + + +class ImportClusterConfig: + """ + # Arguments + instance_id: str + name: str + region: str + """ + + def __init__(self, + instance_id: str = none, + name: str = none, + region: str = none): + self.instance_id = instance_id + self.name = name + self.region = region + + +class ImportClusterRequest: + 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__, + sort_keys=True, indent=4) + + +class InstanceTypesFilterRequest: + def __init__(self, filters: InstanceTypesFilters): + self.filters = filters + + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) + + +class RollConfig: + """ + # Arguments + batch_min_healthy_percentage: int + batch_size_percentage: int + comment: str + instance_ids: List[str] + launch_spec_ids: List[str] + """ + + def __init__( + self, + batch_min_healthy_percentage: int = none, + batch_size_percentage: int = none, + comment: str = none, + launch_spec_ids: List[str] = none, + instance_ids: List[str] = none): + self.batch_min_healthy_percentage = batch_min_healthy_percentage + self.batch_size_percentage = batch_size_percentage + self.comment = comment + self.instance_ids = instance_ids + self.launch_spec_ids = launch_spec_ids + + +class ClusterRollInitiateRequest: + def __init__(self, roll_config: RollConfig = none): + self.roll = roll_config + + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) + + +class ClusterRollUpdateRequest: + def __init__(self, status: str = none): + self.roll = dict(status=status) + + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) + + +class DetachInstancesConfig: + """ + # Arguments + instances_to_detach: List[str] + should_decrement_target_capacity: bool + should_terminate_instances: bool + """ + + def __init__( + self, + instances_to_detach: List[str] = none, + should_decrement_target_capacity: bool = none, + should_terminate_instances: bool = none): + self.instances_to_detach = instances_to_detach + self.should_decrement_target_capacity = should_decrement_target_capacity + self.should_terminate_instances = should_terminate_instances + + +class DetachInstancesRequest: + 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 Attribute: + """ + # Arguments + key: str + value: str + """ + + def __init__(self, + key: str = none, + value: str = none): + self.key = key + self.value = value + + +class AutoScale: + """ + # Arguments + headrooms: List[Headrooms] + """ + + def __init__(self, + headrooms: List[Headroom] = none): + self.headrooms = headrooms + + +class Image: + """ + # Arguments + id: str + """ + + def __init__(self, + id: str = none): + self.id = id + + +class VngTask: + """ + # Arguments + config: List[Headroom] + cron_expression: str + is_enabled: bool + task_type: str + """ + + def __init__(self, + config: List[Headroom] = none, + cron_expression: str = none, + is_enabled: bool = none, + task_type: str = none): + self.config = config + self.cron_expression = cron_expression + self.is_enabled = is_enabled + self.task_type = task_type + + +class VngScheduling: + """ + # Arguments + tasks: List[VngTask] + """ + + def __init__(self, + tasks: List[VngTask]): + self.tasks = tasks + + +class VirtualNodeGroup: + """ + # 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 + """ + + def __init__(self, + attributes: List[Attribute] = none, + auto_scale: AutoScale = none, + block_device_mappings: List[BlockDeviceMapping] = none, + iam_instance_profile: IamInstanceProfile = none, + image_id: str = none, + images: List[Image] = none, + instance_metadata_options: InstanceMetadataOptions = none, + instance_types: List[str] = none, + name: str = none, + ocean_id: str = none, + preferred_spot_types: List[str] = none, + restrict_scale_down: bool = none, + scheduling: VngScheduling = none, + security_group_ids: List[str] = none, + strategy: Strategy = none, + subnet_ids: List[str] = none, + tags: List[Tag] = none, + user_data: str = none): + self.attributes = attributes + self.auto_scale = auto_scale + self.block_device_mappings = block_device_mappings + self.iam_instance_profile = iam_instance_profile + self.image_id = image_id + self.images = images + self.instance_metadata_options = instance_metadata_options + self.instance_types = instance_types + self.name = name + self.ocean_id = ocean_id + self.preferred_spot_types = preferred_spot_types + self.restrict_scale_down = restrict_scale_down + self.scheduling = scheduling + self.security_group_ids = security_group_ids + self.strategy = strategy + self.subnet_ids = subnet_ids + self.tags = tags + self.user_data = user_data + + +class VNGRequest: + def __init__(self, vng: VirtualNodeGroup): + self.launch_spec = vng + + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) + + +class ImportFargateToExistingOceanCluster: + """ + # Arguments + services: List[str] + simple_new_service_names: bool + """ + + def __init__(self, + services: List[str] = none, + simple_new_service_names: bool = none): + self.services = services + self.simple_new_service_names = simple_new_service_names + + +class ImportFargateToExistingOceanClusterRequest: + 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__, + sort_keys=True, indent=4) + + +class ImportFargateToNewOceanCluster: + """ + # Arguments + ecs_cluster_name: str + key_pair: str + ocean_cluster_name: str + region: str + services: List[str] + 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 + self.region = region + self.services = services + self.tags = tags + + +class ImportFargateToNewOceanClusterRequest: + 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__, + sort_keys=True, indent=4) + + +class LaunchInstancesRequest: + def __init__(self, amount: int = none): + self.launch_request = dict(amount=amount) + + def toJSON(self): + return json.dumps(self, default=lambda o: o.__dict__, + sort_keys=True, indent=4) 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'