diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/README.md b/resource-manager/containerservice/2023-09-02-preview/agentpools/README.md new file mode 100644 index 00000000000..fb9f674841d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/README.md @@ -0,0 +1,139 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools` Documentation + +The `agentpools` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools" +``` + + +### Client Initialization + +```go +client := agentpools.NewAgentPoolsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `AgentPoolsClient.AbortLatestOperation` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + +if err := client.AbortLatestOperationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentPoolsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + +payload := agentpools.AgentPool{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentPoolsClient.Delete` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + +if err := client.DeleteThenPoll(ctx, id, agentpools.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `AgentPoolsClient.Get` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgentPoolsClient.GetAvailableAgentPoolVersions` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.GetAvailableAgentPoolVersions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgentPoolsClient.GetUpgradeProfile` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + +read, err := client.GetUpgradeProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `AgentPoolsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `AgentPoolsClient.UpgradeNodeImageVersion` + +```go +ctx := context.TODO() +id := agentpools.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + +if err := client.UpgradeNodeImageVersionThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/client.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/client.go new file mode 100644 index 00000000000..2edad36c005 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/client.go @@ -0,0 +1,26 @@ +package agentpools + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolsClient struct { + Client *resourcemanager.Client +} + +func NewAgentPoolsClientWithBaseURI(sdkApi sdkEnv.Api) (*AgentPoolsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "agentpools", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating AgentPoolsClient: %+v", err) + } + + return &AgentPoolsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/constants.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/constants.go new file mode 100644 index 00000000000..24305aa95a3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/constants.go @@ -0,0 +1,614 @@ +package agentpools + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolMode string + +const ( + AgentPoolModeSystem AgentPoolMode = "System" + AgentPoolModeUser AgentPoolMode = "User" +) + +func PossibleValuesForAgentPoolMode() []string { + return []string{ + string(AgentPoolModeSystem), + string(AgentPoolModeUser), + } +} + +func (s *AgentPoolMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolMode(input string) (*AgentPoolMode, error) { + vals := map[string]AgentPoolMode{ + "system": AgentPoolModeSystem, + "user": AgentPoolModeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolMode(input) + return &out, nil +} + +type AgentPoolSSHAccess string + +const ( + AgentPoolSSHAccessDisabled AgentPoolSSHAccess = "Disabled" + AgentPoolSSHAccessLocalUser AgentPoolSSHAccess = "LocalUser" +) + +func PossibleValuesForAgentPoolSSHAccess() []string { + return []string{ + string(AgentPoolSSHAccessDisabled), + string(AgentPoolSSHAccessLocalUser), + } +} + +func (s *AgentPoolSSHAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolSSHAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolSSHAccess(input string) (*AgentPoolSSHAccess, error) { + vals := map[string]AgentPoolSSHAccess{ + "disabled": AgentPoolSSHAccessDisabled, + "localuser": AgentPoolSSHAccessLocalUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolSSHAccess(input) + return &out, nil +} + +type AgentPoolType string + +const ( + AgentPoolTypeAvailabilitySet AgentPoolType = "AvailabilitySet" + AgentPoolTypeVirtualMachineScaleSets AgentPoolType = "VirtualMachineScaleSets" + AgentPoolTypeVirtualMachines AgentPoolType = "VirtualMachines" +) + +func PossibleValuesForAgentPoolType() []string { + return []string{ + string(AgentPoolTypeAvailabilitySet), + string(AgentPoolTypeVirtualMachineScaleSets), + string(AgentPoolTypeVirtualMachines), + } +} + +func (s *AgentPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolType(input string) (*AgentPoolType, error) { + vals := map[string]AgentPoolType{ + "availabilityset": AgentPoolTypeAvailabilitySet, + "virtualmachinescalesets": AgentPoolTypeVirtualMachineScaleSets, + "virtualmachines": AgentPoolTypeVirtualMachines, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolType(input) + return &out, nil +} + +type Code string + +const ( + CodeRunning Code = "Running" + CodeStopped Code = "Stopped" +) + +func PossibleValuesForCode() []string { + return []string{ + string(CodeRunning), + string(CodeStopped), + } +} + +func (s *Code) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCode(input string) (*Code, error) { + vals := map[string]Code{ + "running": CodeRunning, + "stopped": CodeStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Code(input) + return &out, nil +} + +type GPUInstanceProfile string + +const ( + GPUInstanceProfileMIGFourg GPUInstanceProfile = "MIG4g" + GPUInstanceProfileMIGOneg GPUInstanceProfile = "MIG1g" + GPUInstanceProfileMIGSeveng GPUInstanceProfile = "MIG7g" + GPUInstanceProfileMIGThreeg GPUInstanceProfile = "MIG3g" + GPUInstanceProfileMIGTwog GPUInstanceProfile = "MIG2g" +) + +func PossibleValuesForGPUInstanceProfile() []string { + return []string{ + string(GPUInstanceProfileMIGFourg), + string(GPUInstanceProfileMIGOneg), + string(GPUInstanceProfileMIGSeveng), + string(GPUInstanceProfileMIGThreeg), + string(GPUInstanceProfileMIGTwog), + } +} + +func (s *GPUInstanceProfile) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGPUInstanceProfile(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGPUInstanceProfile(input string) (*GPUInstanceProfile, error) { + vals := map[string]GPUInstanceProfile{ + "mig4g": GPUInstanceProfileMIGFourg, + "mig1g": GPUInstanceProfileMIGOneg, + "mig7g": GPUInstanceProfileMIGSeveng, + "mig3g": GPUInstanceProfileMIGThreeg, + "mig2g": GPUInstanceProfileMIGTwog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GPUInstanceProfile(input) + return &out, nil +} + +type KubeletDiskType string + +const ( + KubeletDiskTypeOS KubeletDiskType = "OS" + KubeletDiskTypeTemporary KubeletDiskType = "Temporary" +) + +func PossibleValuesForKubeletDiskType() []string { + return []string{ + string(KubeletDiskTypeOS), + string(KubeletDiskTypeTemporary), + } +} + +func (s *KubeletDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeletDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubeletDiskType(input string) (*KubeletDiskType, error) { + vals := map[string]KubeletDiskType{ + "os": KubeletDiskTypeOS, + "temporary": KubeletDiskTypeTemporary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubeletDiskType(input) + return &out, nil +} + +type OSDiskType string + +const ( + OSDiskTypeEphemeral OSDiskType = "Ephemeral" + OSDiskTypeManaged OSDiskType = "Managed" +) + +func PossibleValuesForOSDiskType() []string { + return []string{ + string(OSDiskTypeEphemeral), + string(OSDiskTypeManaged), + } +} + +func (s *OSDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSDiskType(input string) (*OSDiskType, error) { + vals := map[string]OSDiskType{ + "ephemeral": OSDiskTypeEphemeral, + "managed": OSDiskTypeManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSDiskType(input) + return &out, nil +} + +type OSSKU string + +const ( + OSSKUAzureLinux OSSKU = "AzureLinux" + OSSKUCBLMariner OSSKU = "CBLMariner" + OSSKUMariner OSSKU = "Mariner" + OSSKUUbuntu OSSKU = "Ubuntu" + OSSKUWindowsAnnual OSSKU = "WindowsAnnual" + OSSKUWindowsTwoZeroOneNine OSSKU = "Windows2019" + OSSKUWindowsTwoZeroTwoTwo OSSKU = "Windows2022" +) + +func PossibleValuesForOSSKU() []string { + return []string{ + string(OSSKUAzureLinux), + string(OSSKUCBLMariner), + string(OSSKUMariner), + string(OSSKUUbuntu), + string(OSSKUWindowsAnnual), + string(OSSKUWindowsTwoZeroOneNine), + string(OSSKUWindowsTwoZeroTwoTwo), + } +} + +func (s *OSSKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSSKU(input string) (*OSSKU, error) { + vals := map[string]OSSKU{ + "azurelinux": OSSKUAzureLinux, + "cblmariner": OSSKUCBLMariner, + "mariner": OSSKUMariner, + "ubuntu": OSSKUUbuntu, + "windowsannual": OSSKUWindowsAnnual, + "windows2019": OSSKUWindowsTwoZeroOneNine, + "windows2022": OSSKUWindowsTwoZeroTwoTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSSKU(input) + return &out, nil +} + +type OSType string + +const ( + OSTypeLinux OSType = "Linux" + OSTypeWindows OSType = "Windows" +) + +func PossibleValuesForOSType() []string { + return []string{ + string(OSTypeLinux), + string(OSTypeWindows), + } +} + +func (s *OSType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSType(input string) (*OSType, error) { + vals := map[string]OSType{ + "linux": OSTypeLinux, + "windows": OSTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSType(input) + return &out, nil +} + +type Protocol string + +const ( + ProtocolTCP Protocol = "TCP" + ProtocolUDP Protocol = "UDP" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolTCP), + string(ProtocolUDP), + } +} + +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocol(input string) (*Protocol, error) { + vals := map[string]Protocol{ + "tcp": ProtocolTCP, + "udp": ProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Protocol(input) + return &out, nil +} + +type ScaleDownMode string + +const ( + ScaleDownModeDeallocate ScaleDownMode = "Deallocate" + ScaleDownModeDelete ScaleDownMode = "Delete" +) + +func PossibleValuesForScaleDownMode() []string { + return []string{ + string(ScaleDownModeDeallocate), + string(ScaleDownModeDelete), + } +} + +func (s *ScaleDownMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleDownMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleDownMode(input string) (*ScaleDownMode, error) { + vals := map[string]ScaleDownMode{ + "deallocate": ScaleDownModeDeallocate, + "delete": ScaleDownModeDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleDownMode(input) + return &out, nil +} + +type ScaleSetEvictionPolicy string + +const ( + ScaleSetEvictionPolicyDeallocate ScaleSetEvictionPolicy = "Deallocate" + ScaleSetEvictionPolicyDelete ScaleSetEvictionPolicy = "Delete" +) + +func PossibleValuesForScaleSetEvictionPolicy() []string { + return []string{ + string(ScaleSetEvictionPolicyDeallocate), + string(ScaleSetEvictionPolicyDelete), + } +} + +func (s *ScaleSetEvictionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetEvictionPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetEvictionPolicy(input string) (*ScaleSetEvictionPolicy, error) { + vals := map[string]ScaleSetEvictionPolicy{ + "deallocate": ScaleSetEvictionPolicyDeallocate, + "delete": ScaleSetEvictionPolicyDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetEvictionPolicy(input) + return &out, nil +} + +type ScaleSetPriority string + +const ( + ScaleSetPriorityRegular ScaleSetPriority = "Regular" + ScaleSetPrioritySpot ScaleSetPriority = "Spot" +) + +func PossibleValuesForScaleSetPriority() []string { + return []string{ + string(ScaleSetPriorityRegular), + string(ScaleSetPrioritySpot), + } +} + +func (s *ScaleSetPriority) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetPriority(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetPriority(input string) (*ScaleSetPriority, error) { + vals := map[string]ScaleSetPriority{ + "regular": ScaleSetPriorityRegular, + "spot": ScaleSetPrioritySpot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetPriority(input) + return &out, nil +} + +type WorkloadRuntime string + +const ( + WorkloadRuntimeKataMshvVMIsolation WorkloadRuntime = "KataMshvVmIsolation" + WorkloadRuntimeOCIContainer WorkloadRuntime = "OCIContainer" + WorkloadRuntimeWasmWasi WorkloadRuntime = "WasmWasi" +) + +func PossibleValuesForWorkloadRuntime() []string { + return []string{ + string(WorkloadRuntimeKataMshvVMIsolation), + string(WorkloadRuntimeOCIContainer), + string(WorkloadRuntimeWasmWasi), + } +} + +func (s *WorkloadRuntime) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkloadRuntime(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkloadRuntime(input string) (*WorkloadRuntime, error) { + vals := map[string]WorkloadRuntime{ + "katamshvvmisolation": WorkloadRuntimeKataMshvVMIsolation, + "ocicontainer": WorkloadRuntimeOCIContainer, + "wasmwasi": WorkloadRuntimeWasmWasi, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadRuntime(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/id_agentpool.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/id_agentpool.go new file mode 100644 index 00000000000..3f847038351 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/id_agentpool.go @@ -0,0 +1,139 @@ +package agentpools + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AgentPoolId{}) +} + +var _ resourceids.ResourceId = &AgentPoolId{} + +// AgentPoolId is a struct representing the Resource ID for a Agent Pool +type AgentPoolId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + AgentPoolName string +} + +// NewAgentPoolID returns a new AgentPoolId struct +func NewAgentPoolID(subscriptionId string, resourceGroupName string, managedClusterName string, agentPoolName string) AgentPoolId { + return AgentPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + AgentPoolName: agentPoolName, + } +} + +// ParseAgentPoolID parses 'input' into a AgentPoolId +func ParseAgentPoolID(input string) (*AgentPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&AgentPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AgentPoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAgentPoolIDInsensitively parses 'input' case-insensitively into a AgentPoolId +// note: this method should only be used for API response data and not user input +func ParseAgentPoolIDInsensitively(input string) (*AgentPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&AgentPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AgentPoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AgentPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.AgentPoolName, ok = input.Parsed["agentPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "agentPoolName", input) + } + + return nil +} + +// ValidateAgentPoolID checks that 'input' can be parsed as a Agent Pool ID +func ValidateAgentPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAgentPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Agent Pool ID +func (id AgentPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/agentPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.AgentPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Agent Pool ID +func (id AgentPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticAgentPools", "agentPools", "agentPools"), + resourceids.UserSpecifiedSegment("agentPoolName", "agentPoolValue"), + } +} + +// String returns a human-readable description of this Agent Pool ID +func (id AgentPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Agent Pool Name: %q", id.AgentPoolName), + } + return fmt.Sprintf("Agent Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/id_agentpool_test.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/id_agentpool_test.go new file mode 100644 index 00000000000..4c32bcb833f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/id_agentpool_test.go @@ -0,0 +1,327 @@ +package agentpools + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AgentPoolId{} + +func TestNewAgentPoolID(t *testing.T) { + id := NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.AgentPoolName != "agentPoolValue" { + t.Fatalf("Expected %q but got %q for Segment 'AgentPoolName'", id.AgentPoolName, "agentPoolValue") + } +} + +func TestFormatAgentPoolID(t *testing.T) { + actual := NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAgentPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AgentPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AgentPoolName: "agentPoolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAgentPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + } +} + +func TestParseAgentPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AgentPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AgentPoolName: "agentPoolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + AgentPoolName: "aGeNtPoOlVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAgentPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + } +} + +func TestSegmentsForAgentPoolId(t *testing.T) { + segments := AgentPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AgentPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_abortlatestoperation.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_abortlatestoperation.go new file mode 100644 index 00000000000..bb6d06d7487 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_abortlatestoperation.go @@ -0,0 +1,70 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AbortLatestOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AbortLatestOperation ... +func (c AgentPoolsClient) AbortLatestOperation(ctx context.Context, id AgentPoolId) (result AbortLatestOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/abort", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// AbortLatestOperationThenPoll performs AbortLatestOperation then polls until it's completed +func (c AgentPoolsClient) AbortLatestOperationThenPoll(ctx context.Context, id AgentPoolId) error { + result, err := c.AbortLatestOperation(ctx, id) + if err != nil { + return fmt.Errorf("performing AbortLatestOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AbortLatestOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_createorupdate.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_createorupdate.go new file mode 100644 index 00000000000..8df06205d3a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_createorupdate.go @@ -0,0 +1,75 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AgentPool +} + +// CreateOrUpdate ... +func (c AgentPoolsClient) CreateOrUpdate(ctx context.Context, id AgentPoolId, input AgentPool) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c AgentPoolsClient) CreateOrUpdateThenPoll(ctx context.Context, id AgentPoolId, input AgentPool) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_delete.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_delete.go new file mode 100644 index 00000000000..d628abea0ea --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_delete.go @@ -0,0 +1,98 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IgnorePodDisruptionBudget *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IgnorePodDisruptionBudget != nil { + out.Append("ignore-pod-disruption-budget", fmt.Sprintf("%v", *o.IgnorePodDisruptionBudget)) + } + return &out +} + +// Delete ... +func (c AgentPoolsClient) Delete(ctx context.Context, id AgentPoolId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c AgentPoolsClient) DeleteThenPoll(ctx context.Context, id AgentPoolId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_get.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_get.go new file mode 100644 index 00000000000..97eecd6a97a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_get.go @@ -0,0 +1,54 @@ +package agentpools + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgentPool +} + +// Get ... +func (c AgentPoolsClient) Get(ctx context.Context, id AgentPoolId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AgentPool + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_getavailableagentpoolversions.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_getavailableagentpoolversions.go new file mode 100644 index 00000000000..81aa1c660a4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_getavailableagentpoolversions.go @@ -0,0 +1,56 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAvailableAgentPoolVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgentPoolAvailableVersions +} + +// GetAvailableAgentPoolVersions ... +func (c AgentPoolsClient) GetAvailableAgentPoolVersions(ctx context.Context, id commonids.KubernetesClusterId) (result GetAvailableAgentPoolVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/availableAgentPoolVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AgentPoolAvailableVersions + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_getupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_getupgradeprofile.go new file mode 100644 index 00000000000..e8d8a91ceed --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_getupgradeprofile.go @@ -0,0 +1,55 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUpgradeProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AgentPoolUpgradeProfile +} + +// GetUpgradeProfile ... +func (c AgentPoolsClient) GetUpgradeProfile(ctx context.Context, id AgentPoolId) (result GetUpgradeProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/upgradeProfiles/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model AgentPoolUpgradeProfile + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_list.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_list.go new file mode 100644 index 00000000000..d4f58e969de --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_list.go @@ -0,0 +1,92 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AgentPool +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AgentPool +} + +// List ... +func (c AgentPoolsClient) List(ctx context.Context, id commonids.KubernetesClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/agentPools", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AgentPool `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c AgentPoolsClient) ListComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, AgentPoolOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c AgentPoolsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate AgentPoolOperationPredicate) (result ListCompleteResult, err error) { + items := make([]AgentPool, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/method_upgradenodeimageversion.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_upgradenodeimageversion.go new file mode 100644 index 00000000000..fa6b0240a55 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/method_upgradenodeimageversion.go @@ -0,0 +1,71 @@ +package agentpools + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeNodeImageVersionOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *AgentPool +} + +// UpgradeNodeImageVersion ... +func (c AgentPoolsClient) UpgradeNodeImageVersion(ctx context.Context, id AgentPoolId) (result UpgradeNodeImageVersionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/upgradeNodeImageVersion", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpgradeNodeImageVersionThenPoll performs UpgradeNodeImageVersion then polls until it's completed +func (c AgentPoolsClient) UpgradeNodeImageVersionThenPoll(ctx context.Context, id AgentPoolId) error { + result, err := c.UpgradeNodeImageVersion(ctx, id) + if err != nil { + return fmt.Errorf("performing UpgradeNodeImageVersion: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpgradeNodeImageVersion: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpool.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpool.go new file mode 100644 index 00000000000..c67ae33e826 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpool.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPool struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ManagedClusterAgentPoolProfileProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolartifactstreamingprofile.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolartifactstreamingprofile.go new file mode 100644 index 00000000000..2c5eb8911dc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolartifactstreamingprofile.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolArtifactStreamingProfile struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversions.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversions.go new file mode 100644 index 00000000000..0b65a05c663 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversions.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolAvailableVersions struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AgentPoolAvailableVersionsProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversionsproperties.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversionsproperties.go new file mode 100644 index 00000000000..a8369deaba7 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversionsproperties.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolAvailableVersionsProperties struct { + AgentPoolVersions *[]AgentPoolAvailableVersionsPropertiesAgentPoolVersionsInlined `json:"agentPoolVersions,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversionspropertiesagentpoolversionsinlined.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversionspropertiesagentpoolversionsinlined.go new file mode 100644 index 00000000000..1631b3137d1 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolavailableversionspropertiesagentpoolversionsinlined.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolAvailableVersionsPropertiesAgentPoolVersionsInlined struct { + Default *bool `json:"default,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolgpuprofile.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolgpuprofile.go new file mode 100644 index 00000000000..ad7abfd97f6 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolgpuprofile.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolGPUProfile struct { + InstallGPUDriver *bool `json:"installGPUDriver,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolnetworkprofile.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolnetworkprofile.go new file mode 100644 index 00000000000..db217a29cc5 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolnetworkprofile.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolNetworkProfile struct { + AllowedHostPorts *[]PortRange `json:"allowedHostPorts,omitempty"` + ApplicationSecurityGroups *[]string `json:"applicationSecurityGroups,omitempty"` + NodePublicIPTags *[]IPTag `json:"nodePublicIPTags,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolsecurityprofile.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolsecurityprofile.go new file mode 100644 index 00000000000..d3f054598f9 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolsecurityprofile.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolSecurityProfile struct { + SshAccess *AgentPoolSSHAccess `json:"sshAccess,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofile.go new file mode 100644 index 00000000000..23cc2927f28 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofile.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties AgentPoolUpgradeProfileProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofileproperties.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofileproperties.go new file mode 100644 index 00000000000..5df00c96762 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofileproperties.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeProfileProperties struct { + KubernetesVersion string `json:"kubernetesVersion"` + LatestNodeImageVersion *string `json:"latestNodeImageVersion,omitempty"` + OsType OSType `json:"osType"` + Upgrades *[]AgentPoolUpgradeProfilePropertiesUpgradesInlined `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofilepropertiesupgradesinlined.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofilepropertiesupgradesinlined.go new file mode 100644 index 00000000000..b45442f6cf0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradeprofilepropertiesupgradesinlined.go @@ -0,0 +1,9 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeProfilePropertiesUpgradesInlined struct { + IsPreview *bool `json:"isPreview,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradesettings.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradesettings.go new file mode 100644 index 00000000000..c7afb34fc0c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolupgradesettings.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeSettings struct { + DrainTimeoutInMinutes *int64 `json:"drainTimeoutInMinutes,omitempty"` + MaxSurge *string `json:"maxSurge,omitempty"` + NodeSoakDurationInMinutes *int64 `json:"nodeSoakDurationInMinutes,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolwindowsprofile.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolwindowsprofile.go new file mode 100644 index 00000000000..d7ad07f7f69 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_agentpoolwindowsprofile.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolWindowsProfile struct { + DisableOutboundNat *bool `json:"disableOutboundNat,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_creationdata.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_creationdata.go new file mode 100644 index 00000000000..88a8fe8123b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_creationdata.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreationData struct { + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_iptag.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_iptag.go new file mode 100644 index 00000000000..8a805afc241 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_iptag.go @@ -0,0 +1,9 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_kubeletconfig.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_kubeletconfig.go new file mode 100644 index 00000000000..7d56f79880c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_kubeletconfig.go @@ -0,0 +1,18 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeletConfig struct { + AllowedUnsafeSysctls *[]string `json:"allowedUnsafeSysctls,omitempty"` + ContainerLogMaxFiles *int64 `json:"containerLogMaxFiles,omitempty"` + ContainerLogMaxSizeMB *int64 `json:"containerLogMaxSizeMB,omitempty"` + CpuCfsQuota *bool `json:"cpuCfsQuota,omitempty"` + CpuCfsQuotaPeriod *string `json:"cpuCfsQuotaPeriod,omitempty"` + CpuManagerPolicy *string `json:"cpuManagerPolicy,omitempty"` + FailSwapOn *bool `json:"failSwapOn,omitempty"` + ImageGcHighThreshold *int64 `json:"imageGcHighThreshold,omitempty"` + ImageGcLowThreshold *int64 `json:"imageGcLowThreshold,omitempty"` + PodMaxPids *int64 `json:"podMaxPids,omitempty"` + TopologyManagerPolicy *string `json:"topologyManagerPolicy,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_linuxosconfig.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_linuxosconfig.go new file mode 100644 index 00000000000..8256b210a85 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_linuxosconfig.go @@ -0,0 +1,11 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxOSConfig struct { + SwapFileSizeMB *int64 `json:"swapFileSizeMB,omitempty"` + Sysctls *SysctlConfig `json:"sysctls,omitempty"` + TransparentHugePageDefrag *string `json:"transparentHugePageDefrag,omitempty"` + TransparentHugePageEnabled *string `json:"transparentHugePageEnabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_managedclusteragentpoolprofileproperties.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_managedclusteragentpoolprofileproperties.go new file mode 100644 index 00000000000..ef2f5729d3e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_managedclusteragentpoolprofileproperties.go @@ -0,0 +1,60 @@ +package agentpools + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAgentPoolProfileProperties struct { + ArtifactStreamingProfile *AgentPoolArtifactStreamingProfile `json:"artifactStreamingProfile,omitempty"` + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + CapacityReservationGroupID *string `json:"capacityReservationGroupID,omitempty"` + Count *int64 `json:"count,omitempty"` + CreationData *CreationData `json:"creationData,omitempty"` + CurrentOrchestratorVersion *string `json:"currentOrchestratorVersion,omitempty"` + EnableAutoScaling *bool `json:"enableAutoScaling,omitempty"` + EnableCustomCATrust *bool `json:"enableCustomCATrust,omitempty"` + EnableEncryptionAtHost *bool `json:"enableEncryptionAtHost,omitempty"` + EnableFIPS *bool `json:"enableFIPS,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIP,omitempty"` + EnableUltraSSD *bool `json:"enableUltraSSD,omitempty"` + GpuInstanceProfile *GPUInstanceProfile `json:"gpuInstanceProfile,omitempty"` + GpuProfile *AgentPoolGPUProfile `json:"gpuProfile,omitempty"` + HostGroupID *string `json:"hostGroupID,omitempty"` + KubeletConfig *KubeletConfig `json:"kubeletConfig,omitempty"` + KubeletDiskType *KubeletDiskType `json:"kubeletDiskType,omitempty"` + LinuxOSConfig *LinuxOSConfig `json:"linuxOSConfig,omitempty"` + MaxCount *int64 `json:"maxCount,omitempty"` + MaxPods *int64 `json:"maxPods,omitempty"` + MessageOfTheDay *string `json:"messageOfTheDay,omitempty"` + MinCount *int64 `json:"minCount,omitempty"` + Mode *AgentPoolMode `json:"mode,omitempty"` + NetworkProfile *AgentPoolNetworkProfile `json:"networkProfile,omitempty"` + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + NodeLabels *map[string]string `json:"nodeLabels,omitempty"` + NodePublicIPPrefixID *string `json:"nodePublicIPPrefixID,omitempty"` + NodeTaints *[]string `json:"nodeTaints,omitempty"` + OrchestratorVersion *string `json:"orchestratorVersion,omitempty"` + OsDiskSizeGB *int64 `json:"osDiskSizeGB,omitempty"` + OsDiskType *OSDiskType `json:"osDiskType,omitempty"` + OsSKU *OSSKU `json:"osSKU,omitempty"` + OsType *OSType `json:"osType,omitempty"` + PodSubnetID *string `json:"podSubnetID,omitempty"` + PowerState *PowerState `json:"powerState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ProximityPlacementGroupID *string `json:"proximityPlacementGroupID,omitempty"` + ScaleDownMode *ScaleDownMode `json:"scaleDownMode,omitempty"` + ScaleSetEvictionPolicy *ScaleSetEvictionPolicy `json:"scaleSetEvictionPolicy,omitempty"` + ScaleSetPriority *ScaleSetPriority `json:"scaleSetPriority,omitempty"` + SecurityProfile *AgentPoolSecurityProfile `json:"securityProfile,omitempty"` + SpotMaxPrice *float64 `json:"spotMaxPrice,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *AgentPoolType `json:"type,omitempty"` + UpgradeSettings *AgentPoolUpgradeSettings `json:"upgradeSettings,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + VnetSubnetID *string `json:"vnetSubnetID,omitempty"` + WindowsProfile *AgentPoolWindowsProfile `json:"windowsProfile,omitempty"` + WorkloadRuntime *WorkloadRuntime `json:"workloadRuntime,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_portrange.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_portrange.go new file mode 100644 index 00000000000..45b2a562032 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_portrange.go @@ -0,0 +1,10 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortRange struct { + PortEnd *int64 `json:"portEnd,omitempty"` + PortStart *int64 `json:"portStart,omitempty"` + Protocol *Protocol `json:"protocol,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_powerstate.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_powerstate.go new file mode 100644 index 00000000000..c5939d90672 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_powerstate.go @@ -0,0 +1,8 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PowerState struct { + Code *Code `json:"code,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/model_sysctlconfig.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_sysctlconfig.go new file mode 100644 index 00000000000..aa739bf4f68 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/model_sysctlconfig.go @@ -0,0 +1,35 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SysctlConfig struct { + FsAioMaxNr *int64 `json:"fsAioMaxNr,omitempty"` + FsFileMax *int64 `json:"fsFileMax,omitempty"` + FsInotifyMaxUserWatches *int64 `json:"fsInotifyMaxUserWatches,omitempty"` + FsNrOpen *int64 `json:"fsNrOpen,omitempty"` + KernelThreadsMax *int64 `json:"kernelThreadsMax,omitempty"` + NetCoreNetdevMaxBacklog *int64 `json:"netCoreNetdevMaxBacklog,omitempty"` + NetCoreOptmemMax *int64 `json:"netCoreOptmemMax,omitempty"` + NetCoreRmemDefault *int64 `json:"netCoreRmemDefault,omitempty"` + NetCoreRmemMax *int64 `json:"netCoreRmemMax,omitempty"` + NetCoreSomaxconn *int64 `json:"netCoreSomaxconn,omitempty"` + NetCoreWmemDefault *int64 `json:"netCoreWmemDefault,omitempty"` + NetCoreWmemMax *int64 `json:"netCoreWmemMax,omitempty"` + NetIPv4IPLocalPortRange *string `json:"netIpv4IpLocalPortRange,omitempty"` + NetIPv4NeighDefaultGcThresh1 *int64 `json:"netIpv4NeighDefaultGcThresh1,omitempty"` + NetIPv4NeighDefaultGcThresh2 *int64 `json:"netIpv4NeighDefaultGcThresh2,omitempty"` + NetIPv4NeighDefaultGcThresh3 *int64 `json:"netIpv4NeighDefaultGcThresh3,omitempty"` + NetIPv4TcpFinTimeout *int64 `json:"netIpv4TcpFinTimeout,omitempty"` + NetIPv4TcpKeepaliveProbes *int64 `json:"netIpv4TcpKeepaliveProbes,omitempty"` + NetIPv4TcpKeepaliveTime *int64 `json:"netIpv4TcpKeepaliveTime,omitempty"` + NetIPv4TcpMaxSynBacklog *int64 `json:"netIpv4TcpMaxSynBacklog,omitempty"` + NetIPv4TcpMaxTwBuckets *int64 `json:"netIpv4TcpMaxTwBuckets,omitempty"` + NetIPv4TcpTwReuse *bool `json:"netIpv4TcpTwReuse,omitempty"` + NetIPv4TcpkeepaliveIntvl *int64 `json:"netIpv4TcpkeepaliveIntvl,omitempty"` + NetNetfilterNfConntrackBuckets *int64 `json:"netNetfilterNfConntrackBuckets,omitempty"` + NetNetfilterNfConntrackMax *int64 `json:"netNetfilterNfConntrackMax,omitempty"` + VMMaxMapCount *int64 `json:"vmMaxMapCount,omitempty"` + VMSwappiness *int64 `json:"vmSwappiness,omitempty"` + VMVfsCachePressure *int64 `json:"vmVfsCachePressure,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/predicates.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/predicates.go new file mode 100644 index 00000000000..94a2db5c63b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/predicates.go @@ -0,0 +1,27 @@ +package agentpools + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p AgentPoolOperationPredicate) Matches(input AgentPool) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerservice/2023-09-02-preview/agentpools/version.go b/resource-manager/containerservice/2023-09-02-preview/agentpools/version.go new file mode 100644 index 00000000000..48761a95215 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/agentpools/version.go @@ -0,0 +1,12 @@ +package agentpools + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/agentpools/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/client.go b/resource-manager/containerservice/2023-09-02-preview/client.go new file mode 100644 index 00000000000..41f766692d3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/client.go @@ -0,0 +1,109 @@ +package v2023_09_02_preview + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/agentpools" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/machines" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/privatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots" + "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/trustedaccess" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + AgentPools *agentpools.AgentPoolsClient + Machines *machines.MachinesClient + MaintenanceConfigurations *maintenanceconfigurations.MaintenanceConfigurationsClient + ManagedClusterSnapshots *managedclustersnapshots.ManagedClusterSnapshotsClient + ManagedClusters *managedclusters.ManagedClustersClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + PrivateLinkResources *privatelinkresources.PrivateLinkResourcesClient + ResolvePrivateLinkServiceId *resolveprivatelinkserviceid.ResolvePrivateLinkServiceIdClient + Snapshots *snapshots.SnapshotsClient + TrustedAccess *trustedaccess.TrustedAccessClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + agentPoolsClient, err := agentpools.NewAgentPoolsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building AgentPools client: %+v", err) + } + configureFunc(agentPoolsClient.Client) + + machinesClient, err := machines.NewMachinesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Machines client: %+v", err) + } + configureFunc(machinesClient.Client) + + maintenanceConfigurationsClient, err := maintenanceconfigurations.NewMaintenanceConfigurationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MaintenanceConfigurations client: %+v", err) + } + configureFunc(maintenanceConfigurationsClient.Client) + + managedClusterSnapshotsClient, err := managedclustersnapshots.NewManagedClusterSnapshotsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedClusterSnapshots client: %+v", err) + } + configureFunc(managedClusterSnapshotsClient.Client) + + managedClustersClient, err := managedclusters.NewManagedClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedClusters client: %+v", err) + } + configureFunc(managedClustersClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + privateLinkResourcesClient, err := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateLinkResources client: %+v", err) + } + configureFunc(privateLinkResourcesClient.Client) + + resolvePrivateLinkServiceIdClient, err := resolveprivatelinkserviceid.NewResolvePrivateLinkServiceIdClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ResolvePrivateLinkServiceId client: %+v", err) + } + configureFunc(resolvePrivateLinkServiceIdClient.Client) + + snapshotsClient, err := snapshots.NewSnapshotsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Snapshots client: %+v", err) + } + configureFunc(snapshotsClient.Client) + + trustedAccessClient, err := trustedaccess.NewTrustedAccessClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building TrustedAccess client: %+v", err) + } + configureFunc(trustedAccessClient.Client) + + return &Client{ + AgentPools: agentPoolsClient, + Machines: machinesClient, + MaintenanceConfigurations: maintenanceConfigurationsClient, + ManagedClusterSnapshots: managedClusterSnapshotsClient, + ManagedClusters: managedClustersClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + PrivateLinkResources: privateLinkResourcesClient, + ResolvePrivateLinkServiceId: resolvePrivateLinkServiceIdClient, + Snapshots: snapshotsClient, + TrustedAccess: trustedAccessClient, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/README.md b/resource-manager/containerservice/2023-09-02-preview/machines/README.md new file mode 100644 index 00000000000..e006cc2390d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/machines` Documentation + +The `machines` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/machines" +``` + + +### Client Initialization + +```go +client := machines.NewMachinesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MachinesClient.Get` + +```go +ctx := context.TODO() +id := machines.NewMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue", "machineValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MachinesClient.List` + +```go +ctx := context.TODO() +id := machines.NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/client.go b/resource-manager/containerservice/2023-09-02-preview/machines/client.go new file mode 100644 index 00000000000..e0daf908061 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/client.go @@ -0,0 +1,26 @@ +package machines + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachinesClient struct { + Client *resourcemanager.Client +} + +func NewMachinesClientWithBaseURI(sdkApi sdkEnv.Api) (*MachinesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "machines", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MachinesClient: %+v", err) + } + + return &MachinesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/constants.go b/resource-manager/containerservice/2023-09-02-preview/machines/constants.go new file mode 100644 index 00000000000..3401f05d4e3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/constants.go @@ -0,0 +1,51 @@ +package machines + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPFamily string + +const ( + IPFamilyIPvFour IPFamily = "IPv4" + IPFamilyIPvSix IPFamily = "IPv6" +) + +func PossibleValuesForIPFamily() []string { + return []string{ + string(IPFamilyIPvFour), + string(IPFamilyIPvSix), + } +} + +func (s *IPFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFamily(input string) (*IPFamily, error) { + vals := map[string]IPFamily{ + "ipv4": IPFamilyIPvFour, + "ipv6": IPFamilyIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFamily(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/id_agentpool.go b/resource-manager/containerservice/2023-09-02-preview/machines/id_agentpool.go new file mode 100644 index 00000000000..37959edf6f0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/id_agentpool.go @@ -0,0 +1,139 @@ +package machines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AgentPoolId{}) +} + +var _ resourceids.ResourceId = &AgentPoolId{} + +// AgentPoolId is a struct representing the Resource ID for a Agent Pool +type AgentPoolId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + AgentPoolName string +} + +// NewAgentPoolID returns a new AgentPoolId struct +func NewAgentPoolID(subscriptionId string, resourceGroupName string, managedClusterName string, agentPoolName string) AgentPoolId { + return AgentPoolId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + AgentPoolName: agentPoolName, + } +} + +// ParseAgentPoolID parses 'input' into a AgentPoolId +func ParseAgentPoolID(input string) (*AgentPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&AgentPoolId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AgentPoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAgentPoolIDInsensitively parses 'input' case-insensitively into a AgentPoolId +// note: this method should only be used for API response data and not user input +func ParseAgentPoolIDInsensitively(input string) (*AgentPoolId, error) { + parser := resourceids.NewParserFromResourceIdType(&AgentPoolId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AgentPoolId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AgentPoolId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.AgentPoolName, ok = input.Parsed["agentPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "agentPoolName", input) + } + + return nil +} + +// ValidateAgentPoolID checks that 'input' can be parsed as a Agent Pool ID +func ValidateAgentPoolID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAgentPoolID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Agent Pool ID +func (id AgentPoolId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/agentPools/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.AgentPoolName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Agent Pool ID +func (id AgentPoolId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticAgentPools", "agentPools", "agentPools"), + resourceids.UserSpecifiedSegment("agentPoolName", "agentPoolValue"), + } +} + +// String returns a human-readable description of this Agent Pool ID +func (id AgentPoolId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Agent Pool Name: %q", id.AgentPoolName), + } + return fmt.Sprintf("Agent Pool (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/id_agentpool_test.go b/resource-manager/containerservice/2023-09-02-preview/machines/id_agentpool_test.go new file mode 100644 index 00000000000..9d1d09ef62a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/id_agentpool_test.go @@ -0,0 +1,327 @@ +package machines + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AgentPoolId{} + +func TestNewAgentPoolID(t *testing.T) { + id := NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.AgentPoolName != "agentPoolValue" { + t.Fatalf("Expected %q but got %q for Segment 'AgentPoolName'", id.AgentPoolName, "agentPoolValue") + } +} + +func TestFormatAgentPoolID(t *testing.T) { + actual := NewAgentPoolID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAgentPoolID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AgentPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AgentPoolName: "agentPoolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAgentPoolID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + } +} + +func TestParseAgentPoolIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AgentPoolId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AgentPoolName: "agentPoolValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE", + Expected: &AgentPoolId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + AgentPoolName: "aGeNtPoOlVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAgentPoolIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + } +} + +func TestSegmentsForAgentPoolId(t *testing.T) { + segments := AgentPoolId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AgentPoolId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/id_machine.go b/resource-manager/containerservice/2023-09-02-preview/machines/id_machine.go new file mode 100644 index 00000000000..8b8a3741439 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/id_machine.go @@ -0,0 +1,148 @@ +package machines + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MachineId{}) +} + +var _ resourceids.ResourceId = &MachineId{} + +// MachineId is a struct representing the Resource ID for a Machine +type MachineId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + AgentPoolName string + MachineName string +} + +// NewMachineID returns a new MachineId struct +func NewMachineID(subscriptionId string, resourceGroupName string, managedClusterName string, agentPoolName string, machineName string) MachineId { + return MachineId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + AgentPoolName: agentPoolName, + MachineName: machineName, + } +} + +// ParseMachineID parses 'input' into a MachineId +func ParseMachineID(input string) (*MachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&MachineId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMachineIDInsensitively parses 'input' case-insensitively into a MachineId +// note: this method should only be used for API response data and not user input +func ParseMachineIDInsensitively(input string) (*MachineId, error) { + parser := resourceids.NewParserFromResourceIdType(&MachineId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MachineId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MachineId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.AgentPoolName, ok = input.Parsed["agentPoolName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "agentPoolName", input) + } + + if id.MachineName, ok = input.Parsed["machineName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "machineName", input) + } + + return nil +} + +// ValidateMachineID checks that 'input' can be parsed as a Machine ID +func ValidateMachineID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMachineID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Machine ID +func (id MachineId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/agentPools/%s/machines/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.AgentPoolName, id.MachineName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Machine ID +func (id MachineId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticAgentPools", "agentPools", "agentPools"), + resourceids.UserSpecifiedSegment("agentPoolName", "agentPoolValue"), + resourceids.StaticSegment("staticMachines", "machines", "machines"), + resourceids.UserSpecifiedSegment("machineName", "machineValue"), + } +} + +// String returns a human-readable description of this Machine ID +func (id MachineId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Agent Pool Name: %q", id.AgentPoolName), + fmt.Sprintf("Machine Name: %q", id.MachineName), + } + return fmt.Sprintf("Machine (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/id_machine_test.go b/resource-manager/containerservice/2023-09-02-preview/machines/id_machine_test.go new file mode 100644 index 00000000000..d291e602074 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/id_machine_test.go @@ -0,0 +1,372 @@ +package machines + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MachineId{} + +func TestNewMachineID(t *testing.T) { + id := NewMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue", "machineValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.AgentPoolName != "agentPoolValue" { + t.Fatalf("Expected %q but got %q for Segment 'AgentPoolName'", id.AgentPoolName, "agentPoolValue") + } + + if id.MachineName != "machineValue" { + t.Fatalf("Expected %q but got %q for Segment 'MachineName'", id.MachineName, "machineValue") + } +} + +func TestFormatMachineID(t *testing.T) { + actual := NewMachineID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "agentPoolValue", "machineValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/machines/machineValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMachineID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/machines", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/machines/machineValue", + Expected: &MachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AgentPoolName: "agentPoolValue", + MachineName: "machineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/machines/machineValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMachineID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + if actual.MachineName != v.Expected.MachineName { + t.Fatalf("Expected %q but got %q for MachineName", v.Expected.MachineName, actual.MachineName) + } + + } +} + +func TestParseMachineIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MachineId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/machines", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE/mAcHiNeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/machines/machineValue", + Expected: &MachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AgentPoolName: "agentPoolValue", + MachineName: "machineValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/agentPools/agentPoolValue/machines/machineValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE/mAcHiNeS/mAcHiNeVaLuE", + Expected: &MachineId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + AgentPoolName: "aGeNtPoOlVaLuE", + MachineName: "mAcHiNeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aGeNtPoOlS/aGeNtPoOlVaLuE/mAcHiNeS/mAcHiNeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMachineIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AgentPoolName != v.Expected.AgentPoolName { + t.Fatalf("Expected %q but got %q for AgentPoolName", v.Expected.AgentPoolName, actual.AgentPoolName) + } + + if actual.MachineName != v.Expected.MachineName { + t.Fatalf("Expected %q but got %q for MachineName", v.Expected.MachineName, actual.MachineName) + } + + } +} + +func TestSegmentsForMachineId(t *testing.T) { + segments := MachineId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MachineId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/method_get.go b/resource-manager/containerservice/2023-09-02-preview/machines/method_get.go new file mode 100644 index 00000000000..28a34563dec --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/method_get.go @@ -0,0 +1,54 @@ +package machines + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Machine +} + +// Get ... +func (c MachinesClient) Get(ctx context.Context, id MachineId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Machine + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/method_list.go b/resource-manager/containerservice/2023-09-02-preview/machines/method_list.go new file mode 100644 index 00000000000..58a5df1521f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/method_list.go @@ -0,0 +1,91 @@ +package machines + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Machine +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Machine +} + +// List ... +func (c MachinesClient) List(ctx context.Context, id AgentPoolId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/machines", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Machine `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c MachinesClient) ListComplete(ctx context.Context, id AgentPoolId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, MachineOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MachinesClient) ListCompleteMatchingPredicate(ctx context.Context, id AgentPoolId, predicate MachineOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Machine, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/model_machine.go b/resource-manager/containerservice/2023-09-02-preview/machines/model_machine.go new file mode 100644 index 00000000000..33038791b72 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/model_machine.go @@ -0,0 +1,11 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Machine struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MachineProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/model_machineipaddress.go b/resource-manager/containerservice/2023-09-02-preview/machines/model_machineipaddress.go new file mode 100644 index 00000000000..213cc86efcc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/model_machineipaddress.go @@ -0,0 +1,9 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineIPAddress struct { + Family *IPFamily `json:"family,omitempty"` + IP *string `json:"ip,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/model_machinenetworkproperties.go b/resource-manager/containerservice/2023-09-02-preview/machines/model_machinenetworkproperties.go new file mode 100644 index 00000000000..5183ee2722f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/model_machinenetworkproperties.go @@ -0,0 +1,8 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineNetworkProperties struct { + IPAddresses *[]MachineIPAddress `json:"ipAddresses,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/model_machineproperties.go b/resource-manager/containerservice/2023-09-02-preview/machines/model_machineproperties.go new file mode 100644 index 00000000000..041457c0e7c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/model_machineproperties.go @@ -0,0 +1,9 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineProperties struct { + Network *MachineNetworkProperties `json:"network,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/predicates.go b/resource-manager/containerservice/2023-09-02-preview/machines/predicates.go new file mode 100644 index 00000000000..ebc0babfdc2 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/predicates.go @@ -0,0 +1,27 @@ +package machines + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MachineOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MachineOperationPredicate) Matches(input Machine) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerservice/2023-09-02-preview/machines/version.go b/resource-manager/containerservice/2023-09-02-preview/machines/version.go new file mode 100644 index 00000000000..dea43a5e02b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/machines/version.go @@ -0,0 +1,12 @@ +package machines + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/machines/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/README.md b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/README.md new file mode 100644 index 00000000000..257970049ec --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/README.md @@ -0,0 +1,91 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations` Documentation + +The `maintenanceconfigurations` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations" +``` + + +### Client Initialization + +```go +client := maintenanceconfigurations.NewMaintenanceConfigurationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MaintenanceConfigurationsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := maintenanceconfigurations.NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "maintenanceConfigurationValue") + +payload := maintenanceconfigurations.MaintenanceConfiguration{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MaintenanceConfigurationsClient.Delete` + +```go +ctx := context.TODO() +id := maintenanceconfigurations.NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "maintenanceConfigurationValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MaintenanceConfigurationsClient.Get` + +```go +ctx := context.TODO() +id := maintenanceconfigurations.NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "maintenanceConfigurationValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MaintenanceConfigurationsClient.ListByManagedCluster` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// alternatively `client.ListByManagedCluster(ctx, id)` can be used to do batched pagination +items, err := client.ListByManagedClusterComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/client.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/client.go new file mode 100644 index 00000000000..4d799de617c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/client.go @@ -0,0 +1,26 @@ +package maintenanceconfigurations + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceConfigurationsClient struct { + Client *resourcemanager.Client +} + +func NewMaintenanceConfigurationsClientWithBaseURI(sdkApi sdkEnv.Api) (*MaintenanceConfigurationsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "maintenanceconfigurations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MaintenanceConfigurationsClient: %+v", err) + } + + return &MaintenanceConfigurationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/constants.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/constants.go new file mode 100644 index 00000000000..2fdd49e9763 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/constants.go @@ -0,0 +1,116 @@ +package maintenanceconfigurations + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Type string + +const ( + TypeFirst Type = "First" + TypeFourth Type = "Fourth" + TypeLast Type = "Last" + TypeSecond Type = "Second" + TypeThird Type = "Third" +) + +func PossibleValuesForType() []string { + return []string{ + string(TypeFirst), + string(TypeFourth), + string(TypeLast), + string(TypeSecond), + string(TypeThird), + } +} + +func (s *Type) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseType(input string) (*Type, error) { + vals := map[string]Type{ + "first": TypeFirst, + "fourth": TypeFourth, + "last": TypeLast, + "second": TypeSecond, + "third": TypeThird, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Type(input) + return &out, nil +} + +type WeekDay string + +const ( + WeekDayFriday WeekDay = "Friday" + WeekDayMonday WeekDay = "Monday" + WeekDaySaturday WeekDay = "Saturday" + WeekDaySunday WeekDay = "Sunday" + WeekDayThursday WeekDay = "Thursday" + WeekDayTuesday WeekDay = "Tuesday" + WeekDayWednesday WeekDay = "Wednesday" +) + +func PossibleValuesForWeekDay() []string { + return []string{ + string(WeekDayFriday), + string(WeekDayMonday), + string(WeekDaySaturday), + string(WeekDaySunday), + string(WeekDayThursday), + string(WeekDayTuesday), + string(WeekDayWednesday), + } +} + +func (s *WeekDay) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWeekDay(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWeekDay(input string) (*WeekDay, error) { + vals := map[string]WeekDay{ + "friday": WeekDayFriday, + "monday": WeekDayMonday, + "saturday": WeekDaySaturday, + "sunday": WeekDaySunday, + "thursday": WeekDayThursday, + "tuesday": WeekDayTuesday, + "wednesday": WeekDayWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WeekDay(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/id_maintenanceconfiguration.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/id_maintenanceconfiguration.go new file mode 100644 index 00000000000..cb172f6bd60 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/id_maintenanceconfiguration.go @@ -0,0 +1,139 @@ +package maintenanceconfigurations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MaintenanceConfigurationId{}) +} + +var _ resourceids.ResourceId = &MaintenanceConfigurationId{} + +// MaintenanceConfigurationId is a struct representing the Resource ID for a Maintenance Configuration +type MaintenanceConfigurationId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + MaintenanceConfigurationName string +} + +// NewMaintenanceConfigurationID returns a new MaintenanceConfigurationId struct +func NewMaintenanceConfigurationID(subscriptionId string, resourceGroupName string, managedClusterName string, maintenanceConfigurationName string) MaintenanceConfigurationId { + return MaintenanceConfigurationId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + MaintenanceConfigurationName: maintenanceConfigurationName, + } +} + +// ParseMaintenanceConfigurationID parses 'input' into a MaintenanceConfigurationId +func ParseMaintenanceConfigurationID(input string) (*MaintenanceConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MaintenanceConfigurationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MaintenanceConfigurationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMaintenanceConfigurationIDInsensitively parses 'input' case-insensitively into a MaintenanceConfigurationId +// note: this method should only be used for API response data and not user input +func ParseMaintenanceConfigurationIDInsensitively(input string) (*MaintenanceConfigurationId, error) { + parser := resourceids.NewParserFromResourceIdType(&MaintenanceConfigurationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MaintenanceConfigurationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MaintenanceConfigurationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.MaintenanceConfigurationName, ok = input.Parsed["maintenanceConfigurationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "maintenanceConfigurationName", input) + } + + return nil +} + +// ValidateMaintenanceConfigurationID checks that 'input' can be parsed as a Maintenance Configuration ID +func ValidateMaintenanceConfigurationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMaintenanceConfigurationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Maintenance Configuration ID +func (id MaintenanceConfigurationId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/maintenanceConfigurations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.MaintenanceConfigurationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Maintenance Configuration ID +func (id MaintenanceConfigurationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticMaintenanceConfigurations", "maintenanceConfigurations", "maintenanceConfigurations"), + resourceids.UserSpecifiedSegment("maintenanceConfigurationName", "maintenanceConfigurationValue"), + } +} + +// String returns a human-readable description of this Maintenance Configuration ID +func (id MaintenanceConfigurationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Maintenance Configuration Name: %q", id.MaintenanceConfigurationName), + } + return fmt.Sprintf("Maintenance Configuration (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/id_maintenanceconfiguration_test.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/id_maintenanceconfiguration_test.go new file mode 100644 index 00000000000..6931501293c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/id_maintenanceconfiguration_test.go @@ -0,0 +1,327 @@ +package maintenanceconfigurations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MaintenanceConfigurationId{} + +func TestNewMaintenanceConfigurationID(t *testing.T) { + id := NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "maintenanceConfigurationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.MaintenanceConfigurationName != "maintenanceConfigurationValue" { + t.Fatalf("Expected %q but got %q for Segment 'MaintenanceConfigurationName'", id.MaintenanceConfigurationName, "maintenanceConfigurationValue") + } +} + +func TestFormatMaintenanceConfigurationID(t *testing.T) { + actual := NewMaintenanceConfigurationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "maintenanceConfigurationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/maintenanceConfigurations/maintenanceConfigurationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMaintenanceConfigurationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MaintenanceConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/maintenanceConfigurations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/maintenanceConfigurations/maintenanceConfigurationValue", + Expected: &MaintenanceConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + MaintenanceConfigurationName: "maintenanceConfigurationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/maintenanceConfigurations/maintenanceConfigurationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMaintenanceConfigurationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MaintenanceConfigurationName != v.Expected.MaintenanceConfigurationName { + t.Fatalf("Expected %q but got %q for MaintenanceConfigurationName", v.Expected.MaintenanceConfigurationName, actual.MaintenanceConfigurationName) + } + + } +} + +func TestParseMaintenanceConfigurationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MaintenanceConfigurationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/maintenanceConfigurations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/mAiNtEnAnCeCoNfIgUrAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/maintenanceConfigurations/maintenanceConfigurationValue", + Expected: &MaintenanceConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + MaintenanceConfigurationName: "maintenanceConfigurationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/maintenanceConfigurations/maintenanceConfigurationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/mAiNtEnAnCeCoNfIgUrAtIoNs/mAiNtEnAnCeCoNfIgUrAtIoNvAlUe", + Expected: &MaintenanceConfigurationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + MaintenanceConfigurationName: "mAiNtEnAnCeCoNfIgUrAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/mAiNtEnAnCeCoNfIgUrAtIoNs/mAiNtEnAnCeCoNfIgUrAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMaintenanceConfigurationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MaintenanceConfigurationName != v.Expected.MaintenanceConfigurationName { + t.Fatalf("Expected %q but got %q for MaintenanceConfigurationName", v.Expected.MaintenanceConfigurationName, actual.MaintenanceConfigurationName) + } + + } +} + +func TestSegmentsForMaintenanceConfigurationId(t *testing.T) { + segments := MaintenanceConfigurationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MaintenanceConfigurationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_createorupdate.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_createorupdate.go new file mode 100644 index 00000000000..6f8389d858d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_createorupdate.go @@ -0,0 +1,59 @@ +package maintenanceconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MaintenanceConfiguration +} + +// CreateOrUpdate ... +func (c MaintenanceConfigurationsClient) CreateOrUpdate(ctx context.Context, id MaintenanceConfigurationId, input MaintenanceConfiguration) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MaintenanceConfiguration + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_delete.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_delete.go new file mode 100644 index 00000000000..5993be4c15a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_delete.go @@ -0,0 +1,47 @@ +package maintenanceconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c MaintenanceConfigurationsClient) Delete(ctx context.Context, id MaintenanceConfigurationId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_get.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_get.go new file mode 100644 index 00000000000..6ea658ab6d5 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_get.go @@ -0,0 +1,54 @@ +package maintenanceconfigurations + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MaintenanceConfiguration +} + +// Get ... +func (c MaintenanceConfigurationsClient) Get(ctx context.Context, id MaintenanceConfigurationId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MaintenanceConfiguration + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_listbymanagedcluster.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_listbymanagedcluster.go new file mode 100644 index 00000000000..dae38e85821 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/method_listbymanagedcluster.go @@ -0,0 +1,92 @@ +package maintenanceconfigurations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByManagedClusterOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MaintenanceConfiguration +} + +type ListByManagedClusterCompleteResult struct { + LatestHttpResponse *http.Response + Items []MaintenanceConfiguration +} + +// ListByManagedCluster ... +func (c MaintenanceConfigurationsClient) ListByManagedCluster(ctx context.Context, id commonids.KubernetesClusterId) (result ListByManagedClusterOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/maintenanceConfigurations", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MaintenanceConfiguration `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByManagedClusterComplete retrieves all the results into a single object +func (c MaintenanceConfigurationsClient) ListByManagedClusterComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListByManagedClusterCompleteResult, error) { + return c.ListByManagedClusterCompleteMatchingPredicate(ctx, id, MaintenanceConfigurationOperationPredicate{}) +} + +// ListByManagedClusterCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MaintenanceConfigurationsClient) ListByManagedClusterCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate MaintenanceConfigurationOperationPredicate) (result ListByManagedClusterCompleteResult, err error) { + items := make([]MaintenanceConfiguration, 0) + + resp, err := c.ListByManagedCluster(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByManagedClusterCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_absolutemonthlyschedule.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_absolutemonthlyschedule.go new file mode 100644 index 00000000000..ca6966896ff --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_absolutemonthlyschedule.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AbsoluteMonthlySchedule struct { + DayOfMonth int64 `json:"dayOfMonth"` + IntervalMonths int64 `json:"intervalMonths"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_dailyschedule.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_dailyschedule.go new file mode 100644 index 00000000000..57fb3e994dd --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_dailyschedule.go @@ -0,0 +1,8 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DailySchedule struct { + IntervalDays int64 `json:"intervalDays"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_datespan.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_datespan.go new file mode 100644 index 00000000000..863c4704427 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_datespan.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DateSpan struct { + End string `json:"end"` + Start string `json:"start"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenanceconfiguration.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenanceconfiguration.go new file mode 100644 index 00000000000..9066e53bff3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenanceconfiguration.go @@ -0,0 +1,16 @@ +package maintenanceconfigurations + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceConfiguration struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MaintenanceConfigurationProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenanceconfigurationproperties.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenanceconfigurationproperties.go new file mode 100644 index 00000000000..d7c91bcf9f6 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenanceconfigurationproperties.go @@ -0,0 +1,10 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceConfigurationProperties struct { + MaintenanceWindow *MaintenanceWindow `json:"maintenanceWindow,omitempty"` + NotAllowedTime *[]TimeSpan `json:"notAllowedTime,omitempty"` + TimeInWeek *[]TimeInWeek `json:"timeInWeek,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenancewindow.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenancewindow.go new file mode 100644 index 00000000000..8f1a42f818c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_maintenancewindow.go @@ -0,0 +1,13 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceWindow struct { + DurationHours int64 `json:"durationHours"` + NotAllowedDates *[]DateSpan `json:"notAllowedDates,omitempty"` + Schedule Schedule `json:"schedule"` + StartDate *string `json:"startDate,omitempty"` + StartTime string `json:"startTime"` + UtcOffset *string `json:"utcOffset,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_relativemonthlyschedule.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_relativemonthlyschedule.go new file mode 100644 index 00000000000..0dfc104da98 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_relativemonthlyschedule.go @@ -0,0 +1,10 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RelativeMonthlySchedule struct { + DayOfWeek WeekDay `json:"dayOfWeek"` + IntervalMonths int64 `json:"intervalMonths"` + WeekIndex Type `json:"weekIndex"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_schedule.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_schedule.go new file mode 100644 index 00000000000..cc4397aba4c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_schedule.go @@ -0,0 +1,11 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Schedule struct { + AbsoluteMonthly *AbsoluteMonthlySchedule `json:"absoluteMonthly,omitempty"` + Daily *DailySchedule `json:"daily,omitempty"` + RelativeMonthly *RelativeMonthlySchedule `json:"relativeMonthly,omitempty"` + Weekly *WeeklySchedule `json:"weekly,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_timeinweek.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_timeinweek.go new file mode 100644 index 00000000000..cba259f76fc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_timeinweek.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TimeInWeek struct { + Day *WeekDay `json:"day,omitempty"` + HourSlots *[]int64 `json:"hourSlots,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_timespan.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_timespan.go new file mode 100644 index 00000000000..7bbc8c5ba72 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_timespan.go @@ -0,0 +1,39 @@ +package maintenanceconfigurations + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TimeSpan struct { + End *string `json:"end,omitempty"` + Start *string `json:"start,omitempty"` +} + +func (o *TimeSpan) GetEndAsTime() (*time.Time, error) { + if o.End == nil { + return nil, nil + } + return dates.ParseAsFormat(o.End, "2006-01-02T15:04:05Z07:00") +} + +func (o *TimeSpan) SetEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.End = &formatted +} + +func (o *TimeSpan) GetStartAsTime() (*time.Time, error) { + if o.Start == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Start, "2006-01-02T15:04:05Z07:00") +} + +func (o *TimeSpan) SetStartAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Start = &formatted +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_weeklyschedule.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_weeklyschedule.go new file mode 100644 index 00000000000..ed775ad784e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/model_weeklyschedule.go @@ -0,0 +1,9 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WeeklySchedule struct { + DayOfWeek WeekDay `json:"dayOfWeek"` + IntervalWeeks int64 `json:"intervalWeeks"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/predicates.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/predicates.go new file mode 100644 index 00000000000..c7eedb4fa7b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/predicates.go @@ -0,0 +1,27 @@ +package maintenanceconfigurations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaintenanceConfigurationOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MaintenanceConfigurationOperationPredicate) Matches(input MaintenanceConfiguration) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/version.go b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/version.go new file mode 100644 index 00000000000..062be907928 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/maintenanceconfigurations/version.go @@ -0,0 +1,12 @@ +package maintenanceconfigurations + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/maintenanceconfigurations/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/README.md b/resource-manager/containerservice/2023-09-02-preview/managedclusters/README.md new file mode 100644 index 00000000000..feabd3665b6 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/README.md @@ -0,0 +1,472 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters` Documentation + +The `managedclusters` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclusters" +``` + + +### Client Initialization + +```go +client := managedclusters.NewManagedClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedClustersClient.AbortLatestOperation` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +if err := client.AbortLatestOperationThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := managedclusters.ManagedCluster{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Delete` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +if err := client.DeleteThenPoll(ctx, id, managedclusters.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetAccessProfile` + +```go +ctx := context.TODO() +id := managedclusters.NewAccessProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "accessProfileValue") + +read, err := client.GetAccessProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetCommandResult` + +```go +ctx := context.TODO() +id := managedclusters.NewCommandResultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "commandIdValue") + +read, err := client.GetCommandResult(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetGuardrailsVersions` + +```go +ctx := context.TODO() +id := managedclusters.NewGuardrailsVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "guardrailsVersionValue") + +read, err := client.GetGuardrailsVersions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetMeshRevisionProfile` + +```go +ctx := context.TODO() +id := managedclusters.NewMeshRevisionProfileID("12345678-1234-9876-4563-123456789012", "locationValue", "meshRevisionProfileValue") + +read, err := client.GetMeshRevisionProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetMeshUpgradeProfile` + +```go +ctx := context.TODO() +id := managedclusters.NewMeshUpgradeProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "meshUpgradeProfileValue") + +read, err := client.GetMeshUpgradeProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetOSOptions` + +```go +ctx := context.TODO() +id := managedclusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +read, err := client.GetOSOptions(ctx, id, managedclusters.DefaultGetOSOptionsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.GetUpgradeProfile` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.GetUpgradeProfile(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ListClusterAdminCredentials` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.ListClusterAdminCredentials(ctx, id, managedclusters.DefaultListClusterAdminCredentialsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListClusterMonitoringUserCredentials` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.ListClusterMonitoringUserCredentials(ctx, id, managedclusters.DefaultListClusterMonitoringUserCredentialsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListClusterUserCredentials` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.ListClusterUserCredentials(ctx, id, managedclusters.DefaultListClusterUserCredentialsOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListGuardrailsVersions` + +```go +ctx := context.TODO() +id := managedclusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListGuardrailsVersions(ctx, id)` can be used to do batched pagination +items, err := client.ListGuardrailsVersionsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ListKubernetesVersions` + +```go +ctx := context.TODO() +id := managedclusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +read, err := client.ListKubernetesVersions(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClustersClient.ListMeshRevisionProfiles` + +```go +ctx := context.TODO() +id := managedclusters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.ListMeshRevisionProfiles(ctx, id)` can be used to do batched pagination +items, err := client.ListMeshRevisionProfilesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ListMeshUpgradeProfiles` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// alternatively `client.ListMeshUpgradeProfiles(ctx, id)` can be used to do batched pagination +items, err := client.ListMeshUpgradeProfilesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ListOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// alternatively `client.ListOutboundNetworkDependenciesEndpoints(ctx, id)` can be used to do batched pagination +items, err := client.ListOutboundNetworkDependenciesEndpointsComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClustersClient.ResetAADProfile` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := managedclusters.ManagedClusterAADProfile{ + // ... +} + + +if err := client.ResetAADProfileThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.ResetServicePrincipalProfile` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := managedclusters.ManagedClusterServicePrincipalProfile{ + // ... +} + + +if err := client.ResetServicePrincipalProfileThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.RotateClusterCertificates` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +if err := client.RotateClusterCertificatesThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.RotateServiceAccountSigningKeys` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +if err := client.RotateServiceAccountSigningKeysThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.RunCommand` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := managedclusters.RunCommandRequest{ + // ... +} + + +if err := client.RunCommandThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Start` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +if err := client.StartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.Stop` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +if err := client.StopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedClustersClient.UpdateTags` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := managedclusters.TagsObject{ + // ... +} + + +if err := client.UpdateTagsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/client.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/client.go new file mode 100644 index 00000000000..5081c63c8e6 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/client.go @@ -0,0 +1,26 @@ +package managedclusters + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClustersClient struct { + Client *resourcemanager.Client +} + +func NewManagedClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClustersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClustersClient: %+v", err) + } + + return &ManagedClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/constants.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/constants.go new file mode 100644 index 00000000000..a5155a2bdcb --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/constants.go @@ -0,0 +1,1854 @@ +package managedclusters + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AddonAutoscaling string + +const ( + AddonAutoscalingDisabled AddonAutoscaling = "Disabled" + AddonAutoscalingEnabled AddonAutoscaling = "Enabled" +) + +func PossibleValuesForAddonAutoscaling() []string { + return []string{ + string(AddonAutoscalingDisabled), + string(AddonAutoscalingEnabled), + } +} + +func (s *AddonAutoscaling) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAddonAutoscaling(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAddonAutoscaling(input string) (*AddonAutoscaling, error) { + vals := map[string]AddonAutoscaling{ + "disabled": AddonAutoscalingDisabled, + "enabled": AddonAutoscalingEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AddonAutoscaling(input) + return &out, nil +} + +type AgentPoolMode string + +const ( + AgentPoolModeSystem AgentPoolMode = "System" + AgentPoolModeUser AgentPoolMode = "User" +) + +func PossibleValuesForAgentPoolMode() []string { + return []string{ + string(AgentPoolModeSystem), + string(AgentPoolModeUser), + } +} + +func (s *AgentPoolMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolMode(input string) (*AgentPoolMode, error) { + vals := map[string]AgentPoolMode{ + "system": AgentPoolModeSystem, + "user": AgentPoolModeUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolMode(input) + return &out, nil +} + +type AgentPoolSSHAccess string + +const ( + AgentPoolSSHAccessDisabled AgentPoolSSHAccess = "Disabled" + AgentPoolSSHAccessLocalUser AgentPoolSSHAccess = "LocalUser" +) + +func PossibleValuesForAgentPoolSSHAccess() []string { + return []string{ + string(AgentPoolSSHAccessDisabled), + string(AgentPoolSSHAccessLocalUser), + } +} + +func (s *AgentPoolSSHAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolSSHAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolSSHAccess(input string) (*AgentPoolSSHAccess, error) { + vals := map[string]AgentPoolSSHAccess{ + "disabled": AgentPoolSSHAccessDisabled, + "localuser": AgentPoolSSHAccessLocalUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolSSHAccess(input) + return &out, nil +} + +type AgentPoolType string + +const ( + AgentPoolTypeAvailabilitySet AgentPoolType = "AvailabilitySet" + AgentPoolTypeVirtualMachineScaleSets AgentPoolType = "VirtualMachineScaleSets" + AgentPoolTypeVirtualMachines AgentPoolType = "VirtualMachines" +) + +func PossibleValuesForAgentPoolType() []string { + return []string{ + string(AgentPoolTypeAvailabilitySet), + string(AgentPoolTypeVirtualMachineScaleSets), + string(AgentPoolTypeVirtualMachines), + } +} + +func (s *AgentPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAgentPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAgentPoolType(input string) (*AgentPoolType, error) { + vals := map[string]AgentPoolType{ + "availabilityset": AgentPoolTypeAvailabilitySet, + "virtualmachinescalesets": AgentPoolTypeVirtualMachineScaleSets, + "virtualmachines": AgentPoolTypeVirtualMachines, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AgentPoolType(input) + return &out, nil +} + +type BackendPoolType string + +const ( + BackendPoolTypeNodeIP BackendPoolType = "NodeIP" + BackendPoolTypeNodeIPConfiguration BackendPoolType = "NodeIPConfiguration" +) + +func PossibleValuesForBackendPoolType() []string { + return []string{ + string(BackendPoolTypeNodeIP), + string(BackendPoolTypeNodeIPConfiguration), + } +} + +func (s *BackendPoolType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBackendPoolType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBackendPoolType(input string) (*BackendPoolType, error) { + vals := map[string]BackendPoolType{ + "nodeip": BackendPoolTypeNodeIP, + "nodeipconfiguration": BackendPoolTypeNodeIPConfiguration, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BackendPoolType(input) + return &out, nil +} + +type Code string + +const ( + CodeRunning Code = "Running" + CodeStopped Code = "Stopped" +) + +func PossibleValuesForCode() []string { + return []string{ + string(CodeRunning), + string(CodeStopped), + } +} + +func (s *Code) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCode(input string) (*Code, error) { + vals := map[string]Code{ + "running": CodeRunning, + "stopped": CodeStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Code(input) + return &out, nil +} + +type Expander string + +const ( + ExpanderLeastNegativewaste Expander = "least-waste" + ExpanderMostNegativepods Expander = "most-pods" + ExpanderPriority Expander = "priority" + ExpanderRandom Expander = "random" +) + +func PossibleValuesForExpander() []string { + return []string{ + string(ExpanderLeastNegativewaste), + string(ExpanderMostNegativepods), + string(ExpanderPriority), + string(ExpanderRandom), + } +} + +func (s *Expander) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseExpander(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseExpander(input string) (*Expander, error) { + vals := map[string]Expander{ + "least-waste": ExpanderLeastNegativewaste, + "most-pods": ExpanderMostNegativepods, + "priority": ExpanderPriority, + "random": ExpanderRandom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Expander(input) + return &out, nil +} + +type Format string + +const ( + FormatAzure Format = "azure" + FormatExec Format = "exec" +) + +func PossibleValuesForFormat() []string { + return []string{ + string(FormatAzure), + string(FormatExec), + } +} + +func (s *Format) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFormat(input string) (*Format, error) { + vals := map[string]Format{ + "azure": FormatAzure, + "exec": FormatExec, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Format(input) + return &out, nil +} + +type GPUInstanceProfile string + +const ( + GPUInstanceProfileMIGFourg GPUInstanceProfile = "MIG4g" + GPUInstanceProfileMIGOneg GPUInstanceProfile = "MIG1g" + GPUInstanceProfileMIGSeveng GPUInstanceProfile = "MIG7g" + GPUInstanceProfileMIGThreeg GPUInstanceProfile = "MIG3g" + GPUInstanceProfileMIGTwog GPUInstanceProfile = "MIG2g" +) + +func PossibleValuesForGPUInstanceProfile() []string { + return []string{ + string(GPUInstanceProfileMIGFourg), + string(GPUInstanceProfileMIGOneg), + string(GPUInstanceProfileMIGSeveng), + string(GPUInstanceProfileMIGThreeg), + string(GPUInstanceProfileMIGTwog), + } +} + +func (s *GPUInstanceProfile) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGPUInstanceProfile(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGPUInstanceProfile(input string) (*GPUInstanceProfile, error) { + vals := map[string]GPUInstanceProfile{ + "mig4g": GPUInstanceProfileMIGFourg, + "mig1g": GPUInstanceProfileMIGOneg, + "mig7g": GPUInstanceProfileMIGSeveng, + "mig3g": GPUInstanceProfileMIGThreeg, + "mig2g": GPUInstanceProfileMIGTwog, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GPUInstanceProfile(input) + return &out, nil +} + +type GuardrailsSupport string + +const ( + GuardrailsSupportPreview GuardrailsSupport = "Preview" + GuardrailsSupportStable GuardrailsSupport = "Stable" +) + +func PossibleValuesForGuardrailsSupport() []string { + return []string{ + string(GuardrailsSupportPreview), + string(GuardrailsSupportStable), + } +} + +func (s *GuardrailsSupport) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGuardrailsSupport(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGuardrailsSupport(input string) (*GuardrailsSupport, error) { + vals := map[string]GuardrailsSupport{ + "preview": GuardrailsSupportPreview, + "stable": GuardrailsSupportStable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := GuardrailsSupport(input) + return &out, nil +} + +type IPFamily string + +const ( + IPFamilyIPvFour IPFamily = "IPv4" + IPFamilyIPvSix IPFamily = "IPv6" +) + +func PossibleValuesForIPFamily() []string { + return []string{ + string(IPFamilyIPvFour), + string(IPFamilyIPvSix), + } +} + +func (s *IPFamily) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPFamily(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPFamily(input string) (*IPFamily, error) { + vals := map[string]IPFamily{ + "ipv4": IPFamilyIPvFour, + "ipv6": IPFamilyIPvSix, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPFamily(input) + return &out, nil +} + +type IPvsScheduler string + +const ( + IPvsSchedulerLeastConnection IPvsScheduler = "LeastConnection" + IPvsSchedulerRoundRobin IPvsScheduler = "RoundRobin" +) + +func PossibleValuesForIPvsScheduler() []string { + return []string{ + string(IPvsSchedulerLeastConnection), + string(IPvsSchedulerRoundRobin), + } +} + +func (s *IPvsScheduler) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIPvsScheduler(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIPvsScheduler(input string) (*IPvsScheduler, error) { + vals := map[string]IPvsScheduler{ + "leastconnection": IPvsSchedulerLeastConnection, + "roundrobin": IPvsSchedulerRoundRobin, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IPvsScheduler(input) + return &out, nil +} + +type IstioIngressGatewayMode string + +const ( + IstioIngressGatewayModeExternal IstioIngressGatewayMode = "External" + IstioIngressGatewayModeInternal IstioIngressGatewayMode = "Internal" +) + +func PossibleValuesForIstioIngressGatewayMode() []string { + return []string{ + string(IstioIngressGatewayModeExternal), + string(IstioIngressGatewayModeInternal), + } +} + +func (s *IstioIngressGatewayMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIstioIngressGatewayMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIstioIngressGatewayMode(input string) (*IstioIngressGatewayMode, error) { + vals := map[string]IstioIngressGatewayMode{ + "external": IstioIngressGatewayModeExternal, + "internal": IstioIngressGatewayModeInternal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IstioIngressGatewayMode(input) + return &out, nil +} + +type KeyVaultNetworkAccessTypes string + +const ( + KeyVaultNetworkAccessTypesPrivate KeyVaultNetworkAccessTypes = "Private" + KeyVaultNetworkAccessTypesPublic KeyVaultNetworkAccessTypes = "Public" +) + +func PossibleValuesForKeyVaultNetworkAccessTypes() []string { + return []string{ + string(KeyVaultNetworkAccessTypesPrivate), + string(KeyVaultNetworkAccessTypesPublic), + } +} + +func (s *KeyVaultNetworkAccessTypes) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyVaultNetworkAccessTypes(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyVaultNetworkAccessTypes(input string) (*KeyVaultNetworkAccessTypes, error) { + vals := map[string]KeyVaultNetworkAccessTypes{ + "private": KeyVaultNetworkAccessTypesPrivate, + "public": KeyVaultNetworkAccessTypesPublic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyVaultNetworkAccessTypes(input) + return &out, nil +} + +type KubeletDiskType string + +const ( + KubeletDiskTypeOS KubeletDiskType = "OS" + KubeletDiskTypeTemporary KubeletDiskType = "Temporary" +) + +func PossibleValuesForKubeletDiskType() []string { + return []string{ + string(KubeletDiskTypeOS), + string(KubeletDiskTypeTemporary), + } +} + +func (s *KubeletDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubeletDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubeletDiskType(input string) (*KubeletDiskType, error) { + vals := map[string]KubeletDiskType{ + "os": KubeletDiskTypeOS, + "temporary": KubeletDiskTypeTemporary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubeletDiskType(input) + return &out, nil +} + +type KubernetesSupportPlan string + +const ( + KubernetesSupportPlanAKSLongTermSupport KubernetesSupportPlan = "AKSLongTermSupport" + KubernetesSupportPlanKubernetesOfficial KubernetesSupportPlan = "KubernetesOfficial" +) + +func PossibleValuesForKubernetesSupportPlan() []string { + return []string{ + string(KubernetesSupportPlanAKSLongTermSupport), + string(KubernetesSupportPlanKubernetesOfficial), + } +} + +func (s *KubernetesSupportPlan) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKubernetesSupportPlan(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKubernetesSupportPlan(input string) (*KubernetesSupportPlan, error) { + vals := map[string]KubernetesSupportPlan{ + "akslongtermsupport": KubernetesSupportPlanAKSLongTermSupport, + "kubernetesofficial": KubernetesSupportPlanKubernetesOfficial, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KubernetesSupportPlan(input) + return &out, nil +} + +type Level string + +const ( + LevelEnforcement Level = "Enforcement" + LevelOff Level = "Off" + LevelWarning Level = "Warning" +) + +func PossibleValuesForLevel() []string { + return []string{ + string(LevelEnforcement), + string(LevelOff), + string(LevelWarning), + } +} + +func (s *Level) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLevel(input string) (*Level, error) { + vals := map[string]Level{ + "enforcement": LevelEnforcement, + "off": LevelOff, + "warning": LevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Level(input) + return &out, nil +} + +type LicenseType string + +const ( + LicenseTypeNone LicenseType = "None" + LicenseTypeWindowsServer LicenseType = "Windows_Server" +) + +func PossibleValuesForLicenseType() []string { + return []string{ + string(LicenseTypeNone), + string(LicenseTypeWindowsServer), + } +} + +func (s *LicenseType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLicenseType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLicenseType(input string) (*LicenseType, error) { + vals := map[string]LicenseType{ + "none": LicenseTypeNone, + "windows_server": LicenseTypeWindowsServer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LicenseType(input) + return &out, nil +} + +type LoadBalancerSku string + +const ( + LoadBalancerSkuBasic LoadBalancerSku = "basic" + LoadBalancerSkuStandard LoadBalancerSku = "standard" +) + +func PossibleValuesForLoadBalancerSku() []string { + return []string{ + string(LoadBalancerSkuBasic), + string(LoadBalancerSkuStandard), + } +} + +func (s *LoadBalancerSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerSku(input string) (*LoadBalancerSku, error) { + vals := map[string]LoadBalancerSku{ + "basic": LoadBalancerSkuBasic, + "standard": LoadBalancerSkuStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerSku(input) + return &out, nil +} + +type ManagedClusterPodIdentityProvisioningState string + +const ( + ManagedClusterPodIdentityProvisioningStateAssigned ManagedClusterPodIdentityProvisioningState = "Assigned" + ManagedClusterPodIdentityProvisioningStateCanceled ManagedClusterPodIdentityProvisioningState = "Canceled" + ManagedClusterPodIdentityProvisioningStateDeleting ManagedClusterPodIdentityProvisioningState = "Deleting" + ManagedClusterPodIdentityProvisioningStateFailed ManagedClusterPodIdentityProvisioningState = "Failed" + ManagedClusterPodIdentityProvisioningStateSucceeded ManagedClusterPodIdentityProvisioningState = "Succeeded" + ManagedClusterPodIdentityProvisioningStateUpdating ManagedClusterPodIdentityProvisioningState = "Updating" +) + +func PossibleValuesForManagedClusterPodIdentityProvisioningState() []string { + return []string{ + string(ManagedClusterPodIdentityProvisioningStateAssigned), + string(ManagedClusterPodIdentityProvisioningStateCanceled), + string(ManagedClusterPodIdentityProvisioningStateDeleting), + string(ManagedClusterPodIdentityProvisioningStateFailed), + string(ManagedClusterPodIdentityProvisioningStateSucceeded), + string(ManagedClusterPodIdentityProvisioningStateUpdating), + } +} + +func (s *ManagedClusterPodIdentityProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterPodIdentityProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterPodIdentityProvisioningState(input string) (*ManagedClusterPodIdentityProvisioningState, error) { + vals := map[string]ManagedClusterPodIdentityProvisioningState{ + "assigned": ManagedClusterPodIdentityProvisioningStateAssigned, + "canceled": ManagedClusterPodIdentityProvisioningStateCanceled, + "deleting": ManagedClusterPodIdentityProvisioningStateDeleting, + "failed": ManagedClusterPodIdentityProvisioningStateFailed, + "succeeded": ManagedClusterPodIdentityProvisioningStateSucceeded, + "updating": ManagedClusterPodIdentityProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterPodIdentityProvisioningState(input) + return &out, nil +} + +type ManagedClusterSKUName string + +const ( + ManagedClusterSKUNameBase ManagedClusterSKUName = "Base" +) + +func PossibleValuesForManagedClusterSKUName() []string { + return []string{ + string(ManagedClusterSKUNameBase), + } +} + +func (s *ManagedClusterSKUName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterSKUName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterSKUName(input string) (*ManagedClusterSKUName, error) { + vals := map[string]ManagedClusterSKUName{ + "base": ManagedClusterSKUNameBase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterSKUName(input) + return &out, nil +} + +type ManagedClusterSKUTier string + +const ( + ManagedClusterSKUTierFree ManagedClusterSKUTier = "Free" + ManagedClusterSKUTierPremium ManagedClusterSKUTier = "Premium" + ManagedClusterSKUTierStandard ManagedClusterSKUTier = "Standard" +) + +func PossibleValuesForManagedClusterSKUTier() []string { + return []string{ + string(ManagedClusterSKUTierFree), + string(ManagedClusterSKUTierPremium), + string(ManagedClusterSKUTierStandard), + } +} + +func (s *ManagedClusterSKUTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterSKUTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterSKUTier(input string) (*ManagedClusterSKUTier, error) { + vals := map[string]ManagedClusterSKUTier{ + "free": ManagedClusterSKUTierFree, + "premium": ManagedClusterSKUTierPremium, + "standard": ManagedClusterSKUTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterSKUTier(input) + return &out, nil +} + +type Mode string + +const ( + ModeIPTABLES Mode = "IPTABLES" + ModeIPVS Mode = "IPVS" +) + +func PossibleValuesForMode() []string { + return []string{ + string(ModeIPTABLES), + string(ModeIPVS), + } +} + +func (s *Mode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMode(input string) (*Mode, error) { + vals := map[string]Mode{ + "iptables": ModeIPTABLES, + "ipvs": ModeIPVS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Mode(input) + return &out, nil +} + +type NetworkDataplane string + +const ( + NetworkDataplaneAzure NetworkDataplane = "azure" + NetworkDataplaneCilium NetworkDataplane = "cilium" +) + +func PossibleValuesForNetworkDataplane() []string { + return []string{ + string(NetworkDataplaneAzure), + string(NetworkDataplaneCilium), + } +} + +func (s *NetworkDataplane) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkDataplane(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkDataplane(input string) (*NetworkDataplane, error) { + vals := map[string]NetworkDataplane{ + "azure": NetworkDataplaneAzure, + "cilium": NetworkDataplaneCilium, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkDataplane(input) + return &out, nil +} + +type NetworkMode string + +const ( + NetworkModeBridge NetworkMode = "bridge" + NetworkModeTransparent NetworkMode = "transparent" +) + +func PossibleValuesForNetworkMode() []string { + return []string{ + string(NetworkModeBridge), + string(NetworkModeTransparent), + } +} + +func (s *NetworkMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkMode(input string) (*NetworkMode, error) { + vals := map[string]NetworkMode{ + "bridge": NetworkModeBridge, + "transparent": NetworkModeTransparent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkMode(input) + return &out, nil +} + +type NetworkPlugin string + +const ( + NetworkPluginAzure NetworkPlugin = "azure" + NetworkPluginKubenet NetworkPlugin = "kubenet" + NetworkPluginNone NetworkPlugin = "none" +) + +func PossibleValuesForNetworkPlugin() []string { + return []string{ + string(NetworkPluginAzure), + string(NetworkPluginKubenet), + string(NetworkPluginNone), + } +} + +func (s *NetworkPlugin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPlugin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPlugin(input string) (*NetworkPlugin, error) { + vals := map[string]NetworkPlugin{ + "azure": NetworkPluginAzure, + "kubenet": NetworkPluginKubenet, + "none": NetworkPluginNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPlugin(input) + return &out, nil +} + +type NetworkPluginMode string + +const ( + NetworkPluginModeOverlay NetworkPluginMode = "overlay" +) + +func PossibleValuesForNetworkPluginMode() []string { + return []string{ + string(NetworkPluginModeOverlay), + } +} + +func (s *NetworkPluginMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPluginMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPluginMode(input string) (*NetworkPluginMode, error) { + vals := map[string]NetworkPluginMode{ + "overlay": NetworkPluginModeOverlay, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPluginMode(input) + return &out, nil +} + +type NetworkPolicy string + +const ( + NetworkPolicyAzure NetworkPolicy = "azure" + NetworkPolicyCalico NetworkPolicy = "calico" + NetworkPolicyCilium NetworkPolicy = "cilium" + NetworkPolicyNone NetworkPolicy = "none" +) + +func PossibleValuesForNetworkPolicy() []string { + return []string{ + string(NetworkPolicyAzure), + string(NetworkPolicyCalico), + string(NetworkPolicyCilium), + string(NetworkPolicyNone), + } +} + +func (s *NetworkPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPolicy(input string) (*NetworkPolicy, error) { + vals := map[string]NetworkPolicy{ + "azure": NetworkPolicyAzure, + "calico": NetworkPolicyCalico, + "cilium": NetworkPolicyCilium, + "none": NetworkPolicyNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPolicy(input) + return &out, nil +} + +type NodeOSUpgradeChannel string + +const ( + NodeOSUpgradeChannelNodeImage NodeOSUpgradeChannel = "NodeImage" + NodeOSUpgradeChannelNone NodeOSUpgradeChannel = "None" + NodeOSUpgradeChannelSecurityPatch NodeOSUpgradeChannel = "SecurityPatch" + NodeOSUpgradeChannelUnmanaged NodeOSUpgradeChannel = "Unmanaged" +) + +func PossibleValuesForNodeOSUpgradeChannel() []string { + return []string{ + string(NodeOSUpgradeChannelNodeImage), + string(NodeOSUpgradeChannelNone), + string(NodeOSUpgradeChannelSecurityPatch), + string(NodeOSUpgradeChannelUnmanaged), + } +} + +func (s *NodeOSUpgradeChannel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeOSUpgradeChannel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodeOSUpgradeChannel(input string) (*NodeOSUpgradeChannel, error) { + vals := map[string]NodeOSUpgradeChannel{ + "nodeimage": NodeOSUpgradeChannelNodeImage, + "none": NodeOSUpgradeChannelNone, + "securitypatch": NodeOSUpgradeChannelSecurityPatch, + "unmanaged": NodeOSUpgradeChannelUnmanaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodeOSUpgradeChannel(input) + return &out, nil +} + +type NodeProvisioningMode string + +const ( + NodeProvisioningModeAuto NodeProvisioningMode = "Auto" + NodeProvisioningModeManual NodeProvisioningMode = "Manual" +) + +func PossibleValuesForNodeProvisioningMode() []string { + return []string{ + string(NodeProvisioningModeAuto), + string(NodeProvisioningModeManual), + } +} + +func (s *NodeProvisioningMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeProvisioningMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodeProvisioningMode(input string) (*NodeProvisioningMode, error) { + vals := map[string]NodeProvisioningMode{ + "auto": NodeProvisioningModeAuto, + "manual": NodeProvisioningModeManual, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodeProvisioningMode(input) + return &out, nil +} + +type OSDiskType string + +const ( + OSDiskTypeEphemeral OSDiskType = "Ephemeral" + OSDiskTypeManaged OSDiskType = "Managed" +) + +func PossibleValuesForOSDiskType() []string { + return []string{ + string(OSDiskTypeEphemeral), + string(OSDiskTypeManaged), + } +} + +func (s *OSDiskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSDiskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSDiskType(input string) (*OSDiskType, error) { + vals := map[string]OSDiskType{ + "ephemeral": OSDiskTypeEphemeral, + "managed": OSDiskTypeManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSDiskType(input) + return &out, nil +} + +type OSSKU string + +const ( + OSSKUAzureLinux OSSKU = "AzureLinux" + OSSKUCBLMariner OSSKU = "CBLMariner" + OSSKUMariner OSSKU = "Mariner" + OSSKUUbuntu OSSKU = "Ubuntu" + OSSKUWindowsAnnual OSSKU = "WindowsAnnual" + OSSKUWindowsTwoZeroOneNine OSSKU = "Windows2019" + OSSKUWindowsTwoZeroTwoTwo OSSKU = "Windows2022" +) + +func PossibleValuesForOSSKU() []string { + return []string{ + string(OSSKUAzureLinux), + string(OSSKUCBLMariner), + string(OSSKUMariner), + string(OSSKUUbuntu), + string(OSSKUWindowsAnnual), + string(OSSKUWindowsTwoZeroOneNine), + string(OSSKUWindowsTwoZeroTwoTwo), + } +} + +func (s *OSSKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSSKU(input string) (*OSSKU, error) { + vals := map[string]OSSKU{ + "azurelinux": OSSKUAzureLinux, + "cblmariner": OSSKUCBLMariner, + "mariner": OSSKUMariner, + "ubuntu": OSSKUUbuntu, + "windowsannual": OSSKUWindowsAnnual, + "windows2019": OSSKUWindowsTwoZeroOneNine, + "windows2022": OSSKUWindowsTwoZeroTwoTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSSKU(input) + return &out, nil +} + +type OSType string + +const ( + OSTypeLinux OSType = "Linux" + OSTypeWindows OSType = "Windows" +) + +func PossibleValuesForOSType() []string { + return []string{ + string(OSTypeLinux), + string(OSTypeWindows), + } +} + +func (s *OSType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSType(input string) (*OSType, error) { + vals := map[string]OSType{ + "linux": OSTypeLinux, + "windows": OSTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSType(input) + return &out, nil +} + +type OutboundType string + +const ( + OutboundTypeLoadBalancer OutboundType = "loadBalancer" + OutboundTypeManagedNATGateway OutboundType = "managedNATGateway" + OutboundTypeUserAssignedNATGateway OutboundType = "userAssignedNATGateway" + OutboundTypeUserDefinedRouting OutboundType = "userDefinedRouting" +) + +func PossibleValuesForOutboundType() []string { + return []string{ + string(OutboundTypeLoadBalancer), + string(OutboundTypeManagedNATGateway), + string(OutboundTypeUserAssignedNATGateway), + string(OutboundTypeUserDefinedRouting), + } +} + +func (s *OutboundType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOutboundType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOutboundType(input string) (*OutboundType, error) { + vals := map[string]OutboundType{ + "loadbalancer": OutboundTypeLoadBalancer, + "managednatgateway": OutboundTypeManagedNATGateway, + "userassignednatgateway": OutboundTypeUserAssignedNATGateway, + "userdefinedrouting": OutboundTypeUserDefinedRouting, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OutboundType(input) + return &out, nil +} + +type Protocol string + +const ( + ProtocolTCP Protocol = "TCP" + ProtocolUDP Protocol = "UDP" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolTCP), + string(ProtocolUDP), + } +} + +func (s *Protocol) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProtocol(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProtocol(input string) (*Protocol, error) { + vals := map[string]Protocol{ + "tcp": ProtocolTCP, + "udp": ProtocolUDP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Protocol(input) + return &out, nil +} + +type PublicNetworkAccess string + +const ( + PublicNetworkAccessDisabled PublicNetworkAccess = "Disabled" + PublicNetworkAccessEnabled PublicNetworkAccess = "Enabled" + PublicNetworkAccessSecuredByPerimeter PublicNetworkAccess = "SecuredByPerimeter" +) + +func PossibleValuesForPublicNetworkAccess() []string { + return []string{ + string(PublicNetworkAccessDisabled), + string(PublicNetworkAccessEnabled), + string(PublicNetworkAccessSecuredByPerimeter), + } +} + +func (s *PublicNetworkAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccess(input string) (*PublicNetworkAccess, error) { + vals := map[string]PublicNetworkAccess{ + "disabled": PublicNetworkAccessDisabled, + "enabled": PublicNetworkAccessEnabled, + "securedbyperimeter": PublicNetworkAccessSecuredByPerimeter, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccess(input) + return &out, nil +} + +type RestrictionLevel string + +const ( + RestrictionLevelReadOnly RestrictionLevel = "ReadOnly" + RestrictionLevelUnrestricted RestrictionLevel = "Unrestricted" +) + +func PossibleValuesForRestrictionLevel() []string { + return []string{ + string(RestrictionLevelReadOnly), + string(RestrictionLevelUnrestricted), + } +} + +func (s *RestrictionLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRestrictionLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRestrictionLevel(input string) (*RestrictionLevel, error) { + vals := map[string]RestrictionLevel{ + "readonly": RestrictionLevelReadOnly, + "unrestricted": RestrictionLevelUnrestricted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RestrictionLevel(input) + return &out, nil +} + +type ScaleDownMode string + +const ( + ScaleDownModeDeallocate ScaleDownMode = "Deallocate" + ScaleDownModeDelete ScaleDownMode = "Delete" +) + +func PossibleValuesForScaleDownMode() []string { + return []string{ + string(ScaleDownModeDeallocate), + string(ScaleDownModeDelete), + } +} + +func (s *ScaleDownMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleDownMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleDownMode(input string) (*ScaleDownMode, error) { + vals := map[string]ScaleDownMode{ + "deallocate": ScaleDownModeDeallocate, + "delete": ScaleDownModeDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleDownMode(input) + return &out, nil +} + +type ScaleSetEvictionPolicy string + +const ( + ScaleSetEvictionPolicyDeallocate ScaleSetEvictionPolicy = "Deallocate" + ScaleSetEvictionPolicyDelete ScaleSetEvictionPolicy = "Delete" +) + +func PossibleValuesForScaleSetEvictionPolicy() []string { + return []string{ + string(ScaleSetEvictionPolicyDeallocate), + string(ScaleSetEvictionPolicyDelete), + } +} + +func (s *ScaleSetEvictionPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetEvictionPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetEvictionPolicy(input string) (*ScaleSetEvictionPolicy, error) { + vals := map[string]ScaleSetEvictionPolicy{ + "deallocate": ScaleSetEvictionPolicyDeallocate, + "delete": ScaleSetEvictionPolicyDelete, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetEvictionPolicy(input) + return &out, nil +} + +type ScaleSetPriority string + +const ( + ScaleSetPriorityRegular ScaleSetPriority = "Regular" + ScaleSetPrioritySpot ScaleSetPriority = "Spot" +) + +func PossibleValuesForScaleSetPriority() []string { + return []string{ + string(ScaleSetPriorityRegular), + string(ScaleSetPrioritySpot), + } +} + +func (s *ScaleSetPriority) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleSetPriority(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleSetPriority(input string) (*ScaleSetPriority, error) { + vals := map[string]ScaleSetPriority{ + "regular": ScaleSetPriorityRegular, + "spot": ScaleSetPrioritySpot, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleSetPriority(input) + return &out, nil +} + +type ServiceMeshMode string + +const ( + ServiceMeshModeDisabled ServiceMeshMode = "Disabled" + ServiceMeshModeIstio ServiceMeshMode = "Istio" +) + +func PossibleValuesForServiceMeshMode() []string { + return []string{ + string(ServiceMeshModeDisabled), + string(ServiceMeshModeIstio), + } +} + +func (s *ServiceMeshMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceMeshMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceMeshMode(input string) (*ServiceMeshMode, error) { + vals := map[string]ServiceMeshMode{ + "disabled": ServiceMeshModeDisabled, + "istio": ServiceMeshModeIstio, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceMeshMode(input) + return &out, nil +} + +type UpgradeChannel string + +const ( + UpgradeChannelNodeNegativeimage UpgradeChannel = "node-image" + UpgradeChannelNone UpgradeChannel = "none" + UpgradeChannelPatch UpgradeChannel = "patch" + UpgradeChannelRapid UpgradeChannel = "rapid" + UpgradeChannelStable UpgradeChannel = "stable" +) + +func PossibleValuesForUpgradeChannel() []string { + return []string{ + string(UpgradeChannelNodeNegativeimage), + string(UpgradeChannelNone), + string(UpgradeChannelPatch), + string(UpgradeChannelRapid), + string(UpgradeChannelStable), + } +} + +func (s *UpgradeChannel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUpgradeChannel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUpgradeChannel(input string) (*UpgradeChannel, error) { + vals := map[string]UpgradeChannel{ + "node-image": UpgradeChannelNodeNegativeimage, + "none": UpgradeChannelNone, + "patch": UpgradeChannelPatch, + "rapid": UpgradeChannelRapid, + "stable": UpgradeChannelStable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UpgradeChannel(input) + return &out, nil +} + +type WorkloadRuntime string + +const ( + WorkloadRuntimeKataMshvVMIsolation WorkloadRuntime = "KataMshvVmIsolation" + WorkloadRuntimeOCIContainer WorkloadRuntime = "OCIContainer" + WorkloadRuntimeWasmWasi WorkloadRuntime = "WasmWasi" +) + +func PossibleValuesForWorkloadRuntime() []string { + return []string{ + string(WorkloadRuntimeKataMshvVMIsolation), + string(WorkloadRuntimeOCIContainer), + string(WorkloadRuntimeWasmWasi), + } +} + +func (s *WorkloadRuntime) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWorkloadRuntime(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWorkloadRuntime(input string) (*WorkloadRuntime, error) { + vals := map[string]WorkloadRuntime{ + "katamshvvmisolation": WorkloadRuntimeKataMshvVMIsolation, + "ocicontainer": WorkloadRuntimeOCIContainer, + "wasmwasi": WorkloadRuntimeWasmWasi, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WorkloadRuntime(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_accessprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_accessprofile.go new file mode 100644 index 00000000000..6719ccebee1 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_accessprofile.go @@ -0,0 +1,139 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&AccessProfileId{}) +} + +var _ resourceids.ResourceId = &AccessProfileId{} + +// AccessProfileId is a struct representing the Resource ID for a Access Profile +type AccessProfileId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + AccessProfileName string +} + +// NewAccessProfileID returns a new AccessProfileId struct +func NewAccessProfileID(subscriptionId string, resourceGroupName string, managedClusterName string, accessProfileName string) AccessProfileId { + return AccessProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + AccessProfileName: accessProfileName, + } +} + +// ParseAccessProfileID parses 'input' into a AccessProfileId +func ParseAccessProfileID(input string) (*AccessProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessProfileId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccessProfileIDInsensitively parses 'input' case-insensitively into a AccessProfileId +// note: this method should only be used for API response data and not user input +func ParseAccessProfileIDInsensitively(input string) (*AccessProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccessProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccessProfileId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccessProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.AccessProfileName, ok = input.Parsed["accessProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accessProfileName", input) + } + + return nil +} + +// ValidateAccessProfileID checks that 'input' can be parsed as a Access Profile ID +func ValidateAccessProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseAccessProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Access Profile ID +func (id AccessProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/accessProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.AccessProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Access Profile ID +func (id AccessProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticAccessProfiles", "accessProfiles", "accessProfiles"), + resourceids.UserSpecifiedSegment("accessProfileName", "accessProfileValue"), + } +} + +// String returns a human-readable description of this Access Profile ID +func (id AccessProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Access Profile Name: %q", id.AccessProfileName), + } + return fmt.Sprintf("Access Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_accessprofile_test.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_accessprofile_test.go new file mode 100644 index 00000000000..ae85155dd07 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_accessprofile_test.go @@ -0,0 +1,327 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &AccessProfileId{} + +func TestNewAccessProfileID(t *testing.T) { + id := NewAccessProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "accessProfileValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.AccessProfileName != "accessProfileValue" { + t.Fatalf("Expected %q but got %q for Segment 'AccessProfileName'", id.AccessProfileName, "accessProfileValue") + } +} + +func TestFormatAccessProfileID(t *testing.T) { + actual := NewAccessProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "accessProfileValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/accessProfiles/accessProfileValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseAccessProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/accessProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/accessProfiles/accessProfileValue", + Expected: &AccessProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AccessProfileName: "accessProfileValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/accessProfiles/accessProfileValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AccessProfileName != v.Expected.AccessProfileName { + t.Fatalf("Expected %q but got %q for AccessProfileName", v.Expected.AccessProfileName, actual.AccessProfileName) + } + + } +} + +func TestParseAccessProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *AccessProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/accessProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aCcEsSpRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/accessProfiles/accessProfileValue", + Expected: &AccessProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + AccessProfileName: "accessProfileValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/accessProfiles/accessProfileValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aCcEsSpRoFiLeS/aCcEsSpRoFiLeVaLuE", + Expected: &AccessProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + AccessProfileName: "aCcEsSpRoFiLeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/aCcEsSpRoFiLeS/aCcEsSpRoFiLeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseAccessProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.AccessProfileName != v.Expected.AccessProfileName { + t.Fatalf("Expected %q but got %q for AccessProfileName", v.Expected.AccessProfileName, actual.AccessProfileName) + } + + } +} + +func TestSegmentsForAccessProfileId(t *testing.T) { + segments := AccessProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("AccessProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_commandresult.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_commandresult.go new file mode 100644 index 00000000000..8cad7061547 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_commandresult.go @@ -0,0 +1,139 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CommandResultId{}) +} + +var _ resourceids.ResourceId = &CommandResultId{} + +// CommandResultId is a struct representing the Resource ID for a Command Result +type CommandResultId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + CommandId string +} + +// NewCommandResultID returns a new CommandResultId struct +func NewCommandResultID(subscriptionId string, resourceGroupName string, managedClusterName string, commandId string) CommandResultId { + return CommandResultId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + CommandId: commandId, + } +} + +// ParseCommandResultID parses 'input' into a CommandResultId +func ParseCommandResultID(input string) (*CommandResultId, error) { + parser := resourceids.NewParserFromResourceIdType(&CommandResultId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CommandResultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCommandResultIDInsensitively parses 'input' case-insensitively into a CommandResultId +// note: this method should only be used for API response data and not user input +func ParseCommandResultIDInsensitively(input string) (*CommandResultId, error) { + parser := resourceids.NewParserFromResourceIdType(&CommandResultId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CommandResultId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CommandResultId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.CommandId, ok = input.Parsed["commandId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "commandId", input) + } + + return nil +} + +// ValidateCommandResultID checks that 'input' can be parsed as a Command Result ID +func ValidateCommandResultID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCommandResultID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Command Result ID +func (id CommandResultId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/commandResults/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.CommandId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Command Result ID +func (id CommandResultId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticCommandResults", "commandResults", "commandResults"), + resourceids.UserSpecifiedSegment("commandId", "commandIdValue"), + } +} + +// String returns a human-readable description of this Command Result ID +func (id CommandResultId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Command: %q", id.CommandId), + } + return fmt.Sprintf("Command Result (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_commandresult_test.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_commandresult_test.go new file mode 100644 index 00000000000..708a5b3b98d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_commandresult_test.go @@ -0,0 +1,327 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CommandResultId{} + +func TestNewCommandResultID(t *testing.T) { + id := NewCommandResultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "commandIdValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.CommandId != "commandIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'CommandId'", id.CommandId, "commandIdValue") + } +} + +func TestFormatCommandResultID(t *testing.T) { + actual := NewCommandResultID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "commandIdValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/commandResults/commandIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCommandResultID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CommandResultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/commandResults", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/commandResults/commandIdValue", + Expected: &CommandResultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + CommandId: "commandIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/commandResults/commandIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCommandResultID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.CommandId != v.Expected.CommandId { + t.Fatalf("Expected %q but got %q for CommandId", v.Expected.CommandId, actual.CommandId) + } + + } +} + +func TestParseCommandResultIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CommandResultId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/commandResults", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/cOmMaNdReSuLtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/commandResults/commandIdValue", + Expected: &CommandResultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + CommandId: "commandIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/commandResults/commandIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/cOmMaNdReSuLtS/cOmMaNdIdVaLuE", + Expected: &CommandResultId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + CommandId: "cOmMaNdIdVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/cOmMaNdReSuLtS/cOmMaNdIdVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCommandResultIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.CommandId != v.Expected.CommandId { + t.Fatalf("Expected %q but got %q for CommandId", v.Expected.CommandId, actual.CommandId) + } + + } +} + +func TestSegmentsForCommandResultId(t *testing.T) { + segments := CommandResultId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CommandResultId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_guardrailsversion.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_guardrailsversion.go new file mode 100644 index 00000000000..893637a2d7a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_guardrailsversion.go @@ -0,0 +1,130 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&GuardrailsVersionId{}) +} + +var _ resourceids.ResourceId = &GuardrailsVersionId{} + +// GuardrailsVersionId is a struct representing the Resource ID for a Guardrails Version +type GuardrailsVersionId struct { + SubscriptionId string + LocationName string + GuardrailsVersionName string +} + +// NewGuardrailsVersionID returns a new GuardrailsVersionId struct +func NewGuardrailsVersionID(subscriptionId string, locationName string, guardrailsVersionName string) GuardrailsVersionId { + return GuardrailsVersionId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + GuardrailsVersionName: guardrailsVersionName, + } +} + +// ParseGuardrailsVersionID parses 'input' into a GuardrailsVersionId +func ParseGuardrailsVersionID(input string) (*GuardrailsVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&GuardrailsVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GuardrailsVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseGuardrailsVersionIDInsensitively parses 'input' case-insensitively into a GuardrailsVersionId +// note: this method should only be used for API response data and not user input +func ParseGuardrailsVersionIDInsensitively(input string) (*GuardrailsVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&GuardrailsVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := GuardrailsVersionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *GuardrailsVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.GuardrailsVersionName, ok = input.Parsed["guardrailsVersionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "guardrailsVersionName", input) + } + + return nil +} + +// ValidateGuardrailsVersionID checks that 'input' can be parsed as a Guardrails Version ID +func ValidateGuardrailsVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseGuardrailsVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Guardrails Version ID +func (id GuardrailsVersionId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ContainerService/locations/%s/guardrailsVersions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.GuardrailsVersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Guardrails Version ID +func (id GuardrailsVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticGuardrailsVersions", "guardrailsVersions", "guardrailsVersions"), + resourceids.UserSpecifiedSegment("guardrailsVersionName", "guardrailsVersionValue"), + } +} + +// String returns a human-readable description of this Guardrails Version ID +func (id GuardrailsVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Guardrails Version Name: %q", id.GuardrailsVersionName), + } + return fmt.Sprintf("Guardrails Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_guardrailsversion_test.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_guardrailsversion_test.go new file mode 100644 index 00000000000..23a53f5a8cc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_guardrailsversion_test.go @@ -0,0 +1,282 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &GuardrailsVersionId{} + +func TestNewGuardrailsVersionID(t *testing.T) { + id := NewGuardrailsVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "guardrailsVersionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } + + if id.GuardrailsVersionName != "guardrailsVersionValue" { + t.Fatalf("Expected %q but got %q for Segment 'GuardrailsVersionName'", id.GuardrailsVersionName, "guardrailsVersionValue") + } +} + +func TestFormatGuardrailsVersionID(t *testing.T) { + actual := NewGuardrailsVersionID("12345678-1234-9876-4563-123456789012", "locationValue", "guardrailsVersionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/guardrailsVersions/guardrailsVersionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseGuardrailsVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GuardrailsVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/guardrailsVersions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/guardrailsVersions/guardrailsVersionValue", + Expected: &GuardrailsVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + GuardrailsVersionName: "guardrailsVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/guardrailsVersions/guardrailsVersionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGuardrailsVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.GuardrailsVersionName != v.Expected.GuardrailsVersionName { + t.Fatalf("Expected %q but got %q for GuardrailsVersionName", v.Expected.GuardrailsVersionName, actual.GuardrailsVersionName) + } + + } +} + +func TestParseGuardrailsVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *GuardrailsVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/guardrailsVersions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/gUaRdRaIlSvErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/guardrailsVersions/guardrailsVersionValue", + Expected: &GuardrailsVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + GuardrailsVersionName: "guardrailsVersionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/guardrailsVersions/guardrailsVersionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/gUaRdRaIlSvErSiOnS/gUaRdRaIlSvErSiOnVaLuE", + Expected: &GuardrailsVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + GuardrailsVersionName: "gUaRdRaIlSvErSiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/gUaRdRaIlSvErSiOnS/gUaRdRaIlSvErSiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseGuardrailsVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.GuardrailsVersionName != v.Expected.GuardrailsVersionName { + t.Fatalf("Expected %q but got %q for GuardrailsVersionName", v.Expected.GuardrailsVersionName, actual.GuardrailsVersionName) + } + + } +} + +func TestSegmentsForGuardrailsVersionId(t *testing.T) { + segments := GuardrailsVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("GuardrailsVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_location.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_location.go new file mode 100644 index 00000000000..2a97028d499 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_location.go @@ -0,0 +1,121 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ContainerService/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_location_test.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_location_test.go new file mode 100644 index 00000000000..1d6af703274 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_location_test.go @@ -0,0 +1,237 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshrevisionprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshrevisionprofile.go new file mode 100644 index 00000000000..6a9b778fbae --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshrevisionprofile.go @@ -0,0 +1,130 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MeshRevisionProfileId{}) +} + +var _ resourceids.ResourceId = &MeshRevisionProfileId{} + +// MeshRevisionProfileId is a struct representing the Resource ID for a Mesh Revision Profile +type MeshRevisionProfileId struct { + SubscriptionId string + LocationName string + MeshRevisionProfileName string +} + +// NewMeshRevisionProfileID returns a new MeshRevisionProfileId struct +func NewMeshRevisionProfileID(subscriptionId string, locationName string, meshRevisionProfileName string) MeshRevisionProfileId { + return MeshRevisionProfileId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + MeshRevisionProfileName: meshRevisionProfileName, + } +} + +// ParseMeshRevisionProfileID parses 'input' into a MeshRevisionProfileId +func ParseMeshRevisionProfileID(input string) (*MeshRevisionProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshRevisionProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshRevisionProfileId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMeshRevisionProfileIDInsensitively parses 'input' case-insensitively into a MeshRevisionProfileId +// note: this method should only be used for API response data and not user input +func ParseMeshRevisionProfileIDInsensitively(input string) (*MeshRevisionProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshRevisionProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshRevisionProfileId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MeshRevisionProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.MeshRevisionProfileName, ok = input.Parsed["meshRevisionProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "meshRevisionProfileName", input) + } + + return nil +} + +// ValidateMeshRevisionProfileID checks that 'input' can be parsed as a Mesh Revision Profile ID +func ValidateMeshRevisionProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMeshRevisionProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mesh Revision Profile ID +func (id MeshRevisionProfileId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ContainerService/locations/%s/meshRevisionProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.MeshRevisionProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mesh Revision Profile ID +func (id MeshRevisionProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + resourceids.StaticSegment("staticMeshRevisionProfiles", "meshRevisionProfiles", "meshRevisionProfiles"), + resourceids.UserSpecifiedSegment("meshRevisionProfileName", "meshRevisionProfileValue"), + } +} + +// String returns a human-readable description of this Mesh Revision Profile ID +func (id MeshRevisionProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Mesh Revision Profile Name: %q", id.MeshRevisionProfileName), + } + return fmt.Sprintf("Mesh Revision Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshrevisionprofile_test.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshrevisionprofile_test.go new file mode 100644 index 00000000000..8261181fc8c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshrevisionprofile_test.go @@ -0,0 +1,282 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MeshRevisionProfileId{} + +func TestNewMeshRevisionProfileID(t *testing.T) { + id := NewMeshRevisionProfileID("12345678-1234-9876-4563-123456789012", "locationValue", "meshRevisionProfileValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } + + if id.MeshRevisionProfileName != "meshRevisionProfileValue" { + t.Fatalf("Expected %q but got %q for Segment 'MeshRevisionProfileName'", id.MeshRevisionProfileName, "meshRevisionProfileValue") + } +} + +func TestFormatMeshRevisionProfileID(t *testing.T) { + actual := NewMeshRevisionProfileID("12345678-1234-9876-4563-123456789012", "locationValue", "meshRevisionProfileValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/meshRevisionProfiles/meshRevisionProfileValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMeshRevisionProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshRevisionProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/meshRevisionProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/meshRevisionProfiles/meshRevisionProfileValue", + Expected: &MeshRevisionProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + MeshRevisionProfileName: "meshRevisionProfileValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/meshRevisionProfiles/meshRevisionProfileValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshRevisionProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.MeshRevisionProfileName != v.Expected.MeshRevisionProfileName { + t.Fatalf("Expected %q but got %q for MeshRevisionProfileName", v.Expected.MeshRevisionProfileName, actual.MeshRevisionProfileName) + } + + } +} + +func TestParseMeshRevisionProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshRevisionProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/meshRevisionProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/mEsHrEvIsIoNpRoFiLeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/meshRevisionProfiles/meshRevisionProfileValue", + Expected: &MeshRevisionProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + MeshRevisionProfileName: "meshRevisionProfileValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/meshRevisionProfiles/meshRevisionProfileValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/mEsHrEvIsIoNpRoFiLeS/mEsHrEvIsIoNpRoFiLeVaLuE", + Expected: &MeshRevisionProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + MeshRevisionProfileName: "mEsHrEvIsIoNpRoFiLeVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/mEsHrEvIsIoNpRoFiLeS/mEsHrEvIsIoNpRoFiLeVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshRevisionProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + if actual.MeshRevisionProfileName != v.Expected.MeshRevisionProfileName { + t.Fatalf("Expected %q but got %q for MeshRevisionProfileName", v.Expected.MeshRevisionProfileName, actual.MeshRevisionProfileName) + } + + } +} + +func TestSegmentsForMeshRevisionProfileId(t *testing.T) { + segments := MeshRevisionProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MeshRevisionProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshupgradeprofile.go new file mode 100644 index 00000000000..6354c5ca0b8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshupgradeprofile.go @@ -0,0 +1,139 @@ +package managedclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MeshUpgradeProfileId{}) +} + +var _ resourceids.ResourceId = &MeshUpgradeProfileId{} + +// MeshUpgradeProfileId is a struct representing the Resource ID for a Mesh Upgrade Profile +type MeshUpgradeProfileId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + MeshUpgradeProfileName string +} + +// NewMeshUpgradeProfileID returns a new MeshUpgradeProfileId struct +func NewMeshUpgradeProfileID(subscriptionId string, resourceGroupName string, managedClusterName string, meshUpgradeProfileName string) MeshUpgradeProfileId { + return MeshUpgradeProfileId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + MeshUpgradeProfileName: meshUpgradeProfileName, + } +} + +// ParseMeshUpgradeProfileID parses 'input' into a MeshUpgradeProfileId +func ParseMeshUpgradeProfileID(input string) (*MeshUpgradeProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshUpgradeProfileId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshUpgradeProfileId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMeshUpgradeProfileIDInsensitively parses 'input' case-insensitively into a MeshUpgradeProfileId +// note: this method should only be used for API response data and not user input +func ParseMeshUpgradeProfileIDInsensitively(input string) (*MeshUpgradeProfileId, error) { + parser := resourceids.NewParserFromResourceIdType(&MeshUpgradeProfileId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MeshUpgradeProfileId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MeshUpgradeProfileId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.MeshUpgradeProfileName, ok = input.Parsed["meshUpgradeProfileName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "meshUpgradeProfileName", input) + } + + return nil +} + +// ValidateMeshUpgradeProfileID checks that 'input' can be parsed as a Mesh Upgrade Profile ID +func ValidateMeshUpgradeProfileID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMeshUpgradeProfileID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Mesh Upgrade Profile ID +func (id MeshUpgradeProfileId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/meshUpgradeProfiles/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.MeshUpgradeProfileName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Mesh Upgrade Profile ID +func (id MeshUpgradeProfileId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticMeshUpgradeProfiles", "meshUpgradeProfiles", "meshUpgradeProfiles"), + resourceids.UserSpecifiedSegment("meshUpgradeProfileName", "meshUpgradeProfileValue"), + } +} + +// String returns a human-readable description of this Mesh Upgrade Profile ID +func (id MeshUpgradeProfileId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Mesh Upgrade Profile Name: %q", id.MeshUpgradeProfileName), + } + return fmt.Sprintf("Mesh Upgrade Profile (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshupgradeprofile_test.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshupgradeprofile_test.go new file mode 100644 index 00000000000..74c791e57d8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/id_meshupgradeprofile_test.go @@ -0,0 +1,327 @@ +package managedclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MeshUpgradeProfileId{} + +func TestNewMeshUpgradeProfileID(t *testing.T) { + id := NewMeshUpgradeProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "meshUpgradeProfileValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.MeshUpgradeProfileName != "meshUpgradeProfileValue" { + t.Fatalf("Expected %q but got %q for Segment 'MeshUpgradeProfileName'", id.MeshUpgradeProfileName, "meshUpgradeProfileValue") + } +} + +func TestFormatMeshUpgradeProfileID(t *testing.T) { + actual := NewMeshUpgradeProfileID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "meshUpgradeProfileValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/meshUpgradeProfiles/meshUpgradeProfileValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMeshUpgradeProfileID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshUpgradeProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/meshUpgradeProfiles", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/meshUpgradeProfiles/meshUpgradeProfileValue", + Expected: &MeshUpgradeProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + MeshUpgradeProfileName: "meshUpgradeProfileValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/meshUpgradeProfiles/meshUpgradeProfileValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshUpgradeProfileID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MeshUpgradeProfileName != v.Expected.MeshUpgradeProfileName { + t.Fatalf("Expected %q but got %q for MeshUpgradeProfileName", v.Expected.MeshUpgradeProfileName, actual.MeshUpgradeProfileName) + } + + } +} + +func TestParseMeshUpgradeProfileIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MeshUpgradeProfileId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/meshUpgradeProfiles", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/mEsHuPgRaDePrOfIlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/meshUpgradeProfiles/meshUpgradeProfileValue", + Expected: &MeshUpgradeProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + MeshUpgradeProfileName: "meshUpgradeProfileValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/meshUpgradeProfiles/meshUpgradeProfileValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/mEsHuPgRaDePrOfIlEs/mEsHuPgRaDePrOfIlEvAlUe", + Expected: &MeshUpgradeProfileId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + MeshUpgradeProfileName: "mEsHuPgRaDePrOfIlEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/mEsHuPgRaDePrOfIlEs/mEsHuPgRaDePrOfIlEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMeshUpgradeProfileIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.MeshUpgradeProfileName != v.Expected.MeshUpgradeProfileName { + t.Fatalf("Expected %q but got %q for MeshUpgradeProfileName", v.Expected.MeshUpgradeProfileName, actual.MeshUpgradeProfileName) + } + + } +} + +func TestSegmentsForMeshUpgradeProfileId(t *testing.T) { + segments := MeshUpgradeProfileId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MeshUpgradeProfileId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_abortlatestoperation.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_abortlatestoperation.go new file mode 100644 index 00000000000..a37480f49c9 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_abortlatestoperation.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AbortLatestOperationOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// AbortLatestOperation ... +func (c ManagedClustersClient) AbortLatestOperation(ctx context.Context, id commonids.KubernetesClusterId) (result AbortLatestOperationOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/abort", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// AbortLatestOperationThenPoll performs AbortLatestOperation then polls until it's completed +func (c ManagedClustersClient) AbortLatestOperationThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.AbortLatestOperation(ctx, id) + if err != nil { + return fmt.Errorf("performing AbortLatestOperation: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after AbortLatestOperation: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_createorupdate.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_createorupdate.go new file mode 100644 index 00000000000..c32d75d0be9 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_createorupdate.go @@ -0,0 +1,76 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCluster +} + +// CreateOrUpdate ... +func (c ManagedClustersClient) CreateOrUpdate(ctx context.Context, id commonids.KubernetesClusterId, input ManagedCluster) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ManagedClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input ManagedCluster) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_delete.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_delete.go new file mode 100644 index 00000000000..53bf6a9ac7c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_delete.go @@ -0,0 +1,99 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type DeleteOperationOptions struct { + IgnorePodDisruptionBudget *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.IgnorePodDisruptionBudget != nil { + out.Append("ignore-pod-disruption-budget", fmt.Sprintf("%v", *o.IgnorePodDisruptionBudget)) + } + return &out +} + +// Delete ... +func (c ManagedClustersClient) Delete(ctx context.Context, id commonids.KubernetesClusterId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ManagedClustersClient) DeleteThenPoll(ctx context.Context, id commonids.KubernetesClusterId, options DeleteOperationOptions) error { + result, err := c.Delete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_get.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_get.go new file mode 100644 index 00000000000..7962c50ca93 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_get.go @@ -0,0 +1,55 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCluster +} + +// Get ... +func (c ManagedClustersClient) Get(ctx context.Context, id commonids.KubernetesClusterId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedCluster + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getaccessprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getaccessprofile.go new file mode 100644 index 00000000000..fb2fd875c42 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getaccessprofile.go @@ -0,0 +1,55 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetAccessProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterAccessProfile +} + +// GetAccessProfile ... +func (c ManagedClustersClient) GetAccessProfile(ctx context.Context, id AccessProfileId) (result GetAccessProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listCredential", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterAccessProfile + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getcommandresult.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getcommandresult.go new file mode 100644 index 00000000000..3f6f4f1f00f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getcommandresult.go @@ -0,0 +1,55 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetCommandResultOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RunCommandResult +} + +// GetCommandResult ... +func (c ManagedClustersClient) GetCommandResult(ctx context.Context, id CommandResultId) (result GetCommandResultOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model RunCommandResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getguardrailsversions.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getguardrailsversions.go new file mode 100644 index 00000000000..fbd1c0ce6c3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getguardrailsversions.go @@ -0,0 +1,54 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetGuardrailsVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GuardrailsAvailableVersion +} + +// GetGuardrailsVersions ... +func (c ManagedClustersClient) GetGuardrailsVersions(ctx context.Context, id GuardrailsVersionId) (result GetGuardrailsVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model GuardrailsAvailableVersion + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getmeshrevisionprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getmeshrevisionprofile.go new file mode 100644 index 00000000000..2aa4f55b1c3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getmeshrevisionprofile.go @@ -0,0 +1,54 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMeshRevisionProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MeshRevisionProfile +} + +// GetMeshRevisionProfile ... +func (c ManagedClustersClient) GetMeshRevisionProfile(ctx context.Context, id MeshRevisionProfileId) (result GetMeshRevisionProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MeshRevisionProfile + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getmeshupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getmeshupgradeprofile.go new file mode 100644 index 00000000000..12b2a1032ed --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getmeshupgradeprofile.go @@ -0,0 +1,54 @@ +package managedclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetMeshUpgradeProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *MeshUpgradeProfile +} + +// GetMeshUpgradeProfile ... +func (c ManagedClustersClient) GetMeshUpgradeProfile(ctx context.Context, id MeshUpgradeProfileId) (result GetMeshUpgradeProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model MeshUpgradeProfile + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getosoptions.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getosoptions.go new file mode 100644 index 00000000000..8f4f629fc4d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getosoptions.go @@ -0,0 +1,83 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOSOptionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OSOptionProfile +} + +type GetOSOptionsOperationOptions struct { + ResourceType *string +} + +func DefaultGetOSOptionsOperationOptions() GetOSOptionsOperationOptions { + return GetOSOptionsOperationOptions{} +} + +func (o GetOSOptionsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o GetOSOptionsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o GetOSOptionsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ResourceType != nil { + out.Append("resource-type", fmt.Sprintf("%v", *o.ResourceType)) + } + return &out +} + +// GetOSOptions ... +func (c ManagedClustersClient) GetOSOptions(ctx context.Context, id LocationId, options GetOSOptionsOperationOptions) (result GetOSOptionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/osOptions/default", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model OSOptionProfile + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getupgradeprofile.go new file mode 100644 index 00000000000..9b500de8b58 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_getupgradeprofile.go @@ -0,0 +1,56 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetUpgradeProfileOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterUpgradeProfile +} + +// GetUpgradeProfile ... +func (c ManagedClustersClient) GetUpgradeProfile(ctx context.Context, id commonids.KubernetesClusterId) (result GetUpgradeProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/upgradeProfiles/default", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterUpgradeProfile + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_list.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_list.go new file mode 100644 index 00000000000..17fb5e8fb68 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_list.go @@ -0,0 +1,92 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedCluster +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// List ... +func (c ManagedClustersClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ContainerService/managedClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listbyresourcegroup.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listbyresourcegroup.go new file mode 100644 index 00000000000..ee4658b5e0f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedCluster +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedCluster +} + +// ListByResourceGroup ... +func (c ManagedClustersClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ContainerService/managedClusters", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedCluster, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclusteradmincredentials.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclusteradmincredentials.go new file mode 100644 index 00000000000..ffd25c8f6ec --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclusteradmincredentials.go @@ -0,0 +1,84 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterAdminCredentialsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CredentialResults +} + +type ListClusterAdminCredentialsOperationOptions struct { + ServerFqdn *string +} + +func DefaultListClusterAdminCredentialsOperationOptions() ListClusterAdminCredentialsOperationOptions { + return ListClusterAdminCredentialsOperationOptions{} +} + +func (o ListClusterAdminCredentialsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListClusterAdminCredentialsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListClusterAdminCredentialsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ServerFqdn != nil { + out.Append("server-fqdn", fmt.Sprintf("%v", *o.ServerFqdn)) + } + return &out +} + +// ListClusterAdminCredentials ... +func (c ManagedClustersClient) ListClusterAdminCredentials(ctx context.Context, id commonids.KubernetesClusterId, options ListClusterAdminCredentialsOperationOptions) (result ListClusterAdminCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listClusterAdminCredential", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CredentialResults + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclustermonitoringusercredentials.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclustermonitoringusercredentials.go new file mode 100644 index 00000000000..085c52f9396 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclustermonitoringusercredentials.go @@ -0,0 +1,84 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterMonitoringUserCredentialsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CredentialResults +} + +type ListClusterMonitoringUserCredentialsOperationOptions struct { + ServerFqdn *string +} + +func DefaultListClusterMonitoringUserCredentialsOperationOptions() ListClusterMonitoringUserCredentialsOperationOptions { + return ListClusterMonitoringUserCredentialsOperationOptions{} +} + +func (o ListClusterMonitoringUserCredentialsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListClusterMonitoringUserCredentialsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListClusterMonitoringUserCredentialsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ServerFqdn != nil { + out.Append("server-fqdn", fmt.Sprintf("%v", *o.ServerFqdn)) + } + return &out +} + +// ListClusterMonitoringUserCredentials ... +func (c ManagedClustersClient) ListClusterMonitoringUserCredentials(ctx context.Context, id commonids.KubernetesClusterId, options ListClusterMonitoringUserCredentialsOperationOptions) (result ListClusterMonitoringUserCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listClusterMonitoringUserCredential", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CredentialResults + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclusterusercredentials.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclusterusercredentials.go new file mode 100644 index 00000000000..b0a714473bd --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listclusterusercredentials.go @@ -0,0 +1,88 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterUserCredentialsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CredentialResults +} + +type ListClusterUserCredentialsOperationOptions struct { + Format *Format + ServerFqdn *string +} + +func DefaultListClusterUserCredentialsOperationOptions() ListClusterUserCredentialsOperationOptions { + return ListClusterUserCredentialsOperationOptions{} +} + +func (o ListClusterUserCredentialsOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListClusterUserCredentialsOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListClusterUserCredentialsOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Format != nil { + out.Append("format", fmt.Sprintf("%v", *o.Format)) + } + if o.ServerFqdn != nil { + out.Append("server-fqdn", fmt.Sprintf("%v", *o.ServerFqdn)) + } + return &out +} + +// ListClusterUserCredentials ... +func (c ManagedClustersClient) ListClusterUserCredentials(ctx context.Context, id commonids.KubernetesClusterId, options ListClusterUserCredentialsOperationOptions) (result ListClusterUserCredentialsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listClusterUserCredential", id.ID()), + OptionsObject: options, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model CredentialResults + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listguardrailsversions.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listguardrailsversions.go new file mode 100644 index 00000000000..659a95775bb --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listguardrailsversions.go @@ -0,0 +1,91 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListGuardrailsVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]GuardrailsAvailableVersion +} + +type ListGuardrailsVersionsCompleteResult struct { + LatestHttpResponse *http.Response + Items []GuardrailsAvailableVersion +} + +// ListGuardrailsVersions ... +func (c ManagedClustersClient) ListGuardrailsVersions(ctx context.Context, id LocationId) (result ListGuardrailsVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/guardrailsVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]GuardrailsAvailableVersion `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListGuardrailsVersionsComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListGuardrailsVersionsComplete(ctx context.Context, id LocationId) (ListGuardrailsVersionsCompleteResult, error) { + return c.ListGuardrailsVersionsCompleteMatchingPredicate(ctx, id, GuardrailsAvailableVersionOperationPredicate{}) +} + +// ListGuardrailsVersionsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListGuardrailsVersionsCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate GuardrailsAvailableVersionOperationPredicate) (result ListGuardrailsVersionsCompleteResult, err error) { + items := make([]GuardrailsAvailableVersion, 0) + + resp, err := c.ListGuardrailsVersions(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListGuardrailsVersionsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listkubernetesversions.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listkubernetesversions.go new file mode 100644 index 00000000000..4de425a9201 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listkubernetesversions.go @@ -0,0 +1,55 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKubernetesVersionsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *KubernetesVersionListResult +} + +// ListKubernetesVersions ... +func (c ManagedClustersClient) ListKubernetesVersions(ctx context.Context, id LocationId) (result ListKubernetesVersionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/kubernetesVersions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model KubernetesVersionListResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listmeshrevisionprofiles.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listmeshrevisionprofiles.go new file mode 100644 index 00000000000..7e81149691c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listmeshrevisionprofiles.go @@ -0,0 +1,91 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMeshRevisionProfilesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MeshRevisionProfile +} + +type ListMeshRevisionProfilesCompleteResult struct { + LatestHttpResponse *http.Response + Items []MeshRevisionProfile +} + +// ListMeshRevisionProfiles ... +func (c ManagedClustersClient) ListMeshRevisionProfiles(ctx context.Context, id LocationId) (result ListMeshRevisionProfilesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/meshRevisionProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MeshRevisionProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMeshRevisionProfilesComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListMeshRevisionProfilesComplete(ctx context.Context, id LocationId) (ListMeshRevisionProfilesCompleteResult, error) { + return c.ListMeshRevisionProfilesCompleteMatchingPredicate(ctx, id, MeshRevisionProfileOperationPredicate{}) +} + +// ListMeshRevisionProfilesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListMeshRevisionProfilesCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate MeshRevisionProfileOperationPredicate) (result ListMeshRevisionProfilesCompleteResult, err error) { + items := make([]MeshRevisionProfile, 0) + + resp, err := c.ListMeshRevisionProfiles(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMeshRevisionProfilesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listmeshupgradeprofiles.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listmeshupgradeprofiles.go new file mode 100644 index 00000000000..56095f44de2 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listmeshupgradeprofiles.go @@ -0,0 +1,92 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListMeshUpgradeProfilesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]MeshUpgradeProfile +} + +type ListMeshUpgradeProfilesCompleteResult struct { + LatestHttpResponse *http.Response + Items []MeshUpgradeProfile +} + +// ListMeshUpgradeProfiles ... +func (c ManagedClustersClient) ListMeshUpgradeProfiles(ctx context.Context, id commonids.KubernetesClusterId) (result ListMeshUpgradeProfilesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/meshUpgradeProfiles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MeshUpgradeProfile `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListMeshUpgradeProfilesComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListMeshUpgradeProfilesComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListMeshUpgradeProfilesCompleteResult, error) { + return c.ListMeshUpgradeProfilesCompleteMatchingPredicate(ctx, id, MeshUpgradeProfileOperationPredicate{}) +} + +// ListMeshUpgradeProfilesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListMeshUpgradeProfilesCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate MeshUpgradeProfileOperationPredicate) (result ListMeshUpgradeProfilesCompleteResult, err error) { + items := make([]MeshUpgradeProfile, 0) + + resp, err := c.ListMeshUpgradeProfiles(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListMeshUpgradeProfilesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listoutboundnetworkdependenciesendpoints.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..759383196b8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_listoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,92 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundEnvironmentEndpoint +} + +type ListOutboundNetworkDependenciesEndpointsCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundEnvironmentEndpoint +} + +// ListOutboundNetworkDependenciesEndpoints ... +func (c ManagedClustersClient) ListOutboundNetworkDependenciesEndpoints(ctx context.Context, id commonids.KubernetesClusterId) (result ListOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/outboundNetworkDependenciesEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OutboundEnvironmentEndpoint `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListOutboundNetworkDependenciesEndpointsComplete retrieves all the results into a single object +func (c ManagedClustersClient) ListOutboundNetworkDependenciesEndpointsComplete(ctx context.Context, id commonids.KubernetesClusterId) (ListOutboundNetworkDependenciesEndpointsCompleteResult, error) { + return c.ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx, id, OutboundEnvironmentEndpointOperationPredicate{}) +} + +// ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClustersClient) ListOutboundNetworkDependenciesEndpointsCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate OutboundEnvironmentEndpointOperationPredicate) (result ListOutboundNetworkDependenciesEndpointsCompleteResult, err error) { + items := make([]OutboundEnvironmentEndpoint, 0) + + resp, err := c.ListOutboundNetworkDependenciesEndpoints(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListOutboundNetworkDependenciesEndpointsCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_resetaadprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_resetaadprofile.go new file mode 100644 index 00000000000..abdbb59c018 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_resetaadprofile.go @@ -0,0 +1,75 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetAADProfileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResetAADProfile ... +func (c ManagedClustersClient) ResetAADProfile(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterAADProfile) (result ResetAADProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetAADProfile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetAADProfileThenPoll performs ResetAADProfile then polls until it's completed +func (c ManagedClustersClient) ResetAADProfileThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterAADProfile) error { + result, err := c.ResetAADProfile(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResetAADProfile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetAADProfile: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_resetserviceprincipalprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_resetserviceprincipalprofile.go new file mode 100644 index 00000000000..54589acaf03 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_resetserviceprincipalprofile.go @@ -0,0 +1,75 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResetServicePrincipalProfileOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResetServicePrincipalProfile ... +func (c ManagedClustersClient) ResetServicePrincipalProfile(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterServicePrincipalProfile) (result ResetServicePrincipalProfileOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resetServicePrincipalProfile", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResetServicePrincipalProfileThenPoll performs ResetServicePrincipalProfile then polls until it's completed +func (c ManagedClustersClient) ResetServicePrincipalProfileThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input ManagedClusterServicePrincipalProfile) error { + result, err := c.ResetServicePrincipalProfile(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ResetServicePrincipalProfile: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResetServicePrincipalProfile: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_rotateclustercertificates.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_rotateclustercertificates.go new file mode 100644 index 00000000000..3d04938f645 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_rotateclustercertificates.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RotateClusterCertificatesOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RotateClusterCertificates ... +func (c ManagedClustersClient) RotateClusterCertificates(ctx context.Context, id commonids.KubernetesClusterId) (result RotateClusterCertificatesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/rotateClusterCertificates", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RotateClusterCertificatesThenPoll performs RotateClusterCertificates then polls until it's completed +func (c ManagedClustersClient) RotateClusterCertificatesThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.RotateClusterCertificates(ctx, id) + if err != nil { + return fmt.Errorf("performing RotateClusterCertificates: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RotateClusterCertificates: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_rotateserviceaccountsigningkeys.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_rotateserviceaccountsigningkeys.go new file mode 100644 index 00000000000..b4cecc16d85 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_rotateserviceaccountsigningkeys.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RotateServiceAccountSigningKeysOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RotateServiceAccountSigningKeys ... +func (c ManagedClustersClient) RotateServiceAccountSigningKeys(ctx context.Context, id commonids.KubernetesClusterId) (result RotateServiceAccountSigningKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/rotateServiceAccountSigningKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RotateServiceAccountSigningKeysThenPoll performs RotateServiceAccountSigningKeys then polls until it's completed +func (c ManagedClustersClient) RotateServiceAccountSigningKeysThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.RotateServiceAccountSigningKeys(ctx, id) + if err != nil { + return fmt.Errorf("performing RotateServiceAccountSigningKeys: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RotateServiceAccountSigningKeys: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_runcommand.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_runcommand.go new file mode 100644 index 00000000000..b64b4ec1b20 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_runcommand.go @@ -0,0 +1,76 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunCommandOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RunCommandResult +} + +// RunCommand ... +func (c ManagedClustersClient) RunCommand(ctx context.Context, id commonids.KubernetesClusterId, input RunCommandRequest) (result RunCommandOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/runCommand", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RunCommandThenPoll performs RunCommand then polls until it's completed +func (c ManagedClustersClient) RunCommandThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input RunCommandRequest) error { + result, err := c.RunCommand(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RunCommand: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RunCommand: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_start.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_start.go new file mode 100644 index 00000000000..ba4549e7615 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_start.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Start ... +func (c ManagedClustersClient) Start(ctx context.Context, id commonids.KubernetesClusterId) (result StartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StartThenPoll performs Start then polls until it's completed +func (c ManagedClustersClient) StartThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.Start(ctx, id) + if err != nil { + return fmt.Errorf("performing Start: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Start: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_stop.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_stop.go new file mode 100644 index 00000000000..3bec609e3b4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_stop.go @@ -0,0 +1,71 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Stop ... +func (c ManagedClustersClient) Stop(ctx context.Context, id commonids.KubernetesClusterId) (result StopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/stop", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// StopThenPoll performs Stop then polls until it's completed +func (c ManagedClustersClient) StopThenPoll(ctx context.Context, id commonids.KubernetesClusterId) error { + result, err := c.Stop(ctx, id) + if err != nil { + return fmt.Errorf("performing Stop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Stop: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_updatetags.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_updatetags.go new file mode 100644 index 00000000000..1ed48544bf9 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/method_updatetags.go @@ -0,0 +1,75 @@ +package managedclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedCluster +} + +// UpdateTags ... +func (c ManagedClustersClient) UpdateTags(ctx context.Context, id commonids.KubernetesClusterId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateTagsThenPoll performs UpdateTags then polls until it's completed +func (c ManagedClustersClient) UpdateTagsThenPoll(ctx context.Context, id commonids.KubernetesClusterId, input TagsObject) error { + result, err := c.UpdateTags(ctx, id, input) + if err != nil { + return fmt.Errorf("performing UpdateTags: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after UpdateTags: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_accessprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_accessprofile.go new file mode 100644 index 00000000000..c13b64ab25d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_accessprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccessProfile struct { + KubeConfig *string `json:"kubeConfig,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolartifactstreamingprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolartifactstreamingprofile.go new file mode 100644 index 00000000000..df1c8baccfc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolartifactstreamingprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolArtifactStreamingProfile struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolgpuprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolgpuprofile.go new file mode 100644 index 00000000000..16f4747078f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolgpuprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolGPUProfile struct { + InstallGPUDriver *bool `json:"installGPUDriver,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolnetworkprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolnetworkprofile.go new file mode 100644 index 00000000000..1a5b19f5db1 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolnetworkprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolNetworkProfile struct { + AllowedHostPorts *[]PortRange `json:"allowedHostPorts,omitempty"` + ApplicationSecurityGroups *[]string `json:"applicationSecurityGroups,omitempty"` + NodePublicIPTags *[]IPTag `json:"nodePublicIPTags,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolsecurityprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolsecurityprofile.go new file mode 100644 index 00000000000..6b9b91c598d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolsecurityprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolSecurityProfile struct { + SshAccess *AgentPoolSSHAccess `json:"sshAccess,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolupgradesettings.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolupgradesettings.go new file mode 100644 index 00000000000..741d796f8a3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolupgradesettings.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolUpgradeSettings struct { + DrainTimeoutInMinutes *int64 `json:"drainTimeoutInMinutes,omitempty"` + MaxSurge *string `json:"maxSurge,omitempty"` + NodeSoakDurationInMinutes *int64 `json:"nodeSoakDurationInMinutes,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolwindowsprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolwindowsprofile.go new file mode 100644 index 00000000000..5558f04ed00 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_agentpoolwindowsprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AgentPoolWindowsProfile struct { + DisableOutboundNat *bool `json:"disableOutboundNat,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_azurekeyvaultkms.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_azurekeyvaultkms.go new file mode 100644 index 00000000000..57c4e7848f3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_azurekeyvaultkms.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AzureKeyVaultKms struct { + Enabled *bool `json:"enabled,omitempty"` + KeyId *string `json:"keyId,omitempty"` + KeyVaultNetworkAccess *KeyVaultNetworkAccessTypes `json:"keyVaultNetworkAccess,omitempty"` + KeyVaultResourceId *string `json:"keyVaultResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_clusterupgradesettings.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_clusterupgradesettings.go new file mode 100644 index 00000000000..1510493ca17 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_clusterupgradesettings.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpgradeSettings struct { + OverrideSettings *UpgradeOverrideSettings `json:"overrideSettings,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_commandresultproperties.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_commandresultproperties.go new file mode 100644 index 00000000000..745a87ae4ea --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_commandresultproperties.go @@ -0,0 +1,43 @@ +package managedclusters + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CommandResultProperties struct { + ExitCode *int64 `json:"exitCode,omitempty"` + FinishedAt *string `json:"finishedAt,omitempty"` + Logs *string `json:"logs,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + Reason *string `json:"reason,omitempty"` + StartedAt *string `json:"startedAt,omitempty"` +} + +func (o *CommandResultProperties) GetFinishedAtAsTime() (*time.Time, error) { + if o.FinishedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FinishedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CommandResultProperties) SetFinishedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FinishedAt = &formatted +} + +func (o *CommandResultProperties) GetStartedAtAsTime() (*time.Time, error) { + if o.StartedAt == nil { + return nil, nil + } + return dates.ParseAsFormat(o.StartedAt, "2006-01-02T15:04:05Z07:00") +} + +func (o *CommandResultProperties) SetStartedAtAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartedAt = &formatted +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_compatibleversions.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_compatibleversions.go new file mode 100644 index 00000000000..585f8e04d7b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_compatibleversions.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CompatibleVersions struct { + Name *string `json:"name,omitempty"` + Versions *[]string `json:"versions,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicelinuxprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicelinuxprofile.go new file mode 100644 index 00000000000..a3abf14adeb --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicelinuxprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceLinuxProfile struct { + AdminUsername string `json:"adminUsername"` + Ssh ContainerServiceSshConfiguration `json:"ssh"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofile.go new file mode 100644 index 00000000000..b3a95c86609 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofile.go @@ -0,0 +1,24 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceNetworkProfile struct { + DnsServiceIP *string `json:"dnsServiceIP,omitempty"` + IPFamilies *[]IPFamily `json:"ipFamilies,omitempty"` + KubeProxyConfig *ContainerServiceNetworkProfileKubeProxyConfig `json:"kubeProxyConfig,omitempty"` + LoadBalancerProfile *ManagedClusterLoadBalancerProfile `json:"loadBalancerProfile,omitempty"` + LoadBalancerSku *LoadBalancerSku `json:"loadBalancerSku,omitempty"` + Monitoring *NetworkMonitoring `json:"monitoring,omitempty"` + NatGatewayProfile *ManagedClusterNATGatewayProfile `json:"natGatewayProfile,omitempty"` + NetworkDataplane *NetworkDataplane `json:"networkDataplane,omitempty"` + NetworkMode *NetworkMode `json:"networkMode,omitempty"` + NetworkPlugin *NetworkPlugin `json:"networkPlugin,omitempty"` + NetworkPluginMode *NetworkPluginMode `json:"networkPluginMode,omitempty"` + NetworkPolicy *NetworkPolicy `json:"networkPolicy,omitempty"` + OutboundType *OutboundType `json:"outboundType,omitempty"` + PodCidr *string `json:"podCidr,omitempty"` + PodCidrs *[]string `json:"podCidrs,omitempty"` + ServiceCidr *string `json:"serviceCidr,omitempty"` + ServiceCidrs *[]string `json:"serviceCidrs,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofilekubeproxyconfig.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofilekubeproxyconfig.go new file mode 100644 index 00000000000..5be387f7c40 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofilekubeproxyconfig.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceNetworkProfileKubeProxyConfig struct { + Enabled *bool `json:"enabled,omitempty"` + IPvsConfig *ContainerServiceNetworkProfileKubeProxyConfigIPvsConfig `json:"ipvsConfig,omitempty"` + Mode *Mode `json:"mode,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofilekubeproxyconfigipvsconfig.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofilekubeproxyconfigipvsconfig.go new file mode 100644 index 00000000000..96dc155e9d5 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicenetworkprofilekubeproxyconfigipvsconfig.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceNetworkProfileKubeProxyConfigIPvsConfig struct { + Scheduler *IPvsScheduler `json:"scheduler,omitempty"` + TcpFinTimeoutSeconds *int64 `json:"tcpFinTimeoutSeconds,omitempty"` + TcpTimeoutSeconds *int64 `json:"tcpTimeoutSeconds,omitempty"` + UdpTimeoutSeconds *int64 `json:"udpTimeoutSeconds,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicesshconfiguration.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicesshconfiguration.go new file mode 100644 index 00000000000..4bf259bd15d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicesshconfiguration.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceSshConfiguration struct { + PublicKeys []ContainerServiceSshPublicKey `json:"publicKeys"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicesshpublickey.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicesshpublickey.go new file mode 100644 index 00000000000..7796cdf6a90 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_containerservicesshpublickey.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerServiceSshPublicKey struct { + KeyData string `json:"keyData"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_creationdata.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_creationdata.go new file mode 100644 index 00000000000..f2f19907006 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_creationdata.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreationData struct { + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_credentialresult.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_credentialresult.go new file mode 100644 index 00000000000..7002f56084e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_credentialresult.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CredentialResult struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_credentialresults.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_credentialresults.go new file mode 100644 index 00000000000..c572432888e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_credentialresults.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CredentialResults struct { + Kubeconfigs *[]CredentialResult `json:"kubeconfigs,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_endpointdependency.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_endpointdependency.go new file mode 100644 index 00000000000..ae8639b529b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_endpointdependency.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDependency struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]EndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_endpointdetail.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_endpointdetail.go new file mode 100644 index 00000000000..de73a2e9168 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_endpointdetail.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointDetail struct { + Description *string `json:"description,omitempty"` + IPAddress *string `json:"ipAddress,omitempty"` + Port *int64 `json:"port,omitempty"` + Protocol *string `json:"protocol,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsavailableversion.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsavailableversion.go new file mode 100644 index 00000000000..40189954790 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsavailableversion.go @@ -0,0 +1,16 @@ +package managedclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuardrailsAvailableVersion struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties GuardrailsAvailableVersionsProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsavailableversionsproperties.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsavailableversionsproperties.go new file mode 100644 index 00000000000..a029efaee56 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsavailableversionsproperties.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuardrailsAvailableVersionsProperties struct { + IsDefaultVersion *bool `json:"isDefaultVersion,omitempty"` + Support *GuardrailsSupport `json:"support,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsprofile.go new file mode 100644 index 00000000000..84c6c832975 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_guardrailsprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuardrailsProfile struct { + ExcludedNamespaces *[]string `json:"excludedNamespaces,omitempty"` + Level Level `json:"level"` + SystemExcludedNamespaces *[]string `json:"systemExcludedNamespaces,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_iptag.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_iptag.go new file mode 100644 index 00000000000..0aefb50d15f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_iptag.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPTag struct { + IPTagType *string `json:"ipTagType,omitempty"` + Tag *string `json:"tag,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istiocertificateauthority.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istiocertificateauthority.go new file mode 100644 index 00000000000..1580575b782 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istiocertificateauthority.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioCertificateAuthority struct { + Plugin *IstioPluginCertificateAuthority `json:"plugin,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istiocomponents.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istiocomponents.go new file mode 100644 index 00000000000..6dff6ff1534 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istiocomponents.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioComponents struct { + EgressGateways *[]IstioEgressGateway `json:"egressGateways,omitempty"` + IngressGateways *[]IstioIngressGateway `json:"ingressGateways,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioegressgateway.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioegressgateway.go new file mode 100644 index 00000000000..5af1bad7023 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioegressgateway.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioEgressGateway struct { + Enabled bool `json:"enabled"` + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioingressgateway.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioingressgateway.go new file mode 100644 index 00000000000..12832f48114 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioingressgateway.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioIngressGateway struct { + Enabled bool `json:"enabled"` + Mode IstioIngressGatewayMode `json:"mode"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioplugincertificateauthority.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioplugincertificateauthority.go new file mode 100644 index 00000000000..4ae2f736c6a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioplugincertificateauthority.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioPluginCertificateAuthority struct { + CertChainObjectName *string `json:"certChainObjectName,omitempty"` + CertObjectName *string `json:"certObjectName,omitempty"` + KeyObjectName *string `json:"keyObjectName,omitempty"` + KeyVaultId *string `json:"keyVaultId,omitempty"` + RootCertObjectName *string `json:"rootCertObjectName,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioservicemesh.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioservicemesh.go new file mode 100644 index 00000000000..968c2f018dc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_istioservicemesh.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IstioServiceMesh struct { + CertificateAuthority *IstioCertificateAuthority `json:"certificateAuthority,omitempty"` + Components *IstioComponents `json:"components,omitempty"` + Revisions *[]string `json:"revisions,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubeletconfig.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubeletconfig.go new file mode 100644 index 00000000000..0f4036b4e7c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubeletconfig.go @@ -0,0 +1,18 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubeletConfig struct { + AllowedUnsafeSysctls *[]string `json:"allowedUnsafeSysctls,omitempty"` + ContainerLogMaxFiles *int64 `json:"containerLogMaxFiles,omitempty"` + ContainerLogMaxSizeMB *int64 `json:"containerLogMaxSizeMB,omitempty"` + CpuCfsQuota *bool `json:"cpuCfsQuota,omitempty"` + CpuCfsQuotaPeriod *string `json:"cpuCfsQuotaPeriod,omitempty"` + CpuManagerPolicy *string `json:"cpuManagerPolicy,omitempty"` + FailSwapOn *bool `json:"failSwapOn,omitempty"` + ImageGcHighThreshold *int64 `json:"imageGcHighThreshold,omitempty"` + ImageGcLowThreshold *int64 `json:"imageGcLowThreshold,omitempty"` + PodMaxPids *int64 `json:"podMaxPids,omitempty"` + TopologyManagerPolicy *string `json:"topologyManagerPolicy,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetespatchversion.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetespatchversion.go new file mode 100644 index 00000000000..017737dac6a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetespatchversion.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesPatchVersion struct { + Upgrades *[]string `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversion.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversion.go new file mode 100644 index 00000000000..2bb83ce16ee --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversion.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesVersion struct { + Capabilities *KubernetesVersionCapabilities `json:"capabilities,omitempty"` + IsPreview *bool `json:"isPreview,omitempty"` + PatchVersions *map[string]KubernetesPatchVersion `json:"patchVersions,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversioncapabilities.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversioncapabilities.go new file mode 100644 index 00000000000..b5729422404 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversioncapabilities.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesVersionCapabilities struct { + SupportPlan *[]KubernetesSupportPlan `json:"supportPlan,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversionlistresult.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversionlistresult.go new file mode 100644 index 00000000000..a8b1127a230 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_kubernetesversionlistresult.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesVersionListResult struct { + Values *[]KubernetesVersion `json:"values,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_linuxosconfig.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_linuxosconfig.go new file mode 100644 index 00000000000..431f6faa2aa --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_linuxosconfig.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LinuxOSConfig struct { + SwapFileSizeMB *int64 `json:"swapFileSizeMB,omitempty"` + Sysctls *SysctlConfig `json:"sysctls,omitempty"` + TransparentHugePageDefrag *string `json:"transparentHugePageDefrag,omitempty"` + TransparentHugePageEnabled *string `json:"transparentHugePageEnabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedcluster.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedcluster.go new file mode 100644 index 00000000000..96f028c8024 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedcluster.go @@ -0,0 +1,23 @@ +package managedclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/edgezones" + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedCluster struct { + ExtendedLocation *edgezones.Model `json:"extendedLocation,omitempty"` + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedClusterProperties `json:"properties,omitempty"` + Sku *ManagedClusterSKU `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraadprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraadprofile.go new file mode 100644 index 00000000000..271addb1fd4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraadprofile.go @@ -0,0 +1,14 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAADProfile struct { + AdminGroupObjectIDs *[]string `json:"adminGroupObjectIDs,omitempty"` + ClientAppID *string `json:"clientAppID,omitempty"` + EnableAzureRBAC *bool `json:"enableAzureRBAC,omitempty"` + Managed *bool `json:"managed,omitempty"` + ServerAppID *string `json:"serverAppID,omitempty"` + ServerAppSecret *string `json:"serverAppSecret,omitempty"` + TenantID *string `json:"tenantID,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraccessprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraccessprofile.go new file mode 100644 index 00000000000..e248b2a253b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraccessprofile.go @@ -0,0 +1,18 @@ +package managedclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAccessProfile struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *AccessProfile `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraddonprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraddonprofile.go new file mode 100644 index 00000000000..7dc1f865d9d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraddonprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAddonProfile struct { + Config *map[string]string `json:"config,omitempty"` + Enabled bool `json:"enabled"` + Identity *UserAssignedIdentity `json:"identity,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteragentpoolprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteragentpoolprofile.go new file mode 100644 index 00000000000..ec634253850 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteragentpoolprofile.go @@ -0,0 +1,61 @@ +package managedclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/zones" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAgentPoolProfile struct { + ArtifactStreamingProfile *AgentPoolArtifactStreamingProfile `json:"artifactStreamingProfile,omitempty"` + AvailabilityZones *zones.Schema `json:"availabilityZones,omitempty"` + CapacityReservationGroupID *string `json:"capacityReservationGroupID,omitempty"` + Count *int64 `json:"count,omitempty"` + CreationData *CreationData `json:"creationData,omitempty"` + CurrentOrchestratorVersion *string `json:"currentOrchestratorVersion,omitempty"` + EnableAutoScaling *bool `json:"enableAutoScaling,omitempty"` + EnableCustomCATrust *bool `json:"enableCustomCATrust,omitempty"` + EnableEncryptionAtHost *bool `json:"enableEncryptionAtHost,omitempty"` + EnableFIPS *bool `json:"enableFIPS,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIP,omitempty"` + EnableUltraSSD *bool `json:"enableUltraSSD,omitempty"` + GpuInstanceProfile *GPUInstanceProfile `json:"gpuInstanceProfile,omitempty"` + GpuProfile *AgentPoolGPUProfile `json:"gpuProfile,omitempty"` + HostGroupID *string `json:"hostGroupID,omitempty"` + KubeletConfig *KubeletConfig `json:"kubeletConfig,omitempty"` + KubeletDiskType *KubeletDiskType `json:"kubeletDiskType,omitempty"` + LinuxOSConfig *LinuxOSConfig `json:"linuxOSConfig,omitempty"` + MaxCount *int64 `json:"maxCount,omitempty"` + MaxPods *int64 `json:"maxPods,omitempty"` + MessageOfTheDay *string `json:"messageOfTheDay,omitempty"` + MinCount *int64 `json:"minCount,omitempty"` + Mode *AgentPoolMode `json:"mode,omitempty"` + Name string `json:"name"` + NetworkProfile *AgentPoolNetworkProfile `json:"networkProfile,omitempty"` + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + NodeLabels *map[string]string `json:"nodeLabels,omitempty"` + NodePublicIPPrefixID *string `json:"nodePublicIPPrefixID,omitempty"` + NodeTaints *[]string `json:"nodeTaints,omitempty"` + OrchestratorVersion *string `json:"orchestratorVersion,omitempty"` + OsDiskSizeGB *int64 `json:"osDiskSizeGB,omitempty"` + OsDiskType *OSDiskType `json:"osDiskType,omitempty"` + OsSKU *OSSKU `json:"osSKU,omitempty"` + OsType *OSType `json:"osType,omitempty"` + PodSubnetID *string `json:"podSubnetID,omitempty"` + PowerState *PowerState `json:"powerState,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + ProximityPlacementGroupID *string `json:"proximityPlacementGroupID,omitempty"` + ScaleDownMode *ScaleDownMode `json:"scaleDownMode,omitempty"` + ScaleSetEvictionPolicy *ScaleSetEvictionPolicy `json:"scaleSetEvictionPolicy,omitempty"` + ScaleSetPriority *ScaleSetPriority `json:"scaleSetPriority,omitempty"` + SecurityProfile *AgentPoolSecurityProfile `json:"securityProfile,omitempty"` + SpotMaxPrice *float64 `json:"spotMaxPrice,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *AgentPoolType `json:"type,omitempty"` + UpgradeSettings *AgentPoolUpgradeSettings `json:"upgradeSettings,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + VnetSubnetID *string `json:"vnetSubnetID,omitempty"` + WindowsProfile *AgentPoolWindowsProfile `json:"windowsProfile,omitempty"` + WorkloadRuntime *WorkloadRuntime `json:"workloadRuntime,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraitoolchainoperatorprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraitoolchainoperatorprofile.go new file mode 100644 index 00000000000..0c2d87296e0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteraitoolchainoperatorprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAIToolchainOperatorProfile struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterapiserveraccessprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterapiserveraccessprofile.go new file mode 100644 index 00000000000..69b53ef85a7 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterapiserveraccessprofile.go @@ -0,0 +1,14 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAPIServerAccessProfile struct { + AuthorizedIPRanges *[]string `json:"authorizedIPRanges,omitempty"` + DisableRunCommand *bool `json:"disableRunCommand,omitempty"` + EnablePrivateCluster *bool `json:"enablePrivateCluster,omitempty"` + EnablePrivateClusterPublicFQDN *bool `json:"enablePrivateClusterPublicFQDN,omitempty"` + EnableVnetIntegration *bool `json:"enableVnetIntegration,omitempty"` + PrivateDNSZone *string `json:"privateDNSZone,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterautoupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterautoupgradeprofile.go new file mode 100644 index 00000000000..e43a6df257f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterautoupgradeprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAutoUpgradeProfile struct { + NodeOSUpgradeChannel *NodeOSUpgradeChannel `json:"nodeOSUpgradeChannel,omitempty"` + UpgradeChannel *UpgradeChannel `json:"upgradeChannel,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofile.go new file mode 100644 index 00000000000..d718bafe5f8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfile struct { + Logs *ManagedClusterAzureMonitorProfileLogs `json:"logs,omitempty"` + Metrics *ManagedClusterAzureMonitorProfileMetrics `json:"metrics,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofileappmonitoring.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofileappmonitoring.go new file mode 100644 index 00000000000..bc58d221f10 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofileappmonitoring.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileAppMonitoring struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofileappmonitoringopentelemetrymetrics.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofileappmonitoringopentelemetrymetrics.go new file mode 100644 index 00000000000..7bdb0e74e3e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofileappmonitoringopentelemetrymetrics.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileAppMonitoringOpenTelemetryMetrics struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilecontainerinsights.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilecontainerinsights.go new file mode 100644 index 00000000000..72da87a462c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilecontainerinsights.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileContainerInsights struct { + Enabled *bool `json:"enabled,omitempty"` + LogAnalyticsWorkspaceResourceId *string `json:"logAnalyticsWorkspaceResourceId,omitempty"` + WindowsHostLogs *ManagedClusterAzureMonitorProfileWindowsHostLogs `json:"windowsHostLogs,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilekubestatemetrics.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilekubestatemetrics.go new file mode 100644 index 00000000000..ef0fb9066e2 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilekubestatemetrics.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileKubeStateMetrics struct { + MetricAnnotationsAllowList *string `json:"metricAnnotationsAllowList,omitempty"` + MetricLabelsAllowlist *string `json:"metricLabelsAllowlist,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilelogs.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilelogs.go new file mode 100644 index 00000000000..a17a247e9c7 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilelogs.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileLogs struct { + AppMonitoring *ManagedClusterAzureMonitorProfileAppMonitoring `json:"appMonitoring,omitempty"` + ContainerInsights *ManagedClusterAzureMonitorProfileContainerInsights `json:"containerInsights,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilemetrics.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilemetrics.go new file mode 100644 index 00000000000..b1ea081f915 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilemetrics.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileMetrics struct { + AppMonitoringOpenTelemetryMetrics *ManagedClusterAzureMonitorProfileAppMonitoringOpenTelemetryMetrics `json:"appMonitoringOpenTelemetryMetrics,omitempty"` + Enabled bool `json:"enabled"` + KubeStateMetrics *ManagedClusterAzureMonitorProfileKubeStateMetrics `json:"kubeStateMetrics,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilewindowshostlogs.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilewindowshostlogs.go new file mode 100644 index 00000000000..cc9edfc6a6f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterazuremonitorprofilewindowshostlogs.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterAzureMonitorProfileWindowsHostLogs struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustercostanalysis.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustercostanalysis.go new file mode 100644 index 00000000000..a54a571fe4e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustercostanalysis.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterCostAnalysis struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterhttpproxyconfig.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterhttpproxyconfig.go new file mode 100644 index 00000000000..b9f46785387 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterhttpproxyconfig.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterHTTPProxyConfig struct { + EffectiveNoProxy *[]string `json:"effectiveNoProxy,omitempty"` + HTTPProxy *string `json:"httpProxy,omitempty"` + HTTPSProxy *string `json:"httpsProxy,omitempty"` + NoProxy *[]string `json:"noProxy,omitempty"` + TrustedCa *string `json:"trustedCa,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteringressprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteringressprofile.go new file mode 100644 index 00000000000..ef54c8e8069 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteringressprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterIngressProfile struct { + WebAppRouting *ManagedClusterIngressProfileWebAppRouting `json:"webAppRouting,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteringressprofilewebapprouting.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteringressprofilewebapprouting.go new file mode 100644 index 00000000000..b8dc1b3b921 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteringressprofilewebapprouting.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterIngressProfileWebAppRouting struct { + DnsZoneResourceIds *[]string `json:"dnsZoneResourceIds,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Identity *UserAssignedIdentity `json:"identity,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofile.go new file mode 100644 index 00000000000..0d2207851bd --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofile.go @@ -0,0 +1,15 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfile struct { + AllocatedOutboundPorts *int64 `json:"allocatedOutboundPorts,omitempty"` + BackendPoolType *BackendPoolType `json:"backendPoolType,omitempty"` + EffectiveOutboundIPs *[]ResourceReference `json:"effectiveOutboundIPs,omitempty"` + EnableMultipleStandardLoadBalancers *bool `json:"enableMultipleStandardLoadBalancers,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ManagedOutboundIPs *ManagedClusterLoadBalancerProfileManagedOutboundIPs `json:"managedOutboundIPs,omitempty"` + OutboundIPPrefixes *ManagedClusterLoadBalancerProfileOutboundIPPrefixes `json:"outboundIPPrefixes,omitempty"` + OutboundIPs *ManagedClusterLoadBalancerProfileOutboundIPs `json:"outboundIPs,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofilemanagedoutboundips.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofilemanagedoutboundips.go new file mode 100644 index 00000000000..b8d24680fed --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofilemanagedoutboundips.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfileManagedOutboundIPs struct { + Count *int64 `json:"count,omitempty"` + CountIPv6 *int64 `json:"countIPv6,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofileoutboundipprefixes.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofileoutboundipprefixes.go new file mode 100644 index 00000000000..76893c76d85 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofileoutboundipprefixes.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfileOutboundIPPrefixes struct { + PublicIPPrefixes *[]ResourceReference `json:"publicIPPrefixes,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofileoutboundips.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofileoutboundips.go new file mode 100644 index 00000000000..f0a60f5817e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterloadbalancerprofileoutboundips.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterLoadBalancerProfileOutboundIPs struct { + PublicIPs *[]ResourceReference `json:"publicIPs,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustermanagedoutboundipprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustermanagedoutboundipprofile.go new file mode 100644 index 00000000000..ec079b6cdf4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustermanagedoutboundipprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterManagedOutboundIPProfile struct { + Count *int64 `json:"count,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustermetricsprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustermetricsprofile.go new file mode 100644 index 00000000000..fd466216881 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustermetricsprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterMetricsProfile struct { + CostAnalysis *ManagedClusterCostAnalysis `json:"costAnalysis,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternatgatewayprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternatgatewayprofile.go new file mode 100644 index 00000000000..a7e37699c62 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternatgatewayprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterNATGatewayProfile struct { + EffectiveOutboundIPs *[]ResourceReference `json:"effectiveOutboundIPs,omitempty"` + IdleTimeoutInMinutes *int64 `json:"idleTimeoutInMinutes,omitempty"` + ManagedOutboundIPProfile *ManagedClusterManagedOutboundIPProfile `json:"managedOutboundIPProfile,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternodeprovisioningprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternodeprovisioningprofile.go new file mode 100644 index 00000000000..6560753a94c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternodeprovisioningprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterNodeProvisioningProfile struct { + Mode *NodeProvisioningMode `json:"mode,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternoderesourcegroupprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternoderesourcegroupprofile.go new file mode 100644 index 00000000000..1ae3147c267 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusternoderesourcegroupprofile.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterNodeResourceGroupProfile struct { + RestrictionLevel *RestrictionLevel `json:"restrictionLevel,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteroidcissuerprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteroidcissuerprofile.go new file mode 100644 index 00000000000..b5d3be88f7d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusteroidcissuerprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterOIDCIssuerProfile struct { + Enabled *bool `json:"enabled,omitempty"` + IssuerURL *string `json:"issuerURL,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentity.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentity.go new file mode 100644 index 00000000000..3bfb6799645 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentity.go @@ -0,0 +1,13 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentity struct { + BindingSelector *string `json:"bindingSelector,omitempty"` + Identity UserAssignedIdentity `json:"identity"` + Name string `json:"name"` + Namespace string `json:"namespace"` + ProvisioningInfo *ManagedClusterPodIdentityProvisioningInfo `json:"provisioningInfo,omitempty"` + ProvisioningState *ManagedClusterPodIdentityProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityexception.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityexception.go new file mode 100644 index 00000000000..28a710f9b5c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityexception.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityException struct { + Name string `json:"name"` + Namespace string `json:"namespace"` + PodLabels map[string]string `json:"podLabels"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprofile.go new file mode 100644 index 00000000000..e32db30028a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProfile struct { + AllowNetworkPluginKubenet *bool `json:"allowNetworkPluginKubenet,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + UserAssignedIdentities *[]ManagedClusterPodIdentity `json:"userAssignedIdentities,omitempty"` + UserAssignedIdentityExceptions *[]ManagedClusterPodIdentityException `json:"userAssignedIdentityExceptions,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioningerror.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioningerror.go new file mode 100644 index 00000000000..1fb66d9034f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioningerror.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProvisioningError struct { + Error *ManagedClusterPodIdentityProvisioningErrorBody `json:"error,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioningerrorbody.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioningerrorbody.go new file mode 100644 index 00000000000..db4466f80bf --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioningerrorbody.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProvisioningErrorBody struct { + Code *string `json:"code,omitempty"` + Details *[]ManagedClusterPodIdentityProvisioningErrorBody `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioninginfo.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioninginfo.go new file mode 100644 index 00000000000..60464e39c82 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpodidentityprovisioninginfo.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPodIdentityProvisioningInfo struct { + Error *ManagedClusterPodIdentityProvisioningError `json:"error,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpoolupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpoolupgradeprofile.go new file mode 100644 index 00000000000..7bafa5df972 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpoolupgradeprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPoolUpgradeProfile struct { + KubernetesVersion string `json:"kubernetesVersion"` + Name *string `json:"name,omitempty"` + OsType OSType `json:"osType"` + Upgrades *[]ManagedClusterPoolUpgradeProfileUpgradesInlined `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpoolupgradeprofileupgradesinlined.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpoolupgradeprofileupgradesinlined.go new file mode 100644 index 00000000000..ccc02dd9957 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpoolupgradeprofileupgradesinlined.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPoolUpgradeProfileUpgradesInlined struct { + IsPreview *bool `json:"isPreview,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterproperties.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterproperties.go new file mode 100644 index 00000000000..9ea44adf4db --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterproperties.go @@ -0,0 +1,54 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterProperties struct { + AadProfile *ManagedClusterAADProfile `json:"aadProfile,omitempty"` + AddonProfiles *map[string]ManagedClusterAddonProfile `json:"addonProfiles,omitempty"` + AgentPoolProfiles *[]ManagedClusterAgentPoolProfile `json:"agentPoolProfiles,omitempty"` + AiToolchainOperatorProfile *ManagedClusterAIToolchainOperatorProfile `json:"aiToolchainOperatorProfile,omitempty"` + ApiServerAccessProfile *ManagedClusterAPIServerAccessProfile `json:"apiServerAccessProfile,omitempty"` + AutoScalerProfile *ManagedClusterPropertiesAutoScalerProfile `json:"autoScalerProfile,omitempty"` + AutoUpgradeProfile *ManagedClusterAutoUpgradeProfile `json:"autoUpgradeProfile,omitempty"` + AzureMonitorProfile *ManagedClusterAzureMonitorProfile `json:"azureMonitorProfile,omitempty"` + AzurePortalFQDN *string `json:"azurePortalFQDN,omitempty"` + CreationData *CreationData `json:"creationData,omitempty"` + CurrentKubernetesVersion *string `json:"currentKubernetesVersion,omitempty"` + DisableLocalAccounts *bool `json:"disableLocalAccounts,omitempty"` + DiskEncryptionSetID *string `json:"diskEncryptionSetID,omitempty"` + DnsPrefix *string `json:"dnsPrefix,omitempty"` + EnableNamespaceResources *bool `json:"enableNamespaceResources,omitempty"` + EnablePodSecurityPolicy *bool `json:"enablePodSecurityPolicy,omitempty"` + EnableRBAC *bool `json:"enableRBAC,omitempty"` + Fqdn *string `json:"fqdn,omitempty"` + FqdnSubdomain *string `json:"fqdnSubdomain,omitempty"` + GuardrailsProfile *GuardrailsProfile `json:"guardrailsProfile,omitempty"` + HTTPProxyConfig *ManagedClusterHTTPProxyConfig `json:"httpProxyConfig,omitempty"` + IdentityProfile *map[string]UserAssignedIdentity `json:"identityProfile,omitempty"` + IngressProfile *ManagedClusterIngressProfile `json:"ingressProfile,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + LinuxProfile *ContainerServiceLinuxProfile `json:"linuxProfile,omitempty"` + MaxAgentPools *int64 `json:"maxAgentPools,omitempty"` + MetricsProfile *ManagedClusterMetricsProfile `json:"metricsProfile,omitempty"` + NetworkProfile *ContainerServiceNetworkProfile `json:"networkProfile,omitempty"` + NodeProvisioningProfile *ManagedClusterNodeProvisioningProfile `json:"nodeProvisioningProfile,omitempty"` + NodeResourceGroup *string `json:"nodeResourceGroup,omitempty"` + NodeResourceGroupProfile *ManagedClusterNodeResourceGroupProfile `json:"nodeResourceGroupProfile,omitempty"` + OidcIssuerProfile *ManagedClusterOIDCIssuerProfile `json:"oidcIssuerProfile,omitempty"` + PodIdentityProfile *ManagedClusterPodIdentityProfile `json:"podIdentityProfile,omitempty"` + PowerState *PowerState `json:"powerState,omitempty"` + PrivateFQDN *string `json:"privateFQDN,omitempty"` + PrivateLinkResources *[]PrivateLinkResource `json:"privateLinkResources,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ResourceUID *string `json:"resourceUID,omitempty"` + SecurityProfile *ManagedClusterSecurityProfile `json:"securityProfile,omitempty"` + ServiceMeshProfile *ServiceMeshProfile `json:"serviceMeshProfile,omitempty"` + ServicePrincipalProfile *ManagedClusterServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"` + StorageProfile *ManagedClusterStorageProfile `json:"storageProfile,omitempty"` + SupportPlan *KubernetesSupportPlan `json:"supportPlan,omitempty"` + UpgradeSettings *ClusterUpgradeSettings `json:"upgradeSettings,omitempty"` + WindowsProfile *ManagedClusterWindowsProfile `json:"windowsProfile,omitempty"` + WorkloadAutoScalerProfile *ManagedClusterWorkloadAutoScalerProfile `json:"workloadAutoScalerProfile,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpropertiesautoscalerprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpropertiesautoscalerprofile.go new file mode 100644 index 00000000000..d8387a1e222 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterpropertiesautoscalerprofile.go @@ -0,0 +1,28 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPropertiesAutoScalerProfile struct { + BalanceSimilarNodeGroups *string `json:"balance-similar-node-groups,omitempty"` + DaemonsetEvictionForEmptyNodes *bool `json:"daemonset-eviction-for-empty-nodes,omitempty"` + DaemonsetEvictionForOccupiedNodes *bool `json:"daemonset-eviction-for-occupied-nodes,omitempty"` + Expander *Expander `json:"expander,omitempty"` + Expanders *[]Expander `json:"expanders,omitempty"` + IgnoreDaemonsetsUtilization *bool `json:"ignore-daemonsets-utilization,omitempty"` + MaxEmptyBulkDelete *string `json:"max-empty-bulk-delete,omitempty"` + MaxGracefulTerminationSec *string `json:"max-graceful-termination-sec,omitempty"` + MaxNodeProvisionTime *string `json:"max-node-provision-time,omitempty"` + MaxTotalUnreadyPercentage *string `json:"max-total-unready-percentage,omitempty"` + NewPodScaleUpDelay *string `json:"new-pod-scale-up-delay,omitempty"` + OkTotalUnreadyCount *string `json:"ok-total-unready-count,omitempty"` + ScaleDownDelayAfterAdd *string `json:"scale-down-delay-after-add,omitempty"` + ScaleDownDelayAfterDelete *string `json:"scale-down-delay-after-delete,omitempty"` + ScaleDownDelayAfterFailure *string `json:"scale-down-delay-after-failure,omitempty"` + ScaleDownUnneededTime *string `json:"scale-down-unneeded-time,omitempty"` + ScaleDownUnreadyTime *string `json:"scale-down-unready-time,omitempty"` + ScaleDownUtilizationThreshold *string `json:"scale-down-utilization-threshold,omitempty"` + ScanInterval *string `json:"scan-interval,omitempty"` + SkipNodesWithLocalStorage *string `json:"skip-nodes-with-local-storage,omitempty"` + SkipNodesWithSystemPods *string `json:"skip-nodes-with-system-pods,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofile.go new file mode 100644 index 00000000000..0f300661a38 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofile.go @@ -0,0 +1,14 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfile struct { + AzureKeyVaultKms *AzureKeyVaultKms `json:"azureKeyVaultKms,omitempty"` + CustomCATrustCertificates *[]string `json:"customCATrustCertificates,omitempty"` + Defender *ManagedClusterSecurityProfileDefender `json:"defender,omitempty"` + ImageCleaner *ManagedClusterSecurityProfileImageCleaner `json:"imageCleaner,omitempty"` + ImageIntegrity *ManagedClusterSecurityProfileImageIntegrity `json:"imageIntegrity,omitempty"` + NodeRestriction *ManagedClusterSecurityProfileNodeRestriction `json:"nodeRestriction,omitempty"` + WorkloadIdentity *ManagedClusterSecurityProfileWorkloadIdentity `json:"workloadIdentity,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofiledefender.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofiledefender.go new file mode 100644 index 00000000000..c63debde097 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofiledefender.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileDefender struct { + LogAnalyticsWorkspaceResourceId *string `json:"logAnalyticsWorkspaceResourceId,omitempty"` + SecurityMonitoring *ManagedClusterSecurityProfileDefenderSecurityMonitoring `json:"securityMonitoring,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofiledefendersecuritymonitoring.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofiledefendersecuritymonitoring.go new file mode 100644 index 00000000000..de84c795fec --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofiledefendersecuritymonitoring.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileDefenderSecurityMonitoring struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileimagecleaner.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileimagecleaner.go new file mode 100644 index 00000000000..eb3e2ea7007 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileimagecleaner.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileImageCleaner struct { + Enabled *bool `json:"enabled,omitempty"` + IntervalHours *int64 `json:"intervalHours,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileimageintegrity.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileimageintegrity.go new file mode 100644 index 00000000000..3ffd0d90c19 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileimageintegrity.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileImageIntegrity struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofilenoderestriction.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofilenoderestriction.go new file mode 100644 index 00000000000..6730a946379 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofilenoderestriction.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileNodeRestriction struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileworkloadidentity.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileworkloadidentity.go new file mode 100644 index 00000000000..84f0312767b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersecurityprofileworkloadidentity.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSecurityProfileWorkloadIdentity struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterserviceprincipalprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterserviceprincipalprofile.go new file mode 100644 index 00000000000..2a03beecdcc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterserviceprincipalprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterServicePrincipalProfile struct { + ClientId string `json:"clientId"` + Secret *string `json:"secret,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersku.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersku.go new file mode 100644 index 00000000000..a4dcf9c50d3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclustersku.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSKU struct { + Name *ManagedClusterSKUName `json:"name,omitempty"` + Tier *ManagedClusterSKUTier `json:"tier,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofile.go new file mode 100644 index 00000000000..11073ae103d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfile struct { + BlobCSIDriver *ManagedClusterStorageProfileBlobCSIDriver `json:"blobCSIDriver,omitempty"` + DiskCSIDriver *ManagedClusterStorageProfileDiskCSIDriver `json:"diskCSIDriver,omitempty"` + FileCSIDriver *ManagedClusterStorageProfileFileCSIDriver `json:"fileCSIDriver,omitempty"` + SnapshotController *ManagedClusterStorageProfileSnapshotController `json:"snapshotController,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofileblobcsidriver.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofileblobcsidriver.go new file mode 100644 index 00000000000..dc0e951be6b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofileblobcsidriver.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileBlobCSIDriver struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilediskcsidriver.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilediskcsidriver.go new file mode 100644 index 00000000000..5a12e13453f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilediskcsidriver.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileDiskCSIDriver struct { + Enabled *bool `json:"enabled,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilefilecsidriver.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilefilecsidriver.go new file mode 100644 index 00000000000..986ece9d933 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilefilecsidriver.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileFileCSIDriver struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilesnapshotcontroller.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilesnapshotcontroller.go new file mode 100644 index 00000000000..d46ee10b683 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterstorageprofilesnapshotcontroller.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterStorageProfileSnapshotController struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterupgradeprofile.go new file mode 100644 index 00000000000..86274cdb14a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterupgradeprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterUpgradeProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ManagedClusterUpgradeProfileProperties `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterupgradeprofileproperties.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterupgradeprofileproperties.go new file mode 100644 index 00000000000..4db4b126760 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterupgradeprofileproperties.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterUpgradeProfileProperties struct { + AgentPoolProfiles []ManagedClusterPoolUpgradeProfile `json:"agentPoolProfiles"` + ControlPlaneProfile ManagedClusterPoolUpgradeProfile `json:"controlPlaneProfile"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterwindowsprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterwindowsprofile.go new file mode 100644 index 00000000000..8e3cffdace8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterwindowsprofile.go @@ -0,0 +1,12 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWindowsProfile struct { + AdminPassword *string `json:"adminPassword,omitempty"` + AdminUsername string `json:"adminUsername"` + EnableCSIProxy *bool `json:"enableCSIProxy,omitempty"` + GmsaProfile *WindowsGmsaProfile `json:"gmsaProfile,omitempty"` + LicenseType *LicenseType `json:"licenseType,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofile.go new file mode 100644 index 00000000000..891a44a0084 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWorkloadAutoScalerProfile struct { + Keda *ManagedClusterWorkloadAutoScalerProfileKeda `json:"keda,omitempty"` + VerticalPodAutoscaler *ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler `json:"verticalPodAutoscaler,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofilekeda.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofilekeda.go new file mode 100644 index 00000000000..7115a06bfb3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofilekeda.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWorkloadAutoScalerProfileKeda struct { + Enabled bool `json:"enabled"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofileverticalpodautoscaler.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofileverticalpodautoscaler.go new file mode 100644 index 00000000000..fe3c0d577b0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_managedclusterworkloadautoscalerprofileverticalpodautoscaler.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterWorkloadAutoScalerProfileVerticalPodAutoscaler struct { + AddonAutoscaling *AddonAutoscaling `json:"addonAutoscaling,omitempty"` + Enabled bool `json:"enabled"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevision.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevision.go new file mode 100644 index 00000000000..e867a34a526 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevision.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MeshRevision struct { + CompatibleWith *[]CompatibleVersions `json:"compatibleWith,omitempty"` + Revision *string `json:"revision,omitempty"` + Upgrades *[]string `json:"upgrades,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevisionprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevisionprofile.go new file mode 100644 index 00000000000..40b56bf28d8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevisionprofile.go @@ -0,0 +1,16 @@ +package managedclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MeshRevisionProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MeshRevisionProfileProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevisionprofileproperties.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevisionprofileproperties.go new file mode 100644 index 00000000000..4d72f23dadb --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshrevisionprofileproperties.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MeshRevisionProfileProperties struct { + MeshRevisions *[]MeshRevision `json:"meshRevisions,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshupgradeprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshupgradeprofile.go new file mode 100644 index 00000000000..804e24cc19b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_meshupgradeprofile.go @@ -0,0 +1,16 @@ +package managedclusters + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MeshUpgradeProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *MeshRevision `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_networkmonitoring.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_networkmonitoring.go new file mode 100644 index 00000000000..aced77970f4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_networkmonitoring.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkMonitoring struct { + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionprofile.go new file mode 100644 index 00000000000..27b0bbc0c20 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionprofile.go @@ -0,0 +1,11 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSOptionProfile struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties OSOptionPropertyList `json:"properties"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionproperty.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionproperty.go new file mode 100644 index 00000000000..4c8a976ae2d --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionproperty.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSOptionProperty struct { + EnableFipsImage bool `json:"enable-fips-image"` + OsType string `json:"os-type"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionpropertylist.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionpropertylist.go new file mode 100644 index 00000000000..5c126250b2c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_osoptionpropertylist.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSOptionPropertyList struct { + OsOptionPropertyList []OSOptionProperty `json:"osOptionPropertyList"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_outboundenvironmentendpoint.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_outboundenvironmentendpoint.go new file mode 100644 index 00000000000..a4f0d234bc8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_outboundenvironmentendpoint.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundEnvironmentEndpoint struct { + Category *string `json:"category,omitempty"` + Endpoints *[]EndpointDependency `json:"endpoints,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_portrange.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_portrange.go new file mode 100644 index 00000000000..0a44c59e9c8 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_portrange.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PortRange struct { + PortEnd *int64 `json:"portEnd,omitempty"` + PortStart *int64 `json:"portStart,omitempty"` + Protocol *Protocol `json:"protocol,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_powerstate.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_powerstate.go new file mode 100644 index 00000000000..d5abeb15b66 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_powerstate.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PowerState struct { + Code *Code `json:"code,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_privatelinkresource.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_privatelinkresource.go new file mode 100644 index 00000000000..14d827574be --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_privatelinkresource.go @@ -0,0 +1,13 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + GroupId *string `json:"groupId,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PrivateLinkServiceID *string `json:"privateLinkServiceID,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_resourcereference.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_resourcereference.go new file mode 100644 index 00000000000..dbb05bb4711 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_resourcereference.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceReference struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_runcommandrequest.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_runcommandrequest.go new file mode 100644 index 00000000000..caa9ae3d0cd --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_runcommandrequest.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunCommandRequest struct { + ClusterToken *string `json:"clusterToken,omitempty"` + Command string `json:"command"` + Context *string `json:"context,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_runcommandresult.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_runcommandresult.go new file mode 100644 index 00000000000..59cfc374de3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_runcommandresult.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RunCommandResult struct { + Id *string `json:"id,omitempty"` + Properties *CommandResultProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_servicemeshprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_servicemeshprofile.go new file mode 100644 index 00000000000..781365d16f3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_servicemeshprofile.go @@ -0,0 +1,9 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceMeshProfile struct { + Istio *IstioServiceMesh `json:"istio,omitempty"` + Mode ServiceMeshMode `json:"mode"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_sysctlconfig.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_sysctlconfig.go new file mode 100644 index 00000000000..00f3cc50224 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_sysctlconfig.go @@ -0,0 +1,35 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SysctlConfig struct { + FsAioMaxNr *int64 `json:"fsAioMaxNr,omitempty"` + FsFileMax *int64 `json:"fsFileMax,omitempty"` + FsInotifyMaxUserWatches *int64 `json:"fsInotifyMaxUserWatches,omitempty"` + FsNrOpen *int64 `json:"fsNrOpen,omitempty"` + KernelThreadsMax *int64 `json:"kernelThreadsMax,omitempty"` + NetCoreNetdevMaxBacklog *int64 `json:"netCoreNetdevMaxBacklog,omitempty"` + NetCoreOptmemMax *int64 `json:"netCoreOptmemMax,omitempty"` + NetCoreRmemDefault *int64 `json:"netCoreRmemDefault,omitempty"` + NetCoreRmemMax *int64 `json:"netCoreRmemMax,omitempty"` + NetCoreSomaxconn *int64 `json:"netCoreSomaxconn,omitempty"` + NetCoreWmemDefault *int64 `json:"netCoreWmemDefault,omitempty"` + NetCoreWmemMax *int64 `json:"netCoreWmemMax,omitempty"` + NetIPv4IPLocalPortRange *string `json:"netIpv4IpLocalPortRange,omitempty"` + NetIPv4NeighDefaultGcThresh1 *int64 `json:"netIpv4NeighDefaultGcThresh1,omitempty"` + NetIPv4NeighDefaultGcThresh2 *int64 `json:"netIpv4NeighDefaultGcThresh2,omitempty"` + NetIPv4NeighDefaultGcThresh3 *int64 `json:"netIpv4NeighDefaultGcThresh3,omitempty"` + NetIPv4TcpFinTimeout *int64 `json:"netIpv4TcpFinTimeout,omitempty"` + NetIPv4TcpKeepaliveProbes *int64 `json:"netIpv4TcpKeepaliveProbes,omitempty"` + NetIPv4TcpKeepaliveTime *int64 `json:"netIpv4TcpKeepaliveTime,omitempty"` + NetIPv4TcpMaxSynBacklog *int64 `json:"netIpv4TcpMaxSynBacklog,omitempty"` + NetIPv4TcpMaxTwBuckets *int64 `json:"netIpv4TcpMaxTwBuckets,omitempty"` + NetIPv4TcpTwReuse *bool `json:"netIpv4TcpTwReuse,omitempty"` + NetIPv4TcpkeepaliveIntvl *int64 `json:"netIpv4TcpkeepaliveIntvl,omitempty"` + NetNetfilterNfConntrackBuckets *int64 `json:"netNetfilterNfConntrackBuckets,omitempty"` + NetNetfilterNfConntrackMax *int64 `json:"netNetfilterNfConntrackMax,omitempty"` + VMMaxMapCount *int64 `json:"vmMaxMapCount,omitempty"` + VMSwappiness *int64 `json:"vmSwappiness,omitempty"` + VMVfsCachePressure *int64 `json:"vmVfsCachePressure,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_tagsobject.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_tagsobject.go new file mode 100644 index 00000000000..69f1454e3b1 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_tagsobject.go @@ -0,0 +1,8 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_upgradeoverridesettings.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_upgradeoverridesettings.go new file mode 100644 index 00000000000..6be73348ea0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_upgradeoverridesettings.go @@ -0,0 +1,27 @@ +package managedclusters + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpgradeOverrideSettings struct { + ForceUpgrade *bool `json:"forceUpgrade,omitempty"` + Until *string `json:"until,omitempty"` +} + +func (o *UpgradeOverrideSettings) GetUntilAsTime() (*time.Time, error) { + if o.Until == nil { + return nil, nil + } + return dates.ParseAsFormat(o.Until, "2006-01-02T15:04:05Z07:00") +} + +func (o *UpgradeOverrideSettings) SetUntilAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.Until = &formatted +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_userassignedidentity.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_userassignedidentity.go new file mode 100644 index 00000000000..b1eecd7085a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_userassignedidentity.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAssignedIdentity struct { + ClientId *string `json:"clientId,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_windowsgmsaprofile.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_windowsgmsaprofile.go new file mode 100644 index 00000000000..742f96764d4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/model_windowsgmsaprofile.go @@ -0,0 +1,10 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WindowsGmsaProfile struct { + DnsServer *string `json:"dnsServer,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + RootDomainName *string `json:"rootDomainName,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/predicates.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/predicates.go new file mode 100644 index 00000000000..c33b6adfd45 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/predicates.go @@ -0,0 +1,114 @@ +package managedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GuardrailsAvailableVersionOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p GuardrailsAvailableVersionOperationPredicate) Matches(input GuardrailsAvailableVersion) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type ManagedClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedClusterOperationPredicate) Matches(input ManagedCluster) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type MeshRevisionProfileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MeshRevisionProfileOperationPredicate) Matches(input MeshRevisionProfile) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type MeshUpgradeProfileOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MeshUpgradeProfileOperationPredicate) Matches(input MeshUpgradeProfile) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type OutboundEnvironmentEndpointOperationPredicate struct { + Category *string +} + +func (p OutboundEnvironmentEndpointOperationPredicate) Matches(input OutboundEnvironmentEndpoint) bool { + + if p.Category != nil && (input.Category == nil || *p.Category != *input.Category) { + return false + } + + return true +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclusters/version.go b/resource-manager/containerservice/2023-09-02-preview/managedclusters/version.go new file mode 100644 index 00000000000..ffcad7e8ebb --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclusters/version.go @@ -0,0 +1,12 @@ +package managedclusters + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedclusters/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/README.md b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/README.md new file mode 100644 index 00000000000..af883467bc0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots` Documentation + +The `managedclustersnapshots` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots" +``` + + +### Client Initialization + +```go +client := managedclustersnapshots.NewManagedClusterSnapshotsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedClusterSnapshotsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := managedclustersnapshots.NewManagedClusterSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterSnapshotValue") + +payload := managedclustersnapshots.ManagedClusterSnapshot{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClusterSnapshotsClient.Delete` + +```go +ctx := context.TODO() +id := managedclustersnapshots.NewManagedClusterSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterSnapshotValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClusterSnapshotsClient.Get` + +```go +ctx := context.TODO() +id := managedclustersnapshots.NewManagedClusterSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterSnapshotValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedClusterSnapshotsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClusterSnapshotsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ManagedClusterSnapshotsClient.UpdateTags` + +```go +ctx := context.TODO() +id := managedclustersnapshots.NewManagedClusterSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterSnapshotValue") + +payload := managedclustersnapshots.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/client.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/client.go new file mode 100644 index 00000000000..939ebd0b984 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/client.go @@ -0,0 +1,26 @@ +package managedclustersnapshots + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSnapshotsClient struct { + Client *resourcemanager.Client +} + +func NewManagedClusterSnapshotsClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedClusterSnapshotsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managedclustersnapshots", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedClusterSnapshotsClient: %+v", err) + } + + return &ManagedClusterSnapshotsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/constants.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/constants.go new file mode 100644 index 00000000000..6d6c18d7a43 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/constants.go @@ -0,0 +1,344 @@ +package managedclustersnapshots + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type LoadBalancerSku string + +const ( + LoadBalancerSkuBasic LoadBalancerSku = "basic" + LoadBalancerSkuStandard LoadBalancerSku = "standard" +) + +func PossibleValuesForLoadBalancerSku() []string { + return []string{ + string(LoadBalancerSkuBasic), + string(LoadBalancerSkuStandard), + } +} + +func (s *LoadBalancerSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerSku(input string) (*LoadBalancerSku, error) { + vals := map[string]LoadBalancerSku{ + "basic": LoadBalancerSkuBasic, + "standard": LoadBalancerSkuStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerSku(input) + return &out, nil +} + +type ManagedClusterSKUName string + +const ( + ManagedClusterSKUNameBase ManagedClusterSKUName = "Base" +) + +func PossibleValuesForManagedClusterSKUName() []string { + return []string{ + string(ManagedClusterSKUNameBase), + } +} + +func (s *ManagedClusterSKUName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterSKUName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterSKUName(input string) (*ManagedClusterSKUName, error) { + vals := map[string]ManagedClusterSKUName{ + "base": ManagedClusterSKUNameBase, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterSKUName(input) + return &out, nil +} + +type ManagedClusterSKUTier string + +const ( + ManagedClusterSKUTierFree ManagedClusterSKUTier = "Free" + ManagedClusterSKUTierPremium ManagedClusterSKUTier = "Premium" + ManagedClusterSKUTierStandard ManagedClusterSKUTier = "Standard" +) + +func PossibleValuesForManagedClusterSKUTier() []string { + return []string{ + string(ManagedClusterSKUTierFree), + string(ManagedClusterSKUTierPremium), + string(ManagedClusterSKUTierStandard), + } +} + +func (s *ManagedClusterSKUTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedClusterSKUTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedClusterSKUTier(input string) (*ManagedClusterSKUTier, error) { + vals := map[string]ManagedClusterSKUTier{ + "free": ManagedClusterSKUTierFree, + "premium": ManagedClusterSKUTierPremium, + "standard": ManagedClusterSKUTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedClusterSKUTier(input) + return &out, nil +} + +type NetworkMode string + +const ( + NetworkModeBridge NetworkMode = "bridge" + NetworkModeTransparent NetworkMode = "transparent" +) + +func PossibleValuesForNetworkMode() []string { + return []string{ + string(NetworkModeBridge), + string(NetworkModeTransparent), + } +} + +func (s *NetworkMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkMode(input string) (*NetworkMode, error) { + vals := map[string]NetworkMode{ + "bridge": NetworkModeBridge, + "transparent": NetworkModeTransparent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkMode(input) + return &out, nil +} + +type NetworkPlugin string + +const ( + NetworkPluginAzure NetworkPlugin = "azure" + NetworkPluginKubenet NetworkPlugin = "kubenet" + NetworkPluginNone NetworkPlugin = "none" +) + +func PossibleValuesForNetworkPlugin() []string { + return []string{ + string(NetworkPluginAzure), + string(NetworkPluginKubenet), + string(NetworkPluginNone), + } +} + +func (s *NetworkPlugin) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPlugin(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPlugin(input string) (*NetworkPlugin, error) { + vals := map[string]NetworkPlugin{ + "azure": NetworkPluginAzure, + "kubenet": NetworkPluginKubenet, + "none": NetworkPluginNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPlugin(input) + return &out, nil +} + +type NetworkPluginMode string + +const ( + NetworkPluginModeOverlay NetworkPluginMode = "overlay" +) + +func PossibleValuesForNetworkPluginMode() []string { + return []string{ + string(NetworkPluginModeOverlay), + } +} + +func (s *NetworkPluginMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPluginMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPluginMode(input string) (*NetworkPluginMode, error) { + vals := map[string]NetworkPluginMode{ + "overlay": NetworkPluginModeOverlay, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPluginMode(input) + return &out, nil +} + +type NetworkPolicy string + +const ( + NetworkPolicyAzure NetworkPolicy = "azure" + NetworkPolicyCalico NetworkPolicy = "calico" + NetworkPolicyCilium NetworkPolicy = "cilium" + NetworkPolicyNone NetworkPolicy = "none" +) + +func PossibleValuesForNetworkPolicy() []string { + return []string{ + string(NetworkPolicyAzure), + string(NetworkPolicyCalico), + string(NetworkPolicyCilium), + string(NetworkPolicyNone), + } +} + +func (s *NetworkPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetworkPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetworkPolicy(input string) (*NetworkPolicy, error) { + vals := map[string]NetworkPolicy{ + "azure": NetworkPolicyAzure, + "calico": NetworkPolicyCalico, + "cilium": NetworkPolicyCilium, + "none": NetworkPolicyNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NetworkPolicy(input) + return &out, nil +} + +type SnapshotType string + +const ( + SnapshotTypeManagedCluster SnapshotType = "ManagedCluster" + SnapshotTypeNodePool SnapshotType = "NodePool" +) + +func PossibleValuesForSnapshotType() []string { + return []string{ + string(SnapshotTypeManagedCluster), + string(SnapshotTypeNodePool), + } +} + +func (s *SnapshotType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSnapshotType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSnapshotType(input string) (*SnapshotType, error) { + vals := map[string]SnapshotType{ + "managedcluster": SnapshotTypeManagedCluster, + "nodepool": SnapshotTypeNodePool, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SnapshotType(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/id_managedclustersnapshot.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/id_managedclustersnapshot.go new file mode 100644 index 00000000000..bd22899cf08 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/id_managedclustersnapshot.go @@ -0,0 +1,130 @@ +package managedclustersnapshots + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ManagedClusterSnapshotId{}) +} + +var _ resourceids.ResourceId = &ManagedClusterSnapshotId{} + +// ManagedClusterSnapshotId is a struct representing the Resource ID for a Managed Cluster Snapshot +type ManagedClusterSnapshotId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterSnapshotName string +} + +// NewManagedClusterSnapshotID returns a new ManagedClusterSnapshotId struct +func NewManagedClusterSnapshotID(subscriptionId string, resourceGroupName string, managedClusterSnapshotName string) ManagedClusterSnapshotId { + return ManagedClusterSnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterSnapshotName: managedClusterSnapshotName, + } +} + +// ParseManagedClusterSnapshotID parses 'input' into a ManagedClusterSnapshotId +func ParseManagedClusterSnapshotID(input string) (*ManagedClusterSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterSnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterSnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseManagedClusterSnapshotIDInsensitively parses 'input' case-insensitively into a ManagedClusterSnapshotId +// note: this method should only be used for API response data and not user input +func ParseManagedClusterSnapshotIDInsensitively(input string) (*ManagedClusterSnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&ManagedClusterSnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ManagedClusterSnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ManagedClusterSnapshotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterSnapshotName, ok = input.Parsed["managedClusterSnapshotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterSnapshotName", input) + } + + return nil +} + +// ValidateManagedClusterSnapshotID checks that 'input' can be parsed as a Managed Cluster Snapshot ID +func ValidateManagedClusterSnapshotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseManagedClusterSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Managed Cluster Snapshot ID +func (id ManagedClusterSnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusterSnapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterSnapshotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Managed Cluster Snapshot ID +func (id ManagedClusterSnapshotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusterSnapshots", "managedClusterSnapshots", "managedClusterSnapshots"), + resourceids.UserSpecifiedSegment("managedClusterSnapshotName", "managedClusterSnapshotValue"), + } +} + +// String returns a human-readable description of this Managed Cluster Snapshot ID +func (id ManagedClusterSnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Snapshot Name: %q", id.ManagedClusterSnapshotName), + } + return fmt.Sprintf("Managed Cluster Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/id_managedclustersnapshot_test.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/id_managedclustersnapshot_test.go new file mode 100644 index 00000000000..13021711720 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/id_managedclustersnapshot_test.go @@ -0,0 +1,282 @@ +package managedclustersnapshots + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ManagedClusterSnapshotId{} + +func TestNewManagedClusterSnapshotID(t *testing.T) { + id := NewManagedClusterSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterSnapshotValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterSnapshotName != "managedClusterSnapshotValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterSnapshotName'", id.ManagedClusterSnapshotName, "managedClusterSnapshotValue") + } +} + +func TestFormatManagedClusterSnapshotID(t *testing.T) { + actual := NewManagedClusterSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterSnapshotValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusterSnapshots/managedClusterSnapshotValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseManagedClusterSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterSnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusterSnapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusterSnapshots/managedClusterSnapshotValue", + Expected: &ManagedClusterSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterSnapshotName: "managedClusterSnapshotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusterSnapshots/managedClusterSnapshotValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterSnapshotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterSnapshotName != v.Expected.ManagedClusterSnapshotName { + t.Fatalf("Expected %q but got %q for ManagedClusterSnapshotName", v.Expected.ManagedClusterSnapshotName, actual.ManagedClusterSnapshotName) + } + + } +} + +func TestParseManagedClusterSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ManagedClusterSnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusterSnapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRsNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusterSnapshots/managedClusterSnapshotValue", + Expected: &ManagedClusterSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterSnapshotName: "managedClusterSnapshotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusterSnapshots/managedClusterSnapshotValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRsNaPsHoTs/mAnAgEdClUsTeRsNaPsHoTvAlUe", + Expected: &ManagedClusterSnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterSnapshotName: "mAnAgEdClUsTeRsNaPsHoTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRsNaPsHoTs/mAnAgEdClUsTeRsNaPsHoTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseManagedClusterSnapshotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterSnapshotName != v.Expected.ManagedClusterSnapshotName { + t.Fatalf("Expected %q but got %q for ManagedClusterSnapshotName", v.Expected.ManagedClusterSnapshotName, actual.ManagedClusterSnapshotName) + } + + } +} + +func TestSegmentsForManagedClusterSnapshotId(t *testing.T) { + segments := ManagedClusterSnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ManagedClusterSnapshotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_createorupdate.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_createorupdate.go new file mode 100644 index 00000000000..1041144ec50 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_createorupdate.go @@ -0,0 +1,59 @@ +package managedclustersnapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterSnapshot +} + +// CreateOrUpdate ... +func (c ManagedClusterSnapshotsClient) CreateOrUpdate(ctx context.Context, id ManagedClusterSnapshotId, input ManagedClusterSnapshot) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterSnapshot + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_delete.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_delete.go new file mode 100644 index 00000000000..3b8fc26cc15 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_delete.go @@ -0,0 +1,47 @@ +package managedclustersnapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ManagedClusterSnapshotsClient) Delete(ctx context.Context, id ManagedClusterSnapshotId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_get.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_get.go new file mode 100644 index 00000000000..ead8643d9dc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_get.go @@ -0,0 +1,54 @@ +package managedclustersnapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterSnapshot +} + +// Get ... +func (c ManagedClusterSnapshotsClient) Get(ctx context.Context, id ManagedClusterSnapshotId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterSnapshot + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_list.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_list.go new file mode 100644 index 00000000000..9f0d4dec699 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_list.go @@ -0,0 +1,92 @@ +package managedclustersnapshots + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedClusterSnapshot +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedClusterSnapshot +} + +// List ... +func (c ManagedClusterSnapshotsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ContainerService/managedClusterSnapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedClusterSnapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c ManagedClusterSnapshotsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ManagedClusterSnapshotOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterSnapshotsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ManagedClusterSnapshotOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ManagedClusterSnapshot, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_listbyresourcegroup.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_listbyresourcegroup.go new file mode 100644 index 00000000000..4b28f6c8a05 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package managedclustersnapshots + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ManagedClusterSnapshot +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []ManagedClusterSnapshot +} + +// ListByResourceGroup ... +func (c ManagedClusterSnapshotsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ContainerService/managedClusterSnapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ManagedClusterSnapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c ManagedClusterSnapshotsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ManagedClusterSnapshotOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedClusterSnapshotsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ManagedClusterSnapshotOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]ManagedClusterSnapshot, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_updatetags.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_updatetags.go new file mode 100644 index 00000000000..f6dcaa5a53e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/method_updatetags.go @@ -0,0 +1,58 @@ +package managedclustersnapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ManagedClusterSnapshot +} + +// UpdateTags ... +func (c ManagedClusterSnapshotsClient) UpdateTags(ctx context.Context, id ManagedClusterSnapshotId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ManagedClusterSnapshot + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_creationdata.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_creationdata.go new file mode 100644 index 00000000000..8fb59d8abec --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_creationdata.go @@ -0,0 +1,8 @@ +package managedclustersnapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreationData struct { + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclusterpropertiesforsnapshot.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclusterpropertiesforsnapshot.go new file mode 100644 index 00000000000..fcf682d5789 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclusterpropertiesforsnapshot.go @@ -0,0 +1,11 @@ +package managedclustersnapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterPropertiesForSnapshot struct { + EnableRbac *bool `json:"enableRbac,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + NetworkProfile *NetworkProfileForSnapshot `json:"networkProfile,omitempty"` + Sku *ManagedClusterSKU `json:"sku,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersku.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersku.go new file mode 100644 index 00000000000..e3e12587809 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersku.go @@ -0,0 +1,9 @@ +package managedclustersnapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSKU struct { + Name *ManagedClusterSKUName `json:"name,omitempty"` + Tier *ManagedClusterSKUTier `json:"tier,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersnapshot.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersnapshot.go new file mode 100644 index 00000000000..43b8096001b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersnapshot.go @@ -0,0 +1,18 @@ +package managedclustersnapshots + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSnapshot struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *ManagedClusterSnapshotProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersnapshotproperties.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersnapshotproperties.go new file mode 100644 index 00000000000..0710501e092 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_managedclustersnapshotproperties.go @@ -0,0 +1,10 @@ +package managedclustersnapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSnapshotProperties struct { + CreationData *CreationData `json:"creationData,omitempty"` + ManagedClusterPropertiesReadOnly *ManagedClusterPropertiesForSnapshot `json:"managedClusterPropertiesReadOnly,omitempty"` + SnapshotType *SnapshotType `json:"snapshotType,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_networkprofileforsnapshot.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_networkprofileforsnapshot.go new file mode 100644 index 00000000000..02c1c65f57a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_networkprofileforsnapshot.go @@ -0,0 +1,12 @@ +package managedclustersnapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NetworkProfileForSnapshot struct { + LoadBalancerSku *LoadBalancerSku `json:"loadBalancerSku,omitempty"` + NetworkMode *NetworkMode `json:"networkMode,omitempty"` + NetworkPlugin *NetworkPlugin `json:"networkPlugin,omitempty"` + NetworkPluginMode *NetworkPluginMode `json:"networkPluginMode,omitempty"` + NetworkPolicy *NetworkPolicy `json:"networkPolicy,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_tagsobject.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_tagsobject.go new file mode 100644 index 00000000000..a9e96162848 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/model_tagsobject.go @@ -0,0 +1,8 @@ +package managedclustersnapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/predicates.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/predicates.go new file mode 100644 index 00000000000..665969defbb --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/predicates.go @@ -0,0 +1,32 @@ +package managedclustersnapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedClusterSnapshotOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ManagedClusterSnapshotOperationPredicate) Matches(input ManagedClusterSnapshot) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/version.go b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/version.go new file mode 100644 index 00000000000..16d00b58c13 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/managedclustersnapshots/version.go @@ -0,0 +1,12 @@ +package managedclustersnapshots + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managedclustersnapshots/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/README.md b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/README.md new file mode 100644 index 00000000000..845c7dfb992 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Delete` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "privateEndpointConnectionValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Get` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "privateEndpointConnectionValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.Update` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "privateEndpointConnectionValue") + +payload := privateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/client.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/client.go new file mode 100644 index 00000000000..3bf7a6afe1f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/client.go @@ -0,0 +1,26 @@ +package privateendpointconnections + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateEndpointConnectionsClient: %+v", err) + } + + return &PrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/constants.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/constants.go new file mode 100644 index 00000000000..20cf74bcad4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/constants.go @@ -0,0 +1,107 @@ +package privateendpointconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectionStatus string + +const ( + ConnectionStatusApproved ConnectionStatus = "Approved" + ConnectionStatusDisconnected ConnectionStatus = "Disconnected" + ConnectionStatusPending ConnectionStatus = "Pending" + ConnectionStatusRejected ConnectionStatus = "Rejected" +) + +func PossibleValuesForConnectionStatus() []string { + return []string{ + string(ConnectionStatusApproved), + string(ConnectionStatusDisconnected), + string(ConnectionStatusPending), + string(ConnectionStatusRejected), + } +} + +func (s *ConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionStatus(input string) (*ConnectionStatus, error) { + vals := map[string]ConnectionStatus{ + "approved": ConnectionStatusApproved, + "disconnected": ConnectionStatusDisconnected, + "pending": ConnectionStatusPending, + "rejected": ConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionStatus(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCanceled PrivateEndpointConnectionProvisioningState = "Canceled" + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCanceled), + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "canceled": PrivateEndpointConnectionProvisioningStateCanceled, + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/id_privateendpointconnection.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..c682166f416 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PrivateEndpointConnectionId{}) +} + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +// PrivateEndpointConnectionId is a struct representing the Resource ID for a Private Endpoint Connection +type PrivateEndpointConnectionId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, managedClusterName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + PrivateEndpointConnectionName: privateEndpointConnectionName, + } +} + +// ParsePrivateEndpointConnectionID parses 'input' into a PrivateEndpointConnectionId +func ParsePrivateEndpointConnectionID(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePrivateEndpointConnectionIDInsensitively parses 'input' case-insensitively into a PrivateEndpointConnectionId +// note: this method should only be used for API response data and not user input +func ParsePrivateEndpointConnectionIDInsensitively(input string) (*PrivateEndpointConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&PrivateEndpointConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PrivateEndpointConnectionId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PrivateEndpointConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.PrivateEndpointConnectionName, ok = input.Parsed["privateEndpointConnectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "privateEndpointConnectionName", input) + } + + return nil +} + +// ValidatePrivateEndpointConnectionID checks that 'input' can be parsed as a Private Endpoint Connection ID +func ValidatePrivateEndpointConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePrivateEndpointConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.PrivateEndpointConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticPrivateEndpointConnections", "privateEndpointConnections", "privateEndpointConnections"), + resourceids.UserSpecifiedSegment("privateEndpointConnectionName", "privateEndpointConnectionValue"), + } +} + +// String returns a human-readable description of this Private Endpoint Connection ID +func (id PrivateEndpointConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Private Endpoint Connection Name: %q", id.PrivateEndpointConnectionName), + } + return fmt.Sprintf("Private Endpoint Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..a2eb3acf095 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PrivateEndpointConnectionId{} + +func TestNewPrivateEndpointConnectionID(t *testing.T) { + id := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "privateEndpointConnectionValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.PrivateEndpointConnectionName != "privateEndpointConnectionValue" { + t.Fatalf("Expected %q but got %q for Segment 'PrivateEndpointConnectionName'", id.PrivateEndpointConnectionName, "privateEndpointConnectionValue") + } +} + +func TestFormatPrivateEndpointConnectionID(t *testing.T) { + actual := NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "privateEndpointConnectionValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/privateEndpointConnections/privateEndpointConnectionValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePrivateEndpointConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestParsePrivateEndpointConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PrivateEndpointConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/privateEndpointConnections/privateEndpointConnectionValue", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + PrivateEndpointConnectionName: "privateEndpointConnectionValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/privateEndpointConnections/privateEndpointConnectionValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + PrivateEndpointConnectionName: "pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePrivateEndpointConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.PrivateEndpointConnectionName != v.Expected.PrivateEndpointConnectionName { + t.Fatalf("Expected %q but got %q for PrivateEndpointConnectionName", v.Expected.PrivateEndpointConnectionName, actual.PrivateEndpointConnectionName) + } + + } +} + +func TestSegmentsForPrivateEndpointConnectionId(t *testing.T) { + segments := PrivateEndpointConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PrivateEndpointConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_delete.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_delete.go new file mode 100644 index 00000000000..2b9a343bdf0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_delete.go @@ -0,0 +1,70 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c PrivateEndpointConnectionsClient) Delete(ctx context.Context, id PrivateEndpointConnectionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c PrivateEndpointConnectionsClient) DeleteThenPoll(ctx context.Context, id PrivateEndpointConnectionId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_get.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_get.go new file mode 100644 index 00000000000..8dc28d7ff7a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_get.go @@ -0,0 +1,54 @@ +package privateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Get ... +func (c PrivateEndpointConnectionsClient) Get(ctx context.Context, id PrivateEndpointConnectionId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_list.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_list.go new file mode 100644 index 00000000000..bd4dd26e8bb --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_list.go @@ -0,0 +1,56 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// List ... +func (c PrivateEndpointConnectionsClient) List(ctx context.Context, id commonids.KubernetesClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateEndpointConnections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnectionListResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_update.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_update.go new file mode 100644 index 00000000000..e0579b67245 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/method_update.go @@ -0,0 +1,59 @@ +package privateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// Update ... +func (c PrivateEndpointConnectionsClient) Update(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateEndpointConnection + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpoint.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpoint.go new file mode 100644 index 00000000000..1bc8cf2a97c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpoint.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..fde7f4db0fc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,11 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnectionlistresult.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnectionlistresult.go new file mode 100644 index 00000000000..92a9ecb105a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnectionlistresult.go @@ -0,0 +1,8 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionListResult struct { + Value *[]PrivateEndpointConnection `json:"value,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..549d255f069 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..677cab99f90 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,9 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + Description *string `json:"description,omitempty"` + Status *ConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/version.go b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/version.go new file mode 100644 index 00000000000..67b25d60806 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privateendpointconnections/version.go @@ -0,0 +1,12 @@ +package privateendpointconnections + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privateendpointconnections/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/README.md b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/README.md new file mode 100644 index 00000000000..9fb614e0b55 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/README.md @@ -0,0 +1,37 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/privatelinkresources` Documentation + +The `privatelinkresources` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/privatelinkresources" +``` + + +### Client Initialization + +```go +client := privatelinkresources.NewPrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateLinkResourcesClient.List` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/client.go b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/client.go new file mode 100644 index 00000000000..e6e22caa746 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/client.go @@ -0,0 +1,26 @@ +package privatelinkresources + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewPrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PrivateLinkResourcesClient: %+v", err) + } + + return &PrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/method_list.go b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/method_list.go new file mode 100644 index 00000000000..836fd220ae3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/method_list.go @@ -0,0 +1,56 @@ +package privatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourcesListResult +} + +// List ... +func (c PrivateLinkResourcesClient) List(ctx context.Context, id commonids.KubernetesClusterId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/privateLinkResources", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResourcesListResult + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/model_privatelinkresource.go b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..3490b3d4e87 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/model_privatelinkresource.go @@ -0,0 +1,13 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + GroupId *string `json:"groupId,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PrivateLinkServiceID *string `json:"privateLinkServiceID,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/model_privatelinkresourceslistresult.go b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/model_privatelinkresourceslistresult.go new file mode 100644 index 00000000000..52cfe88b6e2 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/model_privatelinkresourceslistresult.go @@ -0,0 +1,8 @@ +package privatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesListResult struct { + Value *[]PrivateLinkResource `json:"value,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/version.go b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/version.go new file mode 100644 index 00000000000..0e61a8bb508 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/privatelinkresources/version.go @@ -0,0 +1,12 @@ +package privatelinkresources + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/privatelinkresources/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/README.md b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/README.md new file mode 100644 index 00000000000..a2d93fc4f4b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/README.md @@ -0,0 +1,42 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid` Documentation + +The `resolveprivatelinkserviceid` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid" +``` + + +### Client Initialization + +```go +client := resolveprivatelinkserviceid.NewResolvePrivateLinkServiceIdClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResolvePrivateLinkServiceIdClient.POST` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +payload := resolveprivatelinkserviceid.PrivateLinkResource{ + // ... +} + + +read, err := client.POST(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/client.go b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/client.go new file mode 100644 index 00000000000..dd21ffc0b6b --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/client.go @@ -0,0 +1,26 @@ +package resolveprivatelinkserviceid + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResolvePrivateLinkServiceIdClient struct { + Client *resourcemanager.Client +} + +func NewResolvePrivateLinkServiceIdClientWithBaseURI(sdkApi sdkEnv.Api) (*ResolvePrivateLinkServiceIdClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "resolveprivatelinkserviceid", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResolvePrivateLinkServiceIdClient: %+v", err) + } + + return &ResolvePrivateLinkServiceIdClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/method_post.go b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/method_post.go new file mode 100644 index 00000000000..f583a77cede --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/method_post.go @@ -0,0 +1,60 @@ +package resolveprivatelinkserviceid + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type POSTOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResource +} + +// POST ... +func (c ResolvePrivateLinkServiceIdClient) POST(ctx context.Context, id commonids.KubernetesClusterId, input PrivateLinkResource) (result POSTOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resolvePrivateLinkServiceId", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PrivateLinkResource + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/model_privatelinkresource.go b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/model_privatelinkresource.go new file mode 100644 index 00000000000..4ff07dba897 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/model_privatelinkresource.go @@ -0,0 +1,13 @@ +package resolveprivatelinkserviceid + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + GroupId *string `json:"groupId,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + PrivateLinkServiceID *string `json:"privateLinkServiceID,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/version.go b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/version.go new file mode 100644 index 00000000000..494f5ffdec4 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/resolveprivatelinkserviceid/version.go @@ -0,0 +1,12 @@ +package resolveprivatelinkserviceid + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resolveprivatelinkserviceid/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/README.md b/resource-manager/containerservice/2023-09-02-preview/snapshots/README.md new file mode 100644 index 00000000000..bed60a5f999 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/README.md @@ -0,0 +1,129 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots` Documentation + +The `snapshots` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/snapshots" +``` + + +### Client Initialization + +```go +client := snapshots.NewSnapshotsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `SnapshotsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotValue") + +payload := snapshots.Snapshot{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SnapshotsClient.Delete` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SnapshotsClient.Get` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `SnapshotsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SnapshotsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `SnapshotsClient.UpdateTags` + +```go +ctx := context.TODO() +id := snapshots.NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotValue") + +payload := snapshots.TagsObject{ + // ... +} + + +read, err := client.UpdateTags(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/client.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/client.go new file mode 100644 index 00000000000..620b7900eab --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/client.go @@ -0,0 +1,26 @@ +package snapshots + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotsClient struct { + Client *resourcemanager.Client +} + +func NewSnapshotsClientWithBaseURI(sdkApi sdkEnv.Api) (*SnapshotsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "snapshots", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating SnapshotsClient: %+v", err) + } + + return &SnapshotsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/constants.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/constants.go new file mode 100644 index 00000000000..ea209bb677a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/constants.go @@ -0,0 +1,148 @@ +package snapshots + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OSSKU string + +const ( + OSSKUAzureLinux OSSKU = "AzureLinux" + OSSKUCBLMariner OSSKU = "CBLMariner" + OSSKUMariner OSSKU = "Mariner" + OSSKUUbuntu OSSKU = "Ubuntu" + OSSKUWindowsAnnual OSSKU = "WindowsAnnual" + OSSKUWindowsTwoZeroOneNine OSSKU = "Windows2019" + OSSKUWindowsTwoZeroTwoTwo OSSKU = "Windows2022" +) + +func PossibleValuesForOSSKU() []string { + return []string{ + string(OSSKUAzureLinux), + string(OSSKUCBLMariner), + string(OSSKUMariner), + string(OSSKUUbuntu), + string(OSSKUWindowsAnnual), + string(OSSKUWindowsTwoZeroOneNine), + string(OSSKUWindowsTwoZeroTwoTwo), + } +} + +func (s *OSSKU) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSSKU(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSSKU(input string) (*OSSKU, error) { + vals := map[string]OSSKU{ + "azurelinux": OSSKUAzureLinux, + "cblmariner": OSSKUCBLMariner, + "mariner": OSSKUMariner, + "ubuntu": OSSKUUbuntu, + "windowsannual": OSSKUWindowsAnnual, + "windows2019": OSSKUWindowsTwoZeroOneNine, + "windows2022": OSSKUWindowsTwoZeroTwoTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSSKU(input) + return &out, nil +} + +type OSType string + +const ( + OSTypeLinux OSType = "Linux" + OSTypeWindows OSType = "Windows" +) + +func PossibleValuesForOSType() []string { + return []string{ + string(OSTypeLinux), + string(OSTypeWindows), + } +} + +func (s *OSType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOSType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOSType(input string) (*OSType, error) { + vals := map[string]OSType{ + "linux": OSTypeLinux, + "windows": OSTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OSType(input) + return &out, nil +} + +type SnapshotType string + +const ( + SnapshotTypeManagedCluster SnapshotType = "ManagedCluster" + SnapshotTypeNodePool SnapshotType = "NodePool" +) + +func PossibleValuesForSnapshotType() []string { + return []string{ + string(SnapshotTypeManagedCluster), + string(SnapshotTypeNodePool), + } +} + +func (s *SnapshotType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSnapshotType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSnapshotType(input string) (*SnapshotType, error) { + vals := map[string]SnapshotType{ + "managedcluster": SnapshotTypeManagedCluster, + "nodepool": SnapshotTypeNodePool, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SnapshotType(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/id_snapshot.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/id_snapshot.go new file mode 100644 index 00000000000..36f5d370bdf --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/id_snapshot.go @@ -0,0 +1,130 @@ +package snapshots + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&SnapshotId{}) +} + +var _ resourceids.ResourceId = &SnapshotId{} + +// SnapshotId is a struct representing the Resource ID for a Snapshot +type SnapshotId struct { + SubscriptionId string + ResourceGroupName string + SnapshotName string +} + +// NewSnapshotID returns a new SnapshotId struct +func NewSnapshotID(subscriptionId string, resourceGroupName string, snapshotName string) SnapshotId { + return SnapshotId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + SnapshotName: snapshotName, + } +} + +// ParseSnapshotID parses 'input' into a SnapshotId +func ParseSnapshotID(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseSnapshotIDInsensitively parses 'input' case-insensitively into a SnapshotId +// note: this method should only be used for API response data and not user input +func ParseSnapshotIDInsensitively(input string) (*SnapshotId, error) { + parser := resourceids.NewParserFromResourceIdType(&SnapshotId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := SnapshotId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *SnapshotId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.SnapshotName, ok = input.Parsed["snapshotName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "snapshotName", input) + } + + return nil +} + +// ValidateSnapshotID checks that 'input' can be parsed as a Snapshot ID +func ValidateSnapshotID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseSnapshotID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Snapshot ID +func (id SnapshotId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/snapshots/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.SnapshotName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Snapshot ID +func (id SnapshotId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticSnapshots", "snapshots", "snapshots"), + resourceids.UserSpecifiedSegment("snapshotName", "snapshotValue"), + } +} + +// String returns a human-readable description of this Snapshot ID +func (id SnapshotId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Snapshot Name: %q", id.SnapshotName), + } + return fmt.Sprintf("Snapshot (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/id_snapshot_test.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/id_snapshot_test.go new file mode 100644 index 00000000000..656f7bba56a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/id_snapshot_test.go @@ -0,0 +1,282 @@ +package snapshots + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &SnapshotId{} + +func TestNewSnapshotID(t *testing.T) { + id := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.SnapshotName != "snapshotValue" { + t.Fatalf("Expected %q but got %q for Segment 'SnapshotName'", id.SnapshotName, "snapshotValue") + } +} + +func TestFormatSnapshotID(t *testing.T) { + actual := NewSnapshotID("12345678-1234-9876-4563-123456789012", "example-resource-group", "snapshotValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots/snapshotValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseSnapshotID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots/snapshotValue", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SnapshotName: "snapshotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots/snapshotValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SnapshotName != v.Expected.SnapshotName { + t.Fatalf("Expected %q but got %q for SnapshotName", v.Expected.SnapshotName, actual.SnapshotName) + } + + } +} + +func TestParseSnapshotIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *SnapshotId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/sNaPsHoTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots/snapshotValue", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + SnapshotName: "snapshotValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/snapshots/snapshotValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/sNaPsHoTs/sNaPsHoTvAlUe", + Expected: &SnapshotId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + SnapshotName: "sNaPsHoTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/sNaPsHoTs/sNaPsHoTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseSnapshotIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.SnapshotName != v.Expected.SnapshotName { + t.Fatalf("Expected %q but got %q for SnapshotName", v.Expected.SnapshotName, actual.SnapshotName) + } + + } +} + +func TestSegmentsForSnapshotId(t *testing.T) { + segments := SnapshotId{}.Segments() + if len(segments) == 0 { + t.Fatalf("SnapshotId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/method_createorupdate.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_createorupdate.go new file mode 100644 index 00000000000..201c0eaedc7 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_createorupdate.go @@ -0,0 +1,59 @@ +package snapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Snapshot +} + +// CreateOrUpdate ... +func (c SnapshotsClient) CreateOrUpdate(ctx context.Context, id SnapshotId, input Snapshot) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Snapshot + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/method_delete.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_delete.go new file mode 100644 index 00000000000..575cb8a6929 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_delete.go @@ -0,0 +1,47 @@ +package snapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c SnapshotsClient) Delete(ctx context.Context, id SnapshotId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/method_get.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_get.go new file mode 100644 index 00000000000..d020538006a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_get.go @@ -0,0 +1,54 @@ +package snapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Snapshot +} + +// Get ... +func (c SnapshotsClient) Get(ctx context.Context, id SnapshotId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Snapshot + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/method_list.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_list.go new file mode 100644 index 00000000000..bdefce6bb90 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_list.go @@ -0,0 +1,92 @@ +package snapshots + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +// List ... +func (c SnapshotsClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ContainerService/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c SnapshotsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SnapshotsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate SnapshotOperationPredicate) (result ListCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.List(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/method_listbyresourcegroup.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_listbyresourcegroup.go new file mode 100644 index 00000000000..824b8dc7cb6 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_listbyresourcegroup.go @@ -0,0 +1,92 @@ +package snapshots + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Snapshot +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Snapshot +} + +// ListByResourceGroup ... +func (c SnapshotsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.ContainerService/snapshots", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Snapshot `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c SnapshotsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, SnapshotOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c SnapshotsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate SnapshotOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Snapshot, 0) + + resp, err := c.ListByResourceGroup(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/method_updatetags.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_updatetags.go new file mode 100644 index 00000000000..60346d7cddc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/method_updatetags.go @@ -0,0 +1,58 @@ +package snapshots + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateTagsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Snapshot +} + +// UpdateTags ... +func (c SnapshotsClient) UpdateTags(ctx context.Context, id SnapshotId, input TagsObject) (result UpdateTagsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model Snapshot + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/model_creationdata.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_creationdata.go new file mode 100644 index 00000000000..132e3459c82 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_creationdata.go @@ -0,0 +1,8 @@ +package snapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreationData struct { + SourceResourceId *string `json:"sourceResourceId,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/model_snapshot.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_snapshot.go new file mode 100644 index 00000000000..b2feb4ccdae --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_snapshot.go @@ -0,0 +1,18 @@ +package snapshots + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Snapshot struct { + Id *string `json:"id,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *SnapshotProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/model_snapshotproperties.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_snapshotproperties.go new file mode 100644 index 00000000000..962aa32598f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_snapshotproperties.go @@ -0,0 +1,15 @@ +package snapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotProperties struct { + CreationData *CreationData `json:"creationData,omitempty"` + EnableFIPS *bool `json:"enableFIPS,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + OsSku *OSSKU `json:"osSku,omitempty"` + OsType *OSType `json:"osType,omitempty"` + SnapshotType *SnapshotType `json:"snapshotType,omitempty"` + VMSize *string `json:"vmSize,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/model_tagsobject.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_tagsobject.go new file mode 100644 index 00000000000..30f646c1c9f --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/model_tagsobject.go @@ -0,0 +1,8 @@ +package snapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TagsObject struct { + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/predicates.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/predicates.go new file mode 100644 index 00000000000..832503e3b26 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/predicates.go @@ -0,0 +1,32 @@ +package snapshots + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SnapshotOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p SnapshotOperationPredicate) Matches(input Snapshot) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerservice/2023-09-02-preview/snapshots/version.go b/resource-manager/containerservice/2023-09-02-preview/snapshots/version.go new file mode 100644 index 00000000000..ea2366fd813 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/snapshots/version.go @@ -0,0 +1,12 @@ +package snapshots + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/snapshots/%s", defaultApiVersion) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/README.md b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/README.md new file mode 100644 index 00000000000..52a965ad352 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/README.md @@ -0,0 +1,100 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/trustedaccess` Documentation + +The `trustedaccess` SDK allows for interaction with the Azure Resource Manager Service `containerservice` (API Version `2023-09-02-preview`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/containerservice/2023-09-02-preview/trustedaccess" +``` + + +### Client Initialization + +```go +client := trustedaccess.NewTrustedAccessClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsCreateOrUpdate` + +```go +ctx := context.TODO() +id := trustedaccess.NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "trustedAccessRoleBindingValue") + +payload := trustedaccess.TrustedAccessRoleBinding{ + // ... +} + + +if err := client.RoleBindingsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsDelete` + +```go +ctx := context.TODO() +id := trustedaccess.NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "trustedAccessRoleBindingValue") + +if err := client.RoleBindingsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsGet` + +```go +ctx := context.TODO() +id := trustedaccess.NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "trustedAccessRoleBindingValue") + +read, err := client.RoleBindingsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `TrustedAccessClient.RoleBindingsList` + +```go +ctx := context.TODO() +id := commonids.NewKubernetesClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue") + +// alternatively `client.RoleBindingsList(ctx, id)` can be used to do batched pagination +items, err := client.RoleBindingsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `TrustedAccessClient.RolesList` + +```go +ctx := context.TODO() +id := trustedaccess.NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + +// alternatively `client.RolesList(ctx, id)` can be used to do batched pagination +items, err := client.RolesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/client.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/client.go new file mode 100644 index 00000000000..3478bfc5e37 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/client.go @@ -0,0 +1,26 @@ +package trustedaccess + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessClient struct { + Client *resourcemanager.Client +} + +func NewTrustedAccessClientWithBaseURI(sdkApi sdkEnv.Api) (*TrustedAccessClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "trustedaccess", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating TrustedAccessClient: %+v", err) + } + + return &TrustedAccessClient{ + Client: client, + }, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/constants.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/constants.go new file mode 100644 index 00000000000..8ab993f971c --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/constants.go @@ -0,0 +1,60 @@ +package trustedaccess + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleBindingProvisioningState string + +const ( + TrustedAccessRoleBindingProvisioningStateCanceled TrustedAccessRoleBindingProvisioningState = "Canceled" + TrustedAccessRoleBindingProvisioningStateDeleting TrustedAccessRoleBindingProvisioningState = "Deleting" + TrustedAccessRoleBindingProvisioningStateFailed TrustedAccessRoleBindingProvisioningState = "Failed" + TrustedAccessRoleBindingProvisioningStateSucceeded TrustedAccessRoleBindingProvisioningState = "Succeeded" + TrustedAccessRoleBindingProvisioningStateUpdating TrustedAccessRoleBindingProvisioningState = "Updating" +) + +func PossibleValuesForTrustedAccessRoleBindingProvisioningState() []string { + return []string{ + string(TrustedAccessRoleBindingProvisioningStateCanceled), + string(TrustedAccessRoleBindingProvisioningStateDeleting), + string(TrustedAccessRoleBindingProvisioningStateFailed), + string(TrustedAccessRoleBindingProvisioningStateSucceeded), + string(TrustedAccessRoleBindingProvisioningStateUpdating), + } +} + +func (s *TrustedAccessRoleBindingProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTrustedAccessRoleBindingProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTrustedAccessRoleBindingProvisioningState(input string) (*TrustedAccessRoleBindingProvisioningState, error) { + vals := map[string]TrustedAccessRoleBindingProvisioningState{ + "canceled": TrustedAccessRoleBindingProvisioningStateCanceled, + "deleting": TrustedAccessRoleBindingProvisioningStateDeleting, + "failed": TrustedAccessRoleBindingProvisioningStateFailed, + "succeeded": TrustedAccessRoleBindingProvisioningStateSucceeded, + "updating": TrustedAccessRoleBindingProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TrustedAccessRoleBindingProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_location.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_location.go new file mode 100644 index 00000000000..f2c540d6e65 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_location.go @@ -0,0 +1,121 @@ +package trustedaccess + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.ContainerService/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationValue"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_location_test.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_location_test.go new file mode 100644 index 00000000000..4c581421df5 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_location_test.go @@ -0,0 +1,237 @@ +package trustedaccess + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &LocationId{} + +func TestNewLocationID(t *testing.T) { + id := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.LocationName != "locationValue" { + t.Fatalf("Expected %q but got %q for Segment 'LocationName'", id.LocationName, "locationValue") + } +} + +func TestFormatLocationID(t *testing.T) { + actual := NewLocationID("12345678-1234-9876-4563-123456789012", "locationValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseLocationID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestParseLocationIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *LocationId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "locationValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.ContainerService/locations/locationValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe", + Expected: &LocationId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + LocationName: "lOcAtIoNvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/lOcAtIoNs/lOcAtIoNvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseLocationIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.LocationName != v.Expected.LocationName { + t.Fatalf("Expected %q but got %q for LocationName", v.Expected.LocationName, actual.LocationName) + } + + } +} + +func TestSegmentsForLocationId(t *testing.T) { + segments := LocationId{}.Segments() + if len(segments) == 0 { + t.Fatalf("LocationId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_trustedaccessrolebinding.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_trustedaccessrolebinding.go new file mode 100644 index 00000000000..18c1e6b10f3 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_trustedaccessrolebinding.go @@ -0,0 +1,139 @@ +package trustedaccess + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&TrustedAccessRoleBindingId{}) +} + +var _ resourceids.ResourceId = &TrustedAccessRoleBindingId{} + +// TrustedAccessRoleBindingId is a struct representing the Resource ID for a Trusted Access Role Binding +type TrustedAccessRoleBindingId struct { + SubscriptionId string + ResourceGroupName string + ManagedClusterName string + TrustedAccessRoleBindingName string +} + +// NewTrustedAccessRoleBindingID returns a new TrustedAccessRoleBindingId struct +func NewTrustedAccessRoleBindingID(subscriptionId string, resourceGroupName string, managedClusterName string, trustedAccessRoleBindingName string) TrustedAccessRoleBindingId { + return TrustedAccessRoleBindingId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ManagedClusterName: managedClusterName, + TrustedAccessRoleBindingName: trustedAccessRoleBindingName, + } +} + +// ParseTrustedAccessRoleBindingID parses 'input' into a TrustedAccessRoleBindingId +func ParseTrustedAccessRoleBindingID(input string) (*TrustedAccessRoleBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&TrustedAccessRoleBindingId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TrustedAccessRoleBindingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseTrustedAccessRoleBindingIDInsensitively parses 'input' case-insensitively into a TrustedAccessRoleBindingId +// note: this method should only be used for API response data and not user input +func ParseTrustedAccessRoleBindingIDInsensitively(input string) (*TrustedAccessRoleBindingId, error) { + parser := resourceids.NewParserFromResourceIdType(&TrustedAccessRoleBindingId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := TrustedAccessRoleBindingId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *TrustedAccessRoleBindingId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.ManagedClusterName, ok = input.Parsed["managedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "managedClusterName", input) + } + + if id.TrustedAccessRoleBindingName, ok = input.Parsed["trustedAccessRoleBindingName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "trustedAccessRoleBindingName", input) + } + + return nil +} + +// ValidateTrustedAccessRoleBindingID checks that 'input' can be parsed as a Trusted Access Role Binding ID +func ValidateTrustedAccessRoleBindingID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseTrustedAccessRoleBindingID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Trusted Access Role Binding ID +func (id TrustedAccessRoleBindingId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/managedClusters/%s/trustedAccessRoleBindings/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ManagedClusterName, id.TrustedAccessRoleBindingName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Trusted Access Role Binding ID +func (id TrustedAccessRoleBindingId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), + resourceids.StaticSegment("staticManagedClusters", "managedClusters", "managedClusters"), + resourceids.UserSpecifiedSegment("managedClusterName", "managedClusterValue"), + resourceids.StaticSegment("staticTrustedAccessRoleBindings", "trustedAccessRoleBindings", "trustedAccessRoleBindings"), + resourceids.UserSpecifiedSegment("trustedAccessRoleBindingName", "trustedAccessRoleBindingValue"), + } +} + +// String returns a human-readable description of this Trusted Access Role Binding ID +func (id TrustedAccessRoleBindingId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Managed Cluster Name: %q", id.ManagedClusterName), + fmt.Sprintf("Trusted Access Role Binding Name: %q", id.TrustedAccessRoleBindingName), + } + return fmt.Sprintf("Trusted Access Role Binding (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_trustedaccessrolebinding_test.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_trustedaccessrolebinding_test.go new file mode 100644 index 00000000000..e35fdf7c516 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/id_trustedaccessrolebinding_test.go @@ -0,0 +1,327 @@ +package trustedaccess + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &TrustedAccessRoleBindingId{} + +func TestNewTrustedAccessRoleBindingID(t *testing.T) { + id := NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "trustedAccessRoleBindingValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.ManagedClusterName != "managedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ManagedClusterName'", id.ManagedClusterName, "managedClusterValue") + } + + if id.TrustedAccessRoleBindingName != "trustedAccessRoleBindingValue" { + t.Fatalf("Expected %q but got %q for Segment 'TrustedAccessRoleBindingName'", id.TrustedAccessRoleBindingName, "trustedAccessRoleBindingValue") + } +} + +func TestFormatTrustedAccessRoleBindingID(t *testing.T) { + actual := NewTrustedAccessRoleBindingID("12345678-1234-9876-4563-123456789012", "example-resource-group", "managedClusterValue", "trustedAccessRoleBindingValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/trustedAccessRoleBindings/trustedAccessRoleBindingValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseTrustedAccessRoleBindingID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TrustedAccessRoleBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/trustedAccessRoleBindings", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/trustedAccessRoleBindings/trustedAccessRoleBindingValue", + Expected: &TrustedAccessRoleBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + TrustedAccessRoleBindingName: "trustedAccessRoleBindingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/trustedAccessRoleBindings/trustedAccessRoleBindingValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTrustedAccessRoleBindingID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.TrustedAccessRoleBindingName != v.Expected.TrustedAccessRoleBindingName { + t.Fatalf("Expected %q but got %q for TrustedAccessRoleBindingName", v.Expected.TrustedAccessRoleBindingName, actual.TrustedAccessRoleBindingName) + } + + } +} + +func TestParseTrustedAccessRoleBindingIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *TrustedAccessRoleBindingId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/trustedAccessRoleBindings", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/tRuStEdAcCeSsRoLeBiNdInGs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/trustedAccessRoleBindings/trustedAccessRoleBindingValue", + Expected: &TrustedAccessRoleBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ManagedClusterName: "managedClusterValue", + TrustedAccessRoleBindingName: "trustedAccessRoleBindingValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.ContainerService/managedClusters/managedClusterValue/trustedAccessRoleBindings/trustedAccessRoleBindingValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/tRuStEdAcCeSsRoLeBiNdInGs/tRuStEdAcCeSsRoLeBiNdInGvAlUe", + Expected: &TrustedAccessRoleBindingId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ManagedClusterName: "mAnAgEdClUsTeRvAlUe", + TrustedAccessRoleBindingName: "tRuStEdAcCeSsRoLeBiNdInGvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.cOnTaInErSeRvIcE/mAnAgEdClUsTeRs/mAnAgEdClUsTeRvAlUe/tRuStEdAcCeSsRoLeBiNdInGs/tRuStEdAcCeSsRoLeBiNdInGvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseTrustedAccessRoleBindingIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.ManagedClusterName != v.Expected.ManagedClusterName { + t.Fatalf("Expected %q but got %q for ManagedClusterName", v.Expected.ManagedClusterName, actual.ManagedClusterName) + } + + if actual.TrustedAccessRoleBindingName != v.Expected.TrustedAccessRoleBindingName { + t.Fatalf("Expected %q but got %q for TrustedAccessRoleBindingName", v.Expected.TrustedAccessRoleBindingName, actual.TrustedAccessRoleBindingName) + } + + } +} + +func TestSegmentsForTrustedAccessRoleBindingId(t *testing.T) { + segments := TrustedAccessRoleBindingId{}.Segments() + if len(segments) == 0 { + t.Fatalf("TrustedAccessRoleBindingId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingscreateorupdate.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingscreateorupdate.go new file mode 100644 index 00000000000..682a9388eae --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingscreateorupdate.go @@ -0,0 +1,75 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *TrustedAccessRoleBinding +} + +// RoleBindingsCreateOrUpdate ... +func (c TrustedAccessClient) RoleBindingsCreateOrUpdate(ctx context.Context, id TrustedAccessRoleBindingId, input TrustedAccessRoleBinding) (result RoleBindingsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RoleBindingsCreateOrUpdateThenPoll performs RoleBindingsCreateOrUpdate then polls until it's completed +func (c TrustedAccessClient) RoleBindingsCreateOrUpdateThenPoll(ctx context.Context, id TrustedAccessRoleBindingId, input TrustedAccessRoleBinding) error { + result, err := c.RoleBindingsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RoleBindingsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RoleBindingsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingsdelete.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingsdelete.go new file mode 100644 index 00000000000..7107d14f6f5 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingsdelete.go @@ -0,0 +1,70 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RoleBindingsDelete ... +func (c TrustedAccessClient) RoleBindingsDelete(ctx context.Context, id TrustedAccessRoleBindingId) (result RoleBindingsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RoleBindingsDeleteThenPoll performs RoleBindingsDelete then polls until it's completed +func (c TrustedAccessClient) RoleBindingsDeleteThenPoll(ctx context.Context, id TrustedAccessRoleBindingId) error { + result, err := c.RoleBindingsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RoleBindingsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RoleBindingsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingsget.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingsget.go new file mode 100644 index 00000000000..a0b81891af6 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingsget.go @@ -0,0 +1,54 @@ +package trustedaccess + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *TrustedAccessRoleBinding +} + +// RoleBindingsGet ... +func (c TrustedAccessClient) RoleBindingsGet(ctx context.Context, id TrustedAccessRoleBindingId) (result RoleBindingsGetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model TrustedAccessRoleBinding + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingslist.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingslist.go new file mode 100644 index 00000000000..4fc3b544dc0 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_rolebindingslist.go @@ -0,0 +1,92 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleBindingsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TrustedAccessRoleBinding +} + +type RoleBindingsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []TrustedAccessRoleBinding +} + +// RoleBindingsList ... +func (c TrustedAccessClient) RoleBindingsList(ctx context.Context, id commonids.KubernetesClusterId) (result RoleBindingsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/trustedAccessRoleBindings", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TrustedAccessRoleBinding `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RoleBindingsListComplete retrieves all the results into a single object +func (c TrustedAccessClient) RoleBindingsListComplete(ctx context.Context, id commonids.KubernetesClusterId) (RoleBindingsListCompleteResult, error) { + return c.RoleBindingsListCompleteMatchingPredicate(ctx, id, TrustedAccessRoleBindingOperationPredicate{}) +} + +// RoleBindingsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TrustedAccessClient) RoleBindingsListCompleteMatchingPredicate(ctx context.Context, id commonids.KubernetesClusterId, predicate TrustedAccessRoleBindingOperationPredicate) (result RoleBindingsListCompleteResult, err error) { + items := make([]TrustedAccessRoleBinding, 0) + + resp, err := c.RoleBindingsList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = RoleBindingsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_roleslist.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_roleslist.go new file mode 100644 index 00000000000..124133a7f5e --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/method_roleslist.go @@ -0,0 +1,91 @@ +package trustedaccess + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RolesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]TrustedAccessRole +} + +type RolesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []TrustedAccessRole +} + +// RolesList ... +func (c TrustedAccessClient) RolesList(ctx context.Context, id LocationId) (result RolesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/trustedAccessRoles", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]TrustedAccessRole `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RolesListComplete retrieves all the results into a single object +func (c TrustedAccessClient) RolesListComplete(ctx context.Context, id LocationId) (RolesListCompleteResult, error) { + return c.RolesListCompleteMatchingPredicate(ctx, id, TrustedAccessRoleOperationPredicate{}) +} + +// RolesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c TrustedAccessClient) RolesListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate TrustedAccessRoleOperationPredicate) (result RolesListCompleteResult, err error) { + items := make([]TrustedAccessRole, 0) + + resp, err := c.RolesList(ctx, id) + if err != nil { + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = RolesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrole.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrole.go new file mode 100644 index 00000000000..a24a7344c12 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrole.go @@ -0,0 +1,10 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRole struct { + Name *string `json:"name,omitempty"` + Rules *[]TrustedAccessRoleRule `json:"rules,omitempty"` + SourceResourceType *string `json:"sourceResourceType,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolebinding.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolebinding.go new file mode 100644 index 00000000000..36c110999f6 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolebinding.go @@ -0,0 +1,16 @@ +package trustedaccess + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleBinding struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties TrustedAccessRoleBindingProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolebindingproperties.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolebindingproperties.go new file mode 100644 index 00000000000..b432519d7cc --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolebindingproperties.go @@ -0,0 +1,10 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleBindingProperties struct { + ProvisioningState *TrustedAccessRoleBindingProvisioningState `json:"provisioningState,omitempty"` + Roles []string `json:"roles"` + SourceResourceId string `json:"sourceResourceId"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolerule.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolerule.go new file mode 100644 index 00000000000..808af096d0a --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/model_trustedaccessrolerule.go @@ -0,0 +1,12 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleRule struct { + ApiGroups *[]string `json:"apiGroups,omitempty"` + NonResourceURLs *[]string `json:"nonResourceURLs,omitempty"` + ResourceNames *[]string `json:"resourceNames,omitempty"` + Resources *[]string `json:"resources,omitempty"` + Verbs *[]string `json:"verbs,omitempty"` +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/predicates.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/predicates.go new file mode 100644 index 00000000000..6bab96a78b7 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/predicates.go @@ -0,0 +1,45 @@ +package trustedaccess + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TrustedAccessRoleOperationPredicate struct { + Name *string + SourceResourceType *string +} + +func (p TrustedAccessRoleOperationPredicate) Matches(input TrustedAccessRole) bool { + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.SourceResourceType != nil && (input.SourceResourceType == nil || *p.SourceResourceType != *input.SourceResourceType) { + return false + } + + return true +} + +type TrustedAccessRoleBindingOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p TrustedAccessRoleBindingOperationPredicate) Matches(input TrustedAccessRoleBinding) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/containerservice/2023-09-02-preview/trustedaccess/version.go b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/version.go new file mode 100644 index 00000000000..74db9c99258 --- /dev/null +++ b/resource-manager/containerservice/2023-09-02-preview/trustedaccess/version.go @@ -0,0 +1,12 @@ +package trustedaccess + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-09-02-preview" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/trustedaccess/%s", defaultApiVersion) +}