From 3c1be64807ec2614d3151a1ee350774690924fc1 Mon Sep 17 00:00:00 2001 From: Anurag Sharma Date: Fri, 6 Sep 2024 14:09:59 +0530 Subject: [PATCH] Documentation updated for Ocean Rightsizing --- CHANGELOG.md | 4 + .../clients/ocean/ocean_rightsizing_client.md | 195 +++++++++++ docs/models/ocean/rightsizing.md | 304 ++++++++++++++++++ pydocmd.yml | 8 +- spotinst_sdk2/__init__.py | 13 +- spotinst_sdk2/models/setup/azure/__init__.py | 15 +- spotinst_sdk2/models/setup/gcp/__init__.py | 13 +- spotinst_sdk2/version.py | 2 +- 8 files changed, 535 insertions(+), 19 deletions(-) create mode 100644 docs/clients/ocean/ocean_rightsizing_client.md create mode 100644 docs/models/ocean/rightsizing.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 76556bd2..3c8ff05e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [3.15.0] - 2024-08-26 +### Added +- Updated documentation for Ocean rightsizing APIs. + ## [3.14.0] - 2024-08-26 ### Added - Added support for Ocean ECS. diff --git a/docs/clients/ocean/ocean_rightsizing_client.md b/docs/clients/ocean/ocean_rightsizing_client.md new file mode 100644 index 00000000..d54fdab8 --- /dev/null +++ b/docs/clients/ocean/ocean_rightsizing_client.md @@ -0,0 +1,195 @@ +

OceanRightSizingClient

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

create_right_sizing_rule

+ +```python +OceanRightSizingClient.create_right_sizing_rule( + ocean_id: str, + rule_name: str, + restart_replicas: RestartReplicas, + exclude_preliminary_recommendations: bool, + application_intervals: + typing.List[spotinst_sdk2.models.ocean.rightsizing.RecommendationApplicationInterval], + application_min_threshold: RecommendationApplicationMinThreshold = None, + application_boundaries: RecommendationApplicationBoundaries = None, + application_overhead_values: + RecommendationApplicationOverheadValues = None, + application_hpa: RecommendationApplicationHPA = None) +``` + +Create a right sizing rule for an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __rule_name (String)__: Name of the Right Sizing Rule +- __restart_replicas (RestartReplicas)__: Restart Replicas +- __exclude_preliminary_recommendations (boolean)__: Exclude preliminary recommendations +- __application_intervals (List[RecommendationApplicationIntervals])__: Recommendation Application Intervals +- __application_min_threshold (RecommendationApplicationMinThreshold)__: Recommendation Application Min Threshold +- __application_boundaries (RecommendationApplicationBoundaries)__: Recommendation Application Boundaries +- __application_overhead_values (RecommendationApplicationOverheadValues)__: Recommendation Application Overhead Values +- __application_hpa (RecommendationApplicationHPA)__: Recommendation Application HPA + +__Returns__ + +`(Object)`: Ocean Right Sizing Rule API response + + +

delete_right_sizing_rule

+ +```python +OceanRightSizingClient.delete_right_sizing_rule( + ocean_id: str, rule_names: typing.List[str]) +``` + +Delete a right sizing rule for an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __rule_names (List[String])__: List of Right Sizing Rule Names + +__Returns__ + +`(Object)`: Ocean Right Sizing Rule API response + +

update_right_sizing_rule

+ +```python +OceanRightSizingClient.update_right_sizing_rule( + ocean_id: str, + rule_name: str, + restart_replicas: RestartReplicas, + exclude_preliminary_recommendations: bool, + application_intervals: + typing.List[spotinst_sdk2.models.ocean.rightsizing.RecommendationApplicationInterval], + application_min_threshold: RecommendationApplicationMinThreshold, + application_boundaries: RecommendationApplicationBoundaries, + application_overhead_values: RecommendationApplicationOverheadValues, + application_hpa: RecommendationApplicationHPA = None) +``` + +Update a right sizing rule for an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __rule_name (String)__: Rightsizing Rule name +- __restart_replicas (RestartReplicas)__: Restart Replicas +- __exclude_preliminary_recommendations (boolean)__: Exclude preliminary recommendations +- __application_intervals (RecommendationApplicationIntervals)__: Recommendation Application Intervals +- __application_min_threshold (RecommendationApplicationMinThreshold)__: Recommendation Application Min Threshold +- __application_boundaries (RecommendationApplicationBoundaries)__: Recommendation Application Boundaries +- __application_overhead_values (RecommendationApplicationOverheadValues)__: Recommendation Application Overhead Values +- __application_hpa (RecommendationApplicationHPA)__: Recommendation Application HPA + +__Returns__ + +`(Object)`: Ocean Right Sizing Rule API response + +

