diff --git a/castai/sdk/api.gen.go b/castai/sdk/api.gen.go index a2b994e2..7116277a 100644 --- a/castai/sdk/api.gen.go +++ b/castai/sdk/api.gen.go @@ -1854,6 +1854,11 @@ type NodetemplatesV1FilterInstanceTypesResponse struct { AvailableInstanceTypes *[]NodetemplatesV1AvailableInstanceType `json:"availableInstanceTypes,omitempty"` } +// NodetemplatesV1GenerateNodeTemplatesResponse defines model for nodetemplates.v1.GenerateNodeTemplatesResponse. +type NodetemplatesV1GenerateNodeTemplatesResponse struct { + Items *[]NodetemplatesV1NodeTemplateListItem `json:"items,omitempty"` +} + // NodetemplatesV1Label defines model for nodetemplates.v1.Label. type NodetemplatesV1Label struct { Key *string `json:"key,omitempty"` diff --git a/castai/sdk/client.gen.go b/castai/sdk/client.gen.go index 33a1c432..c6595b3a 100644 --- a/castai/sdk/client.gen.go +++ b/castai/sdk/client.gen.go @@ -138,6 +138,9 @@ type ClientInterface interface { NodeTemplatesAPIFilterInstanceTypes(ctx context.Context, clusterId string, body NodeTemplatesAPIFilterInstanceTypesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // NodeTemplatesAPIGenerateNodeTemplates request + NodeTemplatesAPIGenerateNodeTemplates(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) + // NodeConfigurationAPIListConfigurations request NodeConfigurationAPIListConfigurations(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -629,6 +632,18 @@ func (c *Client) NodeTemplatesAPIFilterInstanceTypes(ctx context.Context, cluste return c.Client.Do(req) } +func (c *Client) NodeTemplatesAPIGenerateNodeTemplates(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewNodeTemplatesAPIGenerateNodeTemplatesRequest(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) NodeConfigurationAPIListConfigurations(ctx context.Context, clusterId string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewNodeConfigurationAPIListConfigurationsRequest(c.Server, clusterId) if err != nil { @@ -2343,6 +2358,40 @@ func NewNodeTemplatesAPIFilterInstanceTypesRequestWithBody(server string, cluste return req, nil } +// NewNodeTemplatesAPIGenerateNodeTemplatesRequest generates requests for NodeTemplatesAPIGenerateNodeTemplates +func NewNodeTemplatesAPIGenerateNodeTemplatesRequest(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/generate-node-templates", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewNodeConfigurationAPIListConfigurationsRequest generates requests for NodeConfigurationAPIListConfigurations func NewNodeConfigurationAPIListConfigurationsRequest(server string, clusterId string) (*http.Request, error) { var err error @@ -5522,6 +5571,9 @@ type ClientWithResponsesInterface interface { NodeTemplatesAPIFilterInstanceTypesWithResponse(ctx context.Context, clusterId string, body NodeTemplatesAPIFilterInstanceTypesJSONRequestBody) (*NodeTemplatesAPIFilterInstanceTypesResponse, error) + // NodeTemplatesAPIGenerateNodeTemplates request + NodeTemplatesAPIGenerateNodeTemplatesWithResponse(ctx context.Context, clusterId string) (*NodeTemplatesAPIGenerateNodeTemplatesResponse, error) + // NodeConfigurationAPIListConfigurations request NodeConfigurationAPIListConfigurationsWithResponse(ctx context.Context, clusterId string) (*NodeConfigurationAPIListConfigurationsResponse, error) @@ -6166,6 +6218,36 @@ func (r NodeTemplatesAPIFilterInstanceTypesResponse) GetBody() []byte { // TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 +type NodeTemplatesAPIGenerateNodeTemplatesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *NodetemplatesV1GenerateNodeTemplatesResponse +} + +// Status returns HTTPResponse.Status +func (r NodeTemplatesAPIGenerateNodeTemplatesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r NodeTemplatesAPIGenerateNodeTemplatesResponse) 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 NodeTemplatesAPIGenerateNodeTemplatesResponse) GetBody() []byte { + return r.Body +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 + type NodeConfigurationAPIListConfigurationsResponse struct { Body []byte HTTPResponse *http.Response @@ -8539,6 +8621,15 @@ func (c *ClientWithResponses) NodeTemplatesAPIFilterInstanceTypesWithResponse(ct return ParseNodeTemplatesAPIFilterInstanceTypesResponse(rsp) } +// NodeTemplatesAPIGenerateNodeTemplatesWithResponse request returning *NodeTemplatesAPIGenerateNodeTemplatesResponse +func (c *ClientWithResponses) NodeTemplatesAPIGenerateNodeTemplatesWithResponse(ctx context.Context, clusterId string) (*NodeTemplatesAPIGenerateNodeTemplatesResponse, error) { + rsp, err := c.NodeTemplatesAPIGenerateNodeTemplates(ctx, clusterId) + if err != nil { + return nil, err + } + return ParseNodeTemplatesAPIGenerateNodeTemplatesResponse(rsp) +} + // NodeConfigurationAPIListConfigurationsWithResponse request returning *NodeConfigurationAPIListConfigurationsResponse func (c *ClientWithResponses) NodeConfigurationAPIListConfigurationsWithResponse(ctx context.Context, clusterId string) (*NodeConfigurationAPIListConfigurationsResponse, error) { rsp, err := c.NodeConfigurationAPIListConfigurations(ctx, clusterId) @@ -9725,6 +9816,32 @@ func ParseNodeTemplatesAPIFilterInstanceTypesResponse(rsp *http.Response) (*Node return response, nil } +// ParseNodeTemplatesAPIGenerateNodeTemplatesResponse parses an HTTP response from a NodeTemplatesAPIGenerateNodeTemplatesWithResponse call +func ParseNodeTemplatesAPIGenerateNodeTemplatesResponse(rsp *http.Response) (*NodeTemplatesAPIGenerateNodeTemplatesResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer rsp.Body.Close() + if err != nil { + return nil, err + } + + response := &NodeTemplatesAPIGenerateNodeTemplatesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest NodetemplatesV1GenerateNodeTemplatesResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseNodeConfigurationAPIListConfigurationsResponse parses an HTTP response from a NodeConfigurationAPIListConfigurationsWithResponse call func ParseNodeConfigurationAPIListConfigurationsResponse(rsp *http.Response) (*NodeConfigurationAPIListConfigurationsResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) diff --git a/castai/sdk/mock/client.go b/castai/sdk/mock/client.go index 95bd76f6..a134930f 100644 --- a/castai/sdk/mock/client.go +++ b/castai/sdk/mock/client.go @@ -1355,6 +1355,26 @@ func (mr *MockClientInterfaceMockRecorder) NodeTemplatesAPIFilterInstanceTypesWi return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NodeTemplatesAPIFilterInstanceTypesWithBody", reflect.TypeOf((*MockClientInterface)(nil).NodeTemplatesAPIFilterInstanceTypesWithBody), varargs...) } +// NodeTemplatesAPIGenerateNodeTemplates mocks base method. +func (m *MockClientInterface) NodeTemplatesAPIGenerateNodeTemplates(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, "NodeTemplatesAPIGenerateNodeTemplates", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// NodeTemplatesAPIGenerateNodeTemplates indicates an expected call of NodeTemplatesAPIGenerateNodeTemplates. +func (mr *MockClientInterfaceMockRecorder) NodeTemplatesAPIGenerateNodeTemplates(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, "NodeTemplatesAPIGenerateNodeTemplates", reflect.TypeOf((*MockClientInterface)(nil).NodeTemplatesAPIGenerateNodeTemplates), varargs...) +} + // NodeTemplatesAPIListNodeTemplates mocks base method. func (m *MockClientInterface) NodeTemplatesAPIListNodeTemplates(ctx context.Context, clusterId string, params *sdk.NodeTemplatesAPIListNodeTemplatesParams, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() @@ -3418,6 +3438,21 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) NodeTemplatesAPIFilterIn return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NodeTemplatesAPIFilterInstanceTypesWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).NodeTemplatesAPIFilterInstanceTypesWithResponse), ctx, clusterId, body) } +// NodeTemplatesAPIGenerateNodeTemplatesWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) NodeTemplatesAPIGenerateNodeTemplatesWithResponse(ctx context.Context, clusterId string) (*sdk.NodeTemplatesAPIGenerateNodeTemplatesResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NodeTemplatesAPIGenerateNodeTemplatesWithResponse", ctx, clusterId) + ret0, _ := ret[0].(*sdk.NodeTemplatesAPIGenerateNodeTemplatesResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// NodeTemplatesAPIGenerateNodeTemplatesWithResponse indicates an expected call of NodeTemplatesAPIGenerateNodeTemplatesWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) NodeTemplatesAPIGenerateNodeTemplatesWithResponse(ctx, clusterId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NodeTemplatesAPIGenerateNodeTemplatesWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).NodeTemplatesAPIGenerateNodeTemplatesWithResponse), ctx, clusterId) +} + // NodeTemplatesAPIListNodeTemplatesWithResponse mocks base method. func (m *MockClientWithResponsesInterface) NodeTemplatesAPIListNodeTemplatesWithResponse(ctx context.Context, clusterId string, params *sdk.NodeTemplatesAPIListNodeTemplatesParams) (*sdk.NodeTemplatesAPIListNodeTemplatesResponse, error) { m.ctrl.T.Helper() diff --git a/examples/eks/eks_cluster_autoscaler_policies/castai.tf b/examples/eks/eks_cluster_autoscaler_policies/castai.tf index 8fca4f88..022374c2 100644 --- a/examples/eks/eks_cluster_autoscaler_policies/castai.tf +++ b/examples/eks/eks_cluster_autoscaler_policies/castai.tf @@ -98,6 +98,10 @@ module "castai-eks-cluster" { volume_iops = 3100 volume_throughput = 130 imds_v1 = true + target_group = { + arn = "arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067" + port = 80 + } } }