From 61066b8e24f022082951c09a4837dec670c4f3a5 Mon Sep 17 00:00:00 2001 From: adityas1netapp <104548677+adityas1netapp@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:31:36 +0530 Subject: [PATCH] Added changes for preliminary recommendations and restart replicas (#179) * Added changes for preliminary recommendations and restart replicas * Documentation Update * Fix update_right_sizing_rule API implementation * Bump Version --------- Co-authored-by: Anurag Sharma --- CHANGELOG.md | 4 ++++ docs/clients/ocean/ocean_gcp_client.md | 2 +- spotinst_sdk2/clients/ocean/__init__.py | 16 ++++++++++++---- .../models/ocean/rightsizing/__init__.py | 14 ++++++++++++++ spotinst_sdk2/version.py | 2 +- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df4270c5..b9cd42a1 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.11.0] - 2024-08-21 +### Fixed +- Updated new fields for ocean Automatic Rightsizing APIs (beta release. For internal use only). + ## [3.10.0] - 2024-07-04 ### Added - Added `initialNodes` query parameter for Ocean GKE `create_virtual_node_group` API. diff --git a/docs/clients/ocean/ocean_gcp_client.md b/docs/clients/ocean/ocean_gcp_client.md index 65d11265..447473b7 100644 --- a/docs/clients/ocean/ocean_gcp_client.md +++ b/docs/clients/ocean/ocean_gcp_client.md @@ -131,7 +131,7 @@ OceanGcpClient.get_elastilog(ocean_id: str, limit: int = None) ``` -Get group’s Elastilog by +Get group's Elastilog by __Arguments__ diff --git a/spotinst_sdk2/clients/ocean/__init__.py b/spotinst_sdk2/clients/ocean/__init__.py index 530ef49d..66765b4a 100644 --- a/spotinst_sdk2/clients/ocean/__init__.py +++ b/spotinst_sdk2/clients/ocean/__init__.py @@ -1988,7 +1988,7 @@ def reimport_ocean_cluster(self, ocean_id: str): def get_elastilog(self, ocean_id: str, from_date: str, to_date: str, severity: str = None, resource_id: str = None, limit: int = None): """ - Get group’s Elastilog by + Get group's Elastilog by # Arguments to_date (String): end date value @@ -2491,6 +2491,8 @@ def launch_nodes_in_vng(self, ocean_launch_spec_id: str, amount: int): class OceanRightSizingClient(Client): def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods: bool, + restart_replicas: right_sizing_ocean.RestartReplicas, + exclude_preliminary_recommendations: bool, application_intervals: List[right_sizing_ocean.RecommendationApplicationInterval], application_min_threshold: right_sizing_ocean.RecommendationApplicationMinThreshold = None, application_boundaries: right_sizing_ocean.RecommendationApplicationBoundaries = None, @@ -2502,6 +2504,8 @@ def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods: ocean_id (String): ID of the Ocean Cluster rule_name (String): Name of the Right Sizing Rule restart_pods (boolean): Enable to sequentially restart pod batches according to recommendations + 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 @@ -2511,7 +2515,7 @@ def create_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods: (Object): Ocean Right Sizing Rule API response """ - right_sizing_rule_request = right_sizing_ocean.CreateRightSizingRuleRequest(rule_name=rule_name, restart_pods=restart_pods, recommendation_application_intervals=application_intervals, + right_sizing_rule_request = right_sizing_ocean.CreateRightSizingRuleRequest(rule_name=rule_name, restart_pods=restart_pods, restart_replicas=restart_replicas, exclude_preliminary_recommendations=exclude_preliminary_recommendations, recommendation_application_intervals=application_intervals, recommendation_application_min_threshold=application_min_threshold, recommendation_application_boundaries=application_boundaries, recommendation_application_overhead_values=application_overhead_values) excluded_missing_dict = self.exclude_missing( @@ -2563,6 +2567,8 @@ def delete_right_sizing_rule(self, ocean_id: str, rule_names: List[str]): def update_right_sizing_rule(self, ocean_id: str, rule_name: str, restart_pods: bool, + restart_replicas: right_sizing_ocean.RestartReplicas, + exclude_preliminary_recommendations: bool, application_intervals: right_sizing_ocean.RecommendationApplicationInterval, application_min_threshold: right_sizing_ocean.RecommendationApplicationMinThreshold, application_boundaries: right_sizing_ocean.RecommendationApplicationBoundaries, @@ -2584,6 +2590,8 @@ def update_right_sizing_rule(self, ocean_id: str, """ right_sizing_rule_request = right_sizing_ocean.UpdateRightSizingRuleRequest( restart_pods, + restart_replicas, + exclude_preliminary_recommendations, application_intervals, application_min_threshold, application_boundaries, @@ -2721,8 +2729,8 @@ def get_ocean_right_sizing_recommendations(self, ocean_id: str, cluster_resource # 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 + cluster_resources (ClusterResources): Cluster Resources + cluster_labels (ClusterLabels): Cluster Labels # Returns (Object): Ocean Right Sizing Rule API response diff --git a/spotinst_sdk2/models/ocean/rightsizing/__init__.py b/spotinst_sdk2/models/ocean/rightsizing/__init__.py index ef0a41a5..430a00fa 100644 --- a/spotinst_sdk2/models/ocean/rightsizing/__init__.py +++ b/spotinst_sdk2/models/ocean/rightsizing/__init__.py @@ -289,16 +289,26 @@ def __init__( # endregion +class RestartReplicas(Enum): + More_than_one_replica = "MORE_THAN_ONE_REPLICA" + All_manifest = "ALL_MANIFEST" + No_restart = "NO_RESTART" + + class CreateRightSizingRuleRequest: def __init__(self, rule_name: str, restart_pods: bool, + restart_replicas: RestartReplicas, + exclude_preliminary_recommendations: bool, recommendation_application_intervals: List[RecommendationApplicationInterval], recommendation_application_min_threshold: RecommendationApplicationMinThreshold, recommendation_application_boundaries: RecommendationApplicationBoundaries, recommendation_application_overhead_values: RecommendationApplicationOverheadValues): self.rule_name = rule_name self.restart_pods = restart_pods + self.restart_replicas = restart_replicas + self.exclude_preliminary_recommendations = exclude_preliminary_recommendations self.recommendation_application_intervals = recommendation_application_intervals self.recommendation_application_min_threshold = recommendation_application_min_threshold self.recommendation_application_boundaries = recommendation_application_boundaries @@ -321,11 +331,15 @@ def toJSON(self): class UpdateRightSizingRuleRequest: def __init__(self, restart_pods: bool, + restart_replicas: RestartReplicas, + exclude_preliminary_recommendations: bool, recommendation_application_intervals: List[RecommendationApplicationInterval], recommendation_application_threshold: RecommendationApplicationMinThreshold, recommendation_application_boundaries: RecommendationApplicationBoundaries, recommendation_application_overhead_values: RecommendationApplicationOverheadValues): self.restart_pods = restart_pods + self.restart_replicas = restart_replicas + self.exclude_preliminary_recommendations = exclude_preliminary_recommendations self.recommendation_application_intervals = recommendation_application_intervals self.recommendation_application_threshold = recommendation_application_threshold self.recommendation_application_boundaries = recommendation_application_boundaries diff --git a/spotinst_sdk2/version.py b/spotinst_sdk2/version.py index 3f3750c9..b8b2efb8 100644 --- a/spotinst_sdk2/version.py +++ b/spotinst_sdk2/version.py @@ -1 +1 @@ -__version__ = '3.10.0' +__version__ = '3.11.0'