attach_right_sizing_rule

+ +```python +OceanRightSizingClient.attach_right_sizing_rule( + ocean_id: str, rule_name: str, namespaces: + typing.List[spotinst_sdk2.models.ocean.rightsizing.Namespace]) +``` + +Attach right sizing rule to an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __rule_name (String)__: Ocean right sizing rule +- __namespaces (List[Namespace])__: List of namespaces to attach the right sizing rule to + +__Returns__ + +`(Object)`: Ocean Right Sizing Rule API response + +

detach_right_sizing_rule

+ +```python +OceanRightSizingClient.detach_right_sizing_rule( + ocean_id: str, rule_name: str, namespaces: + typing.List[spotinst_sdk2.models.ocean.rightsizing.Namespace]) +``` + +Detach right sizing rule from an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __rule_name (String)__: Ocean right sizing rule +- __namespaces (List[Namespace])__: List of namespaces to detach the right sizing rule from + +__Returns__ + +`(Object)`: Ocean Right Sizing Rule API response + +

get_right_sizing_rule

+ +```python +OceanRightSizingClient.get_right_sizing_rule(ocean_id: str, + rule_name: str) +``` + +Get right sizing rule for an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __rule_name (String)__: Name of the Right Sizing Rule + +__Returns__ + +`(Object)`: Ocean Right Sizing Rule API response + +

list_right_sizing_rules

+ +```python +OceanRightSizingClient.list_right_sizing_rules(ocean_id: str) +``` + +Get right sizing rule for an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster + + +__Returns__ + +`(Object)`: Ocean Right Sizing Rules API response + +

get_ocean_right_sizing_recommendations

+ +```python +OceanRightSizingClient.get_ocean_right_sizing_recommendations( + ocean_id: str, + cluster_resources: ClusterResources = None, + cluster_labels: ClusterLabels = None) +``` + +Attach right sizing rule to an Ocean cluster. + +__Arguments__ + +- __ocean_id (String)__: ID of the Ocean Cluster +- __cluster_resources (ClusterResources)__: Cluster Resources +- __cluster_labels (ClusterLabels)__: Cluster Labels + +__Returns__ + +`(Object)`: Ocean Right Sizing Rule API response + diff --git a/docs/models/ocean/rightsizing.md b/docs/models/ocean/rightsizing.md new file mode 100644 index 00000000..af676cab --- /dev/null +++ b/docs/models/ocean/rightsizing.md @@ -0,0 +1,304 @@ +

spotinst_sdk2.models.ocean.rightsizing

+ + +

IntervalHours

