From 01528813e159439e596fcd5f95362e793a3b57de Mon Sep 17 00:00:00 2001 From: Jolanta Date: Wed, 8 Jan 2025 17:26:54 +0200 Subject: [PATCH] WOOP-302: Add support for policy single resource management (#435) * WOOP-302: syncing API changes * WOOP-302: adding support for single resource management option. * WOOP-302: generate docs * WOOP-302: adding minimum required autoscaler version --- castai/resource_workload_scaling_policy.go | 15 + .../resource_workload_scaling_policy_test.go | 4 + castai/sdk/api.gen.go | 136 +++++- castai/sdk/client.gen.go | 433 ++++++++++++++++++ castai/sdk/mock/client.go | 140 ++++++ docs/resources/workload_scaling_policy.md | 3 + .../resource.tf | 1 + 7 files changed, 718 insertions(+), 14 deletions(-) diff --git a/castai/resource_workload_scaling_policy.go b/castai/resource_workload_scaling_policy.go index 28cac43a..cdea413c 100644 --- a/castai/resource_workload_scaling_policy.go +++ b/castai/resource_workload_scaling_policy.go @@ -218,6 +218,14 @@ func workloadScalingPolicyResourceSchema(function string, overhead, minRecommend Description: "Resource limit settings", Elem: workloadScalingPolicyResourceLimitSchema(), }, + "management_option": { + Type: schema.TypeString, + Optional: true, + Description: "Disables management for a single resource when set to `READ_ONLY`. " + + "The resource will use its original workload template requests and limits. " + + "Supported value: `READ_ONLY`. Minimum required workload-autoscaler version: `v0.23.1`.", + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"READ_ONLY"}, false)), + }, }, } } @@ -513,6 +521,9 @@ func toWorkloadScalingPolicies(obj map[string]interface{}) sdk.Workloadoptimizat if v, ok := obj[FieldLimitStrategy].([]any); ok && len(v) > 0 { out.Limit = toWorkloadResourceLimit(v[0].(map[string]any)) } + if v, ok := obj["management_option"].(string); ok && v != "" { + out.ManagementOption = lo.ToPtr(sdk.WorkloadoptimizationV1ManagementOption(v)) + } return out } @@ -556,6 +567,10 @@ func toWorkloadScalingPoliciesMap(p sdk.WorkloadoptimizationV1ResourcePolicies) m[FieldLimitStrategy] = []map[string]any{limit} } + if p.ManagementOption != nil { + m["management_option"] = string(*p.ManagementOption) + } + return []map[string]interface{}{m} } diff --git a/castai/resource_workload_scaling_policy_test.go b/castai/resource_workload_scaling_policy_test.go index 348cadfa..229a6928 100644 --- a/castai/resource_workload_scaling_policy_test.go +++ b/castai/resource_workload_scaling_policy_test.go @@ -50,6 +50,7 @@ func TestAccResourceWorkloadScalingPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "memory.0.min", "100"), resource.TestCheckResourceAttr(resourceName, "memory.0.limit.0.type", "MULTIPLIER"), resource.TestCheckResourceAttr(resourceName, "memory.0.limit.0.multiplier", "1.8"), + resource.TestCheckResourceAttr(resourceName, "memory.0.management_option", "READ_ONLY"), ), }, { @@ -81,6 +82,7 @@ func TestAccResourceWorkloadScalingPolicy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "memory.0.min", "100"), resource.TestCheckResourceAttr(resourceName, "memory.0.max", "512"), resource.TestCheckResourceAttr(resourceName, "memory.0.limit.0.type", "NO_LIMIT"), + resource.TestCheckResourceAttr(resourceName, "memory.0.management_option", "READ_ONLY"), resource.TestCheckResourceAttr(resourceName, "startup.0.period_seconds", "123"), resource.TestCheckResourceAttr(resourceName, "downscaling.0.apply_type", "DEFERRED"), resource.TestCheckResourceAttr(resourceName, "memory_event.0.apply_type", "DEFERRED"), @@ -130,6 +132,7 @@ func scalingPolicyConfig(clusterName, projectID, name string) string { type = "MULTIPLIER" multiplier = 1.8 } + management_option = "READ_ONLY" } }`, name) @@ -165,6 +168,7 @@ func scalingPolicyConfigUpdated(clusterName, projectID, name string) string { limit { type = "NO_LIMIT" } + management_option = "READ_ONLY" } startup { period_seconds = 123 diff --git a/castai/sdk/api.gen.go b/castai/sdk/api.gen.go index b80b1115..c14dbd0c 100644 --- a/castai/sdk/api.gen.go +++ b/castai/sdk/api.gen.go @@ -630,6 +630,59 @@ type CastaiFeaturesV1QueryExpression struct { LogicalOperator CastaiFeaturesV1LogicalOperator `json:"logicalOperator"` } +// CastaiInventoryV1beta1AWSAvailabilityZoneMapping defines model for castai.inventory.v1beta1.AWSAvailabilityZoneMapping. +type CastaiInventoryV1beta1AWSAvailabilityZoneMapping struct { + ZoneId *string `json:"ZoneId,omitempty"` + ZoneName *string `json:"ZoneName,omitempty"` +} + +// CastaiInventoryV1beta1AWSRecurringCharges defines model for castai.inventory.v1beta1.AWSRecurringCharges. +type CastaiInventoryV1beta1AWSRecurringCharges struct { + Amount *float64 `json:"Amount"` + Frequency *string `json:"Frequency"` +} + +// CastaiInventoryV1beta1AWSRegionReservedInstances defines model for castai.inventory.v1beta1.AWSRegionReservedInstances. +type CastaiInventoryV1beta1AWSRegionReservedInstances struct { + AvailabilityZoneMappings *[]CastaiInventoryV1beta1AWSAvailabilityZoneMapping `json:"availabilityZoneMappings,omitempty"` + Region *string `json:"region,omitempty"` + ReservedInstances *[]CastaiInventoryV1beta1AWSReservedInstances `json:"reservedInstances,omitempty"` +} + +// CastaiInventoryV1beta1AWSReservedInstances defines model for castai.inventory.v1beta1.AWSReservedInstances. +type CastaiInventoryV1beta1AWSReservedInstances struct { + AvailabilityZone *string `json:"AvailabilityZone"` + CurrencyCode *string `json:"CurrencyCode,omitempty"` + Duration *string `json:"Duration,omitempty"` + End *string `json:"End,omitempty"` + FixedPrice *float64 `json:"FixedPrice,omitempty"` + InstanceCount *string `json:"InstanceCount,omitempty"` + InstanceTenancy *string `json:"InstanceTenancy,omitempty"` + InstanceType *string `json:"InstanceType,omitempty"` + OfferingType *string `json:"OfferingType,omitempty"` + ProductDescription *string `json:"ProductDescription,omitempty"` + RecurringCharges *[]CastaiInventoryV1beta1AWSRecurringCharges `json:"RecurringCharges,omitempty"` + ReservedInstancesId *string `json:"ReservedInstancesId,omitempty"` + Scope *string `json:"Scope,omitempty"` + Start *string `json:"Start,omitempty"` + State *string `json:"State,omitempty"` + UsagePrice *float64 `json:"UsagePrice,omitempty"` +} + +// CastaiInventoryV1beta1AWSReservedInstancesContext defines model for castai.inventory.v1beta1.AWSReservedInstancesContext. +type CastaiInventoryV1beta1AWSReservedInstancesContext struct { + AvailabilityZoneId *string `json:"availabilityZoneId"` + AvailabilityZoneName *string `json:"availabilityZoneName"` + Id *string `json:"id,omitempty"` + InstanceCount *string `json:"instanceCount,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + InstanceTypeCpu *string `json:"instanceTypeCpu,omitempty"` + InstanceTypeMemoryMib *string `json:"instanceTypeMemoryMib,omitempty"` + InstanceTypesUsage *CastaiInventoryV1beta1InstanceTypeBasedUsage `json:"instanceTypesUsage,omitempty"` + Scope *string `json:"scope,omitempty"` + State *string `json:"state,omitempty"` +} + // CastaiInventoryV1beta1AddReservationResponse defines model for castai.inventory.v1beta1.AddReservationResponse. type CastaiInventoryV1beta1AddReservationResponse struct { Reservation *CastaiInventoryV1beta1ReservationDetails `json:"reservation,omitempty"` @@ -749,14 +802,15 @@ type CastaiInventoryV1beta1Commitment struct { AllowedUsage *float32 `json:"allowedUsage,omitempty"` // Assign commitment to all existing and future clusters that fall within the region of this commitment. - AutoAssignment *bool `json:"autoAssignment,omitempty"` - AzureReservationContext *CastaiInventoryV1beta1AzureReservation `json:"azureReservationContext,omitempty"` - EndDate *time.Time `json:"endDate"` - GcpResourceCudContext *CastaiInventoryV1beta1GCPResourceCUD `json:"gcpResourceCudContext,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Prioritization *bool `json:"prioritization,omitempty"` - Region *string `json:"region,omitempty"` + AutoAssignment *bool `json:"autoAssignment,omitempty"` + AwsReservedInstancesContext *CastaiInventoryV1beta1AWSReservedInstancesContext `json:"awsReservedInstancesContext,omitempty"` + AzureReservationContext *CastaiInventoryV1beta1AzureReservation `json:"azureReservationContext,omitempty"` + EndDate *time.Time `json:"endDate"` + GcpResourceCudContext *CastaiInventoryV1beta1GCPResourceCUD `json:"gcpResourceCudContext,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Prioritization *bool `json:"prioritization,omitempty"` + Region *string `json:"region,omitempty"` // Scaling strategy specifies how to use commitment by autoscaler. // @@ -933,6 +987,11 @@ type CastaiInventoryV1beta1GenericReservationsList struct { Items *[]CastaiInventoryV1beta1GenericReservation `json:"items,omitempty"` } +// CastaiInventoryV1beta1GetAWSReservedInstancesImportCMDResponse defines model for castai.inventory.v1beta1.GetAWSReservedInstancesImportCMDResponse. +type CastaiInventoryV1beta1GetAWSReservedInstancesImportCMDResponse struct { + Cmd *string `json:"cmd,omitempty"` +} + // CastaiInventoryV1beta1GetCommitmentAssignmentsResponse defines model for castai.inventory.v1beta1.GetCommitmentAssignmentsResponse. type CastaiInventoryV1beta1GetCommitmentAssignmentsResponse struct { Assignments *[]CastaiInventoryV1beta1CommitmentAssignment `json:"assignments,omitempty"` @@ -2955,9 +3014,9 @@ type NodeconfigV1EKSConfig struct { // List of supported image families (OSes) for EKS. // - // - FAMILY_AL2: Amazon Linux 2 (https://aws.amazon.com/amazon-linux-2/), EKS-specific. - // - FAMILY_AL2023: Amazon Linux 2023 (https://aws.amazon.com/linux/amazon-linux-2023/), EKS-specific. - // - FAMILY_BOTTLEROCKET: Bottlerocket (https://aws.amazon.com/bottlerocket/), EKS-specific. + // - FAMILY_AL2: Amazon Linux 2 (https://aws.amazon.com/amazon-linux-2/). + // - FAMILY_AL2023: Amazon Linux 2023 (https://aws.amazon.com/linux/amazon-linux-2023/). + // - FAMILY_BOTTLEROCKET: Bottlerocket (https://aws.amazon.com/bottlerocket/). ImageFamily *NodeconfigV1EKSConfigImageFamily `json:"imageFamily,omitempty"` ImdsHopLimit *int32 `json:"imdsHopLimit"` ImdsV1 *bool `json:"imdsV1"` @@ -2995,9 +3054,9 @@ type NodeconfigV1EKSConfig struct { // List of supported image families (OSes) for EKS. // -// - FAMILY_AL2: Amazon Linux 2 (https://aws.amazon.com/amazon-linux-2/), EKS-specific. -// - FAMILY_AL2023: Amazon Linux 2023 (https://aws.amazon.com/linux/amazon-linux-2023/), EKS-specific. -// - FAMILY_BOTTLEROCKET: Bottlerocket (https://aws.amazon.com/bottlerocket/), EKS-specific. +// - FAMILY_AL2: Amazon Linux 2 (https://aws.amazon.com/amazon-linux-2/). +// - FAMILY_AL2023: Amazon Linux 2023 (https://aws.amazon.com/linux/amazon-linux-2023/). +// - FAMILY_BOTTLEROCKET: Bottlerocket (https://aws.amazon.com/bottlerocket/). type NodeconfigV1EKSConfigImageFamily string // NodeconfigV1GKEConfig defines model for nodeconfig.v1.GKEConfig. @@ -3771,6 +3830,9 @@ type PoliciesV1Policies struct { // Defines minimum and maximum amount of CPU the cluster can have. ClusterLimits *PoliciesV1ClusterLimitsPolicy `json:"clusterLimits,omitempty"` + // Version of the default node template at the time when the policies were retrieved. + DefaultNodeTemplateVersion *string `json:"defaultNodeTemplateVersion"` + // Enable/disable all policies. Enabled *bool `json:"enabled"` @@ -4391,6 +4453,11 @@ type WorkloadoptimizationV1ResourceConfig struct { // Period of time over which the resource recommendation is calculated (default value is 24 hours). LookBackPeriodSeconds *int32 `json:"lookBackPeriodSeconds"` + // Defines possible options for workload management. + // READ_ONLY - workload watched (metrics collected), but no actions may be performed by CAST AI. + // MANAGED - workload watched (metrics collected), CAST AI may perform actions on the workload. + ManagementOption *WorkloadoptimizationV1ManagementOption `json:"managementOption,omitempty"` + // Max values for the recommendation. For memory - this is in MiB, for CPU - this is in cores. // If not set, there will be no upper bound for the recommendation (default behaviour). Max *float64 `json:"max"` @@ -4425,6 +4492,11 @@ type WorkloadoptimizationV1ResourceConfigOverrides struct { // Period of time over which the resource recommendation is calculated. LookBackPeriodSeconds *int32 `json:"lookBackPeriodSeconds"` + // Defines possible options for workload management. + // READ_ONLY - workload watched (metrics collected), but no actions may be performed by CAST AI. + // MANAGED - workload watched (metrics collected), CAST AI may perform actions on the workload. + ManagementOption *WorkloadoptimizationV1ManagementOption `json:"managementOption,omitempty"` + // Max values for the recommendation. For memory - this is in MiB, for CPU - this is in cores. Max *float64 `json:"max"` @@ -4497,6 +4569,11 @@ type WorkloadoptimizationV1ResourcePolicies struct { // Period of time over which the resource recommendation is calculated (default value is 24 hours). LookBackPeriodSeconds *int32 `json:"lookBackPeriodSeconds"` + // Defines possible options for workload management. + // READ_ONLY - workload watched (metrics collected), but no actions may be performed by CAST AI. + // MANAGED - workload watched (metrics collected), CAST AI may perform actions on the workload. + ManagementOption *WorkloadoptimizationV1ManagementOption `json:"managementOption,omitempty"` + // Max values for the recommendation, applies to every container. For memory - this is in MiB, for CPU - this is in cores. // If not set, there will be no upper bound for the recommendation (default behaviour). This value will be overridden if configured on workload level. Max *float64 `json:"max"` @@ -4780,6 +4857,11 @@ type WorkloadoptimizationV1WorkloadResourceConfigUpdate struct { // Period of time over which the resource recommendation is calculated (default value is 24 hours). LookBackPeriodSeconds *int32 `json:"lookBackPeriodSeconds"` + // Defines possible options for workload management. + // READ_ONLY - workload watched (metrics collected), but no actions may be performed by CAST AI. + // MANAGED - workload watched (metrics collected), CAST AI may perform actions on the workload. + ManagementOption *WorkloadoptimizationV1ManagementOption `json:"managementOption,omitempty"` + // Max values for the recommendation. For memory - this is in MiB, for CPU - this is in cores. // If not set, there will be no upper bound for the recommendation (default behaviour). Max *float64 `json:"max"` @@ -4820,6 +4902,26 @@ type CommitmentsAPIGetCommitmentUsageHistoryParams struct { // CommitmentsAPIGetCommitmentUsageHistoryParamsAggregationInterval defines parameters for CommitmentsAPIGetCommitmentUsageHistory. type CommitmentsAPIGetCommitmentUsageHistoryParamsAggregationInterval string +// CommitmentsAPIGetAWSReservedInstancesImportCMDParams defines parameters for CommitmentsAPIGetAWSReservedInstancesImportCMD. +type CommitmentsAPIGetAWSReservedInstancesImportCMDParams struct { + // AWS region IDs + RegionIds *[]string `form:"regionIds,omitempty" json:"regionIds,omitempty"` +} + +// CommitmentsAPIImportAWSReservedInstancesJSONBody defines parameters for CommitmentsAPIImportAWSReservedInstances. +type CommitmentsAPIImportAWSReservedInstancesJSONBody = []CastaiInventoryV1beta1AWSRegionReservedInstances + +// CommitmentsAPIImportAWSReservedInstancesParams defines parameters for CommitmentsAPIImportAWSReservedInstances. +type CommitmentsAPIImportAWSReservedInstancesParams struct { + // Behaviour + // + // - OVERWRITE: Overwrite all existing commitments + Behaviour *CommitmentsAPIImportAWSReservedInstancesParamsBehaviour `form:"behaviour,omitempty" json:"behaviour,omitempty"` +} + +// CommitmentsAPIImportAWSReservedInstancesParamsBehaviour defines parameters for CommitmentsAPIImportAWSReservedInstances. +type CommitmentsAPIImportAWSReservedInstancesParamsBehaviour string + // AuthTokenAPIListAuthTokensParams defines parameters for AuthTokenAPIListAuthTokens. type AuthTokenAPIListAuthTokensParams struct { // User id to filter by, if this is set we will only return tokens that have this user id. @@ -4873,6 +4975,9 @@ type NodeConfigurationAPIUpdateConfigurationJSONBody = NodeconfigV1NodeConfigura type NodeTemplatesAPIListNodeTemplatesParams struct { // Flag whether to include the default template IncludeDefault *bool `form:"includeDefault,omitempty" json:"includeDefault,omitempty"` + + // Flag whether to exclude stats about template nodes. + ExcludeStats *bool `form:"excludeStats,omitempty" json:"excludeStats,omitempty"` } // NodeTemplatesAPICreateNodeTemplateJSONBody defines parameters for NodeTemplatesAPICreateNodeTemplate. @@ -5218,6 +5323,9 @@ type CommitmentsAPIBatchDeleteCommitmentsJSONRequestBody = CommitmentsAPIBatchDe // CommitmentsAPIBatchUpdateCommitmentsJSONRequestBody defines body for CommitmentsAPIBatchUpdateCommitments for application/json ContentType. type CommitmentsAPIBatchUpdateCommitmentsJSONRequestBody = CommitmentsAPIBatchUpdateCommitmentsJSONBody +// CommitmentsAPIImportAWSReservedInstancesJSONRequestBody defines body for CommitmentsAPIImportAWSReservedInstances for application/json ContentType. +type CommitmentsAPIImportAWSReservedInstancesJSONRequestBody = CommitmentsAPIImportAWSReservedInstancesJSONBody + // AuthTokenAPICreateAuthTokenJSONRequestBody defines body for AuthTokenAPICreateAuthToken for application/json ContentType. type AuthTokenAPICreateAuthTokenJSONRequestBody = AuthTokenAPICreateAuthTokenJSONBody diff --git a/castai/sdk/client.gen.go b/castai/sdk/client.gen.go index 271525c9..6e38d85d 100644 --- a/castai/sdk/client.gen.go +++ b/castai/sdk/client.gen.go @@ -103,6 +103,17 @@ type ClientInterface interface { // CommitmentsAPIGetCommitmentUsageHistory request CommitmentsAPIGetCommitmentUsageHistory(ctx context.Context, organizationId string, commitmentId string, params *CommitmentsAPIGetCommitmentUsageHistoryParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // CommitmentsAPIGetAWSReservedInstancesImportCMD request + CommitmentsAPIGetAWSReservedInstancesImportCMD(ctx context.Context, organizationId string, params *CommitmentsAPIGetAWSReservedInstancesImportCMDParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CommitmentsAPIGetAWSReservedInstancesImportScript request + CommitmentsAPIGetAWSReservedInstancesImportScript(ctx context.Context, organizationId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CommitmentsAPIImportAWSReservedInstances request with any body + CommitmentsAPIImportAWSReservedInstancesWithBody(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CommitmentsAPIImportAWSReservedInstances(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, body CommitmentsAPIImportAWSReservedInstancesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // AuthTokenAPIListAuthTokens request AuthTokenAPIListAuthTokens(ctx context.Context, params *AuthTokenAPIListAuthTokensParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -693,6 +704,54 @@ func (c *Client) CommitmentsAPIGetCommitmentUsageHistory(ctx context.Context, or return c.Client.Do(req) } +func (c *Client) CommitmentsAPIGetAWSReservedInstancesImportCMD(ctx context.Context, organizationId string, params *CommitmentsAPIGetAWSReservedInstancesImportCMDParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCommitmentsAPIGetAWSReservedInstancesImportCMDRequest(c.Server, organizationId, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CommitmentsAPIGetAWSReservedInstancesImportScript(ctx context.Context, organizationId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCommitmentsAPIGetAWSReservedInstancesImportScriptRequest(c.Server, organizationId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CommitmentsAPIImportAWSReservedInstancesWithBody(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCommitmentsAPIImportAWSReservedInstancesRequestWithBody(c.Server, organizationId, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CommitmentsAPIImportAWSReservedInstances(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, body CommitmentsAPIImportAWSReservedInstancesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCommitmentsAPIImportAWSReservedInstancesRequest(c.Server, organizationId, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) AuthTokenAPIListAuthTokens(ctx context.Context, params *AuthTokenAPIListAuthTokensParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewAuthTokenAPIListAuthTokensRequest(c.Server, params) if err != nil { @@ -3184,6 +3243,161 @@ func NewCommitmentsAPIGetCommitmentUsageHistoryRequest(server string, organizati return req, nil } +// NewCommitmentsAPIGetAWSReservedInstancesImportCMDRequest generates requests for CommitmentsAPIGetAWSReservedInstancesImportCMD +func NewCommitmentsAPIGetAWSReservedInstancesImportCMDRequest(server string, organizationId string, params *CommitmentsAPIGetAWSReservedInstancesImportCMDParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "organizationId", runtime.ParamLocationPath, organizationId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/savings/v1beta/organizations/%s/commitments:getAWSReservedInstancesImportCMD", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.RegionIds != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "regionIds", runtime.ParamLocationQuery, *params.RegionIds); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCommitmentsAPIGetAWSReservedInstancesImportScriptRequest generates requests for CommitmentsAPIGetAWSReservedInstancesImportScript +func NewCommitmentsAPIGetAWSReservedInstancesImportScriptRequest(server string, organizationId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "organizationId", runtime.ParamLocationPath, organizationId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/savings/v1beta/organizations/%s/commitments:getAWSReservedInstancesImportScript", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewCommitmentsAPIImportAWSReservedInstancesRequest calls the generic CommitmentsAPIImportAWSReservedInstances builder with application/json body +func NewCommitmentsAPIImportAWSReservedInstancesRequest(server string, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, body CommitmentsAPIImportAWSReservedInstancesJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCommitmentsAPIImportAWSReservedInstancesRequestWithBody(server, organizationId, params, "application/json", bodyReader) +} + +// NewCommitmentsAPIImportAWSReservedInstancesRequestWithBody generates requests for CommitmentsAPIImportAWSReservedInstances with any type of body +func NewCommitmentsAPIImportAWSReservedInstancesRequestWithBody(server string, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "organizationId", runtime.ParamLocationPath, organizationId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/savings/v1beta/organizations/%s/commitments:importAWSReservedInstances", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.Behaviour != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "behaviour", runtime.ParamLocationQuery, *params.Behaviour); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewAuthTokenAPIListAuthTokensRequest generates requests for AuthTokenAPIListAuthTokens func NewAuthTokenAPIListAuthTokensRequest(server string, params *AuthTokenAPIListAuthTokensParams) (*http.Request, error) { var err error @@ -4181,6 +4395,22 @@ func NewNodeTemplatesAPIListNodeTemplatesRequest(server string, clusterId string } + if params.ExcludeStats != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "excludeStats", runtime.ParamLocationQuery, *params.ExcludeStats); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + queryURL.RawQuery = queryValues.Encode() req, err := http.NewRequest("GET", queryURL.String(), nil) @@ -9932,6 +10162,17 @@ type ClientWithResponsesInterface interface { // CommitmentsAPIGetCommitmentUsageHistory request CommitmentsAPIGetCommitmentUsageHistoryWithResponse(ctx context.Context, organizationId string, commitmentId string, params *CommitmentsAPIGetCommitmentUsageHistoryParams) (*CommitmentsAPIGetCommitmentUsageHistoryResponse, error) + // CommitmentsAPIGetAWSReservedInstancesImportCMD request + CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse(ctx context.Context, organizationId string, params *CommitmentsAPIGetAWSReservedInstancesImportCMDParams) (*CommitmentsAPIGetAWSReservedInstancesImportCMDResponse, error) + + // CommitmentsAPIGetAWSReservedInstancesImportScript request + CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse(ctx context.Context, organizationId string) (*CommitmentsAPIGetAWSReservedInstancesImportScriptResponse, error) + + // CommitmentsAPIImportAWSReservedInstances request with any body + CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, contentType string, body io.Reader) (*CommitmentsAPIImportAWSReservedInstancesResponse, error) + + CommitmentsAPIImportAWSReservedInstancesWithResponse(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, body CommitmentsAPIImportAWSReservedInstancesJSONRequestBody) (*CommitmentsAPIImportAWSReservedInstancesResponse, error) + // AuthTokenAPIListAuthTokens request AuthTokenAPIListAuthTokensWithResponse(ctx context.Context, params *AuthTokenAPIListAuthTokensParams) (*AuthTokenAPIListAuthTokensResponse, error) @@ -10561,6 +10802,95 @@ func (r CommitmentsAPIGetCommitmentUsageHistoryResponse) GetBody() []byte { // TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 +type CommitmentsAPIGetAWSReservedInstancesImportCMDResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CastaiInventoryV1beta1GetAWSReservedInstancesImportCMDResponse +} + +// Status returns HTTPResponse.Status +func (r CommitmentsAPIGetAWSReservedInstancesImportCMDResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CommitmentsAPIGetAWSReservedInstancesImportCMDResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 +// Body returns body of byte array +func (r CommitmentsAPIGetAWSReservedInstancesImportCMDResponse) GetBody() []byte { + return r.Body +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 + +type CommitmentsAPIGetAWSReservedInstancesImportScriptResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r CommitmentsAPIGetAWSReservedInstancesImportScriptResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CommitmentsAPIGetAWSReservedInstancesImportScriptResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 +// Body returns body of byte array +func (r CommitmentsAPIGetAWSReservedInstancesImportScriptResponse) GetBody() []byte { + return r.Body +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 + +type CommitmentsAPIImportAWSReservedInstancesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *map[string]interface{} +} + +// Status returns HTTPResponse.Status +func (r CommitmentsAPIImportAWSReservedInstancesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CommitmentsAPIImportAWSReservedInstancesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 +// Body returns body of byte array +func (r CommitmentsAPIImportAWSReservedInstancesResponse) GetBody() []byte { + return r.Body +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 + type AuthTokenAPIListAuthTokensResponse struct { Body []byte HTTPResponse *http.Response @@ -14891,6 +15221,41 @@ func (c *ClientWithResponses) CommitmentsAPIGetCommitmentUsageHistoryWithRespons return ParseCommitmentsAPIGetCommitmentUsageHistoryResponse(rsp) } +// CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse request returning *CommitmentsAPIGetAWSReservedInstancesImportCMDResponse +func (c *ClientWithResponses) CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse(ctx context.Context, organizationId string, params *CommitmentsAPIGetAWSReservedInstancesImportCMDParams) (*CommitmentsAPIGetAWSReservedInstancesImportCMDResponse, error) { + rsp, err := c.CommitmentsAPIGetAWSReservedInstancesImportCMD(ctx, organizationId, params) + if err != nil { + return nil, err + } + return ParseCommitmentsAPIGetAWSReservedInstancesImportCMDResponse(rsp) +} + +// CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse request returning *CommitmentsAPIGetAWSReservedInstancesImportScriptResponse +func (c *ClientWithResponses) CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse(ctx context.Context, organizationId string) (*CommitmentsAPIGetAWSReservedInstancesImportScriptResponse, error) { + rsp, err := c.CommitmentsAPIGetAWSReservedInstancesImportScript(ctx, organizationId) + if err != nil { + return nil, err + } + return ParseCommitmentsAPIGetAWSReservedInstancesImportScriptResponse(rsp) +} + +// CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse request with arbitrary body returning *CommitmentsAPIImportAWSReservedInstancesResponse +func (c *ClientWithResponses) CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, contentType string, body io.Reader) (*CommitmentsAPIImportAWSReservedInstancesResponse, error) { + rsp, err := c.CommitmentsAPIImportAWSReservedInstancesWithBody(ctx, organizationId, params, contentType, body) + if err != nil { + return nil, err + } + return ParseCommitmentsAPIImportAWSReservedInstancesResponse(rsp) +} + +func (c *ClientWithResponses) CommitmentsAPIImportAWSReservedInstancesWithResponse(ctx context.Context, organizationId string, params *CommitmentsAPIImportAWSReservedInstancesParams, body CommitmentsAPIImportAWSReservedInstancesJSONRequestBody) (*CommitmentsAPIImportAWSReservedInstancesResponse, error) { + rsp, err := c.CommitmentsAPIImportAWSReservedInstances(ctx, organizationId, params, body) + if err != nil { + return nil, err + } + return ParseCommitmentsAPIImportAWSReservedInstancesResponse(rsp) +} + // AuthTokenAPIListAuthTokensWithResponse request returning *AuthTokenAPIListAuthTokensResponse func (c *ClientWithResponses) AuthTokenAPIListAuthTokensWithResponse(ctx context.Context, params *AuthTokenAPIListAuthTokensParams) (*AuthTokenAPIListAuthTokensResponse, error) { rsp, err := c.AuthTokenAPIListAuthTokens(ctx, params) @@ -16656,6 +17021,74 @@ func ParseCommitmentsAPIGetCommitmentUsageHistoryResponse(rsp *http.Response) (* return response, nil } +// ParseCommitmentsAPIGetAWSReservedInstancesImportCMDResponse parses an HTTP response from a CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse call +func ParseCommitmentsAPIGetAWSReservedInstancesImportCMDResponse(rsp *http.Response) (*CommitmentsAPIGetAWSReservedInstancesImportCMDResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer rsp.Body.Close() + if err != nil { + return nil, err + } + + response := &CommitmentsAPIGetAWSReservedInstancesImportCMDResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CastaiInventoryV1beta1GetAWSReservedInstancesImportCMDResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseCommitmentsAPIGetAWSReservedInstancesImportScriptResponse parses an HTTP response from a CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse call +func ParseCommitmentsAPIGetAWSReservedInstancesImportScriptResponse(rsp *http.Response) (*CommitmentsAPIGetAWSReservedInstancesImportScriptResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer rsp.Body.Close() + if err != nil { + return nil, err + } + + response := &CommitmentsAPIGetAWSReservedInstancesImportScriptResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseCommitmentsAPIImportAWSReservedInstancesResponse parses an HTTP response from a CommitmentsAPIImportAWSReservedInstancesWithResponse call +func ParseCommitmentsAPIImportAWSReservedInstancesResponse(rsp *http.Response) (*CommitmentsAPIImportAWSReservedInstancesResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer rsp.Body.Close() + if err != nil { + return nil, err + } + + response := &CommitmentsAPIImportAWSReservedInstancesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest map[string]interface{} + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseAuthTokenAPIListAuthTokensResponse parses an HTTP response from a AuthTokenAPIListAuthTokensWithResponse call func ParseAuthTokenAPIListAuthTokensResponse(rsp *http.Response) (*AuthTokenAPIListAuthTokensResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) diff --git a/castai/sdk/mock/client.go b/castai/sdk/mock/client.go index 640d5762..e9801971 100644 --- a/castai/sdk/mock/client.go +++ b/castai/sdk/mock/client.go @@ -355,6 +355,46 @@ func (mr *MockClientInterfaceMockRecorder) CommitmentsAPIDeleteCommitmentAssignm return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIDeleteCommitmentAssignment", reflect.TypeOf((*MockClientInterface)(nil).CommitmentsAPIDeleteCommitmentAssignment), varargs...) } +// CommitmentsAPIGetAWSReservedInstancesImportCMD mocks base method. +func (m *MockClientInterface) CommitmentsAPIGetAWSReservedInstancesImportCMD(ctx context.Context, organizationId string, params *sdk.CommitmentsAPIGetAWSReservedInstancesImportCMDParams, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, organizationId, params} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CommitmentsAPIGetAWSReservedInstancesImportCMD", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIGetAWSReservedInstancesImportCMD indicates an expected call of CommitmentsAPIGetAWSReservedInstancesImportCMD. +func (mr *MockClientInterfaceMockRecorder) CommitmentsAPIGetAWSReservedInstancesImportCMD(ctx, organizationId, params interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, organizationId, params}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIGetAWSReservedInstancesImportCMD", reflect.TypeOf((*MockClientInterface)(nil).CommitmentsAPIGetAWSReservedInstancesImportCMD), varargs...) +} + +// CommitmentsAPIGetAWSReservedInstancesImportScript mocks base method. +func (m *MockClientInterface) CommitmentsAPIGetAWSReservedInstancesImportScript(ctx context.Context, organizationId string, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, organizationId} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CommitmentsAPIGetAWSReservedInstancesImportScript", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIGetAWSReservedInstancesImportScript indicates an expected call of CommitmentsAPIGetAWSReservedInstancesImportScript. +func (mr *MockClientInterfaceMockRecorder) CommitmentsAPIGetAWSReservedInstancesImportScript(ctx, organizationId interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, organizationId}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIGetAWSReservedInstancesImportScript", reflect.TypeOf((*MockClientInterface)(nil).CommitmentsAPIGetAWSReservedInstancesImportScript), varargs...) +} + // CommitmentsAPIGetCommitment mocks base method. func (m *MockClientInterface) CommitmentsAPIGetCommitment(ctx context.Context, commitmentId string, params *sdk.CommitmentsAPIGetCommitmentParams, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() @@ -495,6 +535,46 @@ func (mr *MockClientInterfaceMockRecorder) CommitmentsAPIGetGCPCommitmentsScript return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIGetGCPCommitmentsScriptTemplate", reflect.TypeOf((*MockClientInterface)(nil).CommitmentsAPIGetGCPCommitmentsScriptTemplate), varargs...) } +// CommitmentsAPIImportAWSReservedInstances mocks base method. +func (m *MockClientInterface) CommitmentsAPIImportAWSReservedInstances(ctx context.Context, organizationId string, params *sdk.CommitmentsAPIImportAWSReservedInstancesParams, body sdk.CommitmentsAPIImportAWSReservedInstancesJSONRequestBody, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, organizationId, params, body} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CommitmentsAPIImportAWSReservedInstances", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIImportAWSReservedInstances indicates an expected call of CommitmentsAPIImportAWSReservedInstances. +func (mr *MockClientInterfaceMockRecorder) CommitmentsAPIImportAWSReservedInstances(ctx, organizationId, params, body interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, organizationId, params, body}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIImportAWSReservedInstances", reflect.TypeOf((*MockClientInterface)(nil).CommitmentsAPIImportAWSReservedInstances), varargs...) +} + +// CommitmentsAPIImportAWSReservedInstancesWithBody mocks base method. +func (m *MockClientInterface) CommitmentsAPIImportAWSReservedInstancesWithBody(ctx context.Context, organizationId string, params *sdk.CommitmentsAPIImportAWSReservedInstancesParams, contentType string, body io.Reader, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, organizationId, params, contentType, body} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "CommitmentsAPIImportAWSReservedInstancesWithBody", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIImportAWSReservedInstancesWithBody indicates an expected call of CommitmentsAPIImportAWSReservedInstancesWithBody. +func (mr *MockClientInterfaceMockRecorder) CommitmentsAPIImportAWSReservedInstancesWithBody(ctx, organizationId, params, contentType, body interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, organizationId, params, contentType, body}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIImportAWSReservedInstancesWithBody", reflect.TypeOf((*MockClientInterface)(nil).CommitmentsAPIImportAWSReservedInstancesWithBody), varargs...) +} + // CommitmentsAPIImportAzureReservations mocks base method. func (m *MockClientInterface) CommitmentsAPIImportAzureReservations(ctx context.Context, params *sdk.CommitmentsAPIImportAzureReservationsParams, body sdk.CommitmentsAPIImportAzureReservationsJSONRequestBody, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() @@ -4268,6 +4348,36 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CommitmentsAPIDeleteComm return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIDeleteCommitmentWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).CommitmentsAPIDeleteCommitmentWithResponse), ctx, commitmentId) } +// CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse(ctx context.Context, organizationId string, params *sdk.CommitmentsAPIGetAWSReservedInstancesImportCMDParams) (*sdk.CommitmentsAPIGetAWSReservedInstancesImportCMDResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse", ctx, organizationId, params) + ret0, _ := ret[0].(*sdk.CommitmentsAPIGetAWSReservedInstancesImportCMDResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse indicates an expected call of CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse(ctx, organizationId, params interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).CommitmentsAPIGetAWSReservedInstancesImportCMDWithResponse), ctx, organizationId, params) +} + +// CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse(ctx context.Context, organizationId string) (*sdk.CommitmentsAPIGetAWSReservedInstancesImportScriptResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse", ctx, organizationId) + ret0, _ := ret[0].(*sdk.CommitmentsAPIGetAWSReservedInstancesImportScriptResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse indicates an expected call of CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse(ctx, organizationId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).CommitmentsAPIGetAWSReservedInstancesImportScriptWithResponse), ctx, organizationId) +} + // CommitmentsAPIGetCommitmentAssignmentsWithResponse mocks base method. func (m *MockClientWithResponsesInterface) CommitmentsAPIGetCommitmentAssignmentsWithResponse(ctx context.Context, commitmentId string) (*sdk.CommitmentsAPIGetCommitmentAssignmentsResponse, error) { m.ctrl.T.Helper() @@ -4373,6 +4483,36 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CommitmentsAPIGetGCPComm return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIGetGCPCommitmentsScriptTemplateWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).CommitmentsAPIGetGCPCommitmentsScriptTemplateWithResponse), ctx) } +// CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse(ctx context.Context, organizationId string, params *sdk.CommitmentsAPIImportAWSReservedInstancesParams, contentType string, body io.Reader) (*sdk.CommitmentsAPIImportAWSReservedInstancesResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse", ctx, organizationId, params, contentType, body) + ret0, _ := ret[0].(*sdk.CommitmentsAPIImportAWSReservedInstancesResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse indicates an expected call of CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse(ctx, organizationId, params, contentType, body interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).CommitmentsAPIImportAWSReservedInstancesWithBodyWithResponse), ctx, organizationId, params, contentType, body) +} + +// CommitmentsAPIImportAWSReservedInstancesWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) CommitmentsAPIImportAWSReservedInstancesWithResponse(ctx context.Context, organizationId string, params *sdk.CommitmentsAPIImportAWSReservedInstancesParams, body sdk.CommitmentsAPIImportAWSReservedInstancesJSONRequestBody) (*sdk.CommitmentsAPIImportAWSReservedInstancesResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CommitmentsAPIImportAWSReservedInstancesWithResponse", ctx, organizationId, params, body) + ret0, _ := ret[0].(*sdk.CommitmentsAPIImportAWSReservedInstancesResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CommitmentsAPIImportAWSReservedInstancesWithResponse indicates an expected call of CommitmentsAPIImportAWSReservedInstancesWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) CommitmentsAPIImportAWSReservedInstancesWithResponse(ctx, organizationId, params, body interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CommitmentsAPIImportAWSReservedInstancesWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).CommitmentsAPIImportAWSReservedInstancesWithResponse), ctx, organizationId, params, body) +} + // CommitmentsAPIImportAzureReservationsWithBodyWithResponse mocks base method. func (m *MockClientWithResponsesInterface) CommitmentsAPIImportAzureReservationsWithBodyWithResponse(ctx context.Context, params *sdk.CommitmentsAPIImportAzureReservationsParams, contentType string, body io.Reader) (*sdk.CommitmentsAPIImportAzureReservationsResponse, error) { m.ctrl.T.Helper() diff --git a/docs/resources/workload_scaling_policy.md b/docs/resources/workload_scaling_policy.md index cfcbdfbd..ffa49b9a 100644 --- a/docs/resources/workload_scaling_policy.md +++ b/docs/resources/workload_scaling_policy.md @@ -37,6 +37,7 @@ resource "castai_workload_scaling_policy" "services" { type = "MULTIPLIER" multiplier = 1.5 } + management_option = "READ_ONLY" } startup { period_seconds = 240 @@ -91,6 +92,7 @@ Optional: - `function` (String) The function used to calculate the resource recommendation. Supported values: `QUANTILE`, `MAX` - `limit` (Block List, Max: 1) Resource limit settings (see [below for nested schema](#nestedblock--cpu--limit)) - `look_back_period_seconds` (Number) The look back period in seconds for the recommendation. +- `management_option` (String) Disables management for a single resource when set to `READ_ONLY`. The resource will use its original workload template requests and limits. Supported value: `READ_ONLY`. Minimum required workload-autoscaler version: `v0.23.1`. - `max` (Number) Max values for the recommendation, applies to every container. For memory - this is in MiB, for CPU - this is in cores. - `min` (Number) Min values for the recommendation, applies to every container. For memory - this is in MiB, for CPU - this is in cores. - `overhead` (Number) Overhead for the recommendation, e.g. `0.1` will result in 10% higher recommendation @@ -120,6 +122,7 @@ Optional: - `function` (String) The function used to calculate the resource recommendation. Supported values: `QUANTILE`, `MAX` - `limit` (Block List, Max: 1) Resource limit settings (see [below for nested schema](#nestedblock--memory--limit)) - `look_back_period_seconds` (Number) The look back period in seconds for the recommendation. +- `management_option` (String) Disables management for a single resource when set to `READ_ONLY`. The resource will use its original workload template requests and limits. Supported value: `READ_ONLY`. Minimum required workload-autoscaler version: `v0.23.1`. - `max` (Number) Max values for the recommendation, applies to every container. For memory - this is in MiB, for CPU - this is in cores. - `min` (Number) Min values for the recommendation, applies to every container. For memory - this is in MiB, for CPU - this is in cores. - `overhead` (Number) Overhead for the recommendation, e.g. `0.1` will result in 10% higher recommendation diff --git a/examples/resources/castai_workload_scaling_policy/resource.tf b/examples/resources/castai_workload_scaling_policy/resource.tf index 1c4146bb..2b3c3fc2 100644 --- a/examples/resources/castai_workload_scaling_policy/resource.tf +++ b/examples/resources/castai_workload_scaling_policy/resource.tf @@ -20,6 +20,7 @@ resource "castai_workload_scaling_policy" "services" { type = "MULTIPLIER" multiplier = 1.5 } + management_option = "READ_ONLY" } startup { period_seconds = 240