From 86be329383d17ace42db2710d0f9ba25af0e5e7f Mon Sep 17 00:00:00 2001 From: Jan Sykora Date: Tue, 17 Oct 2023 16:10:33 +0200 Subject: [PATCH] feat: add evictor API to SDK --- Makefile | 2 +- castai/sdk/api.gen.go | 159 ++++++++++++++++++++-- castai/sdk/client.gen.go | 271 ++++++++++++++++++++++++++++++++++++++ castai/sdk/mock/client.go | 105 +++++++++++++++ 4 files changed, 527 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 0db9fd99..94e1ab4e 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ init-examples: generate-sdk: @echo "==> Generating castai sdk client" - @API_TAGS=ExternalClusterAPI,PoliciesAPI,NodeConfigurationAPI,NodeTemplatesAPI,AuthTokenAPI,ScheduledRebalancingAPI,InventoryAPI,UsersAPI,OperationsAPI go generate castai/sdk/generate.go + @API_TAGS=ExternalClusterAPI,PoliciesAPI,NodeConfigurationAPI,NodeTemplatesAPI,AuthTokenAPI,ScheduledRebalancingAPI,InventoryAPI,UsersAPI,OperationsAPI,EvictorAPI go generate castai/sdk/generate.go # The following command also rewrites existing documentation generate-docs: diff --git a/castai/sdk/api.gen.go b/castai/sdk/api.gen.go index eddba1f3..421eeaea 100644 --- a/castai/sdk/api.gen.go +++ b/castai/sdk/api.gen.go @@ -23,6 +23,15 @@ const ( Viewer OrganizationRole = "viewer" ) +// Defines values for CastaiEvictorV1LabelSelectorExpressionOperator. +const ( + CastaiEvictorV1LabelSelectorExpressionOperatorDoesNotExist CastaiEvictorV1LabelSelectorExpressionOperator = "DoesNotExist" + CastaiEvictorV1LabelSelectorExpressionOperatorExists CastaiEvictorV1LabelSelectorExpressionOperator = "Exists" + CastaiEvictorV1LabelSelectorExpressionOperatorIn CastaiEvictorV1LabelSelectorExpressionOperator = "In" + CastaiEvictorV1LabelSelectorExpressionOperatorInvalid CastaiEvictorV1LabelSelectorExpressionOperator = "Invalid" + CastaiEvictorV1LabelSelectorExpressionOperatorNotIn CastaiEvictorV1LabelSelectorExpressionOperator = "NotIn" +) + // Defines values for CastaiInventoryV1beta1AttachableGPUDeviceManufacturer. const ( CastaiInventoryV1beta1AttachableGPUDeviceManufacturerAMD CastaiInventoryV1beta1AttachableGPUDeviceManufacturer = "AMD" @@ -53,14 +62,14 @@ const ( // Defines values for CastaiV1Cloud. const ( - AWS CastaiV1Cloud = "AWS" - AZURE CastaiV1Cloud = "AZURE" - Aws CastaiV1Cloud = "aws" - Azure CastaiV1Cloud = "azure" - GCP CastaiV1Cloud = "GCP" - Gcp CastaiV1Cloud = "gcp" - INVALID CastaiV1Cloud = "INVALID" - Invalid CastaiV1Cloud = "invalid" + CastaiV1CloudAWS CastaiV1Cloud = "AWS" + CastaiV1CloudAZURE CastaiV1Cloud = "AZURE" + CastaiV1CloudAws CastaiV1Cloud = "aws" + CastaiV1CloudAzure CastaiV1Cloud = "azure" + CastaiV1CloudGCP CastaiV1Cloud = "GCP" + CastaiV1CloudGcp CastaiV1Cloud = "gcp" + CastaiV1CloudINVALID CastaiV1Cloud = "INVALID" + CastaiV1CloudInvalid CastaiV1Cloud = "invalid" ) // Defines values for ExternalclusterV1NodeType. @@ -261,6 +270,78 @@ type CastaiAuthtokenV1beta1ListAuthTokensResponse struct { Items *[]CastaiAuthtokenV1beta1AuthToken `json:"items,omitempty"` } +// AdvancedConfig the evictor advanced configuration. +type CastaiEvictorV1AdvancedConfig struct { + EvictionConfig []CastaiEvictorV1EvictionConfig `json:"evictionConfig"` +} + +// EvictionConfig used to specify more granular settings per node/pod filters. +type CastaiEvictorV1EvictionConfig struct { + NodeSelector *CastaiEvictorV1NodeSelector `json:"nodeSelector,omitempty"` + PodSelector *CastaiEvictorV1PodSelector `json:"podSelector,omitempty"` + Settings CastaiEvictorV1EvictionSettings `json:"settings"` +} + +// CastaiEvictorV1EvictionSettings defines model for castai.evictor.v1.EvictionSettings. +type CastaiEvictorV1EvictionSettings struct { + Aggressive *CastaiEvictorV1EvictionSettingsSettingEnabled `json:"aggressive,omitempty"` + Disposable *CastaiEvictorV1EvictionSettingsSettingEnabled `json:"disposable,omitempty"` + RemovalDisabled *CastaiEvictorV1EvictionSettingsSettingEnabled `json:"removalDisabled,omitempty"` +} + +// CastaiEvictorV1EvictionSettingsSettingEnabled defines model for castai.evictor.v1.EvictionSettings.SettingEnabled. +type CastaiEvictorV1EvictionSettingsSettingEnabled struct { + Enabled bool `json:"enabled"` +} + +// LabelSelector is a proto mirror of the metav1.LabelSelector K8s API object. Properties `match_labels` and +// `match_expressions` are ANDed. +type CastaiEvictorV1LabelSelector struct { + // A more advanced label query with operators. Multiple expressions are ANDed. + MatchExpressions *[]CastaiEvictorV1LabelSelectorExpression `json:"matchExpressions,omitempty"` + + // Used to query resource labels. + MatchLabels *CastaiEvictorV1LabelSelector_MatchLabels `json:"matchLabels,omitempty"` +} + +// Used to query resource labels. +type CastaiEvictorV1LabelSelector_MatchLabels struct { + AdditionalProperties map[string]string `json:"-"` +} + +// Expression is a proto mirror of the metav1.LabelSelectorRequirement K8s API object. +type CastaiEvictorV1LabelSelectorExpression struct { + // Key is a label. + Key string `json:"key"` + + // Operator set of operators which can be used in the label selector expressions. + Operator CastaiEvictorV1LabelSelectorExpressionOperator `json:"operator"` + + // Values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the + // operator is Exists or DoesNotExist, the values array must be empty. + Values *[]string `json:"values,omitempty"` +} + +// Operator set of operators which can be used in the label selector expressions. +type CastaiEvictorV1LabelSelectorExpressionOperator string + +// CastaiEvictorV1NodeSelector defines model for castai.evictor.v1.NodeSelector. +type CastaiEvictorV1NodeSelector struct { + // LabelSelector is a proto mirror of the metav1.LabelSelector K8s API object. Properties `match_labels` and + // `match_expressions` are ANDed. + LabelSelector CastaiEvictorV1LabelSelector `json:"labelSelector"` +} + +// CastaiEvictorV1PodSelector defines model for castai.evictor.v1.PodSelector. +type CastaiEvictorV1PodSelector struct { + Kind *string `json:"kind,omitempty"` + + // LabelSelector is a proto mirror of the metav1.LabelSelector K8s API object. Properties `match_labels` and + // `match_expressions` are ANDed. + LabelSelector CastaiEvictorV1LabelSelector `json:"labelSelector"` + Namespace *string `json:"namespace,omitempty"` +} + // CastaiInventoryV1beta1AddReservationResponse defines model for castai.inventory.v1beta1.AddReservationResponse. type CastaiInventoryV1beta1AddReservationResponse struct { Reservation *CastaiInventoryV1beta1ReservationDetails `json:"reservation,omitempty"` @@ -1564,7 +1645,8 @@ type NodetemplatesV1TemplateConstraints struct { MinMemory *int32 `json:"minMemory"` // Should include on-demand instances in the considered pool. - OnDemand *bool `json:"onDemand"` + OnDemand *bool `json:"onDemand"` + Os *[]string `json:"os,omitempty"` // Should include spot instances in the considered pool. // Note 1: if both spot and on-demand are false, then on-demand is assumed. @@ -2036,6 +2118,9 @@ type CreateInvitationJSONBody = NewInvitations // ClaimInvitationJSONBody defines parameters for ClaimInvitation. type ClaimInvitationJSONBody = map[string]interface{} +// EvictorAPIUpsertAdvancedConfigJSONBody defines parameters for EvictorAPIUpsertAdvancedConfig. +type EvictorAPIUpsertAdvancedConfigJSONBody = CastaiEvictorV1AdvancedConfig + // NodeTemplatesAPIFilterInstanceTypesJSONBody defines parameters for NodeTemplatesAPIFilterInstanceTypes. type NodeTemplatesAPIFilterInstanceTypesJSONBody = NodetemplatesV1NodeTemplate @@ -2172,6 +2257,9 @@ type CreateInvitationJSONRequestBody = CreateInvitationJSONBody // ClaimInvitationJSONRequestBody defines body for ClaimInvitation for application/json ContentType. type ClaimInvitationJSONRequestBody = ClaimInvitationJSONBody +// EvictorAPIUpsertAdvancedConfigJSONRequestBody defines body for EvictorAPIUpsertAdvancedConfig for application/json ContentType. +type EvictorAPIUpsertAdvancedConfigJSONRequestBody = EvictorAPIUpsertAdvancedConfigJSONBody + // NodeTemplatesAPIFilterInstanceTypesJSONRequestBody defines body for NodeTemplatesAPIFilterInstanceTypes for application/json ContentType. type NodeTemplatesAPIFilterInstanceTypesJSONRequestBody = NodeTemplatesAPIFilterInstanceTypesJSONBody @@ -2244,6 +2332,59 @@ type ScheduledRebalancingAPICreateRebalancingScheduleJSONRequestBody = Scheduled // ScheduledRebalancingAPIUpdateRebalancingScheduleJSONRequestBody defines body for ScheduledRebalancingAPIUpdateRebalancingSchedule for application/json ContentType. type ScheduledRebalancingAPIUpdateRebalancingScheduleJSONRequestBody = ScheduledRebalancingAPIUpdateRebalancingScheduleJSONBody +// Getter for additional properties for CastaiEvictorV1LabelSelector_MatchLabels. Returns the specified +// element and whether it was found +func (a CastaiEvictorV1LabelSelector_MatchLabels) Get(fieldName string) (value string, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for CastaiEvictorV1LabelSelector_MatchLabels +func (a *CastaiEvictorV1LabelSelector_MatchLabels) Set(fieldName string, value string) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]string) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for CastaiEvictorV1LabelSelector_MatchLabels to handle AdditionalProperties +func (a *CastaiEvictorV1LabelSelector_MatchLabels) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]string) + for fieldName, fieldBuf := range object { + var fieldVal string + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for CastaiEvictorV1LabelSelector_MatchLabels to handle AdditionalProperties +func (a CastaiEvictorV1LabelSelector_MatchLabels) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + // Getter for additional properties for ExternalclusterV1EKSClusterParams_Tags. Returns the specified // element and whether it was found func (a ExternalclusterV1EKSClusterParams_Tags) Get(fieldName string) (value string, found bool) { diff --git a/castai/sdk/client.gen.go b/castai/sdk/client.gen.go index 8cec0722..d936d843 100644 --- a/castai/sdk/client.gen.go +++ b/castai/sdk/client.gen.go @@ -125,6 +125,14 @@ type ClientInterface interface { ClaimInvitation(ctx context.Context, id string, body ClaimInvitationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // EvictorAPIGetAdvancedConfig request + EvictorAPIGetAdvancedConfig(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // EvictorAPIUpsertAdvancedConfig request with any body + EvictorAPIUpsertAdvancedConfigWithBody(ctx context.Context, clusterId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + EvictorAPIUpsertAdvancedConfig(ctx context.Context, clusterId string, body EvictorAPIUpsertAdvancedConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // NodeTemplatesAPIFilterInstanceTypes request with any body NodeTemplatesAPIFilterInstanceTypesWithBody(ctx context.Context, clusterId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -534,6 +542,42 @@ func (c *Client) ClaimInvitation(ctx context.Context, id string, body ClaimInvit return c.Client.Do(req) } +func (c *Client) EvictorAPIGetAdvancedConfig(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewEvictorAPIGetAdvancedConfigRequest(c.Server, clusterId) + 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) EvictorAPIUpsertAdvancedConfigWithBody(ctx context.Context, clusterId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewEvictorAPIUpsertAdvancedConfigRequestWithBody(c.Server, clusterId, 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) EvictorAPIUpsertAdvancedConfig(ctx context.Context, clusterId string, body EvictorAPIUpsertAdvancedConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewEvictorAPIUpsertAdvancedConfigRequest(c.Server, clusterId, 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) NodeTemplatesAPIFilterInstanceTypesWithBody(ctx context.Context, clusterId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewNodeTemplatesAPIFilterInstanceTypesRequestWithBody(c.Server, clusterId, contentType, body) if err != nil { @@ -2024,6 +2068,87 @@ func NewClaimInvitationRequestWithBody(server string, id string, contentType str return req, nil } +// NewEvictorAPIGetAdvancedConfigRequest generates requests for EvictorAPIGetAdvancedConfig +func NewEvictorAPIGetAdvancedConfigRequest(server string, clusterId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/kubernetes/clusters/%s/evictor-advanced-config", 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 +} + +// NewEvictorAPIUpsertAdvancedConfigRequest calls the generic EvictorAPIUpsertAdvancedConfig builder with application/json body +func NewEvictorAPIUpsertAdvancedConfigRequest(server string, clusterId string, body EvictorAPIUpsertAdvancedConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewEvictorAPIUpsertAdvancedConfigRequestWithBody(server, clusterId, "application/json", bodyReader) +} + +// NewEvictorAPIUpsertAdvancedConfigRequestWithBody generates requests for EvictorAPIUpsertAdvancedConfig with any type of body +func NewEvictorAPIUpsertAdvancedConfigRequestWithBody(server string, clusterId string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "clusterId", runtime.ParamLocationPath, clusterId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/kubernetes/clusters/%s/evictor-advanced-config", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewNodeTemplatesAPIFilterInstanceTypesRequest calls the generic NodeTemplatesAPIFilterInstanceTypes builder with application/json body func NewNodeTemplatesAPIFilterInstanceTypesRequest(server string, clusterId string, body NodeTemplatesAPIFilterInstanceTypesJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -4972,6 +5097,14 @@ type ClientWithResponsesInterface interface { ClaimInvitationWithResponse(ctx context.Context, id string, body ClaimInvitationJSONRequestBody) (*ClaimInvitationResponse, error) + // EvictorAPIGetAdvancedConfig request + EvictorAPIGetAdvancedConfigWithResponse(ctx context.Context, clusterId string) (*EvictorAPIGetAdvancedConfigResponse, error) + + // EvictorAPIUpsertAdvancedConfig request with any body + EvictorAPIUpsertAdvancedConfigWithBodyWithResponse(ctx context.Context, clusterId string, contentType string, body io.Reader) (*EvictorAPIUpsertAdvancedConfigResponse, error) + + EvictorAPIUpsertAdvancedConfigWithResponse(ctx context.Context, clusterId string, body EvictorAPIUpsertAdvancedConfigJSONRequestBody) (*EvictorAPIUpsertAdvancedConfigResponse, error) + // NodeTemplatesAPIFilterInstanceTypes request with any body NodeTemplatesAPIFilterInstanceTypesWithBodyWithResponse(ctx context.Context, clusterId string, contentType string, body io.Reader) (*NodeTemplatesAPIFilterInstanceTypesResponse, error) @@ -5504,6 +5637,66 @@ func (r ClaimInvitationResponse) GetBody() []byte { // TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 +type EvictorAPIGetAdvancedConfigResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CastaiEvictorV1AdvancedConfig +} + +// Status returns HTTPResponse.Status +func (r EvictorAPIGetAdvancedConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r EvictorAPIGetAdvancedConfigResponse) 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 EvictorAPIGetAdvancedConfigResponse) GetBody() []byte { + return r.Body +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 + +type EvictorAPIUpsertAdvancedConfigResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CastaiEvictorV1AdvancedConfig +} + +// Status returns HTTPResponse.Status +func (r EvictorAPIUpsertAdvancedConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r EvictorAPIUpsertAdvancedConfigResponse) 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 EvictorAPIUpsertAdvancedConfigResponse) GetBody() []byte { + return r.Body +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 + type NodeTemplatesAPIFilterInstanceTypesResponse struct { Body []byte HTTPResponse *http.Response @@ -7654,6 +7847,32 @@ func (c *ClientWithResponses) ClaimInvitationWithResponse(ctx context.Context, i return ParseClaimInvitationResponse(rsp) } +// EvictorAPIGetAdvancedConfigWithResponse request returning *EvictorAPIGetAdvancedConfigResponse +func (c *ClientWithResponses) EvictorAPIGetAdvancedConfigWithResponse(ctx context.Context, clusterId string) (*EvictorAPIGetAdvancedConfigResponse, error) { + rsp, err := c.EvictorAPIGetAdvancedConfig(ctx, clusterId) + if err != nil { + return nil, err + } + return ParseEvictorAPIGetAdvancedConfigResponse(rsp) +} + +// EvictorAPIUpsertAdvancedConfigWithBodyWithResponse request with arbitrary body returning *EvictorAPIUpsertAdvancedConfigResponse +func (c *ClientWithResponses) EvictorAPIUpsertAdvancedConfigWithBodyWithResponse(ctx context.Context, clusterId string, contentType string, body io.Reader) (*EvictorAPIUpsertAdvancedConfigResponse, error) { + rsp, err := c.EvictorAPIUpsertAdvancedConfigWithBody(ctx, clusterId, contentType, body) + if err != nil { + return nil, err + } + return ParseEvictorAPIUpsertAdvancedConfigResponse(rsp) +} + +func (c *ClientWithResponses) EvictorAPIUpsertAdvancedConfigWithResponse(ctx context.Context, clusterId string, body EvictorAPIUpsertAdvancedConfigJSONRequestBody) (*EvictorAPIUpsertAdvancedConfigResponse, error) { + rsp, err := c.EvictorAPIUpsertAdvancedConfig(ctx, clusterId, body) + if err != nil { + return nil, err + } + return ParseEvictorAPIUpsertAdvancedConfigResponse(rsp) +} + // NodeTemplatesAPIFilterInstanceTypesWithBodyWithResponse request with arbitrary body returning *NodeTemplatesAPIFilterInstanceTypesResponse func (c *ClientWithResponses) NodeTemplatesAPIFilterInstanceTypesWithBodyWithResponse(ctx context.Context, clusterId string, contentType string, body io.Reader) (*NodeTemplatesAPIFilterInstanceTypesResponse, error) { rsp, err := c.NodeTemplatesAPIFilterInstanceTypesWithBody(ctx, clusterId, contentType, body) @@ -8692,6 +8911,58 @@ func ParseClaimInvitationResponse(rsp *http.Response) (*ClaimInvitationResponse, return response, nil } +// ParseEvictorAPIGetAdvancedConfigResponse parses an HTTP response from a EvictorAPIGetAdvancedConfigWithResponse call +func ParseEvictorAPIGetAdvancedConfigResponse(rsp *http.Response) (*EvictorAPIGetAdvancedConfigResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer rsp.Body.Close() + if err != nil { + return nil, err + } + + response := &EvictorAPIGetAdvancedConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CastaiEvictorV1AdvancedConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseEvictorAPIUpsertAdvancedConfigResponse parses an HTTP response from a EvictorAPIUpsertAdvancedConfigWithResponse call +func ParseEvictorAPIUpsertAdvancedConfigResponse(rsp *http.Response) (*EvictorAPIUpsertAdvancedConfigResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer rsp.Body.Close() + if err != nil { + return nil, err + } + + response := &EvictorAPIUpsertAdvancedConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CastaiEvictorV1AdvancedConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseNodeTemplatesAPIFilterInstanceTypesResponse parses an HTTP response from a NodeTemplatesAPIFilterInstanceTypesWithResponse call func ParseNodeTemplatesAPIFilterInstanceTypesResponse(rsp *http.Response) (*NodeTemplatesAPIFilterInstanceTypesResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) diff --git a/castai/sdk/mock/client.go b/castai/sdk/mock/client.go index 028c4af7..73d2782a 100644 --- a/castai/sdk/mock/client.go +++ b/castai/sdk/mock/client.go @@ -455,6 +455,66 @@ func (mr *MockClientInterfaceMockRecorder) DeleteOrganizationUser(ctx, id, userI return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteOrganizationUser", reflect.TypeOf((*MockClientInterface)(nil).DeleteOrganizationUser), varargs...) } +// EvictorAPIGetAdvancedConfig mocks base method. +func (m *MockClientInterface) EvictorAPIGetAdvancedConfig(ctx context.Context, clusterId string, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, clusterId} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "EvictorAPIGetAdvancedConfig", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EvictorAPIGetAdvancedConfig indicates an expected call of EvictorAPIGetAdvancedConfig. +func (mr *MockClientInterfaceMockRecorder) EvictorAPIGetAdvancedConfig(ctx, clusterId interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, clusterId}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvictorAPIGetAdvancedConfig", reflect.TypeOf((*MockClientInterface)(nil).EvictorAPIGetAdvancedConfig), varargs...) +} + +// EvictorAPIUpsertAdvancedConfig mocks base method. +func (m *MockClientInterface) EvictorAPIUpsertAdvancedConfig(ctx context.Context, clusterId string, body sdk.EvictorAPIUpsertAdvancedConfigJSONRequestBody, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, clusterId, body} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "EvictorAPIUpsertAdvancedConfig", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EvictorAPIUpsertAdvancedConfig indicates an expected call of EvictorAPIUpsertAdvancedConfig. +func (mr *MockClientInterfaceMockRecorder) EvictorAPIUpsertAdvancedConfig(ctx, clusterId, body interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, clusterId, body}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvictorAPIUpsertAdvancedConfig", reflect.TypeOf((*MockClientInterface)(nil).EvictorAPIUpsertAdvancedConfig), varargs...) +} + +// EvictorAPIUpsertAdvancedConfigWithBody mocks base method. +func (m *MockClientInterface) EvictorAPIUpsertAdvancedConfigWithBody(ctx context.Context, clusterId, contentType string, body io.Reader, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, clusterId, contentType, body} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "EvictorAPIUpsertAdvancedConfigWithBody", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EvictorAPIUpsertAdvancedConfigWithBody indicates an expected call of EvictorAPIUpsertAdvancedConfigWithBody. +func (mr *MockClientInterfaceMockRecorder) EvictorAPIUpsertAdvancedConfigWithBody(ctx, clusterId, contentType, body interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, clusterId, contentType, body}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvictorAPIUpsertAdvancedConfigWithBody", reflect.TypeOf((*MockClientInterface)(nil).EvictorAPIUpsertAdvancedConfigWithBody), varargs...) +} + // ExternalClusterAPIAddNode mocks base method. func (m *MockClientInterface) ExternalClusterAPIAddNode(ctx context.Context, clusterId string, body sdk.ExternalClusterAPIAddNodeJSONRequestBody, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() @@ -2483,6 +2543,51 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) DeleteOrganizationWithRe return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteOrganizationWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).DeleteOrganizationWithResponse), ctx, id) } +// EvictorAPIGetAdvancedConfigWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) EvictorAPIGetAdvancedConfigWithResponse(ctx context.Context, clusterId string) (*sdk.EvictorAPIGetAdvancedConfigResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EvictorAPIGetAdvancedConfigWithResponse", ctx, clusterId) + ret0, _ := ret[0].(*sdk.EvictorAPIGetAdvancedConfigResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EvictorAPIGetAdvancedConfigWithResponse indicates an expected call of EvictorAPIGetAdvancedConfigWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) EvictorAPIGetAdvancedConfigWithResponse(ctx, clusterId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvictorAPIGetAdvancedConfigWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).EvictorAPIGetAdvancedConfigWithResponse), ctx, clusterId) +} + +// EvictorAPIUpsertAdvancedConfigWithBodyWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) EvictorAPIUpsertAdvancedConfigWithBodyWithResponse(ctx context.Context, clusterId, contentType string, body io.Reader) (*sdk.EvictorAPIUpsertAdvancedConfigResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EvictorAPIUpsertAdvancedConfigWithBodyWithResponse", ctx, clusterId, contentType, body) + ret0, _ := ret[0].(*sdk.EvictorAPIUpsertAdvancedConfigResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EvictorAPIUpsertAdvancedConfigWithBodyWithResponse indicates an expected call of EvictorAPIUpsertAdvancedConfigWithBodyWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) EvictorAPIUpsertAdvancedConfigWithBodyWithResponse(ctx, clusterId, contentType, body interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvictorAPIUpsertAdvancedConfigWithBodyWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).EvictorAPIUpsertAdvancedConfigWithBodyWithResponse), ctx, clusterId, contentType, body) +} + +// EvictorAPIUpsertAdvancedConfigWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) EvictorAPIUpsertAdvancedConfigWithResponse(ctx context.Context, clusterId string, body sdk.EvictorAPIUpsertAdvancedConfigJSONRequestBody) (*sdk.EvictorAPIUpsertAdvancedConfigResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EvictorAPIUpsertAdvancedConfigWithResponse", ctx, clusterId, body) + ret0, _ := ret[0].(*sdk.EvictorAPIUpsertAdvancedConfigResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// EvictorAPIUpsertAdvancedConfigWithResponse indicates an expected call of EvictorAPIUpsertAdvancedConfigWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) EvictorAPIUpsertAdvancedConfigWithResponse(ctx, clusterId, body interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EvictorAPIUpsertAdvancedConfigWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).EvictorAPIUpsertAdvancedConfigWithResponse), ctx, clusterId, body) +} + // ExternalClusterAPIAddNodeWithBodyWithResponse mocks base method. func (m *MockClientWithResponsesInterface) ExternalClusterAPIAddNodeWithBodyWithResponse(ctx context.Context, clusterId, contentType string, body io.Reader) (*sdk.ExternalClusterAPIAddNodeResponse, error) { m.ctrl.T.Helper()