+ +```python +IntervalHours(self, + start_time: str = 'd3043820717d74d9a17694c176d39733', + end_time: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __start_time__: str +- __end_time__: str + +

IntervalDays

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

Friday

+ + +

Monday

+ + +

Saturday

+ + +

Sunday

+ + +

Thursday

+ + +

Tuesday

+ + +

Wednesday

+ + +

WeeklyRepetitionBasis

+ +```python +WeeklyRepetitionBasis( + self, + interval_days: + typing.List[spotinst_sdk2.models.ocean.rightsizing.IntervalDays] = 'd3043820717d74d9a17694c176d39733', + interval_hours: IntervalHours = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __interval_days__: List[IntervalDays] +- __interval_hours__: IntervalHours + +

WeekOfTheMonth

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

First

+ + +

Fourth

+ + +

Last

+ + +

Second

+ + +

Third

+ + +

MonthlyRepetitionBasis

+ +```python +MonthlyRepetitionBasis( + self, + interval_months: typing.List[int] = 'd3043820717d74d9a17694c176d39733', + week_of_the_month: + typing.List[spotinst_sdk2.models.ocean.rightsizing.WeekOfTheMonth] = 'd3043820717d74d9a17694c176d39733', + weekly_repetition_basis: + WeeklyRepetitionBasis = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __interval_months__: List[int] +- __week_of_the_month__: List[WeekOfTheMonth] +- __weekly_repetition_basis__: WeeklyRepetitionBasis + +

RepetitionBasis

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

Monthly

+ + +

Weekly

+ + +

RecommendationApplicationInterval

+ +```python +RecommendationApplicationInterval( + self, + repetition_basis: RepetitionBasis = 'd3043820717d74d9a17694c176d39733', + monthly_repetition_basis: + MonthlyRepetitionBasis = 'd3043820717d74d9a17694c176d39733', + weekly_repetition_basis: + WeeklyRepetitionBasis = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __repetition_basis__: RepetitionBasis +- __monthly_repetition_basis__: MonthlyRepetitionBasis +- __weekly_repetition_basis__: WeeklyRepetitionBasis + +

RecommendationApplicationMinThreshold

+ +```python +RecommendationApplicationMinThreshold( + self, + cpu_percentage: float = 'd3043820717d74d9a17694c176d39733', + memory_percentage: float = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __cpu_percentage__: float +- __memory_percentage__: float + +

CPU

+ +```python +CPU(self, + min: int = 'd3043820717d74d9a17694c176d39733', + max: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __min__: int +- __max__: int + +

Memory

+ +```python +Memory(self, + min: int = 'd3043820717d74d9a17694c176d39733', + max: int = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __min__: int +- __max__: int + +

RecommendationApplicationBoundaries

+ +```python +RecommendationApplicationBoundaries( + self, + cpu: CPU = 'd3043820717d74d9a17694c176d39733', + memory: Memory = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __cpu__: CPU +- __memory__: Memory + +

RecommendationApplicationOverheadValues

+ +```python +RecommendationApplicationOverheadValues( + self, + cpu_percentage: float = 'd3043820717d74d9a17694c176d39733', + memory_percentage: float = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __cpu_percentage__: float +- __memory_percentage__: float + +

RecommendationApplicationHPA

+ +```python +RecommendationApplicationHPA( + self, + allow_h_p_a_recommendations: bool = 'd3043820717d74d9a17694c176d39733' +) +``` + +__Arguments__ + +- __allow_h_p_a_recommendations__: bool + +

Label

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

Workload

+ +```python +Workload(self, + name: str = 'd3043820717d74d9a17694c176d39733', + workload_type: str = 'd3043820717d74d9a17694c176d39733', + regex_name: str = 'd3043820717d74d9a17694c176d39733') +``` + +__Arguments__ + +- __name__: str +- __workload_type__: str +- __regex_name__: str + +

Namespace

+ +```python +Namespace( + self, + namespace_name: str = 'd3043820717d74d9a17694c176d39733', + labels: + typing.List[spotinst_sdk2.models.ocean.rightsizing.Label] = 'd3043820717d74d9a17694c176d39733', + workloads: + typing.List[spotinst_sdk2.models.ocean.rightsizing.Workload] = 'd3043820717d74d9a17694c176d39733' +) +``` + +__Arguments__ + +- __namespace_name__: str +- __labels__: List[Label] +- __workloads__: List[Workload] + +

ClusterResources

+ +```python +ClusterResources(self, data: dict) +``` + +__Arguments__ + +- __data__: dict + +

ClusterLabels

+ +```python +ClusterLabels(self, data: dict) +``` + +__Arguments__ + +- __data__: dict + +

RestartReplicas

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

All_manifest

+ + +

More_than_one_replica

+ + +

No_restart

+ + diff --git a/pydocmd.yml b/pydocmd.yml index 0a724792..2fa4a709 100755 --- a/pydocmd.yml +++ b/pydocmd.yml @@ -27,8 +27,8 @@ generate: - 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/ocean_rightsizing_client.md: + - spotinst_sdk2.clients.ocean.OceanRightSizingClient++ - clients/ocean_cd/ocean_cd_client.md: - spotinst_sdk2.clients.ocean_cd.OceanCDClient++ - clients/subscription/subscription_client.md: @@ -63,8 +63,8 @@ generate: - 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/rightsizing.md: + - spotinst_sdk2.models.ocean.rightsizing++ - models/ocean_cd.md: - spotinst_sdk2.models.ocean_cd++ - spotinst_sdk2.models.ocean_cd.rollout_spec++ diff --git a/spotinst_sdk2/__init__.py b/spotinst_sdk2/__init__.py index d5334e54..32c8afc6 100644 --- a/spotinst_sdk2/__init__.py +++ b/spotinst_sdk2/__init__.py @@ -13,6 +13,7 @@ from spotinst_sdk2.clients.ocean_cd import * from spotinst_sdk2.clients.hpc import * + class SpotinstSession: def __init__(self, base_url=None, @@ -54,25 +55,25 @@ def client(self, service, print_output=True, log_level=None, user_agent=None, ti "ocean_aws": OceanAwsClient(session=self.session, print_output=print_output, log_level=log_level, user_agent=user_agent, timeout=timeout), "ocean_azure": OceanAzureClient(session=self.session, print_output=print_output, log_level=log_level, - 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_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), + user_agent=user_agent, timeout=timeout), "oceancd": OceanCDClient(session=self.session, print_output=print_output, log_level=log_level, - user_agent=user_agent, timeout=timeout), + user_agent=user_agent, timeout=timeout), "managed_instance_aws": ManagedInstanceAwsClient(session=self.session, print_output=print_output, log_level=log_level, user_agent=user_agent, timeout=timeout), "subscription": SubscriptionClient(session=self.session, print_output=print_output, log_level=log_level, user_agent=user_agent, timeout=timeout), "hpc": HPCAwsClient(session=self.session, print_output=print_output, - log_level=log_level, user_agent=user_agent, timeout=timeout) + log_level=log_level, user_agent=user_agent, timeout=timeout) } client = switcher.get(service) if client is None: raise ValueError(f"Invalid service selected: {service}") - return client \ No newline at end of file + return client diff --git a/spotinst_sdk2/models/setup/azure/__init__.py b/spotinst_sdk2/models/setup/azure/__init__.py index 9d1373bb..dbda7e23 100644 --- a/spotinst_sdk2/models/setup/azure/__init__.py +++ b/spotinst_sdk2/models/setup/azure/__init__.py @@ -3,6 +3,8 @@ none = "d3043820717d74d9a17694c176d39733" # region AzureCredentials + + class AzureCredentials: """ # Arguments @@ -11,11 +13,12 @@ class AzureCredentials: tenant_id: str subscription_id: str """ + def __init__( - self, - client_id, - client_secret, - tenant_id, + self, + client_id, + client_secret, + tenant_id, subscription_id): self.client_id = client_id @@ -23,11 +26,13 @@ def __init__( self.tenant_id = tenant_id self.subscription_id = subscription_id + class AzureSetCredentialsRequest: """ # Arguments azure_credentials: AzureCredentials """ + def __init__(self, azure_credentials): self.client_id = azure_credentials.client_id self.client_secret = azure_credentials.client_secret @@ -40,4 +45,4 @@ def to_json(self): default=lambda o: o.__dict__, sort_keys=True, indent=4) -# endregion \ No newline at end of file +# endregion diff --git a/spotinst_sdk2/models/setup/gcp/__init__.py b/spotinst_sdk2/models/setup/gcp/__init__.py index 8d0069db..ba175646 100644 --- a/spotinst_sdk2/models/setup/gcp/__init__.py +++ b/spotinst_sdk2/models/setup/gcp/__init__.py @@ -3,17 +3,21 @@ none = "d3043820717d74d9a17694c176d39733" # region GcpCredentials + + class GcpCredentials: """ # Arguments serviceAccount: ServiceAccount """ + def __init__( - self, + self, serviceAccount): self.serviceAccount = serviceAccount + class ServiceAccount: """ # Arguments @@ -28,8 +32,9 @@ class ServiceAccount: auth_provider_x509_cert_url: str client_x509_cert_url: str """ + def __init__( - self, + self, type, project_id, private_key_id, @@ -52,11 +57,13 @@ def __init__( self.auth_provider_x509_cert_url = auth_provider_x509_cert_url self.client_x509_cert_url = client_x509_cert_url + class GcpSetCredentialsRequest: """ # Arguments gcp_credentials: GcpCredentials """ + def __init__(self, gcp_credentials): self.serviceAccount = gcp_credentials.serviceAccount @@ -66,4 +73,4 @@ def to_json(self): default=lambda o: o.__dict__, sort_keys=True, indent=4) -# endregion \ No newline at end of file +# endregion diff --git a/spotinst_sdk2/version.py b/spotinst_sdk2/version.py index 6e9b3ce4..254db7b7 100644 --- a/spotinst_sdk2/version.py +++ b/spotinst_sdk2/version.py @@ -1 +1 @@ -__version__ = '3.14.0' +__version__ = '3.15.0'