From a168fd6ddc5ddee7c50aa37c67022d6f877d49a3 Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Tue, 12 Dec 2023 21:46:34 +0000 Subject: [PATCH] Updating based on 00ee6aaa3 --- .../hybridkubernetes/2024-01-01/client.go | 28 ++ .../2024-01-01/connectedclusters/README.md | 141 ++++++++ .../2024-01-01/connectedclusters/client.go | 26 ++ .../2024-01-01/connectedclusters/constants.go | 318 ++++++++++++++++++ .../connectedclusters/id_connectedcluster.go | 125 +++++++ .../id_connectedcluster_test.go | 282 ++++++++++++++++ .../method_connectedclustercreate.go | 74 ++++ .../method_connectedclusterdelete.go | 71 ++++ .../method_connectedclusterget.go | 51 +++ ...hod_connectedclusterlistbyresourcegroup.go | 90 +++++ ...thod_connectedclusterlistbysubscription.go | 90 +++++ ...nnectedclusterlistclusterusercredential.go | 56 +++ .../method_connectedclusterupdate.go | 55 +++ .../connectedclusters/model_aadprofile.go | 10 + .../model_arcagentprofile.go | 9 + .../model_connectedcluster.go | 21 ++ .../model_connectedclusterpatch.go | 9 + .../model_connectedclusterpatchproperties.go | 10 + .../model_connectedclusterproperties.go | 56 +++ .../model_credentialresult.go | 9 + .../model_credentialresults.go | 9 + .../model_hybridconnectionconfig.go | 11 + ...del_listclusterusercredentialproperties.go | 9 + .../connectedclusters/predicates.go | 32 ++ .../2024-01-01/connectedclusters/version.go | 12 + 25 files changed, 1604 insertions(+) create mode 100644 resource-manager/hybridkubernetes/2024-01-01/client.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/README.md create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/client.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/constants.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster_test.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclustercreate.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterdelete.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterget.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbyresourcegroup.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbysubscription.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistclusterusercredential.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterupdate.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_aadprofile.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_arcagentprofile.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedcluster.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatch.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatchproperties.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterproperties.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresult.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresults.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_hybridconnectionconfig.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_listclusterusercredentialproperties.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/predicates.go create mode 100644 resource-manager/hybridkubernetes/2024-01-01/connectedclusters/version.go diff --git a/resource-manager/hybridkubernetes/2024-01-01/client.go b/resource-manager/hybridkubernetes/2024-01-01/client.go new file mode 100644 index 00000000000..39b4b63e9ce --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/client.go @@ -0,0 +1,28 @@ +package v2024_01_01 + +// 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/hybridkubernetes/2024-01-01/connectedclusters" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + ConnectedClusters *connectedclusters.ConnectedClustersClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + connectedClustersClient, err := connectedclusters.NewConnectedClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ConnectedClusters client: %+v", err) + } + configureFunc(connectedClustersClient.Client) + + return &Client{ + ConnectedClusters: connectedClustersClient, + }, nil +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/README.md b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/README.md new file mode 100644 index 00000000000..03f38f8d58a --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/README.md @@ -0,0 +1,141 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/hybridkubernetes/2024-01-01/connectedclusters` Documentation + +The `connectedclusters` SDK allows for interaction with the Azure Resource Manager Service `hybridkubernetes` (API Version `2024-01-01`). + +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/hybridkubernetes/2024-01-01/connectedclusters" +``` + + +### Client Initialization + +```go +client := connectedclusters.NewConnectedClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ConnectedClustersClient.ConnectedClusterCreate` + +```go +ctx := context.TODO() +id := connectedclusters.NewConnectedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedClusterValue") + +payload := connectedclusters.ConnectedCluster{ + // ... +} + + +if err := client.ConnectedClusterCreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectedClustersClient.ConnectedClusterDelete` + +```go +ctx := context.TODO() +id := connectedclusters.NewConnectedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedClusterValue") + +if err := client.ConnectedClusterDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ConnectedClustersClient.ConnectedClusterGet` + +```go +ctx := context.TODO() +id := connectedclusters.NewConnectedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedClusterValue") + +read, err := client.ConnectedClusterGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedClustersClient.ConnectedClusterListByResourceGroup` + +```go +ctx := context.TODO() +id := connectedclusters.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ConnectedClusterListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ConnectedClusterListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ConnectedClustersClient.ConnectedClusterListBySubscription` + +```go +ctx := context.TODO() +id := connectedclusters.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ConnectedClusterListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ConnectedClusterListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ConnectedClustersClient.ConnectedClusterListClusterUserCredential` + +```go +ctx := context.TODO() +id := connectedclusters.NewConnectedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedClusterValue") + +payload := connectedclusters.ListClusterUserCredentialProperties{ + // ... +} + + +read, err := client.ConnectedClusterListClusterUserCredential(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ConnectedClustersClient.ConnectedClusterUpdate` + +```go +ctx := context.TODO() +id := connectedclusters.NewConnectedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedClusterValue") + +payload := connectedclusters.ConnectedClusterPatch{ + // ... +} + + +read, err := client.ConnectedClusterUpdate(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/hybridkubernetes/2024-01-01/connectedclusters/client.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/client.go new file mode 100644 index 00000000000..c25ebd209c7 --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/client.go @@ -0,0 +1,26 @@ +package connectedclusters + +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 ConnectedClustersClient struct { + Client *resourcemanager.Client +} + +func NewConnectedClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*ConnectedClustersClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "connectedclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ConnectedClustersClient: %+v", err) + } + + return &ConnectedClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/constants.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/constants.go new file mode 100644 index 00000000000..9b706c7815a --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/constants.go @@ -0,0 +1,318 @@ +package connectedclusters + +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 AuthenticationMethod string + +const ( + AuthenticationMethodAAD AuthenticationMethod = "AAD" + AuthenticationMethodToken AuthenticationMethod = "Token" +) + +func PossibleValuesForAuthenticationMethod() []string { + return []string{ + string(AuthenticationMethodAAD), + string(AuthenticationMethodToken), + } +} + +func (s *AuthenticationMethod) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAuthenticationMethod(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) { + vals := map[string]AuthenticationMethod{ + "aad": AuthenticationMethodAAD, + "token": AuthenticationMethodToken, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AuthenticationMethod(input) + return &out, nil +} + +type AutoUpgradeOptions string + +const ( + AutoUpgradeOptionsDisabled AutoUpgradeOptions = "Disabled" + AutoUpgradeOptionsEnabled AutoUpgradeOptions = "Enabled" +) + +func PossibleValuesForAutoUpgradeOptions() []string { + return []string{ + string(AutoUpgradeOptionsDisabled), + string(AutoUpgradeOptionsEnabled), + } +} + +func (s *AutoUpgradeOptions) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoUpgradeOptions(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoUpgradeOptions(input string) (*AutoUpgradeOptions, error) { + vals := map[string]AutoUpgradeOptions{ + "disabled": AutoUpgradeOptionsDisabled, + "enabled": AutoUpgradeOptionsEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoUpgradeOptions(input) + return &out, nil +} + +type AzureHybridBenefit string + +const ( + AzureHybridBenefitFalse AzureHybridBenefit = "False" + AzureHybridBenefitNotApplicable AzureHybridBenefit = "NotApplicable" + AzureHybridBenefitTrue AzureHybridBenefit = "True" +) + +func PossibleValuesForAzureHybridBenefit() []string { + return []string{ + string(AzureHybridBenefitFalse), + string(AzureHybridBenefitNotApplicable), + string(AzureHybridBenefitTrue), + } +} + +func (s *AzureHybridBenefit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAzureHybridBenefit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAzureHybridBenefit(input string) (*AzureHybridBenefit, error) { + vals := map[string]AzureHybridBenefit{ + "false": AzureHybridBenefitFalse, + "notapplicable": AzureHybridBenefitNotApplicable, + "true": AzureHybridBenefitTrue, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AzureHybridBenefit(input) + return &out, nil +} + +type ConnectedClusterKind string + +const ( + ConnectedClusterKindProvisionedCluster ConnectedClusterKind = "ProvisionedCluster" +) + +func PossibleValuesForConnectedClusterKind() []string { + return []string{ + string(ConnectedClusterKindProvisionedCluster), + } +} + +func (s *ConnectedClusterKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectedClusterKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectedClusterKind(input string) (*ConnectedClusterKind, error) { + vals := map[string]ConnectedClusterKind{ + "provisionedcluster": ConnectedClusterKindProvisionedCluster, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectedClusterKind(input) + return &out, nil +} + +type ConnectivityStatus string + +const ( + ConnectivityStatusConnected ConnectivityStatus = "Connected" + ConnectivityStatusConnecting ConnectivityStatus = "Connecting" + ConnectivityStatusExpired ConnectivityStatus = "Expired" + ConnectivityStatusOffline ConnectivityStatus = "Offline" +) + +func PossibleValuesForConnectivityStatus() []string { + return []string{ + string(ConnectivityStatusConnected), + string(ConnectivityStatusConnecting), + string(ConnectivityStatusExpired), + string(ConnectivityStatusOffline), + } +} + +func (s *ConnectivityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectivityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectivityStatus(input string) (*ConnectivityStatus, error) { + vals := map[string]ConnectivityStatus{ + "connected": ConnectivityStatusConnected, + "connecting": ConnectivityStatusConnecting, + "expired": ConnectivityStatusExpired, + "offline": ConnectivityStatusOffline, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectivityStatus(input) + return &out, nil +} + +type PrivateLinkState string + +const ( + PrivateLinkStateDisabled PrivateLinkState = "Disabled" + PrivateLinkStateEnabled PrivateLinkState = "Enabled" +) + +func PossibleValuesForPrivateLinkState() []string { + return []string{ + string(PrivateLinkStateDisabled), + string(PrivateLinkStateEnabled), + } +} + +func (s *PrivateLinkState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateLinkState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateLinkState(input string) (*PrivateLinkState, error) { + vals := map[string]PrivateLinkState{ + "disabled": PrivateLinkStateDisabled, + "enabled": PrivateLinkStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateLinkState(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster.go new file mode 100644 index 00000000000..5d31ea4b9ef --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster.go @@ -0,0 +1,125 @@ +package connectedclusters + +import ( + "fmt" + "strings" + + "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 = ConnectedClusterId{} + +// ConnectedClusterId is a struct representing the Resource ID for a Connected Cluster +type ConnectedClusterId struct { + SubscriptionId string + ResourceGroupName string + ConnectedClusterName string +} + +// NewConnectedClusterID returns a new ConnectedClusterId struct +func NewConnectedClusterID(subscriptionId string, resourceGroupName string, connectedClusterName string) ConnectedClusterId { + return ConnectedClusterId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ConnectedClusterName: connectedClusterName, + } +} + +// ParseConnectedClusterID parses 'input' into a ConnectedClusterId +func ParseConnectedClusterID(input string) (*ConnectedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(ConnectedClusterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectedClusterIDInsensitively parses 'input' case-insensitively into a ConnectedClusterId +// note: this method should only be used for API response data and not user input +func ParseConnectedClusterIDInsensitively(input string) (*ConnectedClusterId, error) { + parser := resourceids.NewParserFromResourceIdType(ConnectedClusterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectedClusterId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectedClusterId) 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.ConnectedClusterName, ok = input.Parsed["connectedClusterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectedClusterName", input) + } + + return nil +} + +// ValidateConnectedClusterID checks that 'input' can be parsed as a Connected Cluster ID +func ValidateConnectedClusterID(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 := ParseConnectedClusterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connected Cluster ID +func (id ConnectedClusterId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Kubernetes/connectedClusters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ConnectedClusterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connected Cluster ID +func (id ConnectedClusterId) 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("staticMicrosoftKubernetes", "Microsoft.Kubernetes", "Microsoft.Kubernetes"), + resourceids.StaticSegment("staticConnectedClusters", "connectedClusters", "connectedClusters"), + resourceids.UserSpecifiedSegment("connectedClusterName", "connectedClusterValue"), + } +} + +// String returns a human-readable description of this Connected Cluster ID +func (id ConnectedClusterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Connected Cluster Name: %q", id.ConnectedClusterName), + } + return fmt.Sprintf("Connected Cluster (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster_test.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster_test.go new file mode 100644 index 00000000000..a9ba36c435a --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/id_connectedcluster_test.go @@ -0,0 +1,282 @@ +package connectedclusters + +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 = ConnectedClusterId{} + +func TestNewConnectedClusterID(t *testing.T) { + id := NewConnectedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedClusterValue") + + 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.ConnectedClusterName != "connectedClusterValue" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectedClusterName'", id.ConnectedClusterName, "connectedClusterValue") + } +} + +func TestFormatConnectedClusterID(t *testing.T) { + actual := NewConnectedClusterID("12345678-1234-9876-4563-123456789012", "example-resource-group", "connectedClusterValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kubernetes/connectedClusters/connectedClusterValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectedClusterID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedClusterId + }{ + { + // 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.Kubernetes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kubernetes/connectedClusters", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kubernetes/connectedClusters/connectedClusterValue", + Expected: &ConnectedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedClusterName: "connectedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kubernetes/connectedClusters/connectedClusterValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedClusterID(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.ConnectedClusterName != v.Expected.ConnectedClusterName { + t.Fatalf("Expected %q but got %q for ConnectedClusterName", v.Expected.ConnectedClusterName, actual.ConnectedClusterName) + } + + } +} + +func TestParseConnectedClusterIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectedClusterId + }{ + { + // 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.Kubernetes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUbErNeTeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kubernetes/connectedClusters", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUbErNeTeS/cOnNeCtEdClUsTeRs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kubernetes/connectedClusters/connectedClusterValue", + Expected: &ConnectedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + ConnectedClusterName: "connectedClusterValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.Kubernetes/connectedClusters/connectedClusterValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.kUbErNeTeS/cOnNeCtEdClUsTeRs/cOnNeCtEdClUsTeRvAlUe", + Expected: &ConnectedClusterId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + ConnectedClusterName: "cOnNeCtEdClUsTeRvAlUe", + }, + }, + { + // 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.kUbErNeTeS/cOnNeCtEdClUsTeRs/cOnNeCtEdClUsTeRvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectedClusterIDInsensitively(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.ConnectedClusterName != v.Expected.ConnectedClusterName { + t.Fatalf("Expected %q but got %q for ConnectedClusterName", v.Expected.ConnectedClusterName, actual.ConnectedClusterName) + } + + } +} + +func TestSegmentsForConnectedClusterId(t *testing.T) { + segments := ConnectedClusterId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectedClusterId 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/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclustercreate.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclustercreate.go new file mode 100644 index 00000000000..09ae5e4d585 --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclustercreate.go @@ -0,0 +1,74 @@ +package connectedclusters + +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 ConnectedClusterCreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ConnectedClusterCreate ... +func (c ConnectedClustersClient) ConnectedClusterCreate(ctx context.Context, id ConnectedClusterId, input ConnectedCluster) (result ConnectedClusterCreateOperationResponse, 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 +} + +// ConnectedClusterCreateThenPoll performs ConnectedClusterCreate then polls until it's completed +func (c ConnectedClustersClient) ConnectedClusterCreateThenPoll(ctx context.Context, id ConnectedClusterId, input ConnectedCluster) error { + result, err := c.ConnectedClusterCreate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ConnectedClusterCreate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConnectedClusterCreate: %+v", err) + } + + return nil +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterdelete.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterdelete.go new file mode 100644 index 00000000000..26ad549db1b --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterdelete.go @@ -0,0 +1,71 @@ +package connectedclusters + +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 ConnectedClusterDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ConnectedClusterDelete ... +func (c ConnectedClustersClient) ConnectedClusterDelete(ctx context.Context, id ConnectedClusterId) (result ConnectedClusterDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + 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 +} + +// ConnectedClusterDeleteThenPoll performs ConnectedClusterDelete then polls until it's completed +func (c ConnectedClustersClient) ConnectedClusterDeleteThenPoll(ctx context.Context, id ConnectedClusterId) error { + result, err := c.ConnectedClusterDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing ConnectedClusterDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ConnectedClusterDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterget.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterget.go new file mode 100644 index 00000000000..0ea52a6eddd --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterget.go @@ -0,0 +1,51 @@ +package connectedclusters + +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 ConnectedClusterGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectedCluster +} + +// ConnectedClusterGet ... +func (c ConnectedClustersClient) ConnectedClusterGet(ctx context.Context, id ConnectedClusterId) (result ConnectedClusterGetOperationResponse, 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbyresourcegroup.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbyresourcegroup.go new file mode 100644 index 00000000000..2304bcbbeac --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbyresourcegroup.go @@ -0,0 +1,90 @@ +package connectedclusters + +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 ConnectedClusterListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ConnectedCluster +} + +type ConnectedClusterListByResourceGroupCompleteResult struct { + Items []ConnectedCluster +} + +// ConnectedClusterListByResourceGroup ... +func (c ConnectedClustersClient) ConnectedClusterListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ConnectedClusterListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Kubernetes/connectedClusters", 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 *[]ConnectedCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ConnectedClusterListByResourceGroupComplete retrieves all the results into a single object +func (c ConnectedClustersClient) ConnectedClusterListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ConnectedClusterListByResourceGroupCompleteResult, error) { + return c.ConnectedClusterListByResourceGroupCompleteMatchingPredicate(ctx, id, ConnectedClusterOperationPredicate{}) +} + +// ConnectedClusterListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConnectedClustersClient) ConnectedClusterListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ConnectedClusterOperationPredicate) (result ConnectedClusterListByResourceGroupCompleteResult, err error) { + items := make([]ConnectedCluster, 0) + + resp, err := c.ConnectedClusterListByResourceGroup(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 = ConnectedClusterListByResourceGroupCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbysubscription.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbysubscription.go new file mode 100644 index 00000000000..8f3abc45664 --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistbysubscription.go @@ -0,0 +1,90 @@ +package connectedclusters + +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 ConnectedClusterListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ConnectedCluster +} + +type ConnectedClusterListBySubscriptionCompleteResult struct { + Items []ConnectedCluster +} + +// ConnectedClusterListBySubscription ... +func (c ConnectedClustersClient) ConnectedClusterListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ConnectedClusterListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Kubernetes/connectedClusters", 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 *[]ConnectedCluster `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ConnectedClusterListBySubscriptionComplete retrieves all the results into a single object +func (c ConnectedClustersClient) ConnectedClusterListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ConnectedClusterListBySubscriptionCompleteResult, error) { + return c.ConnectedClusterListBySubscriptionCompleteMatchingPredicate(ctx, id, ConnectedClusterOperationPredicate{}) +} + +// ConnectedClusterListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ConnectedClustersClient) ConnectedClusterListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate ConnectedClusterOperationPredicate) (result ConnectedClusterListBySubscriptionCompleteResult, err error) { + items := make([]ConnectedCluster, 0) + + resp, err := c.ConnectedClusterListBySubscription(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 = ConnectedClusterListBySubscriptionCompleteResult{ + Items: items, + } + return +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistclusterusercredential.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistclusterusercredential.go new file mode 100644 index 00000000000..49153e1816a --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterlistclusterusercredential.go @@ -0,0 +1,56 @@ +package connectedclusters + +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 ConnectedClusterListClusterUserCredentialOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CredentialResults +} + +// ConnectedClusterListClusterUserCredential ... +func (c ConnectedClustersClient) ConnectedClusterListClusterUserCredential(ctx context.Context, id ConnectedClusterId, input ListClusterUserCredentialProperties) (result ConnectedClusterListClusterUserCredentialOperationResponse, 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()), + } + + 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterupdate.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterupdate.go new file mode 100644 index 00000000000..56b6b85664c --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/method_connectedclusterupdate.go @@ -0,0 +1,55 @@ +package connectedclusters + +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 ConnectedClusterUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ConnectedCluster +} + +// ConnectedClusterUpdate ... +func (c ConnectedClustersClient) ConnectedClusterUpdate(ctx context.Context, id ConnectedClusterId, input ConnectedClusterPatch) (result ConnectedClusterUpdateOperationResponse, 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 + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_aadprofile.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_aadprofile.go new file mode 100644 index 00000000000..28c27010df9 --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_aadprofile.go @@ -0,0 +1,10 @@ +package connectedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AadProfile struct { + AdminGroupObjectIDs *[]string `json:"adminGroupObjectIDs,omitempty"` + EnableAzureRBAC *bool `json:"enableAzureRBAC,omitempty"` + TenantID *string `json:"tenantID,omitempty"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_arcagentprofile.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_arcagentprofile.go new file mode 100644 index 00000000000..e2eca88a309 --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_arcagentprofile.go @@ -0,0 +1,9 @@ +package connectedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArcAgentProfile struct { + AgentAutoUpgrade *AutoUpgradeOptions `json:"agentAutoUpgrade,omitempty"` + DesiredAgentVersion *string `json:"desiredAgentVersion,omitempty"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedcluster.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedcluster.go new file mode 100644 index 00000000000..68a2de2367c --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedcluster.go @@ -0,0 +1,21 @@ +package connectedclusters + +import ( + "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 ConnectedCluster struct { + Id *string `json:"id,omitempty"` + Identity identity.SystemAssigned `json:"identity"` + Kind *ConnectedClusterKind `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ConnectedClusterProperties `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatch.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatch.go new file mode 100644 index 00000000000..71202d914fd --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatch.go @@ -0,0 +1,9 @@ +package connectedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedClusterPatch struct { + Properties *ConnectedClusterPatchProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatchproperties.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatchproperties.go new file mode 100644 index 00000000000..6bb957d6660 --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterpatchproperties.go @@ -0,0 +1,10 @@ +package connectedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedClusterPatchProperties struct { + AzureHybridBenefit *AzureHybridBenefit `json:"azureHybridBenefit,omitempty"` + Distribution *string `json:"distribution,omitempty"` + DistributionVersion *string `json:"distributionVersion,omitempty"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterproperties.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterproperties.go new file mode 100644 index 00000000000..28beb01e24f --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_connectedclusterproperties.go @@ -0,0 +1,56 @@ +package connectedclusters + +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 ConnectedClusterProperties struct { + AadProfile *AadProfile `json:"aadProfile,omitempty"` + AgentPublicKeyCertificate string `json:"agentPublicKeyCertificate"` + AgentVersion *string `json:"agentVersion,omitempty"` + ArcAgentProfile *ArcAgentProfile `json:"arcAgentProfile,omitempty"` + AzureHybridBenefit *AzureHybridBenefit `json:"azureHybridBenefit,omitempty"` + ConnectivityStatus *ConnectivityStatus `json:"connectivityStatus,omitempty"` + Distribution *string `json:"distribution,omitempty"` + DistributionVersion *string `json:"distributionVersion,omitempty"` + Infrastructure *string `json:"infrastructure,omitempty"` + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + LastConnectivityTime *string `json:"lastConnectivityTime,omitempty"` + ManagedIdentityCertificateExpirationTime *string `json:"managedIdentityCertificateExpirationTime,omitempty"` + MiscellaneousProperties *map[string]string `json:"miscellaneousProperties,omitempty"` + Offering *string `json:"offering,omitempty"` + PrivateLinkScopeResourceId *string `json:"privateLinkScopeResourceId,omitempty"` + PrivateLinkState *PrivateLinkState `json:"privateLinkState,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + TotalCoreCount *int64 `json:"totalCoreCount,omitempty"` + TotalNodeCount *int64 `json:"totalNodeCount,omitempty"` +} + +func (o *ConnectedClusterProperties) GetLastConnectivityTimeAsTime() (*time.Time, error) { + if o.LastConnectivityTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.LastConnectivityTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ConnectedClusterProperties) SetLastConnectivityTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.LastConnectivityTime = &formatted +} + +func (o *ConnectedClusterProperties) GetManagedIdentityCertificateExpirationTimeAsTime() (*time.Time, error) { + if o.ManagedIdentityCertificateExpirationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ManagedIdentityCertificateExpirationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ConnectedClusterProperties) SetManagedIdentityCertificateExpirationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ManagedIdentityCertificateExpirationTime = &formatted +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresult.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresult.go new file mode 100644 index 00000000000..dc74c9fd42e --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresult.go @@ -0,0 +1,9 @@ +package connectedclusters + +// 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/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresults.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresults.go new file mode 100644 index 00000000000..a64afb76a34 --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_credentialresults.go @@ -0,0 +1,9 @@ +package connectedclusters + +// 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 { + HybridConnectionConfig *HybridConnectionConfig `json:"hybridConnectionConfig,omitempty"` + Kubeconfigs *[]CredentialResult `json:"kubeconfigs,omitempty"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_hybridconnectionconfig.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_hybridconnectionconfig.go new file mode 100644 index 00000000000..2f2c102d61a --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_hybridconnectionconfig.go @@ -0,0 +1,11 @@ +package connectedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HybridConnectionConfig struct { + ExpirationTime *int64 `json:"expirationTime,omitempty"` + HybridConnectionName *string `json:"hybridConnectionName,omitempty"` + Relay *string `json:"relay,omitempty"` + Token *string `json:"token,omitempty"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_listclusterusercredentialproperties.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_listclusterusercredentialproperties.go new file mode 100644 index 00000000000..e8e0c57aaab --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/model_listclusterusercredentialproperties.go @@ -0,0 +1,9 @@ +package connectedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListClusterUserCredentialProperties struct { + AuthenticationMethod AuthenticationMethod `json:"authenticationMethod"` + ClientProxy bool `json:"clientProxy"` +} diff --git a/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/predicates.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/predicates.go new file mode 100644 index 00000000000..a1dcf6aaa3a --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/predicates.go @@ -0,0 +1,32 @@ +package connectedclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConnectedClusterOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ConnectedClusterOperationPredicate) Matches(input ConnectedCluster) 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/hybridkubernetes/2024-01-01/connectedclusters/version.go b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/version.go new file mode 100644 index 00000000000..2e5041f7dcc --- /dev/null +++ b/resource-manager/hybridkubernetes/2024-01-01/connectedclusters/version.go @@ -0,0 +1,12 @@ +package connectedclusters + +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 = "2024-01-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/connectedclusters/%s", defaultApiVersion) +}