diff --git a/castai/resource_node_configuration.go b/castai/resource_node_configuration.go index eb092fb1..0f978d30 100644 --- a/castai/resource_node_configuration.go +++ b/castai/resource_node_configuration.go @@ -717,11 +717,11 @@ func toEKSImageFamily(v string) *sdk.NodeconfigV1EKSConfigImageFamily { switch strings.ToLower(v) { case eksImageFamilyAL2: - return lo.ToPtr(sdk.FAMILYAL2) + return lo.ToPtr(sdk.NodeconfigV1EKSConfigImageFamilyFamilyAl2) case eksImageFamilyAL2023: - return lo.ToPtr(sdk.FAMILYAL2023) + return lo.ToPtr(sdk.NodeconfigV1EKSConfigImageFamilyFAMILYAL2023) case eksImageFamilyBottlerocket: - return lo.ToPtr(sdk.FAMILYBOTTLEROCKET) + return lo.ToPtr(sdk.NodeconfigV1EKSConfigImageFamilyFAMILYBOTTLEROCKET) default: return nil } @@ -801,11 +801,11 @@ func flattenEKSConfig(config *sdk.NodeconfigV1EKSConfig) []map[string]interface{ func fromEKSImageFamily(family sdk.NodeconfigV1EKSConfigImageFamily) string { switch family { - case sdk.FAMILYBOTTLEROCKET, sdk.FamilyBottlerocket: + case sdk.NodeconfigV1EKSConfigImageFamilyFAMILYBOTTLEROCKET, sdk.NodeconfigV1EKSConfigImageFamilyFamilyBottlerocket: return eksImageFamilyBottlerocket - case sdk.FAMILYAL2, sdk.FamilyAl2: + case sdk.NodeconfigV1EKSConfigImageFamilyFAMILYAL2, sdk.NodeconfigV1EKSConfigImageFamilyFamilyAl2: return eksImageFamilyAL2 - case sdk.FAMILYAL2023, sdk.FamilyAl2023: + case sdk.NodeconfigV1EKSConfigImageFamilyFAMILYAL2023, sdk.NodeconfigV1EKSConfigImageFamilyFamilyAl2023: return eksImageFamilyAL2023 default: return "" diff --git a/castai/resource_node_template.go b/castai/resource_node_template.go index c4b5ddf1..69e16051 100644 --- a/castai/resource_node_template.go +++ b/castai/resource_node_template.go @@ -69,6 +69,7 @@ const ( FieldNodeTemplateAffinityValuesName = "values" FieldNodeTemplateBurstableInstances = "burstable_instances" FieldNodeTemplateCustomerSpecific = "customer_specific" + FieldNodeTemplateCPUManufacturers = "cpu_manufacturers" ) const ( @@ -116,6 +117,7 @@ func resourceNodeTemplate() *schema.Resource { supportedArchitectures := []string{ArchAMD64, ArchARM64} supportedOs := []string{OsLinux, OsWindows} supportedSelectorOperations := nodeSelectorOperators + supportedCPUManufacturers := []string{string(sdk.AMD), string(sdk.AMPERE), string(sdk.APPLE), string(sdk.AWS), string(sdk.INTEL)} return &schema.Resource{ CreateContext: resourceNodeTemplateCreate, @@ -498,6 +500,16 @@ func resourceNodeTemplate() *schema.Resource { Description: "Will include customer specific (preview) instances when enabled otherwise they will be excluded. Supported values: `enabled`, `disabled` or ``.", ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice([]string{"", Enabled, Disabled}, false)), }, + FieldNodeTemplateCPUManufacturers: { + Type: schema.TypeList, + MinItems: 1, + Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateDiagFunc: validation.ToDiagFunc(validation.StringInSlice(supportedCPUManufacturers, false)), + }, + Description: fmt.Sprintf("List of acceptable CPU manufacturers. Allowed values: %s.", strings.Join(supportedCPUManufacturers, ", ")), + }, }, }, }, @@ -714,6 +726,9 @@ func flattenConstraints(c *sdk.NodetemplatesV1TemplateConstraints) ([]map[string if c.Azs != nil { out[FieldNodeTemplateAZs] = lo.FromPtr(c.Azs) } + if c.CpuManufacturers != nil { + out[FieldNodeTemplateCPUManufacturers] = lo.FromPtr(c.CpuManufacturers) + } setStateConstraintValue(c.Burstable, FieldNodeTemplateBurstableInstances, out) setStateConstraintValue(c.CustomerSpecific, FieldNodeTemplateCustomerSpecific, out) return []map[string]any{out}, nil @@ -1289,6 +1304,12 @@ func toTemplateConstraints(obj map[string]any) *sdk.NodetemplatesV1TemplateConst } } + if v, ok := obj[FieldNodeTemplateCPUManufacturers].([]any); ok { + out.CpuManufacturers = toPtr(lo.Map(v, func(item any, _ int) sdk.NodetemplatesV1TemplateConstraintsCPUManufacturer { + return sdk.NodetemplatesV1TemplateConstraintsCPUManufacturer(item.(string)) + })) + } + return out } diff --git a/castai/resource_node_template_test.go b/castai/resource_node_template_test.go index 1ed3e41f..944f9ee8 100644 --- a/castai/resource_node_template_test.go +++ b/castai/resource_node_template_test.go @@ -102,7 +102,8 @@ func TestNodeTemplateResourceReadContext(t *testing.T) { } ] } - ] + ], + "cpuManufacturers": ["INTEL", "AMD"] }, "version": "3", "shouldTaint": true, @@ -161,6 +162,9 @@ constraints.0.azs.1 = us-west-2b constraints.0.azs.2 = us-west-2c constraints.0.compute_optimized = false constraints.0.compute_optimized_state = disabled +constraints.0.cpu_manufacturers.# = 2 +constraints.0.cpu_manufacturers.0 = INTEL +constraints.0.cpu_manufacturers.1 = AMD constraints.0.custom_priority.# = 1 constraints.0.custom_priority.0.instance_families.# = 2 constraints.0.custom_priority.0.instance_families.0 = a @@ -556,6 +560,9 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "constraints.0.dedicated_node_affinity.#", "0"), resource.TestCheckResourceAttr(resourceName, "constraints.0.storage_optimized_state", "disabled"), resource.TestCheckResourceAttr(resourceName, "constraints.0.compute_optimized_state", ""), + resource.TestCheckResourceAttr(resourceName, "constraints.0.cpu_manufacturers.#", "2"), + resource.TestCheckResourceAttr(resourceName, "constraints.0.cpu_manufacturers.0", "INTEL"), + resource.TestCheckResourceAttr(resourceName, "constraints.0.cpu_manufacturers.1", "AMD"), ), }, { @@ -622,6 +629,9 @@ func TestAccResourceNodeTemplate_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "constraints.0.compute_optimized_state", "disabled"), resource.TestCheckResourceAttr(resourceName, "constraints.0.burstable_instances", "enabled"), resource.TestCheckResourceAttr(resourceName, "constraints.0.customer_specific", "enabled"), + resource.TestCheckResourceAttr(resourceName, "constraints.0.cpu_manufacturers.#", "2"), + resource.TestCheckResourceAttr(resourceName, "constraints.0.cpu_manufacturers.0", "INTEL"), + resource.TestCheckResourceAttr(resourceName, "constraints.0.cpu_manufacturers.1", "AMD"), ), }, }, @@ -696,6 +706,8 @@ func testAccNodeTemplateConfig(rName, clusterName string) string { spot = true on_demand = true } + + cpu_manufacturers = ["INTEL", "AMD"] } } `, rName)) @@ -750,6 +762,8 @@ func testNodeTemplateUpdated(rName, clusterName string) string { spot = true on_demand = true } + + cpu_manufacturers = ["INTEL", "AMD"] } } `, rName)) diff --git a/castai/resource_organization_members.go b/castai/resource_organization_members.go index 55e71460..991a628a 100644 --- a/castai/resource_organization_members.go +++ b/castai/resource_organization_members.go @@ -5,10 +5,11 @@ import ( "fmt" "time" - "github.com/castai/terraform-provider-castai/castai/sdk" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/samber/lo" + + "github.com/castai/terraform-provider-castai/castai/sdk" ) const ( @@ -142,7 +143,7 @@ func resourceOrganizationMembersRead(ctx context.Context, data *schema.ResourceD client := meta.(*ProviderConfig).api organizationID := data.Id() - usersResp, err := client.UsersAPIListOrganizationUsersWithResponse(ctx, organizationID) + usersResp, err := client.UsersAPIListOrganizationUsersWithResponse(ctx, organizationID, &sdk.UsersAPIListOrganizationUsersParams{}) if err := sdk.CheckOKResponse(usersResp, err); err != nil { return diag.FromErr(fmt.Errorf("retrieving users: %w", err)) } @@ -208,7 +209,7 @@ func resourceOrganizationMembersUpdate(ctx context.Context, data *schema.Resourc client := meta.(*ProviderConfig).api organizationID := data.Id() - usersResp, err := client.UsersAPIListOrganizationUsersWithResponse(ctx, organizationID) + usersResp, err := client.UsersAPIListOrganizationUsersWithResponse(ctx, organizationID, &sdk.UsersAPIListOrganizationUsersParams{}) if err := sdk.CheckOKResponse(usersResp, err); err != nil { return diag.FromErr(fmt.Errorf("retrieving users: %w", err)) } @@ -308,7 +309,7 @@ func resourceOrganizationMembersDelete(ctx context.Context, data *schema.Resourc return diag.FromErr(fmt.Errorf("retrieving current user profile: %w", err)) } - usersResp, err := client.UsersAPIListOrganizationUsersWithResponse(ctx, organizationID) + usersResp, err := client.UsersAPIListOrganizationUsersWithResponse(ctx, organizationID, &sdk.UsersAPIListOrganizationUsersParams{}) if err := sdk.CheckOKResponse(usersResp, err); err != nil { return diag.FromErr(fmt.Errorf("retrieving users: %w", err)) } diff --git a/castai/resource_organization_members_test.go b/castai/resource_organization_members_test.go index 1d259481..5cb13c0e 100644 --- a/castai/resource_organization_members_test.go +++ b/castai/resource_organization_members_test.go @@ -71,7 +71,7 @@ func TestOrganizationResourceReadContext(t *testing.T) { "invitations": [] }`))) mockClient.EXPECT(). - UsersAPIListOrganizationUsers(gomock.Any(), organizationID). + UsersAPIListOrganizationUsers(gomock.Any(), organizationID, &sdk.UsersAPIListOrganizationUsersParams{}). Return(&http.Response{StatusCode: 200, Body: body, Header: map[string][]string{"Content-Type": {"json"}}}, nil) mockClient.EXPECT(). diff --git a/castai/sdk/api.gen.go b/castai/sdk/api.gen.go index b33eab8f..02f8c2f3 100644 --- a/castai/sdk/api.gen.go +++ b/castai/sdk/api.gen.go @@ -149,6 +149,19 @@ const ( NotIn1 K8sSelectorV1Operator = "notIn" ) +// Defines values for NodeconfigV1AKSConfigImageFamily. +const ( + NodeconfigV1AKSConfigImageFamilyFAMILYAZURELINUX NodeconfigV1AKSConfigImageFamily = "FAMILY_AZURE_LINUX" + NodeconfigV1AKSConfigImageFamilyFAMILYUBUNTU NodeconfigV1AKSConfigImageFamily = "FAMILY_UBUNTU" + NodeconfigV1AKSConfigImageFamilyFAMILYUNSPECIFIED NodeconfigV1AKSConfigImageFamily = "FAMILY_UNSPECIFIED" + NodeconfigV1AKSConfigImageFamilyFAMILYWINDOWS2019 NodeconfigV1AKSConfigImageFamily = "FAMILY_WINDOWS_2019" + NodeconfigV1AKSConfigImageFamilyFAMILYWINDOWS2022 NodeconfigV1AKSConfigImageFamily = "FAMILY_WINDOWS_2022" + NodeconfigV1AKSConfigImageFamilyFamilyAzureLinux NodeconfigV1AKSConfigImageFamily = "family_azure_linux" + NodeconfigV1AKSConfigImageFamilyFamilyUbuntu NodeconfigV1AKSConfigImageFamily = "family_ubuntu" + NodeconfigV1AKSConfigImageFamilyFamilyWindows2019 NodeconfigV1AKSConfigImageFamily = "family_windows_2019" + NodeconfigV1AKSConfigImageFamilyFamilyWindows2022 NodeconfigV1AKSConfigImageFamily = "family_windows_2022" +) + // Defines values for NodeconfigV1AKSConfigOsDiskType. const ( OSDISKTYPEPREMIUMSSD NodeconfigV1AKSConfigOsDiskType = "OS_DISK_TYPE_PREMIUM_SSD" @@ -169,13 +182,13 @@ const ( // Defines values for NodeconfigV1EKSConfigImageFamily. const ( - FAMILYAL2 NodeconfigV1EKSConfigImageFamily = "FAMILY_AL2" - FAMILYAL2023 NodeconfigV1EKSConfigImageFamily = "FAMILY_AL2023" - FAMILYBOTTLEROCKET NodeconfigV1EKSConfigImageFamily = "FAMILY_BOTTLEROCKET" - FAMILYUNSPECIFIED NodeconfigV1EKSConfigImageFamily = "FAMILY_UNSPECIFIED" - FamilyAl2 NodeconfigV1EKSConfigImageFamily = "family_al2" - FamilyAl2023 NodeconfigV1EKSConfigImageFamily = "family_al2023" - FamilyBottlerocket NodeconfigV1EKSConfigImageFamily = "family_bottlerocket" + NodeconfigV1EKSConfigImageFamilyFAMILYAL2 NodeconfigV1EKSConfigImageFamily = "FAMILY_AL2" + NodeconfigV1EKSConfigImageFamilyFAMILYAL2023 NodeconfigV1EKSConfigImageFamily = "FAMILY_AL2023" + NodeconfigV1EKSConfigImageFamilyFAMILYBOTTLEROCKET NodeconfigV1EKSConfigImageFamily = "FAMILY_BOTTLEROCKET" + NodeconfigV1EKSConfigImageFamilyFAMILYUNSPECIFIED NodeconfigV1EKSConfigImageFamily = "FAMILY_UNSPECIFIED" + NodeconfigV1EKSConfigImageFamilyFamilyAl2 NodeconfigV1EKSConfigImageFamily = "family_al2" + NodeconfigV1EKSConfigImageFamilyFamilyAl2023 NodeconfigV1EKSConfigImageFamily = "family_al2023" + NodeconfigV1EKSConfigImageFamilyFamilyBottlerocket NodeconfigV1EKSConfigImageFamily = "family_bottlerocket" ) // Defines values for NodetemplatesV1AvailableInstanceTypeOs. @@ -198,6 +211,15 @@ const ( NoSchedule NodetemplatesV1TaintEffect = "NoSchedule" ) +// Defines values for NodetemplatesV1TemplateConstraintsCPUManufacturer. +const ( + AMD NodetemplatesV1TemplateConstraintsCPUManufacturer = "AMD" + AMPERE NodetemplatesV1TemplateConstraintsCPUManufacturer = "AMPERE" + APPLE NodetemplatesV1TemplateConstraintsCPUManufacturer = "APPLE" + AWS NodetemplatesV1TemplateConstraintsCPUManufacturer = "AWS" + INTEL NodetemplatesV1TemplateConstraintsCPUManufacturer = "INTEL" +) + // Defines values for NodetemplatesV1TemplateConstraintsConstraintState. const ( DISABLED NodetemplatesV1TemplateConstraintsConstraintState = "DISABLED" @@ -1254,8 +1276,9 @@ type CastaiUsersV1beta1ListOrganizationsResponse struct { // Membership describes user-organization membership details. type CastaiUsersV1beta1Membership struct { - Groups *[]CastaiUsersV1beta1GroupRef `json:"groups,omitempty"` - Role string `json:"role"` + CreatedAt *time.Time `json:"createdAt,omitempty"` + Groups *[]CastaiUsersV1beta1GroupRef `json:"groups,omitempty"` + Role string `json:"role"` // User represents a single system user. User CastaiUsersV1beta1User `json:"user"` @@ -2023,6 +2046,9 @@ type K8sSelectorV1Operator string // NodeconfigV1AKSConfig defines model for nodeconfig.v1.AKSConfig. type NodeconfigV1AKSConfig struct { + // List of supported image families (OSes) for AKS. + ImageFamily *NodeconfigV1AKSConfigImageFamily `json:"imageFamily,omitempty"` + // Maximum number of pods that can be run on a node, which affects how many IP addresses you will need for each node. // Defaults to 30. Values between 10 and 250 are allowed. // Setting values above 110 will require specific CNI configuration. Please refer to Microsoft documentation for additional guidance. @@ -2032,6 +2058,9 @@ type NodeconfigV1AKSConfig struct { OsDiskType *NodeconfigV1AKSConfigOsDiskType `json:"osDiskType,omitempty"` } +// List of supported image families (OSes) for AKS. +type NodeconfigV1AKSConfigImageFamily string + // OsDiskType represent possible values for AKS node os disk type(this is subset of all available Azure disk types). type NodeconfigV1AKSConfigOsDiskType string @@ -2356,6 +2385,7 @@ type NodetemplatesV1AvailableInstanceType struct { Burstable *bool `json:"burstable,omitempty"` Cpu *string `json:"cpu,omitempty"` CpuCost *float64 `json:"cpuCost,omitempty"` + CpuManufacturers *[]string `json:"cpuManufacturers,omitempty"` CustomerSpecific *bool `json:"customerSpecific,omitempty"` Family *string `json:"family,omitempty"` IsBareMetal *bool `json:"isBareMetal,omitempty"` @@ -2528,6 +2558,9 @@ type NodetemplatesV1TemplateConstraints struct { Burstable *NodetemplatesV1TemplateConstraintsConstraintState `json:"burstable,omitempty"` ComputeOptimized *bool `json:"computeOptimized"` + // Describes the manufacturers of the CPUs the instance type can be equipped with. + CpuManufacturers *[]NodetemplatesV1TemplateConstraintsCPUManufacturer `json:"cpuManufacturers,omitempty"` + // Custom sorting priority - instances matching defined rules will take priority over other candidates. CustomPriority *[]NodetemplatesV1TemplateConstraintsCustomPriority `json:"customPriority,omitempty"` @@ -2599,6 +2632,9 @@ type NodetemplatesV1TemplateConstraints struct { UseSpotFallbacks *bool `json:"useSpotFallbacks"` } +// NodetemplatesV1TemplateConstraintsCPUManufacturer defines model for nodetemplates.v1.TemplateConstraints.CPUManufacturer. +type NodetemplatesV1TemplateConstraintsCPUManufacturer string + // - DISABLED: The constraint is disabled // - ENABLED: The constraint is enabled type NodetemplatesV1TemplateConstraintsConstraintState string @@ -3293,8 +3329,9 @@ type WorkloadoptimizationV1PodMetrics struct { // WorkloadoptimizationV1RecommendationAppliedEvent defines model for workloadoptimization.v1.RecommendationAppliedEvent. type WorkloadoptimizationV1RecommendationAppliedEvent struct { - Current WorkloadoptimizationV1RecommendationAppliedEventChange `json:"current"` - Previous WorkloadoptimizationV1RecommendationAppliedEventChange `json:"previous"` + ApplyType WorkloadoptimizationV1ApplyType `json:"applyType"` + Current WorkloadoptimizationV1RecommendationAppliedEventChange `json:"current"` + Previous WorkloadoptimizationV1RecommendationAppliedEventChange `json:"previous"` } // WorkloadoptimizationV1RecommendationAppliedEventChange defines model for workloadoptimization.v1.RecommendationAppliedEvent.Change. @@ -3644,17 +3681,18 @@ type WorkloadoptimizationV1WorkloadRecommendation struct { // WorkloadoptimizationV1WorkloadScalingPolicy defines model for workloadoptimization.v1.WorkloadScalingPolicy. type WorkloadoptimizationV1WorkloadScalingPolicy struct { - ApplyType WorkloadoptimizationV1ApplyType `json:"applyType"` - ClusterId string `json:"clusterId"` - ConfidenceThreshold float64 `json:"confidenceThreshold"` - CreatedAt time.Time `json:"createdAt"` - Id string `json:"id"` - IsDefault bool `json:"isDefault"` - IsReadonly bool `json:"isReadonly"` - Name string `json:"name"` - OrganizationId string `json:"organizationId"` - RecommendationPolicies WorkloadoptimizationV1RecommendationPolicies `json:"recommendationPolicies"` - UpdatedAt time.Time `json:"updatedAt"` + ApplyType WorkloadoptimizationV1ApplyType `json:"applyType"` + ClusterId string `json:"clusterId"` + ConfidenceThreshold float64 `json:"confidenceThreshold"` + CreatedAt time.Time `json:"createdAt"` + HasWorkloadsConfiguredByAnnotations bool `json:"hasWorkloadsConfiguredByAnnotations"` + Id string `json:"id"` + IsDefault bool `json:"isDefault"` + IsReadonly bool `json:"isReadonly"` + Name string `json:"name"` + OrganizationId string `json:"organizationId"` + RecommendationPolicies WorkloadoptimizationV1RecommendationPolicies `json:"recommendationPolicies"` + UpdatedAt time.Time `json:"updatedAt"` } // AuthTokenAPIListAuthTokensParams defines parameters for AuthTokenAPIListAuthTokens. @@ -3837,6 +3875,12 @@ type UsersAPIRemoveOrganizationUsersParams struct { Users []string `form:"users" json:"users"` } +// UsersAPIListOrganizationUsersParams defines parameters for UsersAPIListOrganizationUsers. +type UsersAPIListOrganizationUsersParams struct { + // IncludeGroups is the flag to include group membership in the response. + IncludeGroups *bool `form:"includeGroups,omitempty" json:"includeGroups,omitempty"` +} + // UsersAPIAddUserToOrganizationJSONBody defines parameters for UsersAPIAddUserToOrganization. type UsersAPIAddUserToOrganizationJSONBody = CastaiUsersV1beta1NewMembership diff --git a/castai/sdk/client.gen.go b/castai/sdk/client.gen.go index e0d3aa22..f540eb6a 100644 --- a/castai/sdk/client.gen.go +++ b/castai/sdk/client.gen.go @@ -362,7 +362,7 @@ type ClientInterface interface { UsersAPIRemoveOrganizationUsers(ctx context.Context, organizationId string, params *UsersAPIRemoveOrganizationUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error) // UsersAPIListOrganizationUsers request - UsersAPIListOrganizationUsers(ctx context.Context, organizationId string, reqEditors ...RequestEditorFn) (*http.Response, error) + UsersAPIListOrganizationUsers(ctx context.Context, organizationId string, params *UsersAPIListOrganizationUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error) // UsersAPIAddUserToOrganization request with any body UsersAPIAddUserToOrganizationWithBody(ctx context.Context, organizationId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -377,6 +377,9 @@ type ClientInterface interface { UsersAPIUpdateOrganizationUser(ctx context.Context, organizationId string, userId string, body UsersAPIUpdateOrganizationUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // UsersAPIListUserGroups request + UsersAPIListUserGroups(ctx context.Context, organizationId string, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) + // ScheduledRebalancingAPIListRebalancingSchedules request ScheduledRebalancingAPIListRebalancingSchedules(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1715,8 +1718,8 @@ func (c *Client) UsersAPIRemoveOrganizationUsers(ctx context.Context, organizati return c.Client.Do(req) } -func (c *Client) UsersAPIListOrganizationUsers(ctx context.Context, organizationId string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUsersAPIListOrganizationUsersRequest(c.Server, organizationId) +func (c *Client) UsersAPIListOrganizationUsers(ctx context.Context, organizationId string, params *UsersAPIListOrganizationUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUsersAPIListOrganizationUsersRequest(c.Server, organizationId, params) if err != nil { return nil, err } @@ -1787,6 +1790,18 @@ func (c *Client) UsersAPIUpdateOrganizationUser(ctx context.Context, organizatio return c.Client.Do(req) } +func (c *Client) UsersAPIListUserGroups(ctx context.Context, organizationId string, userId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUsersAPIListUserGroupsRequest(c.Server, organizationId, userId) + 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) ScheduledRebalancingAPIListRebalancingSchedules(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewScheduledRebalancingAPIListRebalancingSchedulesRequest(c.Server) if err != nil { @@ -5784,7 +5799,7 @@ func NewUsersAPIRemoveOrganizationUsersRequest(server string, organizationId str } // NewUsersAPIListOrganizationUsersRequest generates requests for UsersAPIListOrganizationUsers -func NewUsersAPIListOrganizationUsersRequest(server string, organizationId string) (*http.Request, error) { +func NewUsersAPIListOrganizationUsersRequest(server string, organizationId string, params *UsersAPIListOrganizationUsersParams) (*http.Request, error) { var err error var pathParam0 string @@ -5809,6 +5824,26 @@ func NewUsersAPIListOrganizationUsersRequest(server string, organizationId strin return nil, err } + queryValues := queryURL.Query() + + if params.IncludeGroups != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "includeGroups", runtime.ParamLocationQuery, *params.IncludeGroups); 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 @@ -5959,6 +5994,47 @@ func NewUsersAPIUpdateOrganizationUserRequestWithBody(server string, organizatio return req, nil } +// NewUsersAPIListUserGroupsRequest generates requests for UsersAPIListUserGroups +func NewUsersAPIListUserGroupsRequest(server string, organizationId string, userId 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 + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userId", runtime.ParamLocationPath, userId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/organizations/%s/users/%s/groups", pathParam0, pathParam1) + 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 +} + // NewScheduledRebalancingAPIListRebalancingSchedulesRequest generates requests for ScheduledRebalancingAPIListRebalancingSchedules func NewScheduledRebalancingAPIListRebalancingSchedulesRequest(server string) (*http.Request, error) { var err error @@ -8165,7 +8241,7 @@ type ClientWithResponsesInterface interface { UsersAPIRemoveOrganizationUsersWithResponse(ctx context.Context, organizationId string, params *UsersAPIRemoveOrganizationUsersParams) (*UsersAPIRemoveOrganizationUsersResponse, error) // UsersAPIListOrganizationUsers request - UsersAPIListOrganizationUsersWithResponse(ctx context.Context, organizationId string) (*UsersAPIListOrganizationUsersResponse, error) + UsersAPIListOrganizationUsersWithResponse(ctx context.Context, organizationId string, params *UsersAPIListOrganizationUsersParams) (*UsersAPIListOrganizationUsersResponse, error) // UsersAPIAddUserToOrganization request with any body UsersAPIAddUserToOrganizationWithBodyWithResponse(ctx context.Context, organizationId string, contentType string, body io.Reader) (*UsersAPIAddUserToOrganizationResponse, error) @@ -8180,6 +8256,9 @@ type ClientWithResponsesInterface interface { UsersAPIUpdateOrganizationUserWithResponse(ctx context.Context, organizationId string, userId string, body UsersAPIUpdateOrganizationUserJSONRequestBody) (*UsersAPIUpdateOrganizationUserResponse, error) + // UsersAPIListUserGroups request + UsersAPIListUserGroupsWithResponse(ctx context.Context, organizationId string, userId string) (*UsersAPIListUserGroupsResponse, error) + // ScheduledRebalancingAPIListRebalancingSchedules request ScheduledRebalancingAPIListRebalancingSchedulesWithResponse(ctx context.Context) (*ScheduledRebalancingAPIListRebalancingSchedulesResponse, error) @@ -10648,6 +10727,36 @@ func (r UsersAPIUpdateOrganizationUserResponse) GetBody() []byte { // TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 +type UsersAPIListUserGroupsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]CastaiUsersV1beta1GroupRef +} + +// Status returns HTTPResponse.Status +func (r UsersAPIListUserGroupsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UsersAPIListUserGroupsResponse) 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 UsersAPIListUserGroupsResponse) GetBody() []byte { + return r.Body +} + +// TODO: to have common interface. https://github.com/deepmap/oapi-codegen/issues/240 + type ScheduledRebalancingAPIListRebalancingSchedulesResponse struct { Body []byte HTTPResponse *http.Response @@ -12740,8 +12849,8 @@ func (c *ClientWithResponses) UsersAPIRemoveOrganizationUsersWithResponse(ctx co } // UsersAPIListOrganizationUsersWithResponse request returning *UsersAPIListOrganizationUsersResponse -func (c *ClientWithResponses) UsersAPIListOrganizationUsersWithResponse(ctx context.Context, organizationId string) (*UsersAPIListOrganizationUsersResponse, error) { - rsp, err := c.UsersAPIListOrganizationUsers(ctx, organizationId) +func (c *ClientWithResponses) UsersAPIListOrganizationUsersWithResponse(ctx context.Context, organizationId string, params *UsersAPIListOrganizationUsersParams) (*UsersAPIListOrganizationUsersResponse, error) { + rsp, err := c.UsersAPIListOrganizationUsers(ctx, organizationId, params) if err != nil { return nil, err } @@ -12791,6 +12900,15 @@ func (c *ClientWithResponses) UsersAPIUpdateOrganizationUserWithResponse(ctx con return ParseUsersAPIUpdateOrganizationUserResponse(rsp) } +// UsersAPIListUserGroupsWithResponse request returning *UsersAPIListUserGroupsResponse +func (c *ClientWithResponses) UsersAPIListUserGroupsWithResponse(ctx context.Context, organizationId string, userId string) (*UsersAPIListUserGroupsResponse, error) { + rsp, err := c.UsersAPIListUserGroups(ctx, organizationId, userId) + if err != nil { + return nil, err + } + return ParseUsersAPIListUserGroupsResponse(rsp) +} + // ScheduledRebalancingAPIListRebalancingSchedulesWithResponse request returning *ScheduledRebalancingAPIListRebalancingSchedulesResponse func (c *ClientWithResponses) ScheduledRebalancingAPIListRebalancingSchedulesWithResponse(ctx context.Context) (*ScheduledRebalancingAPIListRebalancingSchedulesResponse, error) { rsp, err := c.ScheduledRebalancingAPIListRebalancingSchedules(ctx) @@ -15256,6 +15374,32 @@ func ParseUsersAPIUpdateOrganizationUserResponse(rsp *http.Response) (*UsersAPIU return response, nil } +// ParseUsersAPIListUserGroupsResponse parses an HTTP response from a UsersAPIListUserGroupsWithResponse call +func ParseUsersAPIListUserGroupsResponse(rsp *http.Response) (*UsersAPIListUserGroupsResponse, error) { + bodyBytes, err := ioutil.ReadAll(rsp.Body) + defer rsp.Body.Close() + if err != nil { + return nil, err + } + + response := &UsersAPIListUserGroupsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []CastaiUsersV1beta1GroupRef + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseScheduledRebalancingAPIListRebalancingSchedulesResponse parses an HTTP response from a ScheduledRebalancingAPIListRebalancingSchedulesWithResponse call func ParseScheduledRebalancingAPIListRebalancingSchedulesResponse(rsp *http.Response) (*ScheduledRebalancingAPIListRebalancingSchedulesResponse, error) { bodyBytes, err := ioutil.ReadAll(rsp.Body) diff --git a/castai/sdk/mock/client.go b/castai/sdk/mock/client.go index e005d951..6fa4398d 100644 --- a/castai/sdk/mock/client.go +++ b/castai/sdk/mock/client.go @@ -2696,9 +2696,9 @@ func (mr *MockClientInterfaceMockRecorder) UsersAPIListInvitations(ctx, params i } // UsersAPIListOrganizationUsers mocks base method. -func (m *MockClientInterface) UsersAPIListOrganizationUsers(ctx context.Context, organizationId string, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { +func (m *MockClientInterface) UsersAPIListOrganizationUsers(ctx context.Context, organizationId string, params *sdk.UsersAPIListOrganizationUsersParams, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() - varargs := []interface{}{ctx, organizationId} + varargs := []interface{}{ctx, organizationId, params} for _, a := range reqEditors { varargs = append(varargs, a) } @@ -2709,9 +2709,9 @@ func (m *MockClientInterface) UsersAPIListOrganizationUsers(ctx context.Context, } // UsersAPIListOrganizationUsers indicates an expected call of UsersAPIListOrganizationUsers. -func (mr *MockClientInterfaceMockRecorder) UsersAPIListOrganizationUsers(ctx, organizationId interface{}, reqEditors ...interface{}) *gomock.Call { +func (mr *MockClientInterfaceMockRecorder) UsersAPIListOrganizationUsers(ctx, organizationId, params interface{}, reqEditors ...interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, organizationId}, reqEditors...) + varargs := append([]interface{}{ctx, organizationId, params}, reqEditors...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UsersAPIListOrganizationUsers", reflect.TypeOf((*MockClientInterface)(nil).UsersAPIListOrganizationUsers), varargs...) } @@ -2735,6 +2735,26 @@ func (mr *MockClientInterfaceMockRecorder) UsersAPIListOrganizations(ctx, params return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UsersAPIListOrganizations", reflect.TypeOf((*MockClientInterface)(nil).UsersAPIListOrganizations), varargs...) } +// UsersAPIListUserGroups mocks base method. +func (m *MockClientInterface) UsersAPIListUserGroups(ctx context.Context, organizationId, userId string, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { + m.ctrl.T.Helper() + varargs := []interface{}{ctx, organizationId, userId} + for _, a := range reqEditors { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "UsersAPIListUserGroups", varargs...) + ret0, _ := ret[0].(*http.Response) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UsersAPIListUserGroups indicates an expected call of UsersAPIListUserGroups. +func (mr *MockClientInterfaceMockRecorder) UsersAPIListUserGroups(ctx, organizationId, userId interface{}, reqEditors ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + varargs := append([]interface{}{ctx, organizationId, userId}, reqEditors...) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UsersAPIListUserGroups", reflect.TypeOf((*MockClientInterface)(nil).UsersAPIListUserGroups), varargs...) +} + // UsersAPIRemoveOrganizationUsers mocks base method. func (m *MockClientInterface) UsersAPIRemoveOrganizationUsers(ctx context.Context, organizationId string, params *sdk.UsersAPIRemoveOrganizationUsersParams, reqEditors ...sdk.RequestEditorFn) (*http.Response, error) { m.ctrl.T.Helper() @@ -5244,18 +5264,18 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) UsersAPIListInvitationsW } // UsersAPIListOrganizationUsersWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) UsersAPIListOrganizationUsersWithResponse(ctx context.Context, organizationId string) (*sdk.UsersAPIListOrganizationUsersResponse, error) { +func (m *MockClientWithResponsesInterface) UsersAPIListOrganizationUsersWithResponse(ctx context.Context, organizationId string, params *sdk.UsersAPIListOrganizationUsersParams) (*sdk.UsersAPIListOrganizationUsersResponse, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UsersAPIListOrganizationUsersWithResponse", ctx, organizationId) + ret := m.ctrl.Call(m, "UsersAPIListOrganizationUsersWithResponse", ctx, organizationId, params) ret0, _ := ret[0].(*sdk.UsersAPIListOrganizationUsersResponse) ret1, _ := ret[1].(error) return ret0, ret1 } // UsersAPIListOrganizationUsersWithResponse indicates an expected call of UsersAPIListOrganizationUsersWithResponse. -func (mr *MockClientWithResponsesInterfaceMockRecorder) UsersAPIListOrganizationUsersWithResponse(ctx, organizationId interface{}) *gomock.Call { +func (mr *MockClientWithResponsesInterfaceMockRecorder) UsersAPIListOrganizationUsersWithResponse(ctx, organizationId, params interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UsersAPIListOrganizationUsersWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).UsersAPIListOrganizationUsersWithResponse), ctx, organizationId) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UsersAPIListOrganizationUsersWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).UsersAPIListOrganizationUsersWithResponse), ctx, organizationId, params) } // UsersAPIListOrganizationsWithResponse mocks base method. @@ -5273,6 +5293,21 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) UsersAPIListOrganization return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UsersAPIListOrganizationsWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).UsersAPIListOrganizationsWithResponse), ctx, params) } +// UsersAPIListUserGroupsWithResponse mocks base method. +func (m *MockClientWithResponsesInterface) UsersAPIListUserGroupsWithResponse(ctx context.Context, organizationId, userId string) (*sdk.UsersAPIListUserGroupsResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UsersAPIListUserGroupsWithResponse", ctx, organizationId, userId) + ret0, _ := ret[0].(*sdk.UsersAPIListUserGroupsResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// UsersAPIListUserGroupsWithResponse indicates an expected call of UsersAPIListUserGroupsWithResponse. +func (mr *MockClientWithResponsesInterfaceMockRecorder) UsersAPIListUserGroupsWithResponse(ctx, organizationId, userId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UsersAPIListUserGroupsWithResponse", reflect.TypeOf((*MockClientWithResponsesInterface)(nil).UsersAPIListUserGroupsWithResponse), ctx, organizationId, userId) +} + // UsersAPIRemoveOrganizationUsersWithResponse mocks base method. func (m *MockClientWithResponsesInterface) UsersAPIRemoveOrganizationUsersWithResponse(ctx context.Context, organizationId string, params *sdk.UsersAPIRemoveOrganizationUsersParams) (*sdk.UsersAPIRemoveOrganizationUsersResponse, error) { m.ctrl.T.Helper() diff --git a/docs/resources/node_template.md b/docs/resources/node_template.md index 49c35e13..93041af9 100644 --- a/docs/resources/node_template.md +++ b/docs/resources/node_template.md @@ -48,6 +48,7 @@ Optional: - `burstable_instances` (String) Will include burstable instances when enabled otherwise they will be excluded. Supported values: `enabled`, `disabled` or ``. - `compute_optimized` (Boolean) Compute optimized instance constraint (deprecated). - `compute_optimized_state` (String) Will only include compute optimized nodes when enabled and exclude compute optimized nodes when disabled. Empty value won't have effect on instances filter. Supported values: `enabled`, `disabled` or empty string. +- `cpu_manufacturers` (List of String) List of acceptable CPU manufacturers. Allowed values: AMD, AMPERE, APPLE, AWS, INTEL. - `custom_priority` (Block List) (see [below for nested schema](#nestedblock--constraints--custom_priority)) - `customer_specific` (String) Will include customer specific (preview) instances when enabled otherwise they will be excluded. Supported values: `enabled`, `disabled` or ``. - `dedicated_node_affinity` (Block List) Dedicated node affinity - creates preference for instances to be created on sole tenancy or dedicated nodes. This