Skip to content

Commit

Permalink
Added support for RestartReplicas, `ExcludePreliminaryRecommendatio…
Browse files Browse the repository at this point in the history
…ns` and `RecommendationApplicationHPA` (#319)
  • Loading branch information
sharadkesarwani authored Aug 27, 2024
1 parent be777e5 commit 11a0d18
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
10 changes: 7 additions & 3 deletions examples/service/ocean/right_sizing/create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ func main() {
// Create a new right sizing rule.
out, err := svc.RightSizing().CreateRightsizingRule(ctx, &right_sizing.CreateRightsizingRuleInput{
RightsizingRule: &right_sizing.RightsizingRule{
RuleName: spotinst.String("test-rule1"),
OceanId: spotinst.String("o-12ab34"),
RestartPods: spotinst.Bool(true),
RuleName: spotinst.String("test-rule1"),
OceanId: spotinst.String("o-12ab34"),
ExcludePreliminaryRecommendations: spotinst.Bool(true),
RestartReplicas: spotinst.String("MORE_THAN_ONE_REPLICA"),
RecommendationApplicationHPA: &right_sizing.RecommendationApplicationHPA{
AllowHPARecommendations: spotinst.Bool(true),
},
RecommendationApplicationIntervals: []*right_sizing.RecommendationApplicationIntervals{
{
RepetitionBasis: spotinst.String("MONTHLY"),
Expand Down
3 changes: 1 addition & 2 deletions examples/service/ocean/right_sizing/update/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ func main() {
out, err := svc.RightSizing().UpdateRightsizingRule(ctx, &right_sizing.UpdateRightsizingRuleInput{
RuleName: spotinst.String("test-rule1"),
RightsizingRule: &right_sizing.RightsizingRule{
OceanId: spotinst.String("o-12ab34"),
RestartPods: spotinst.Bool(true),
OceanId: spotinst.String("o-12ab34"),
RecommendationApplicationIntervals: []*right_sizing.RecommendationApplicationIntervals{
{
RepetitionBasis: spotinst.String("MONTHLY"),
Expand Down
45 changes: 41 additions & 4 deletions service/ocean/right_sizing/right_sizing.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
type RightsizingRule struct {
RuleName *string `json:"ruleName,omitempty"`
OceanId *string `json:"oceanId,omitempty"`
RestartPods *bool `json:"restartPods,omitempty"`
RestartReplicas *string `json:"restartReplicas,omitempty"`
ExcludePreliminaryRecommendations *bool `json:"excludePreliminaryRecommendations,omitempty"`
RecommendationApplicationIntervals []*RecommendationApplicationIntervals `json:"recommendationApplicationIntervals,omitempty"`
RecommendationApplicationMinThreshold *RecommendationApplicationMinThreshold `json:"recommendationApplicationMinThreshold,omitempty"`
RecommendationApplicationBoundaries *RecommendationApplicationBoundaries `json:"recommendationApplicationBoundaries,omitempty"`
RecommendationApplicationOverheadValues *RecommendationApplicationOverheadValues `json:"recommendationApplicationOverheadValues,omitempty"`
RecommendationApplicationHPA *RecommendationApplicationHPA `json:"recommendationApplicationHPA,omitempty"`

forceSendFields []string
nullFields []string
Expand Down Expand Up @@ -123,6 +125,13 @@ type RecommendationApplicationOverheadValues struct {
nullFields []string
}

type RecommendationApplicationHPA struct {
AllowHPARecommendations *bool `json:"allowHPARecommendations,omitempty"`

forceSendFields []string
nullFields []string
}

type ListRightsizingRulesInput struct {
OceanId *string `json:"oceanId,omitempty"`
}
Expand Down Expand Up @@ -414,9 +423,16 @@ func (o *RightsizingRule) SetOceanId(v *string) *RightsizingRule {
return o
}

func (o *RightsizingRule) SetRestartPods(v *bool) *RightsizingRule {
if o.RestartPods = v; o.RestartPods == nil {
o.nullFields = append(o.nullFields, "RestartPods")
func (o *RightsizingRule) SetRestartReplicas(v *string) *RightsizingRule {
if o.RestartReplicas = v; o.RestartReplicas == nil {
o.nullFields = append(o.nullFields, "RestartReplicas")
}
return o
}

func (o *RightsizingRule) SetExcludePreliminaryRecommendations(v *bool) *RightsizingRule {
if o.ExcludePreliminaryRecommendations = v; o.ExcludePreliminaryRecommendations == nil {
o.nullFields = append(o.nullFields, "ExcludePreliminaryRecommendations")
}
return o
}
Expand Down Expand Up @@ -449,6 +465,13 @@ func (o *RightsizingRule) SetRecommendationApplicationOverheadValues(v *Recommen
return o
}

func (o *RightsizingRule) SetRecommendationApplicationHPA(v *RecommendationApplicationHPA) *RightsizingRule {
if o.RecommendationApplicationHPA = v; o.RecommendationApplicationHPA == nil {
o.nullFields = append(o.nullFields, "RecommendationApplicationHPA")
}
return o
}

// region RecommendationApplicationInterval

func (o RecommendationApplicationIntervals) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -636,3 +659,17 @@ func (o *RecommendationApplicationOverheadValues) SetOverheadMemoryPercentage(v
}
return o
}

// region RecommendationApplicationHPA
func (o RecommendationApplicationHPA) MarshalJSON() ([]byte, error) {
type noMethod RecommendationApplicationHPA
raw := noMethod(o)
return jsonutil.MarshalJSON(raw, o.forceSendFields, o.nullFields)
}

func (o *RecommendationApplicationHPA) SetAllowHPARecommendations(v *bool) *RecommendationApplicationHPA {
if o.AllowHPARecommendations = v; o.AllowHPARecommendations == nil {
o.nullFields = append(o.nullFields, "AllowHPARecommendations")
}
return o
}

0 comments on commit 11a0d18

Please sign in to comment.