diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/CHANGELOG.md b/sdk/resourcemanager/hybridaks/armhybridaks/CHANGELOG.md new file mode 100644 index 000000000000..94dae18e98ad --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/CHANGELOG.md @@ -0,0 +1,9 @@ +# Release History + +## 0.1.0 (2022-09-08) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.1.0, which contains breaking changes. + +To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/azsdk/go/mgmt/migration). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/LICENSE.txt b/sdk/resourcemanager/hybridaks/armhybridaks/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/README.md b/sdk/resourcemanager/hybridaks/armhybridaks/README.md new file mode 100644 index 000000000000..df4a6f8a016b --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/README.md @@ -0,0 +1,77 @@ +# Azure Hybrid Container Service Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks) + +The `armhybridaks` module provides operations for working with Azure Hybrid Container Service. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/hybridaks/armhybridaks) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.19 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Hybrid Container Service module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Hybrid Container Service. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure Hybrid Container Service modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armhybridaks.NewProvisionedClustersClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armhybridaks.NewProvisionedClustersClient(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Hybrid Container Service` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/agentpool_client.go b/sdk/resourcemanager/hybridaks/armhybridaks/agentpool_client.go new file mode 100644 index 000000000000..ccdcb9b77e06 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/agentpool_client.go @@ -0,0 +1,357 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AgentPoolClient contains the methods for the AgentPool group. +// Don't use this type directly, use NewAgentPoolClient() instead. +type AgentPoolClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewAgentPoolClient creates a new instance of AgentPoolClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewAgentPoolClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AgentPoolClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &AgentPoolClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates the agent pool in the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// agentPoolName - Parameter for the name of the agent pool in the provisioned cluster +// options - AgentPoolClientBeginCreateOrUpdateOptions contains the optional parameters for the AgentPoolClient.BeginCreateOrUpdate +// method. +func (client *AgentPoolClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, agentPool AgentPool, options *AgentPoolClientBeginCreateOrUpdateOptions) (*runtime.Poller[AgentPoolClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, provisionedClustersName, agentPoolName, agentPool, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AgentPoolClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[AgentPoolClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates the agent pool in the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +func (client *AgentPoolClient) createOrUpdate(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, agentPool AgentPool, options *AgentPoolClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, provisionedClustersName, agentPoolName, agentPool, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AgentPoolClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, agentPool AgentPool, options *AgentPoolClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, agentPool) +} + +// Delete - Deletes the agent pool in the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// agentPoolName - Parameter for the name of the agent pool in the provisioned cluster +// options - AgentPoolClientDeleteOptions contains the optional parameters for the AgentPoolClient.Delete method. +func (client *AgentPoolClient) Delete(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, options *AgentPoolClientDeleteOptions) (AgentPoolClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, provisionedClustersName, agentPoolName, options) + if err != nil { + return AgentPoolClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentPoolClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return AgentPoolClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return AgentPoolClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AgentPoolClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, options *AgentPoolClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the agent pool in the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// agentPoolName - Parameter for the name of the agent pool in the provisioned cluster +// options - AgentPoolClientGetOptions contains the optional parameters for the AgentPoolClient.Get method. +func (client *AgentPoolClient) Get(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, options *AgentPoolClientGetOptions) (AgentPoolClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, provisionedClustersName, agentPoolName, options) + if err != nil { + return AgentPoolClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentPoolClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AgentPoolClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AgentPoolClient) getCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, options *AgentPoolClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AgentPoolClient) getHandleResponse(resp *http.Response) (AgentPoolClientGetResponse, error) { + result := AgentPoolClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AgentPool); err != nil { + return AgentPoolClientGetResponse{}, err + } + return result, nil +} + +// ListByProvisionedCluster - Gets the agent pools in the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// options - AgentPoolClientListByProvisionedClusterOptions contains the optional parameters for the AgentPoolClient.ListByProvisionedCluster +// method. +func (client *AgentPoolClient) ListByProvisionedCluster(ctx context.Context, resourceGroupName string, provisionedClustersName string, options *AgentPoolClientListByProvisionedClusterOptions) (AgentPoolClientListByProvisionedClusterResponse, error) { + req, err := client.listByProvisionedClusterCreateRequest(ctx, resourceGroupName, provisionedClustersName, options) + if err != nil { + return AgentPoolClientListByProvisionedClusterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentPoolClientListByProvisionedClusterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AgentPoolClientListByProvisionedClusterResponse{}, runtime.NewResponseError(resp) + } + return client.listByProvisionedClusterHandleResponse(resp) +} + +// listByProvisionedClusterCreateRequest creates the ListByProvisionedCluster request. +func (client *AgentPoolClient) listByProvisionedClusterCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, options *AgentPoolClientListByProvisionedClusterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/agentPools" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProvisionedClusterHandleResponse handles the ListByProvisionedCluster response. +func (client *AgentPoolClient) listByProvisionedClusterHandleResponse(resp *http.Response) (AgentPoolClientListByProvisionedClusterResponse, error) { + result := AgentPoolClientListByProvisionedClusterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AgentPoolListResult); err != nil { + return AgentPoolClientListByProvisionedClusterResponse{}, err + } + return result, nil +} + +// Update - Updates the agent pool in the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// agentPoolName - Parameter for the name of the agent pool in the provisioned cluster +// options - AgentPoolClientUpdateOptions contains the optional parameters for the AgentPoolClient.Update method. +func (client *AgentPoolClient) Update(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, agentPool AgentPool, options *AgentPoolClientUpdateOptions) (AgentPoolClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, provisionedClustersName, agentPoolName, agentPool, options) + if err != nil { + return AgentPoolClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentPoolClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return AgentPoolClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AgentPoolClient) updateCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, agentPoolName string, agentPool AgentPool, options *AgentPoolClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/agentPools/{agentPoolName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + if agentPoolName == "" { + return nil, errors.New("parameter agentPoolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentPoolName}", url.PathEscape(agentPoolName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, agentPool) +} + +// updateHandleResponse handles the Update response. +func (client *AgentPoolClient) updateHandleResponse(resp *http.Response) (AgentPoolClientUpdateResponse, error) { + result := AgentPoolClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AgentPool); err != nil { + return AgentPoolClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/agentpool_client_example_test.go b/sdk/resourcemanager/hybridaks/armhybridaks/agentpool_client_example_test.go new file mode 100644 index 000000000000..9e4994548514 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/agentpool_client_example_test.go @@ -0,0 +1,127 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridaks_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/GetAgentPool.json +func ExampleAgentPoolClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewAgentPoolClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", "test-hybridaksnodepool", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/PutAgentPool.json +func ExampleAgentPoolClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewAgentPoolClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", "test-hybridaksnodepool", armhybridaks.AgentPool{ + Location: to.Ptr("westus"), + Properties: &armhybridaks.AgentPoolProperties{ + Count: to.Ptr[int32](1), + OSType: to.Ptr(armhybridaks.OsTypeLinux), + VMSize: to.Ptr("Standard_A4_v2"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/DeleteAgentPool.json +func ExampleAgentPoolClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewAgentPoolClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = client.Delete(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", "test-hybridaksnodepool", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/UpdateAgentPool.json +func ExampleAgentPoolClient_Update() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewAgentPoolClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Update(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", "test-hybridaksnodepool", armhybridaks.AgentPool{ + Location: to.Ptr("westus"), + Properties: &armhybridaks.AgentPoolProperties{ + Count: to.Ptr[int32](3), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListAgentPoolByProvisionedCluster.json +func ExampleAgentPoolClient_ListByProvisionedCluster() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewAgentPoolClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.ListByProvisionedCluster(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/autorest.md b/sdk/resourcemanager/hybridaks/armhybridaks/autorest.md new file mode 100644 index 000000000000..65a09cf9f96c --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/374bebd0b0764ba8350cb186e010f1fee987d0b7/specification/hybridaks/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/374bebd0b0764ba8350cb186e010f1fee987d0b7/specification/hybridaks/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/build.go b/sdk/resourcemanager/hybridaks/armhybridaks/build.go new file mode 100644 index 000000000000..e957f7d5ab9a --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/hybridaks/armhybridaks + +package armhybridaks diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/ci.yml b/sdk/resourcemanager/hybridaks/armhybridaks/ci.yml new file mode 100644 index 000000000000..f3fc3ae92998 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/hybridaks/armhybridaks/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/hybridaks/armhybridaks/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/hybridaks/armhybridaks' diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/constants.go b/sdk/resourcemanager/hybridaks/armhybridaks/constants.go new file mode 100644 index 000000000000..cb7e74ae0570 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/constants.go @@ -0,0 +1,233 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +const ( + moduleName = "armhybridaks" + moduleVersion = "v0.1.0" +) + +type AgentPoolProvisioningState string + +const ( + AgentPoolProvisioningStateCanceled AgentPoolProvisioningState = "Canceled" + AgentPoolProvisioningStateDeleting AgentPoolProvisioningState = "Deleting" + AgentPoolProvisioningStateFailed AgentPoolProvisioningState = "Failed" + AgentPoolProvisioningStateInProgress AgentPoolProvisioningState = "InProgress" + AgentPoolProvisioningStateSucceeded AgentPoolProvisioningState = "Succeeded" +) + +// PossibleAgentPoolProvisioningStateValues returns the possible values for the AgentPoolProvisioningState const type. +func PossibleAgentPoolProvisioningStateValues() []AgentPoolProvisioningState { + return []AgentPoolProvisioningState{ + AgentPoolProvisioningStateCanceled, + AgentPoolProvisioningStateDeleting, + AgentPoolProvisioningStateFailed, + AgentPoolProvisioningStateInProgress, + AgentPoolProvisioningStateSucceeded, + } +} + +// AutoUpgradeOptions - Indicates whether the Arc agents on the provisioned clusters be upgraded automatically to the latest +// version. Defaults to Enabled. +type AutoUpgradeOptions string + +const ( + AutoUpgradeOptionsDisabled AutoUpgradeOptions = "Disabled" + AutoUpgradeOptionsEnabled AutoUpgradeOptions = "Enabled" +) + +// PossibleAutoUpgradeOptionsValues returns the possible values for the AutoUpgradeOptions const type. +func PossibleAutoUpgradeOptionsValues() []AutoUpgradeOptions { + return []AutoUpgradeOptions{ + AutoUpgradeOptionsDisabled, + AutoUpgradeOptionsEnabled, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// DeploymentState - Observed deployment state of the Arc Agents on the target cluster. Possible values include: 'pending', +// 'provisioning', 'provisioned', 'deleting', 'failed', 'upgrading' +type DeploymentState string + +const ( + DeploymentStateDeleting DeploymentState = "deleting" + DeploymentStateFailed DeploymentState = "failed" + DeploymentStatePending DeploymentState = "pending" + DeploymentStateProvisioned DeploymentState = "provisioned" + DeploymentStateProvisioning DeploymentState = "provisioning" + DeploymentStateUpgrading DeploymentState = "upgrading" +) + +// PossibleDeploymentStateValues returns the possible values for the DeploymentState const type. +func PossibleDeploymentStateValues() []DeploymentState { + return []DeploymentState{ + DeploymentStateDeleting, + DeploymentStateFailed, + DeploymentStatePending, + DeploymentStateProvisioned, + DeploymentStateProvisioning, + DeploymentStateUpgrading, + } +} + +// LicenseType - LicenseType - The licenseType to use for Windows VMs. WindowsServer is used to enable Azure Hybrid User Benefits +// for Windows VMs. Possible values include: 'None', 'WindowsServer' +type LicenseType string + +const ( + LicenseTypeNone LicenseType = "None" + LicenseTypeWindowsServer LicenseType = "Windows_Server" +) + +// PossibleLicenseTypeValues returns the possible values for the LicenseType const type. +func PossibleLicenseTypeValues() []LicenseType { + return []LicenseType{ + LicenseTypeNone, + LicenseTypeWindowsServer, + } +} + +// LoadBalancerSKU - LoadBalancerSku - The load balancer sku for the provisioned cluster. Possible values: 'unstacked-haproxy', +// 'stacked-kube-vip', 'stacked-metallb', 'unmanaged'. The default is 'unmanaged'. +type LoadBalancerSKU string + +const ( + LoadBalancerSKUStackedKubeVip LoadBalancerSKU = "stacked-kube-vip" + LoadBalancerSKUStackedMetallb LoadBalancerSKU = "stacked-metallb" + LoadBalancerSKUUnmanaged LoadBalancerSKU = "unmanaged" + LoadBalancerSKUUnstackedHaproxy LoadBalancerSKU = "unstacked-haproxy" +) + +// PossibleLoadBalancerSKUValues returns the possible values for the LoadBalancerSKU const type. +func PossibleLoadBalancerSKUValues() []LoadBalancerSKU { + return []LoadBalancerSKU{ + LoadBalancerSKUStackedKubeVip, + LoadBalancerSKUStackedMetallb, + LoadBalancerSKUUnmanaged, + LoadBalancerSKUUnstackedHaproxy, + } +} + +// Mode - Mode - AgentPoolMode represents mode of an agent pool. Possible values include: 'System', 'LB', 'User'. Default +// is 'User' +type Mode string + +const ( + ModeLB Mode = "LB" + ModeSystem Mode = "System" + ModeUser Mode = "User" +) + +// PossibleModeValues returns the possible values for the Mode const type. +func PossibleModeValues() []Mode { + return []Mode{ + ModeLB, + ModeSystem, + ModeUser, + } +} + +// NetworkPolicy - NetworkPolicy - Network policy used for building Kubernetes network. Possible values include: 'calico', +// 'flannel'. Default is 'calico' +type NetworkPolicy string + +const ( + NetworkPolicyCalico NetworkPolicy = "calico" + NetworkPolicyFlannel NetworkPolicy = "flannel" +) + +// PossibleNetworkPolicyValues returns the possible values for the NetworkPolicy const type. +func PossibleNetworkPolicyValues() []NetworkPolicy { + return []NetworkPolicy{ + NetworkPolicyCalico, + NetworkPolicyFlannel, + } +} + +// OsType - OsType - OsType to be used to specify os type. Choose from Linux and Windows. Default to Linux. Possible values +// include: 'Linux', 'Windows' +type OsType string + +const ( + OsTypeLinux OsType = "Linux" + OsTypeWindows OsType = "Windows" +) + +// PossibleOsTypeValues returns the possible values for the OsType const type. +func PossibleOsTypeValues() []OsType { + return []OsType{ + OsTypeLinux, + OsTypeWindows, + } +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreated ProvisioningState = "Created" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateInProgress ProvisioningState = "InProgress" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreated, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateInProgress, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// ResourceIdentityType - The type of identity used for the provisioned cluster. The type SystemAssigned, includes a system +// created identity. The type None means no identity is assigned to the provisioned cluster. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeNone ResourceIdentityType = "None" + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeNone, + ResourceIdentityTypeSystemAssigned, + } +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/go.mod b/sdk/resourcemanager/hybridaks/armhybridaks/go.mod new file mode 100644 index 000000000000..4e211c1c941e --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks + +go 1.19 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect + github.com/golang-jwt/jwt v3.2.1+incompatible // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/go.sum b/sdk/resourcemanager/hybridaks/armhybridaks/go.sum new file mode 100644 index 000000000000..8828b17b1853 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/go.sum @@ -0,0 +1,33 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= +github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= +golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/hybridcontainerservice_client.go b/sdk/resourcemanager/hybridaks/armhybridaks/hybridcontainerservice_client.go new file mode 100644 index 000000000000..0e424fea15c2 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/hybridcontainerservice_client.go @@ -0,0 +1,141 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" +) + +// HybridContainerServiceClient contains the methods for the HybridContainerService group. +// Don't use this type directly, use NewHybridContainerServiceClient() instead. +type HybridContainerServiceClient struct { + host string + pl runtime.Pipeline +} + +// NewHybridContainerServiceClient creates a new instance of HybridContainerServiceClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewHybridContainerServiceClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*HybridContainerServiceClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &HybridContainerServiceClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// ListOrchestrators - Lists the available orchestrators in a custom location for HybridAKS +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// customLocationResourceURI - The fully qualified Azure Resource manager identifier of the custom location resource. +// options - HybridContainerServiceClientListOrchestratorsOptions contains the optional parameters for the HybridContainerServiceClient.ListOrchestrators +// method. +func (client *HybridContainerServiceClient) ListOrchestrators(ctx context.Context, customLocationResourceURI string, options *HybridContainerServiceClientListOrchestratorsOptions) (HybridContainerServiceClientListOrchestratorsResponse, error) { + req, err := client.listOrchestratorsCreateRequest(ctx, customLocationResourceURI, options) + if err != nil { + return HybridContainerServiceClientListOrchestratorsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HybridContainerServiceClientListOrchestratorsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HybridContainerServiceClientListOrchestratorsResponse{}, runtime.NewResponseError(resp) + } + return client.listOrchestratorsHandleResponse(resp) +} + +// listOrchestratorsCreateRequest creates the ListOrchestrators request. +func (client *HybridContainerServiceClient) listOrchestratorsCreateRequest(ctx context.Context, customLocationResourceURI string, options *HybridContainerServiceClientListOrchestratorsOptions) (*policy.Request, error) { + urlPath := "/{customLocationResourceUri}/providers/Microsoft.HybridContainerService/orchestrators" + urlPath = strings.ReplaceAll(urlPath, "{customLocationResourceUri}", customLocationResourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listOrchestratorsHandleResponse handles the ListOrchestrators response. +func (client *HybridContainerServiceClient) listOrchestratorsHandleResponse(resp *http.Response) (HybridContainerServiceClientListOrchestratorsResponse, error) { + result := HybridContainerServiceClientListOrchestratorsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OrchestratorVersionProfileListResult); err != nil { + return HybridContainerServiceClientListOrchestratorsResponse{}, err + } + return result, nil +} + +// ListVMSKUs - Lists the available VM SKUs in a custom location for HybridAKS +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// customLocationResourceURI - The fully qualified Azure Resource manager identifier of the custom location resource. +// options - HybridContainerServiceClientListVMSKUsOptions contains the optional parameters for the HybridContainerServiceClient.ListVMSKUs +// method. +func (client *HybridContainerServiceClient) ListVMSKUs(ctx context.Context, customLocationResourceURI string, options *HybridContainerServiceClientListVMSKUsOptions) (HybridContainerServiceClientListVMSKUsResponse, error) { + req, err := client.listVMSKUsCreateRequest(ctx, customLocationResourceURI, options) + if err != nil { + return HybridContainerServiceClientListVMSKUsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HybridContainerServiceClientListVMSKUsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HybridContainerServiceClientListVMSKUsResponse{}, runtime.NewResponseError(resp) + } + return client.listVMSKUsHandleResponse(resp) +} + +// listVMSKUsCreateRequest creates the ListVMSKUs request. +func (client *HybridContainerServiceClient) listVMSKUsCreateRequest(ctx context.Context, customLocationResourceURI string, options *HybridContainerServiceClientListVMSKUsOptions) (*policy.Request, error) { + urlPath := "/{customLocationResourceUri}/providers/Microsoft.HybridContainerService/vmSkus" + urlPath = strings.ReplaceAll(urlPath, "{customLocationResourceUri}", customLocationResourceURI) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listVMSKUsHandleResponse handles the ListVMSKUs response. +func (client *HybridContainerServiceClient) listVMSKUsHandleResponse(resp *http.Response) (HybridContainerServiceClientListVMSKUsResponse, error) { + result := HybridContainerServiceClientListVMSKUsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VMSKUListResult); err != nil { + return HybridContainerServiceClientListVMSKUsResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/hybridcontainerservice_client_example_test.go b/sdk/resourcemanager/hybridaks/armhybridaks/hybridcontainerservice_client_example_test.go new file mode 100644 index 000000000000..802eb6634bcf --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/hybridcontainerservice_client_example_test.go @@ -0,0 +1,55 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridaks_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListOrchestrators.json +func ExampleHybridContainerServiceClient_ListOrchestrators() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewHybridContainerServiceClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.ListOrchestrators(ctx, "subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourceGroups/test-arcappliance-resgrp/providers/Microsoft.ExtendedLocation/customLocations/testcustomlocation", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListVMSkus.json +func ExampleHybridContainerServiceClient_ListVMSKUs() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewHybridContainerServiceClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.ListVMSKUs(ctx, "subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourceGroups/test-arcappliance-resgrp/providers/Microsoft.ExtendedLocation/customLocations/testcustomlocation", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/hybrididentitymetadata_client.go b/sdk/resourcemanager/hybridaks/armhybridaks/hybrididentitymetadata_client.go new file mode 100644 index 000000000000..bae0399273cb --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/hybrididentitymetadata_client.go @@ -0,0 +1,302 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// HybridIdentityMetadataClient contains the methods for the HybridIdentityMetadata group. +// Don't use this type directly, use NewHybridIdentityMetadataClient() instead. +type HybridIdentityMetadataClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewHybridIdentityMetadataClient creates a new instance of HybridIdentityMetadataClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewHybridIdentityMetadataClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*HybridIdentityMetadataClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &HybridIdentityMetadataClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Delete - Deletes the hybrid identity metadata proxy resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// hybridIdentityMetadataResourceName - Parameter for the name of the hybrid identity metadata resource. +// options - HybridIdentityMetadataClientDeleteOptions contains the optional parameters for the HybridIdentityMetadataClient.Delete +// method. +func (client *HybridIdentityMetadataClient) Delete(ctx context.Context, resourceGroupName string, provisionedClustersName string, hybridIdentityMetadataResourceName string, options *HybridIdentityMetadataClientDeleteOptions) (HybridIdentityMetadataClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, provisionedClustersName, hybridIdentityMetadataResourceName, options) + if err != nil { + return HybridIdentityMetadataClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HybridIdentityMetadataClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return HybridIdentityMetadataClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return HybridIdentityMetadataClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *HybridIdentityMetadataClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, hybridIdentityMetadataResourceName string, options *HybridIdentityMetadataClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/hybridIdentityMetadata/{hybridIdentityMetadataResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + if hybridIdentityMetadataResourceName == "" { + return nil, errors.New("parameter hybridIdentityMetadataResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hybridIdentityMetadataResourceName}", url.PathEscape(hybridIdentityMetadataResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get the hybrid identity metadata proxy resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// hybridIdentityMetadataResourceName - Parameter for the name of the hybrid identity metadata resource. +// options - HybridIdentityMetadataClientGetOptions contains the optional parameters for the HybridIdentityMetadataClient.Get +// method. +func (client *HybridIdentityMetadataClient) Get(ctx context.Context, resourceGroupName string, provisionedClustersName string, hybridIdentityMetadataResourceName string, options *HybridIdentityMetadataClientGetOptions) (HybridIdentityMetadataClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, provisionedClustersName, hybridIdentityMetadataResourceName, options) + if err != nil { + return HybridIdentityMetadataClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HybridIdentityMetadataClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HybridIdentityMetadataClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *HybridIdentityMetadataClient) getCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, hybridIdentityMetadataResourceName string, options *HybridIdentityMetadataClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/hybridIdentityMetadata/{hybridIdentityMetadataResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + if hybridIdentityMetadataResourceName == "" { + return nil, errors.New("parameter hybridIdentityMetadataResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hybridIdentityMetadataResourceName}", url.PathEscape(hybridIdentityMetadataResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *HybridIdentityMetadataClient) getHandleResponse(resp *http.Response) (HybridIdentityMetadataClientGetResponse, error) { + result := HybridIdentityMetadataClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HybridIdentityMetadata); err != nil { + return HybridIdentityMetadataClientGetResponse{}, err + } + return result, nil +} + +// NewListByClusterPager - Lists the hybrid identity metadata proxy resource in a cluster. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// options - HybridIdentityMetadataClientListByClusterOptions contains the optional parameters for the HybridIdentityMetadataClient.ListByCluster +// method. +func (client *HybridIdentityMetadataClient) NewListByClusterPager(resourceGroupName string, provisionedClustersName string, options *HybridIdentityMetadataClientListByClusterOptions) *runtime.Pager[HybridIdentityMetadataClientListByClusterResponse] { + return runtime.NewPager(runtime.PagingHandler[HybridIdentityMetadataClientListByClusterResponse]{ + More: func(page HybridIdentityMetadataClientListByClusterResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *HybridIdentityMetadataClientListByClusterResponse) (HybridIdentityMetadataClientListByClusterResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByClusterCreateRequest(ctx, resourceGroupName, provisionedClustersName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return HybridIdentityMetadataClientListByClusterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HybridIdentityMetadataClientListByClusterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HybridIdentityMetadataClientListByClusterResponse{}, runtime.NewResponseError(resp) + } + return client.listByClusterHandleResponse(resp) + }, + }) +} + +// listByClusterCreateRequest creates the ListByCluster request. +func (client *HybridIdentityMetadataClient) listByClusterCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, options *HybridIdentityMetadataClientListByClusterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/hybridIdentityMetadata" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByClusterHandleResponse handles the ListByCluster response. +func (client *HybridIdentityMetadataClient) listByClusterHandleResponse(resp *http.Response) (HybridIdentityMetadataClientListByClusterResponse, error) { + result := HybridIdentityMetadataClientListByClusterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HybridIdentityMetadataList); err != nil { + return HybridIdentityMetadataClientListByClusterResponse{}, err + } + return result, nil +} + +// Put - Creates the hybrid identity metadata proxy resource that facilitates the managed identity provisioning. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// hybridIdentityMetadataResourceName - Parameter for the name of the hybrid identity metadata resource. +// options - HybridIdentityMetadataClientPutOptions contains the optional parameters for the HybridIdentityMetadataClient.Put +// method. +func (client *HybridIdentityMetadataClient) Put(ctx context.Context, resourceGroupName string, provisionedClustersName string, hybridIdentityMetadataResourceName string, body HybridIdentityMetadata, options *HybridIdentityMetadataClientPutOptions) (HybridIdentityMetadataClientPutResponse, error) { + req, err := client.putCreateRequest(ctx, resourceGroupName, provisionedClustersName, hybridIdentityMetadataResourceName, body, options) + if err != nil { + return HybridIdentityMetadataClientPutResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return HybridIdentityMetadataClientPutResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return HybridIdentityMetadataClientPutResponse{}, runtime.NewResponseError(resp) + } + return client.putHandleResponse(resp) +} + +// putCreateRequest creates the Put request. +func (client *HybridIdentityMetadataClient) putCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, hybridIdentityMetadataResourceName string, body HybridIdentityMetadata, options *HybridIdentityMetadataClientPutOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}/hybridIdentityMetadata/{hybridIdentityMetadataResourceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + if hybridIdentityMetadataResourceName == "" { + return nil, errors.New("parameter hybridIdentityMetadataResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hybridIdentityMetadataResourceName}", url.PathEscape(hybridIdentityMetadataResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// putHandleResponse handles the Put response. +func (client *HybridIdentityMetadataClient) putHandleResponse(resp *http.Response) (HybridIdentityMetadataClientPutResponse, error) { + result := HybridIdentityMetadataClientPutResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HybridIdentityMetadata); err != nil { + return HybridIdentityMetadataClientPutResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/hybrididentitymetadata_client_example_test.go b/sdk/resourcemanager/hybridaks/armhybridaks/hybrididentitymetadata_client_example_test.go new file mode 100644 index 000000000000..9285b0b35279 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/hybrididentitymetadata_client_example_test.go @@ -0,0 +1,102 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridaks_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/CreateHybridIdentityMetadata.json +func ExampleHybridIdentityMetadataClient_Put() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Put(ctx, "testrg", "ContosoTargetCluster", "default", armhybridaks.HybridIdentityMetadata{ + Properties: &armhybridaks.HybridIdentityMetadataProperties{ + PublicKey: to.Ptr("8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2"), + ResourceUID: to.Ptr("f8b82dff-38ef-4220-99ef-d3a3f86ddc6c"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/GetHybridIdentityMetadata.json +func ExampleHybridIdentityMetadataClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "testrg", "ContosoTargetCluster", "default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/DeleteHybridIdentityMetadata.json +func ExampleHybridIdentityMetadataClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = client.Delete(ctx, "testrg", "ContosoTargetCluster", "default", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/HybridIdentityMetadataListByCluster.json +func ExampleHybridIdentityMetadataClient_NewListByClusterPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewHybridIdentityMetadataClient("fd3c3665-1729-4b7b-9a38-238e83b0f98b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByClusterPager("testrg", "ContosoTargetCluster", nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/models.go b/sdk/resourcemanager/hybridaks/armhybridaks/models.go new file mode 100644 index 000000000000..71e4bb7b98bc --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/models.go @@ -0,0 +1,1355 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import "time" + +// AADProfile - AAD Profile specifies attributes for Azure Active Directory integration. +type AADProfile struct { + // The list of AAD group object IDs that will have admin role of the cluster. + AdminGroupObjectIDs []*string `json:"adminGroupObjectIDs,omitempty"` + + // The client AAD application ID. + ClientAppID *string `json:"clientAppID,omitempty"` + + // Whether to enable Azure RBAC for Kubernetes authorization. + EnableAzureRbac *bool `json:"enableAzureRbac,omitempty"` + + // Whether to enable managed AAD. + Managed *bool `json:"managed,omitempty"` + + // The server AAD application ID. + ServerAppID *string `json:"serverAppID,omitempty"` + + // The server AAD application secret. + ServerAppSecret *string `json:"serverAppSecret,omitempty"` + + // The AAD tenant ID to use for authentication. If not specified, will use the tenant of the deployment subscription. + TenantID *string `json:"tenantID,omitempty"` +} + +// AADProfileResponse - AAD Profile specifies attributes for Azure Active Directory integration. +type AADProfileResponse struct { + // The list of AAD group object IDs that will have admin role of the cluster. + AdminGroupObjectIDs []*string `json:"adminGroupObjectIDs,omitempty"` + + // The client AAD application ID. + ClientAppID *string `json:"clientAppID,omitempty"` + + // Whether to enable Azure RBAC for Kubernetes authorization. + EnableAzureRbac *bool `json:"enableAzureRbac,omitempty"` + + // Whether to enable managed AAD. + Managed *bool `json:"managed,omitempty"` + + // The server AAD application ID. + ServerAppID *string `json:"serverAppID,omitempty"` + + // The AAD tenant ID to use for authentication. If not specified, will use the tenant of the deployment subscription. + TenantID *string `json:"tenantID,omitempty"` +} + +// AddonProfiles - Addon configurations +type AddonProfiles struct { + // Config - Key-value pairs for configuring an add-on. + Config map[string]*string `json:"config,omitempty"` + + // Enabled - Whether the add-on is enabled or not. + Enabled *bool `json:"enabled,omitempty"` +} + +// AddonStatus - Status of the addon +type AddonStatus struct { + // ErrorMessage will be set in the event that there is a terminal problem reconciling the AddOn and will contain a more verbose + // string suitable for logging and human consumption. + ErrorMessage *string `json:"errorMessage,omitempty"` + + // Phase represents the current phase of cluster actuation. E.g. Pending, Running, Terminating, Failed etc. + Phase *string `json:"phase,omitempty"` + Ready *bool `json:"ready,omitempty"` +} + +// AgentPool - The agentPool resource definition +type AgentPool struct { + ExtendedLocation *AgentPoolExtendedLocation `json:"extendedLocation,omitempty"` + + // The resource location + Location *string `json:"location,omitempty"` + Properties *AgentPoolProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// AgentPoolClientBeginCreateOrUpdateOptions contains the optional parameters for the AgentPoolClient.BeginCreateOrUpdate +// method. +type AgentPoolClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AgentPoolClientDeleteOptions contains the optional parameters for the AgentPoolClient.Delete method. +type AgentPoolClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolClientGetOptions contains the optional parameters for the AgentPoolClient.Get method. +type AgentPoolClientGetOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolClientListByProvisionedClusterOptions contains the optional parameters for the AgentPoolClient.ListByProvisionedCluster +// method. +type AgentPoolClientListByProvisionedClusterOptions struct { + // placeholder for future optional parameters +} + +// AgentPoolClientUpdateOptions contains the optional parameters for the AgentPoolClient.Update method. +type AgentPoolClientUpdateOptions struct { + // placeholder for future optional parameters +} + +type AgentPoolExtendedLocation struct { + // The extended location name. + Name *string `json:"name,omitempty"` + + // The extended location type. + Type *string `json:"type,omitempty"` +} + +type AgentPoolListResult struct { + NextLink *string `json:"nextLink,omitempty"` + Value []*AgentPool `json:"value,omitempty"` +} + +type AgentPoolProperties struct { + // AvailabilityZones - The list of Availability zones to use for nodes. Datacenter racks modelled as zones + AvailabilityZones []*string `json:"availabilityZones,omitempty"` + + // The underlying cloud infra provider properties. + CloudProviderProfile *CloudProviderProfile `json:"cloudProviderProfile,omitempty"` + + // Count - Number of agents to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default + // value is 1. + Count *int32 `json:"count,omitempty"` + + // The maximum number of nodes for auto-scaling + MaxCount *int32 `json:"maxCount,omitempty"` + + // The maximum number of pods that can run on a node. + MaxPods *int32 `json:"maxPods,omitempty"` + + // The minimum number of nodes for auto-scaling + MinCount *int32 `json:"minCount,omitempty"` + + // Mode - AgentPoolMode represents mode of an agent pool. Possible values include: 'System', 'LB', 'User'. Default is 'User' + Mode *Mode `json:"mode,omitempty"` + + // The version of node image + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + + // NodeLabels - Agent pool node labels to be persisted across all nodes in agent pool. + NodeLabels map[string]*string `json:"nodeLabels,omitempty"` + + // NodeTaints - Taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule. + NodeTaints []*string `json:"nodeTaints,omitempty"` + + // OsType - OsType to be used to specify os type. Choose from Linux and Windows. Default to Linux. Possible values include: + // 'Linux', 'Windows' + OSType *OsType `json:"osType,omitempty"` + + // HybridAKSNodePoolStatus defines the observed state of HybridAKSNodePool + Status *AgentPoolProvisioningStatusStatus `json:"status,omitempty"` + + // VmSize - The size of the agent pool VMs. + VMSize *string `json:"vmSize,omitempty"` + + // READ-ONLY + ProvisioningState *AgentPoolProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +type AgentPoolProvisioningStatusError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +// AgentPoolProvisioningStatusStatus - HybridAKSNodePoolStatus defines the observed state of HybridAKSNodePool +type AgentPoolProvisioningStatusStatus struct { + // ErrorMessage - Error messages during creation of cluster + ErrorMessage *string `json:"errorMessage,omitempty"` + + // Contains Provisioning errors + ProvisioningStatus *AgentPoolProvisioningStatusStatusProvisioningStatus `json:"provisioningStatus,omitempty"` + + // Total number of ready machines targeted by this deployment. + ReadyReplicas *int32 `json:"readyReplicas,omitempty"` + + // Total number of non-terminated machines targeted by this deployment + Replicas *int32 `json:"replicas,omitempty"` +} + +// AgentPoolProvisioningStatusStatusProvisioningStatus - Contains Provisioning errors +type AgentPoolProvisioningStatusStatusProvisioningStatus struct { + Error *AgentPoolProvisioningStatusError `json:"error,omitempty"` + OperationID *string `json:"operationId,omitempty"` + + // Phase represents the current phase of cluster actuation. E.g. Pending, Running, Terminating, Failed etc. + Phase *string `json:"phase,omitempty"` + Status *string `json:"status,omitempty"` +} + +// ArcAgentProfile - Defines the Arc Agent properties for the Provisioned clusters. +type ArcAgentProfile struct { + // Indicates whether the Arc agents on the provisioned clusters be upgraded automatically to the latest version. Defaults + // to Enabled. + AgentAutoUpgrade *AutoUpgradeOptions `json:"agentAutoUpgrade,omitempty"` + + // Version of the Arc agents to be installed on the provisioned Provisioned cluster resource + AgentVersion *string `json:"agentVersion,omitempty"` +} + +// ArcAgentStatus - Defines the observed Arc Agent status that is resourceSynced back to the ARM resource. +type ArcAgentStatus struct { + // Version of the Arc agents currently running on the Provisioned cluster resource. + AgentVersion *string `json:"agentVersion,omitempty"` + + // Number of CPU cores present in the Provisioned cluster resource + CoreCount *int64 `json:"coreCount,omitempty"` + + // Observed deployment state of the Arc Agents on the target cluster. Possible values include: 'pending', 'provisioning', + // 'provisioned', 'deleting', 'failed', 'upgrading' + DeploymentState *DeploymentState `json:"deploymentState,omitempty"` + + // Error messages while onboarding/upgrading/uninstalling the Arc agents + ErrorMessage *string `json:"errorMessage,omitempty"` + + // Last connected timestamp of the Provisioned cluster resource. + LastConnectivityTime *time.Time `json:"lastConnectivityTime,omitempty"` + + // ManagedIdentity certificate expiration time (ValidUntil). + ManagedIdentityCertificateExpirationTime *time.Time `json:"managedIdentityCertificateExpirationTime,omitempty"` + + // Onboarding public key for provisioning the Managed identity for the HybridAKS cluster. Will be used to create the hybridIdentityMetadata + // proxy resource and will not be persisted. + OnboardingPublicKey *string `json:"onboardingPublicKey,omitempty"` +} + +// CloudProviderProfile - The underlying cloud infra provider properties. +type CloudProviderProfile struct { + // InfraNetworkProfile - List of infra network profiles for the provisioned cluster + InfraNetworkProfile *CloudProviderProfileInfraNetworkProfile `json:"infraNetworkProfile,omitempty"` + + // InfraStorageProfile - List of infra storage profiles for the provisioned cluster + InfraStorageProfile *CloudProviderProfileInfraStorageProfile `json:"infraStorageProfile,omitempty"` +} + +// CloudProviderProfileInfraNetworkProfile - InfraNetworkProfile - List of infra network profiles for the provisioned cluster +type CloudProviderProfileInfraNetworkProfile struct { + // Array of references to azure resource corresponding to the new HybridAKSNetwork object e.g. + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/virtualNetworks/{virtualNetworkName} + VnetSubnetIDs []*string `json:"vnetSubnetIds,omitempty"` +} + +// CloudProviderProfileInfraStorageProfile - InfraStorageProfile - List of infra storage profiles for the provisioned cluster +type CloudProviderProfileInfraStorageProfile struct { + // Reference to azure resource corresponding to the new HybridAKSStorage object e.g. + // /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/storageSpaces/{storageSpaceName} + StorageSpaceIDs []*string `json:"storageSpaceIds,omitempty"` +} + +// ControlPlaneEndpointProfileControlPlaneEndpoint - API server endpoint for the control plane +type ControlPlaneEndpointProfileControlPlaneEndpoint struct { + // Host IP address for API server + HostIP *string `json:"hostIP,omitempty"` + + // Port for the API server + Port *string `json:"port,omitempty"` +} + +// ControlPlaneProfile - The control plane properties for the provisioned cluster. +type ControlPlaneProfile struct { + // AvailabilityZones - The list of Availability zones to use for nodes. Datacenter racks modelled as zones + AvailabilityZones []*string `json:"availabilityZones,omitempty"` + + // The underlying cloud infra provider properties. + CloudProviderProfile *CloudProviderProfile `json:"cloudProviderProfile,omitempty"` + + // API server endpoint for the control plane + ControlPlaneEndpoint *ControlPlaneEndpointProfileControlPlaneEndpoint `json:"controlPlaneEndpoint,omitempty"` + + // Count - Number of agents to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default + // value is 1. + Count *int32 `json:"count,omitempty"` + + // Profile for Linux VMs in the container service cluster. + LinuxProfile *LinuxProfileProperties `json:"linuxProfile,omitempty"` + + // The maximum number of nodes for auto-scaling + MaxCount *int32 `json:"maxCount,omitempty"` + + // The maximum number of pods that can run on a node. + MaxPods *int32 `json:"maxPods,omitempty"` + + // The minimum number of nodes for auto-scaling + MinCount *int32 `json:"minCount,omitempty"` + + // Mode - AgentPoolMode represents mode of an agent pool. Possible values include: 'System', 'LB', 'User'. Default is 'User' + Mode *Mode `json:"mode,omitempty"` + + // Unique name of the agent pool profile in the context of the subscription and resource group. + Name *string `json:"name,omitempty"` + + // The version of node image + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + + // NodeLabels - Agent pool node labels to be persisted across all nodes in agent pool. + NodeLabels map[string]*string `json:"nodeLabels,omitempty"` + + // NodeTaints - Taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule. + NodeTaints []*string `json:"nodeTaints,omitempty"` + + // OsType - OsType to be used to specify os type. Choose from Linux and Windows. Default to Linux. Possible values include: + // 'Linux', 'Windows' + OSType *OsType `json:"osType,omitempty"` + + // VmSize - The size of the agent pool VMs. + VMSize *string `json:"vmSize,omitempty"` +} + +// HTTPProxyConfig - Configurations for provisioning the cluster with HTTP proxy servers. +type HTTPProxyConfig struct { + // The HTTP proxy server endpoint to use. + HTTPProxy *string `json:"httpProxy,omitempty"` + + // The HTTPS proxy server endpoint to use. + HTTPSProxy *string `json:"httpsProxy,omitempty"` + + // The endpoints that should not go through proxy. + NoProxy []*string `json:"noProxy,omitempty"` + + // Password to use for connecting to proxy server + Password *string `json:"password,omitempty"` + + // Alternative CA cert to use for connecting to proxy servers. + TrustedCa *string `json:"trustedCa,omitempty"` + + // Username to use for connecting to proxy server + Username *string `json:"username,omitempty"` +} + +// HTTPProxyConfigResponse - Configurations for provisioning the cluster with HTTP proxy servers. +type HTTPProxyConfigResponse struct { + // The HTTP proxy server endpoint to use. + HTTPProxy *string `json:"httpProxy,omitempty"` + + // The HTTPS proxy server endpoint to use. + HTTPSProxy *string `json:"httpsProxy,omitempty"` + + // The endpoints that should not go through proxy. + NoProxy []*string `json:"noProxy,omitempty"` + + // Alternative CA cert to use for connecting to proxy servers. + TrustedCa *string `json:"trustedCa,omitempty"` + + // Username to use for connecting to proxy server + Username *string `json:"username,omitempty"` +} + +// HybridContainerServiceClientListOrchestratorsOptions contains the optional parameters for the HybridContainerServiceClient.ListOrchestrators +// method. +type HybridContainerServiceClientListOrchestratorsOptions struct { + // placeholder for future optional parameters +} + +// HybridContainerServiceClientListVMSKUsOptions contains the optional parameters for the HybridContainerServiceClient.ListVMSKUs +// method. +type HybridContainerServiceClientListVMSKUsOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadata - Defines the hybridIdentityMetadata. +type HybridIdentityMetadata struct { + // REQUIRED; Resource properties. + Properties *HybridIdentityMetadataProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The system data. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// HybridIdentityMetadataClientDeleteOptions contains the optional parameters for the HybridIdentityMetadataClient.Delete +// method. +type HybridIdentityMetadataClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataClientGetOptions contains the optional parameters for the HybridIdentityMetadataClient.Get method. +type HybridIdentityMetadataClientGetOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataClientListByClusterOptions contains the optional parameters for the HybridIdentityMetadataClient.ListByCluster +// method. +type HybridIdentityMetadataClientListByClusterOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataClientPutOptions contains the optional parameters for the HybridIdentityMetadataClient.Put method. +type HybridIdentityMetadataClientPutOptions struct { + // placeholder for future optional parameters +} + +// HybridIdentityMetadataList - List of hybridIdentityMetadata. +type HybridIdentityMetadataList struct { + // REQUIRED; Array of hybridIdentityMetadata + Value []*HybridIdentityMetadata `json:"value,omitempty"` + + // Url to follow for getting next page of hybridIdentityMetadata. + NextLink *string `json:"nextLink,omitempty"` +} + +// HybridIdentityMetadataProperties - Defines the resource properties. +type HybridIdentityMetadataProperties struct { + // The identity of the provisioned cluster. + Identity *ProvisionedClusterIdentity `json:"identity,omitempty"` + + // Onboarding public key for provisioning the Managed identity for the HybridAKS cluster. + PublicKey *string `json:"publicKey,omitempty"` + + // Unique id of the parent provisioned cluster resource. + ResourceUID *string `json:"resourceUid,omitempty"` + + // READ-ONLY; provisioning state of the hybridIdentityMetadata resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// LinuxProfileProperties - LinuxProfile - Profile for Linux VMs in the container service cluster. +type LinuxProfileProperties struct { + // AdminUsername - The administrator username to use for Linux VMs. + AdminUsername *string `json:"adminUsername,omitempty"` + + // SSH - SSH configuration for Linux-based VMs running on Azure. + SSH *LinuxProfilePropertiesSSH `json:"ssh,omitempty"` +} + +// LinuxProfilePropertiesSSH - SSH - SSH configuration for Linux-based VMs running on Azure. +type LinuxProfilePropertiesSSH struct { + // PublicKeys - The list of SSH public keys used to authenticate with Linux-based VMs. Only expect one key specified. + PublicKeys []*LinuxProfilePropertiesSSHPublicKeysItem `json:"publicKeys,omitempty"` +} + +type LinuxProfilePropertiesSSHPublicKeysItem struct { + // KeyData - Certificate public key used to authenticate with VMs through SSH. The certificate must be in PEM format with + // or without headers. + KeyData *string `json:"keyData,omitempty"` +} + +// LoadBalancerProfile - Profile of the cluster load balancer. +type LoadBalancerProfile struct { + // AvailabilityZones - The list of Availability zones to use for nodes. Datacenter racks modelled as zones + AvailabilityZones []*string `json:"availabilityZones,omitempty"` + + // The underlying cloud infra provider properties. + CloudProviderProfile *CloudProviderProfile `json:"cloudProviderProfile,omitempty"` + + // Count - Number of agents to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default + // value is 1. + Count *int32 `json:"count,omitempty"` + + // Profile for Linux VMs in the container service cluster. + LinuxProfile *LinuxProfileProperties `json:"linuxProfile,omitempty"` + + // The maximum number of nodes for auto-scaling + MaxCount *int32 `json:"maxCount,omitempty"` + + // The maximum number of pods that can run on a node. + MaxPods *int32 `json:"maxPods,omitempty"` + + // The minimum number of nodes for auto-scaling + MinCount *int32 `json:"minCount,omitempty"` + + // Mode - AgentPoolMode represents mode of an agent pool. Possible values include: 'System', 'LB', 'User'. Default is 'User' + Mode *Mode `json:"mode,omitempty"` + + // Unique name of the agent pool profile in the context of the subscription and resource group. + Name *string `json:"name,omitempty"` + + // The version of node image + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + + // NodeLabels - Agent pool node labels to be persisted across all nodes in agent pool. + NodeLabels map[string]*string `json:"nodeLabels,omitempty"` + + // NodeTaints - Taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule. + NodeTaints []*string `json:"nodeTaints,omitempty"` + + // OsType - OsType to be used to specify os type. Choose from Linux and Windows. Default to Linux. Possible values include: + // 'Linux', 'Windows' + OSType *OsType `json:"osType,omitempty"` + + // VmSize - The size of the agent pool VMs. + VMSize *string `json:"vmSize,omitempty"` +} + +// NamedAgentPoolProfile - Agent pool profile along with a name parameter +type NamedAgentPoolProfile struct { + // AvailabilityZones - The list of Availability zones to use for nodes. Datacenter racks modelled as zones + AvailabilityZones []*string `json:"availabilityZones,omitempty"` + + // The underlying cloud infra provider properties. + CloudProviderProfile *CloudProviderProfile `json:"cloudProviderProfile,omitempty"` + + // Count - Number of agents to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default + // value is 1. + Count *int32 `json:"count,omitempty"` + + // The maximum number of nodes for auto-scaling + MaxCount *int32 `json:"maxCount,omitempty"` + + // The maximum number of pods that can run on a node. + MaxPods *int32 `json:"maxPods,omitempty"` + + // The minimum number of nodes for auto-scaling + MinCount *int32 `json:"minCount,omitempty"` + + // Mode - AgentPoolMode represents mode of an agent pool. Possible values include: 'System', 'LB', 'User'. Default is 'User' + Mode *Mode `json:"mode,omitempty"` + + // Unique name of the agent pool profile in the context of the subscription and resource group. + Name *string `json:"name,omitempty"` + + // The version of node image + NodeImageVersion *string `json:"nodeImageVersion,omitempty"` + + // NodeLabels - Agent pool node labels to be persisted across all nodes in agent pool. + NodeLabels map[string]*string `json:"nodeLabels,omitempty"` + + // NodeTaints - Taints added to new nodes during node pool create and scale. For example, key=value:NoSchedule. + NodeTaints []*string `json:"nodeTaints,omitempty"` + + // OsType - OsType to be used to specify os type. Choose from Linux and Windows. Default to Linux. Possible values include: + // 'Linux', 'Windows' + OSType *OsType `json:"osType,omitempty"` + + // VmSize - The size of the agent pool VMs. + VMSize *string `json:"vmSize,omitempty"` +} + +// NetworkProfile - Profile of network configuration. +type NetworkProfile struct { + // DNSServiceIP - An IP address assigned to the Kubernetes DNS service. It must be within the Kubernetes service address range + // specified in serviceCidr. + DNSServiceIP *string `json:"dnsServiceIP,omitempty"` + + // LoadBalancerProfile - Profile of the cluster load balancer. + LoadBalancerProfile *LoadBalancerProfile `json:"loadBalancerProfile,omitempty"` + + // LoadBalancerSku - The load balancer sku for the provisioned cluster. Possible values: 'unstacked-haproxy', 'stacked-kube-vip', + // 'stacked-metallb', 'unmanaged'. The default is 'unmanaged'. + LoadBalancerSKU *LoadBalancerSKU `json:"loadBalancerSku,omitempty"` + + // NetworkPolicy - Network policy used for building Kubernetes network. Possible values include: 'calico', 'flannel'. Default + // is 'calico' + NetworkPolicy *NetworkPolicy `json:"networkPolicy,omitempty"` + + // PodCidr - A CIDR notation IP range from which to assign pod IPs when kubenet is used. + PodCidr *string `json:"podCidr,omitempty"` + + // The CIDR notation IP ranges from which to assign pod IPs. One IPv4 CIDR is expected for single-stack networking. Two CIDRs, + // one for each IP family (IPv4/IPv6), is expected for dual-stack networking. + PodCidrs []*string `json:"podCidrs,omitempty"` + + // ServiceCidr - A CIDR notation IP range from which to assign service cluster IPs. It must not overlap with any Subnet IP + // ranges. + ServiceCidr *string `json:"serviceCidr,omitempty"` + + // The CIDR notation IP ranges from which to assign service cluster IPs. One IPv4 CIDR is expected for single-stack networking. + // Two CIDRs, one for each IP family (IPv4/IPv6), is expected for dual-stack + // networking. They must not overlap with any Subnet IP ranges. + ServiceCidrs []*string `json:"serviceCidrs,omitempty"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OrchestratorProfile - Contains information about orchestrator. +type OrchestratorProfile struct { + // READ-ONLY; Whether Kubernetes version is currently in preview. + IsPreview *bool `json:"isPreview,omitempty" azure:"ro"` + + // READ-ONLY; Orchestrator type. + OrchestratorType *string `json:"orchestratorType,omitempty" azure:"ro"` + + // READ-ONLY; Orchestrator version (major, minor, patch). + OrchestratorVersion *string `json:"orchestratorVersion,omitempty" azure:"ro"` +} + +// OrchestratorVersionProfile - The profile of an orchestrator and its available versions. +type OrchestratorVersionProfile struct { + // The list of available upgrade versions. + Upgrades []*OrchestratorProfile `json:"upgrades,omitempty"` + + // READ-ONLY; Installed by default if version is not specified. + Default *bool `json:"default,omitempty" azure:"ro"` + + // READ-ONLY; Whether Kubernetes version is currently in preview. + IsPreview *bool `json:"isPreview,omitempty" azure:"ro"` + + // READ-ONLY; Orchestrator type. + OrchestratorType *string `json:"orchestratorType,omitempty" azure:"ro"` + + // READ-ONLY; Orchestrator version major.minor.patch, for example 1.21.9 + OrchestratorVersion *string `json:"orchestratorVersion,omitempty" azure:"ro"` +} + +// OrchestratorVersionProfileListResult - The list of versions for supported orchestrators. +type OrchestratorVersionProfileListResult struct { + // Profile of the orchestrator versions + Orchestrators []*OrchestratorVersionProfile `json:"orchestrators,omitempty"` + + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ProvisionedClusterIdentity - Identity for the Provisioned cluster. +type ProvisionedClusterIdentity struct { + // REQUIRED; The type of identity used for the provisioned cluster. The type SystemAssigned, includes a system created identity. + // The type None means no identity is assigned to the provisioned cluster. + Type *ResourceIdentityType `json:"type,omitempty"` + + // READ-ONLY; The principal id of provisioned cluster identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant id associated with the provisioned cluster. This property will only be provided for a system assigned + // identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// ProvisionedClusters - The provisionedClusters resource definition. +type ProvisionedClusters struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + ExtendedLocation *ProvisionedClustersExtendedLocation `json:"extendedLocation,omitempty"` + + // Identity for the Provisioned cluster. + Identity *ProvisionedClusterIdentity `json:"identity,omitempty"` + + // All properties of the provisioned cluster + Properties *ProvisionedClustersAllProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ProvisionedClustersAllProperties - All properties of the provisioned cluster +type ProvisionedClustersAllProperties struct { + // AAD profile for the provisioned cluster. + AADProfile *AADProfile `json:"aadProfile,omitempty"` + + // AddonProfiles - Profile of managed cluster add-on. + AddonProfiles map[string]*AddonProfiles `json:"addonProfiles,omitempty"` + + // The agent pools of the cluster. + AgentPoolProfiles []*NamedAgentPoolProfile `json:"agentPoolProfiles,omitempty"` + + // The underlying cloud infra provider properties. + CloudProviderProfile *CloudProviderProfile `json:"cloudProviderProfile,omitempty"` + + // ControlPlane - ControlPlane Configuration + ControlPlane *ControlPlaneProfile `json:"controlPlane,omitempty"` + + // EnableRBAC - Whether to enable Kubernetes Role-Based Access Control. + EnableRbac *bool `json:"enableRbac,omitempty"` + + // Additional features specs like Arc Agent Onboarding. + Features *ProvisionedClustersCommonPropertiesFeatures `json:"features,omitempty"` + + // HttpProxyConfig - Configurations for provisioning the cluster with HTTP proxy servers. + HTTPProxyConfig *HTTPProxyConfig `json:"httpProxyConfig,omitempty"` + + // KubernetesVersion - Version of Kubernetes specified when creating the managed cluster. + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + + // LinuxProfile - The profile for Linux VMs in the Provisioned Cluster. + LinuxProfile *LinuxProfileProperties `json:"linuxProfile,omitempty"` + + // NetworkProfile - Profile of network configuration. + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + + // NodeResourceGroup - Name of the resource group containing agent pool nodes. + NodeResourceGroup *string `json:"nodeResourceGroup,omitempty"` + + // WindowsProfile - Profile for Windows VMs in the Provisioned Cluster. + WindowsProfile *WindowsProfile `json:"windowsProfile,omitempty"` + + // READ-ONLY + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; HybridAKSClusterStatus defines the observed state of HybridAKSCluster + Status *ProvisionedClustersCommonPropertiesStatus `json:"status,omitempty" azure:"ro"` +} + +// ProvisionedClustersClientBeginCreateOrUpdateOptions contains the optional parameters for the ProvisionedClustersClient.BeginCreateOrUpdate +// method. +type ProvisionedClustersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProvisionedClustersClientBeginUpdateOptions contains the optional parameters for the ProvisionedClustersClient.BeginUpdate +// method. +type ProvisionedClustersClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProvisionedClustersClientDeleteOptions contains the optional parameters for the ProvisionedClustersClient.Delete method. +type ProvisionedClustersClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProvisionedClustersClientGetOptions contains the optional parameters for the ProvisionedClustersClient.Get method. +type ProvisionedClustersClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProvisionedClustersClientListByResourceGroupOptions contains the optional parameters for the ProvisionedClustersClient.ListByResourceGroup +// method. +type ProvisionedClustersClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ProvisionedClustersClientListBySubscriptionOptions contains the optional parameters for the ProvisionedClustersClient.ListBySubscription +// method. +type ProvisionedClustersClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ProvisionedClustersCommonPropertiesFeatures - Additional features specs like Arc Agent Onboarding. +type ProvisionedClustersCommonPropertiesFeatures struct { + // Arc agentry configuration for the provisioned cluster. + ArcAgentProfile *ArcAgentProfile `json:"arcAgentProfile,omitempty"` +} + +// ProvisionedClustersCommonPropertiesStatus - HybridAKSClusterStatus defines the observed state of HybridAKSCluster +type ProvisionedClustersCommonPropertiesStatus struct { + // AddonStatus - Status of Addons + AddonStatus map[string]*AddonStatus `json:"addonStatus,omitempty"` + + // ErrorMessage - Error messages during creation of cluster + ErrorMessage *string `json:"errorMessage,omitempty"` + + // Additional features status like Arc Agent Onboarding. + FeaturesStatus *ProvisionedClustersCommonPropertiesStatusFeaturesStatus `json:"featuresStatus,omitempty"` + + // Contains Provisioning errors + ProvisioningStatus *ProvisionedClustersCommonPropertiesStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} + +// ProvisionedClustersCommonPropertiesStatusFeaturesStatus - Additional features status like Arc Agent Onboarding. +type ProvisionedClustersCommonPropertiesStatusFeaturesStatus struct { + // Defines the observed Arc Agent status that is resourceSynced back to the ARM resource. + ArcAgentStatus *ArcAgentStatus `json:"arcAgentStatus,omitempty"` +} + +// ProvisionedClustersCommonPropertiesStatusProvisioningStatus - Contains Provisioning errors +type ProvisionedClustersCommonPropertiesStatusProvisioningStatus struct { + Error *ProvisionedClustersCommonPropertiesStatusProvisioningStatusError `json:"error,omitempty"` + OperationID *string `json:"operationId,omitempty"` + + // Phase represents the current phase of cluster actuation. E.g. Pending, Running, Terminating, Failed etc. + Phase *string `json:"phase,omitempty"` + Status *string `json:"status,omitempty"` +} + +type ProvisionedClustersCommonPropertiesStatusProvisioningStatusError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +type ProvisionedClustersExtendedLocation struct { + // The extended location name. + Name *string `json:"name,omitempty"` + + // The extended location type. + Type *string `json:"type,omitempty"` +} + +// ProvisionedClustersPatch - The provisionedClusters resource patch definition. +type ProvisionedClustersPatch struct { + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// ProvisionedClustersResponse - The provisionedClusters resource definition. +type ProvisionedClustersResponse struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + ExtendedLocation *ProvisionedClustersResponseExtendedLocation `json:"extendedLocation,omitempty"` + + // Identity for the Provisioned cluster. + Identity *ProvisionedClusterIdentity `json:"identity,omitempty"` + Properties *ProvisionedClustersResponseProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +type ProvisionedClustersResponseExtendedLocation struct { + // The extended location name. + Name *string `json:"name,omitempty"` + + // The extended location type. + Type *string `json:"type,omitempty"` +} + +type ProvisionedClustersResponseListResult struct { + NextLink *string `json:"nextLink,omitempty"` + Value []*ProvisionedClustersResponse `json:"value,omitempty"` +} + +type ProvisionedClustersResponseProperties struct { + // AAD profile for the provisioned cluster. + AADProfile *AADProfileResponse `json:"aadProfile,omitempty"` + + // AddonProfiles - Profile of managed cluster add-on. + AddonProfiles map[string]*AddonProfiles `json:"addonProfiles,omitempty"` + + // The agent pools of the cluster. + AgentPoolProfiles []*NamedAgentPoolProfile `json:"agentPoolProfiles,omitempty"` + + // The underlying cloud infra provider properties. + CloudProviderProfile *CloudProviderProfile `json:"cloudProviderProfile,omitempty"` + + // ControlPlane - ControlPlane Configuration + ControlPlane *ControlPlaneProfile `json:"controlPlane,omitempty"` + + // EnableRBAC - Whether to enable Kubernetes Role-Based Access Control. + EnableRbac *bool `json:"enableRbac,omitempty"` + + // Additional features specs like Arc Agent Onboarding. + Features *ProvisionedClustersCommonPropertiesFeatures `json:"features,omitempty"` + + // HttpProxyConfig - Configurations for provisioning the cluster with HTTP proxy servers. + HTTPProxyConfig *HTTPProxyConfigResponse `json:"httpProxyConfig,omitempty"` + + // KubernetesVersion - Version of Kubernetes specified when creating the managed cluster. + KubernetesVersion *string `json:"kubernetesVersion,omitempty"` + + // LinuxProfile - The profile for Linux VMs in the Provisioned Cluster. + LinuxProfile *LinuxProfileProperties `json:"linuxProfile,omitempty"` + + // NetworkProfile - Profile of network configuration. + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + + // NodeResourceGroup - Name of the resource group containing agent pool nodes. + NodeResourceGroup *string `json:"nodeResourceGroup,omitempty"` + + // WindowsProfile - Profile for Windows VMs in the Provisioned Cluster. + WindowsProfile *WindowsProfileResponse `json:"windowsProfile,omitempty"` + + // READ-ONLY + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; HybridAKSClusterStatus defines the observed state of HybridAKSCluster + Status *ProvisionedClustersCommonPropertiesStatus `json:"status,omitempty" azure:"ro"` +} + +// ResourceProviderOperation - Results of the request to list operations. +type ResourceProviderOperation struct { + // Display metadata associated with the operation. + Display *ResourceProviderOperationDisplay `json:"display,omitempty"` + + // Indicates whether the operation applies to data-plane. + IsDataAction *string `json:"isDataAction,omitempty"` + + // Operation name, in format of {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` +} + +// ResourceProviderOperationDisplay - Display metadata associated with the operation. +type ResourceProviderOperationDisplay struct { + // Description of this operation. + Description *string `json:"description,omitempty"` + + // Type of operation: get, read, delete, etc. + Operation *string `json:"operation,omitempty"` + + // The resource provider. + Provider *string `json:"provider,omitempty"` + + // Resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// ResourceProviderOperationList - Results of the request to list operations. +type ResourceProviderOperationList struct { + NextLink *string `json:"nextLink,omitempty"` + Value []*ResourceProviderOperation `json:"value,omitempty"` +} + +// StorageSpaces - The storageSpaces resource definition. +type StorageSpaces struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + ExtendedLocation *StorageSpacesExtendedLocation `json:"extendedLocation,omitempty"` + + // HybridAKSStorageSpec defines the desired state of HybridAKSStorage + Properties *StorageSpacesProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// StorageSpacesClientBeginCreateOrUpdateOptions contains the optional parameters for the StorageSpacesClient.BeginCreateOrUpdate +// method. +type StorageSpacesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StorageSpacesClientBeginUpdateOptions contains the optional parameters for the StorageSpacesClient.BeginUpdate method. +type StorageSpacesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StorageSpacesClientDeleteOptions contains the optional parameters for the StorageSpacesClient.Delete method. +type StorageSpacesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// StorageSpacesClientListByResourceGroupOptions contains the optional parameters for the StorageSpacesClient.ListByResourceGroup +// method. +type StorageSpacesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// StorageSpacesClientListBySubscriptionOptions contains the optional parameters for the StorageSpacesClient.ListBySubscription +// method. +type StorageSpacesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// StorageSpacesClientRetrieveOptions contains the optional parameters for the StorageSpacesClient.Retrieve method. +type StorageSpacesClientRetrieveOptions struct { + // placeholder for future optional parameters +} + +type StorageSpacesExtendedLocation struct { + // The extended location name. + Name *string `json:"name,omitempty"` + + // The extended location type. + Type *string `json:"type,omitempty"` +} + +type StorageSpacesListResult struct { + NextLink *string `json:"nextLink,omitempty"` + Value []*StorageSpaces `json:"value,omitempty"` +} + +// StorageSpacesPatch - The storageSpaces resource patch definition. +type StorageSpacesPatch struct { + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// StorageSpacesProperties - HybridAKSStorageSpec defines the desired state of HybridAKSStorage +type StorageSpacesProperties struct { + HciStorageProfile *StorageSpacesPropertiesHciStorageProfile `json:"hciStorageProfile,omitempty"` + + // HybridAKSStorageStatus defines the observed state of HybridAKSStorage + Status *StorageSpacesPropertiesStatus `json:"status,omitempty"` + VmwareStorageProfile *StorageSpacesPropertiesVmwareStorageProfile `json:"vmwareStorageProfile,omitempty"` + + // READ-ONLY + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +type StorageSpacesPropertiesHciStorageProfile struct { + // Resource group in MOC(Microsoft On-premises Cloud) + MocGroup *string `json:"mocGroup,omitempty"` + + // Location in MOC(Microsoft On-premises Cloud) + MocLocation *string `json:"mocLocation,omitempty"` + + // Name of the storage container in MOC(Microsoft On-premises Cloud) + MocStorageContainer *string `json:"mocStorageContainer,omitempty"` +} + +// StorageSpacesPropertiesStatus - HybridAKSStorageStatus defines the observed state of HybridAKSStorage +type StorageSpacesPropertiesStatus struct { + // Contains Provisioning errors + ProvisioningStatus *StorageSpacesPropertiesStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} + +// StorageSpacesPropertiesStatusProvisioningStatus - Contains Provisioning errors +type StorageSpacesPropertiesStatusProvisioningStatus struct { + Error *StorageSpacesPropertiesStatusProvisioningStatusError `json:"error,omitempty"` + OperationID *string `json:"operationId,omitempty"` + + // Phase represents the current phase of cluster actuation. E.g. Pending, Running, Terminating, Failed etc. + Phase *string `json:"phase,omitempty"` + Status *string `json:"status,omitempty"` +} + +type StorageSpacesPropertiesStatusProvisioningStatusError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +type StorageSpacesPropertiesVmwareStorageProfile struct { + // Name of the datacenter in VSphere + Datacenter *string `json:"datacenter,omitempty"` + + // Name of the datastore in VSphere + Datastore *string `json:"datastore,omitempty"` + + // Name of the folder in VSphere + Folder *string `json:"folder,omitempty"` + + // Name of the resource pool in VSphere + ResourcePool *string `json:"resourcePool,omitempty"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// VMSKUListResult - The list of supported VM SKUs. +type VMSKUListResult struct { + // READ-ONLY; Resource Id + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource Name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource Type + Type *string `json:"type,omitempty" azure:"ro"` + + // READ-ONLY; Supported VM SKUs. + VMSKUs []*string `json:"vmSKUs,omitempty" azure:"ro"` +} + +// VirtualNetworks - The virtualNetworks resource definition. +type VirtualNetworks struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + ExtendedLocation *VirtualNetworksExtendedLocation `json:"extendedLocation,omitempty"` + + // HybridAKSNetworkSpec defines the desired state of HybridAKSNetwork + Properties *VirtualNetworksProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// VirtualNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreateOrUpdate +// method. +type VirtualNetworksClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualNetworksClientBeginUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginUpdate method. +type VirtualNetworksClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualNetworksClientDeleteOptions contains the optional parameters for the VirtualNetworksClient.Delete method. +type VirtualNetworksClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.ListByResourceGroup +// method. +type VirtualNetworksClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientListBySubscriptionOptions contains the optional parameters for the VirtualNetworksClient.ListBySubscription +// method. +type VirtualNetworksClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// VirtualNetworksClientRetrieveOptions contains the optional parameters for the VirtualNetworksClient.Retrieve method. +type VirtualNetworksClientRetrieveOptions struct { + // placeholder for future optional parameters +} + +type VirtualNetworksExtendedLocation struct { + // The extended location name. + Name *string `json:"name,omitempty"` + + // The extended location type. + Type *string `json:"type,omitempty"` +} + +type VirtualNetworksListResult struct { + NextLink *string `json:"nextLink,omitempty"` + Value []*VirtualNetworks `json:"value,omitempty"` +} + +// VirtualNetworksPatch - The virtualNetworks resource patch definition. +type VirtualNetworksPatch struct { + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// VirtualNetworksProperties - HybridAKSNetworkSpec defines the desired state of HybridAKSNetwork +type VirtualNetworksProperties struct { + InfraVnetProfile *VirtualNetworksPropertiesInfraVnetProfile `json:"infraVnetProfile,omitempty"` + + // Virtual IP Pool for Kubernetes + VipPool []*VirtualNetworksPropertiesVipPoolItem `json:"vipPool,omitempty"` + + // IP Pool for Virtual Machines + VmipPool []*VirtualNetworksPropertiesVmipPoolItem `json:"vmipPool,omitempty"` + + // READ-ONLY; Address of the DNS servers associated with the network + DNSServers []*string `json:"dnsServers,omitempty" azure:"ro"` + + // READ-ONLY; Address of the DHCP servers associated with the network + DhcpServers []*string `json:"dhcpServers,omitempty" azure:"ro"` + + // READ-ONLY; Address of the Gateway associated with the network + Gateway *string `json:"gateway,omitempty" azure:"ro"` + + // READ-ONLY; IP Address Prefix of the network + IPAddressPrefix *string `json:"ipAddressPrefix,omitempty" azure:"ro"` + + // READ-ONLY + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; HybridAKSNetworkStatus defines the observed state of HybridAKSNetwork + Status *VirtualNetworksPropertiesStatus `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; VLAN Id used by the network + VlanID *string `json:"vlanID,omitempty" azure:"ro"` +} + +type VirtualNetworksPropertiesInfraVnetProfile struct { + // Infra network profile for HCI platform + Hci *VirtualNetworksPropertiesInfraVnetProfileHci `json:"hci,omitempty"` + + // Infra network profile for KubeVirt platform + Kubevirt *VirtualNetworksPropertiesInfraVnetProfileKubevirt `json:"kubevirt,omitempty"` + + // Infra network profile for VMware platform + Vmware *VirtualNetworksPropertiesInfraVnetProfileVmware `json:"vmware,omitempty"` +} + +// VirtualNetworksPropertiesInfraVnetProfileHci - Infra network profile for HCI platform +type VirtualNetworksPropertiesInfraVnetProfileHci struct { + // Resource group in MOC(Microsoft On-premises Cloud) + MocGroup *string `json:"mocGroup,omitempty"` + + // Location in MOC(Microsoft On-premises Cloud) + MocLocation *string `json:"mocLocation,omitempty"` + + // Virtual Network name in MOC(Microsoft On-premises Cloud) + MocVnetName *string `json:"mocVnetName,omitempty"` +} + +// VirtualNetworksPropertiesInfraVnetProfileKubevirt - Infra network profile for KubeVirt platform +type VirtualNetworksPropertiesInfraVnetProfileKubevirt struct { + // Name of the network in KubeVirt + VnetName *string `json:"vnetName,omitempty"` +} + +// VirtualNetworksPropertiesInfraVnetProfileVmware - Infra network profile for VMware platform +type VirtualNetworksPropertiesInfraVnetProfileVmware struct { + // Name of the network segment in VSphere + SegmentName *string `json:"segmentName,omitempty"` +} + +// VirtualNetworksPropertiesStatus - HybridAKSNetworkStatus defines the observed state of HybridAKSNetwork +type VirtualNetworksPropertiesStatus struct { + // Contains Provisioning errors + ProvisioningStatus *VirtualNetworksPropertiesStatusProvisioningStatus `json:"provisioningStatus,omitempty"` +} + +// VirtualNetworksPropertiesStatusProvisioningStatus - Contains Provisioning errors +type VirtualNetworksPropertiesStatusProvisioningStatus struct { + Error *VirtualNetworksPropertiesStatusProvisioningStatusError `json:"error,omitempty"` + OperationID *string `json:"operationId,omitempty"` + + // Phase represents the current phase of cluster actuation. E.g. Pending, Running, Terminating, Failed etc. + Phase *string `json:"phase,omitempty"` + Status *string `json:"status,omitempty"` +} + +type VirtualNetworksPropertiesStatusProvisioningStatusError struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` +} + +type VirtualNetworksPropertiesVipPoolItem struct { + // Ending IP address for the IP Pool + EndIP *string `json:"endIP,omitempty"` + + // Starting IP address for the IP Pool + StartIP *string `json:"startIP,omitempty"` +} + +type VirtualNetworksPropertiesVmipPoolItem struct { + // Ending IP address for the IP Pool + EndIP *string `json:"endIP,omitempty"` + + // Starting IP address for the IP Pool + StartIP *string `json:"startIP,omitempty"` +} + +// WindowsProfile - Profile for Windows VMs in the container service cluster. +type WindowsProfile struct { + // AdminPassword - Specifies the password of the administrator account. + // Minimum-length: 8 characters + // Max-length: 123 characters + // Complexity requirements: 3 out of 4 conditions below need to be fulfilled + // Has lower characters + // Has upper characters + // Has a digit + // Has a special character (Regex match [\W_]) + // Disallowed values: "abc@123", "P@$$w0rd", "P@ssw0rd", "P@ssword123", "Pa$$word", "pass@word1", "Password!", "Password1", + // "Password22", "iloveyou!" + AdminPassword *string `json:"adminPassword,omitempty"` + + // AdminUsername - Specifies the name of the administrator account. + // restriction: Cannot end in "." + // Disallowed values: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", + // "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", + // "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". + // Minimum-length: 1 character + // Max-length: 20 characters + AdminUsername *string `json:"adminUsername,omitempty"` + + // EnableCSIProxy - Whether to enable CSI proxy. + EnableCsiProxy *bool `json:"enableCsiProxy,omitempty"` + + // LicenseType - The licenseType to use for Windows VMs. WindowsServer is used to enable Azure Hybrid User Benefits for Windows + // VMs. Possible values include: 'None', 'WindowsServer' + LicenseType *LicenseType `json:"licenseType,omitempty"` +} + +// WindowsProfileResponse - Profile for Windows VMs in the container service cluster. +type WindowsProfileResponse struct { + // AdminUsername - Specifies the name of the administrator account. + // restriction: Cannot end in "." + // Disallowed values: "administrator", "admin", "user", "user1", "test", "user2", "test1", "user3", "admin1", "1", "123", + // "a", "actuser", "adm", "admin2", "aspnet", "backup", "console", "david", "guest", + // "john", "owner", "root", "server", "sql", "support", "support_388945a0", "sys", "test2", "test3", "user4", "user5". + // Minimum-length: 1 character + // Max-length: 20 characters + AdminUsername *string `json:"adminUsername,omitempty"` + + // EnableCSIProxy - Whether to enable CSI proxy. + EnableCsiProxy *bool `json:"enableCsiProxy,omitempty"` + + // LicenseType - The licenseType to use for Windows VMs. WindowsServer is used to enable Azure Hybrid User Benefits for Windows + // VMs. Possible values include: 'None', 'WindowsServer' + LicenseType *LicenseType `json:"licenseType,omitempty"` +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/models_serde.go b/sdk/resourcemanager/hybridaks/armhybridaks/models_serde.go new file mode 100644 index 000000000000..b7bf34cbb01c --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/models_serde.go @@ -0,0 +1,3112 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AADProfile. +func (a AADProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adminGroupObjectIDs", a.AdminGroupObjectIDs) + populate(objectMap, "clientAppID", a.ClientAppID) + populate(objectMap, "enableAzureRbac", a.EnableAzureRbac) + populate(objectMap, "managed", a.Managed) + populate(objectMap, "serverAppID", a.ServerAppID) + populate(objectMap, "serverAppSecret", a.ServerAppSecret) + populate(objectMap, "tenantID", a.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AADProfile. +func (a *AADProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adminGroupObjectIDs": + err = unpopulate(val, "AdminGroupObjectIDs", &a.AdminGroupObjectIDs) + delete(rawMsg, key) + case "clientAppID": + err = unpopulate(val, "ClientAppID", &a.ClientAppID) + delete(rawMsg, key) + case "enableAzureRbac": + err = unpopulate(val, "EnableAzureRbac", &a.EnableAzureRbac) + delete(rawMsg, key) + case "managed": + err = unpopulate(val, "Managed", &a.Managed) + delete(rawMsg, key) + case "serverAppID": + err = unpopulate(val, "ServerAppID", &a.ServerAppID) + delete(rawMsg, key) + case "serverAppSecret": + err = unpopulate(val, "ServerAppSecret", &a.ServerAppSecret) + delete(rawMsg, key) + case "tenantID": + err = unpopulate(val, "TenantID", &a.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AADProfileResponse. +func (a AADProfileResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adminGroupObjectIDs", a.AdminGroupObjectIDs) + populate(objectMap, "clientAppID", a.ClientAppID) + populate(objectMap, "enableAzureRbac", a.EnableAzureRbac) + populate(objectMap, "managed", a.Managed) + populate(objectMap, "serverAppID", a.ServerAppID) + populate(objectMap, "tenantID", a.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AADProfileResponse. +func (a *AADProfileResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adminGroupObjectIDs": + err = unpopulate(val, "AdminGroupObjectIDs", &a.AdminGroupObjectIDs) + delete(rawMsg, key) + case "clientAppID": + err = unpopulate(val, "ClientAppID", &a.ClientAppID) + delete(rawMsg, key) + case "enableAzureRbac": + err = unpopulate(val, "EnableAzureRbac", &a.EnableAzureRbac) + delete(rawMsg, key) + case "managed": + err = unpopulate(val, "Managed", &a.Managed) + delete(rawMsg, key) + case "serverAppID": + err = unpopulate(val, "ServerAppID", &a.ServerAppID) + delete(rawMsg, key) + case "tenantID": + err = unpopulate(val, "TenantID", &a.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AddonProfiles. +func (a AddonProfiles) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "config", a.Config) + populate(objectMap, "enabled", a.Enabled) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddonProfiles. +func (a *AddonProfiles) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "config": + err = unpopulate(val, "Config", &a.Config) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &a.Enabled) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AddonStatus. +func (a AddonStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "errorMessage", a.ErrorMessage) + populate(objectMap, "phase", a.Phase) + populate(objectMap, "ready", a.Ready) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AddonStatus. +func (a *AddonStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &a.ErrorMessage) + delete(rawMsg, key) + case "phase": + err = unpopulate(val, "Phase", &a.Phase) + delete(rawMsg, key) + case "ready": + err = unpopulate(val, "Ready", &a.Ready) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPool. +func (a AgentPool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", a.ExtendedLocation) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPool. +func (a *AgentPool) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &a.ExtendedLocation) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolExtendedLocation. +func (a AgentPoolExtendedLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", a.Name) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolExtendedLocation. +func (a *AgentPoolExtendedLocation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolListResult. +func (a AgentPoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolListResult. +func (a *AgentPoolListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolProperties. +func (a AgentPoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityZones", a.AvailabilityZones) + populate(objectMap, "cloudProviderProfile", a.CloudProviderProfile) + populate(objectMap, "count", a.Count) + populate(objectMap, "maxCount", a.MaxCount) + populate(objectMap, "maxPods", a.MaxPods) + populate(objectMap, "minCount", a.MinCount) + populate(objectMap, "mode", a.Mode) + populate(objectMap, "nodeImageVersion", a.NodeImageVersion) + populate(objectMap, "nodeLabels", a.NodeLabels) + populate(objectMap, "nodeTaints", a.NodeTaints) + populate(objectMap, "osType", a.OSType) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "status", a.Status) + populate(objectMap, "vmSize", a.VMSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolProperties. +func (a *AgentPoolProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availabilityZones": + err = unpopulate(val, "AvailabilityZones", &a.AvailabilityZones) + delete(rawMsg, key) + case "cloudProviderProfile": + err = unpopulate(val, "CloudProviderProfile", &a.CloudProviderProfile) + delete(rawMsg, key) + case "count": + err = unpopulate(val, "Count", &a.Count) + delete(rawMsg, key) + case "maxCount": + err = unpopulate(val, "MaxCount", &a.MaxCount) + delete(rawMsg, key) + case "maxPods": + err = unpopulate(val, "MaxPods", &a.MaxPods) + delete(rawMsg, key) + case "minCount": + err = unpopulate(val, "MinCount", &a.MinCount) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &a.Mode) + delete(rawMsg, key) + case "nodeImageVersion": + err = unpopulate(val, "NodeImageVersion", &a.NodeImageVersion) + delete(rawMsg, key) + case "nodeLabels": + err = unpopulate(val, "NodeLabels", &a.NodeLabels) + delete(rawMsg, key) + case "nodeTaints": + err = unpopulate(val, "NodeTaints", &a.NodeTaints) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &a.OSType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "vmSize": + err = unpopulate(val, "VMSize", &a.VMSize) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolProvisioningStatusError. +func (a AgentPoolProvisioningStatusError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", a.Code) + populate(objectMap, "message", a.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolProvisioningStatusError. +func (a *AgentPoolProvisioningStatusError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &a.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &a.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolProvisioningStatusStatus. +func (a AgentPoolProvisioningStatusStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "errorMessage", a.ErrorMessage) + populate(objectMap, "provisioningStatus", a.ProvisioningStatus) + populate(objectMap, "readyReplicas", a.ReadyReplicas) + populate(objectMap, "replicas", a.Replicas) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolProvisioningStatusStatus. +func (a *AgentPoolProvisioningStatusStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &a.ErrorMessage) + delete(rawMsg, key) + case "provisioningStatus": + err = unpopulate(val, "ProvisioningStatus", &a.ProvisioningStatus) + delete(rawMsg, key) + case "readyReplicas": + err = unpopulate(val, "ReadyReplicas", &a.ReadyReplicas) + delete(rawMsg, key) + case "replicas": + err = unpopulate(val, "Replicas", &a.Replicas) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPoolProvisioningStatusStatusProvisioningStatus. +func (a AgentPoolProvisioningStatusStatusProvisioningStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", a.Error) + populate(objectMap, "operationId", a.OperationID) + populate(objectMap, "phase", a.Phase) + populate(objectMap, "status", a.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPoolProvisioningStatusStatusProvisioningStatus. +func (a *AgentPoolProvisioningStatusStatusProvisioningStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &a.Error) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &a.OperationID) + delete(rawMsg, key) + case "phase": + err = unpopulate(val, "Phase", &a.Phase) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ArcAgentProfile. +func (a ArcAgentProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentAutoUpgrade", a.AgentAutoUpgrade) + populate(objectMap, "agentVersion", a.AgentVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArcAgentProfile. +func (a *ArcAgentProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentAutoUpgrade": + err = unpopulate(val, "AgentAutoUpgrade", &a.AgentAutoUpgrade) + delete(rawMsg, key) + case "agentVersion": + err = unpopulate(val, "AgentVersion", &a.AgentVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ArcAgentStatus. +func (a ArcAgentStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentVersion", a.AgentVersion) + populate(objectMap, "coreCount", a.CoreCount) + populate(objectMap, "deploymentState", a.DeploymentState) + populate(objectMap, "errorMessage", a.ErrorMessage) + populateTimeRFC3339(objectMap, "lastConnectivityTime", a.LastConnectivityTime) + populateTimeRFC3339(objectMap, "managedIdentityCertificateExpirationTime", a.ManagedIdentityCertificateExpirationTime) + populate(objectMap, "onboardingPublicKey", a.OnboardingPublicKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ArcAgentStatus. +func (a *ArcAgentStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentVersion": + err = unpopulate(val, "AgentVersion", &a.AgentVersion) + delete(rawMsg, key) + case "coreCount": + err = unpopulate(val, "CoreCount", &a.CoreCount) + delete(rawMsg, key) + case "deploymentState": + err = unpopulate(val, "DeploymentState", &a.DeploymentState) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &a.ErrorMessage) + delete(rawMsg, key) + case "lastConnectivityTime": + err = unpopulateTimeRFC3339(val, "LastConnectivityTime", &a.LastConnectivityTime) + delete(rawMsg, key) + case "managedIdentityCertificateExpirationTime": + err = unpopulateTimeRFC3339(val, "ManagedIdentityCertificateExpirationTime", &a.ManagedIdentityCertificateExpirationTime) + delete(rawMsg, key) + case "onboardingPublicKey": + err = unpopulate(val, "OnboardingPublicKey", &a.OnboardingPublicKey) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CloudProviderProfile. +func (c CloudProviderProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "infraNetworkProfile", c.InfraNetworkProfile) + populate(objectMap, "infraStorageProfile", c.InfraStorageProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudProviderProfile. +func (c *CloudProviderProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "infraNetworkProfile": + err = unpopulate(val, "InfraNetworkProfile", &c.InfraNetworkProfile) + delete(rawMsg, key) + case "infraStorageProfile": + err = unpopulate(val, "InfraStorageProfile", &c.InfraStorageProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CloudProviderProfileInfraNetworkProfile. +func (c CloudProviderProfileInfraNetworkProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "vnetSubnetIds", c.VnetSubnetIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudProviderProfileInfraNetworkProfile. +func (c *CloudProviderProfileInfraNetworkProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "vnetSubnetIds": + err = unpopulate(val, "VnetSubnetIDs", &c.VnetSubnetIDs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CloudProviderProfileInfraStorageProfile. +func (c CloudProviderProfileInfraStorageProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "storageSpaceIds", c.StorageSpaceIDs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudProviderProfileInfraStorageProfile. +func (c *CloudProviderProfileInfraStorageProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "storageSpaceIds": + err = unpopulate(val, "StorageSpaceIDs", &c.StorageSpaceIDs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ControlPlaneEndpointProfileControlPlaneEndpoint. +func (c ControlPlaneEndpointProfileControlPlaneEndpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hostIP", c.HostIP) + populate(objectMap, "port", c.Port) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ControlPlaneEndpointProfileControlPlaneEndpoint. +func (c *ControlPlaneEndpointProfileControlPlaneEndpoint) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hostIP": + err = unpopulate(val, "HostIP", &c.HostIP) + delete(rawMsg, key) + case "port": + err = unpopulate(val, "Port", &c.Port) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ControlPlaneProfile. +func (c ControlPlaneProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityZones", c.AvailabilityZones) + populate(objectMap, "cloudProviderProfile", c.CloudProviderProfile) + populate(objectMap, "controlPlaneEndpoint", c.ControlPlaneEndpoint) + populate(objectMap, "count", c.Count) + populate(objectMap, "linuxProfile", c.LinuxProfile) + populate(objectMap, "maxCount", c.MaxCount) + populate(objectMap, "maxPods", c.MaxPods) + populate(objectMap, "minCount", c.MinCount) + populate(objectMap, "mode", c.Mode) + populate(objectMap, "name", c.Name) + populate(objectMap, "nodeImageVersion", c.NodeImageVersion) + populate(objectMap, "nodeLabels", c.NodeLabels) + populate(objectMap, "nodeTaints", c.NodeTaints) + populate(objectMap, "osType", c.OSType) + populate(objectMap, "vmSize", c.VMSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ControlPlaneProfile. +func (c *ControlPlaneProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availabilityZones": + err = unpopulate(val, "AvailabilityZones", &c.AvailabilityZones) + delete(rawMsg, key) + case "cloudProviderProfile": + err = unpopulate(val, "CloudProviderProfile", &c.CloudProviderProfile) + delete(rawMsg, key) + case "controlPlaneEndpoint": + err = unpopulate(val, "ControlPlaneEndpoint", &c.ControlPlaneEndpoint) + delete(rawMsg, key) + case "count": + err = unpopulate(val, "Count", &c.Count) + delete(rawMsg, key) + case "linuxProfile": + err = unpopulate(val, "LinuxProfile", &c.LinuxProfile) + delete(rawMsg, key) + case "maxCount": + err = unpopulate(val, "MaxCount", &c.MaxCount) + delete(rawMsg, key) + case "maxPods": + err = unpopulate(val, "MaxPods", &c.MaxPods) + delete(rawMsg, key) + case "minCount": + err = unpopulate(val, "MinCount", &c.MinCount) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &c.Mode) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "nodeImageVersion": + err = unpopulate(val, "NodeImageVersion", &c.NodeImageVersion) + delete(rawMsg, key) + case "nodeLabels": + err = unpopulate(val, "NodeLabels", &c.NodeLabels) + delete(rawMsg, key) + case "nodeTaints": + err = unpopulate(val, "NodeTaints", &c.NodeTaints) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &c.OSType) + delete(rawMsg, key) + case "vmSize": + err = unpopulate(val, "VMSize", &c.VMSize) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPProxyConfig. +func (h HTTPProxyConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "httpProxy", h.HTTPProxy) + populate(objectMap, "httpsProxy", h.HTTPSProxy) + populate(objectMap, "noProxy", h.NoProxy) + populate(objectMap, "password", h.Password) + populate(objectMap, "trustedCa", h.TrustedCa) + populate(objectMap, "username", h.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPProxyConfig. +func (h *HTTPProxyConfig) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "httpProxy": + err = unpopulate(val, "HTTPProxy", &h.HTTPProxy) + delete(rawMsg, key) + case "httpsProxy": + err = unpopulate(val, "HTTPSProxy", &h.HTTPSProxy) + delete(rawMsg, key) + case "noProxy": + err = unpopulate(val, "NoProxy", &h.NoProxy) + delete(rawMsg, key) + case "password": + err = unpopulate(val, "Password", &h.Password) + delete(rawMsg, key) + case "trustedCa": + err = unpopulate(val, "TrustedCa", &h.TrustedCa) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &h.Username) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPProxyConfigResponse. +func (h HTTPProxyConfigResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "httpProxy", h.HTTPProxy) + populate(objectMap, "httpsProxy", h.HTTPSProxy) + populate(objectMap, "noProxy", h.NoProxy) + populate(objectMap, "trustedCa", h.TrustedCa) + populate(objectMap, "username", h.Username) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HTTPProxyConfigResponse. +func (h *HTTPProxyConfigResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "httpProxy": + err = unpopulate(val, "HTTPProxy", &h.HTTPProxy) + delete(rawMsg, key) + case "httpsProxy": + err = unpopulate(val, "HTTPSProxy", &h.HTTPSProxy) + delete(rawMsg, key) + case "noProxy": + err = unpopulate(val, "NoProxy", &h.NoProxy) + delete(rawMsg, key) + case "trustedCa": + err = unpopulate(val, "TrustedCa", &h.TrustedCa) + delete(rawMsg, key) + case "username": + err = unpopulate(val, "Username", &h.Username) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HybridIdentityMetadata. +func (h HybridIdentityMetadata) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", h.ID) + populate(objectMap, "name", h.Name) + populate(objectMap, "properties", h.Properties) + populate(objectMap, "systemData", h.SystemData) + populate(objectMap, "type", h.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HybridIdentityMetadata. +func (h *HybridIdentityMetadata) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &h.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &h.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &h.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &h.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &h.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HybridIdentityMetadataList. +func (h HybridIdentityMetadataList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", h.NextLink) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HybridIdentityMetadataList. +func (h *HybridIdentityMetadataList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &h.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &h.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HybridIdentityMetadataProperties. +func (h HybridIdentityMetadataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", h.Identity) + populate(objectMap, "provisioningState", h.ProvisioningState) + populate(objectMap, "publicKey", h.PublicKey) + populate(objectMap, "resourceUid", h.ResourceUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HybridIdentityMetadataProperties. +func (h *HybridIdentityMetadataProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &h.Identity) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &h.ProvisioningState) + delete(rawMsg, key) + case "publicKey": + err = unpopulate(val, "PublicKey", &h.PublicKey) + delete(rawMsg, key) + case "resourceUid": + err = unpopulate(val, "ResourceUID", &h.ResourceUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinuxProfileProperties. +func (l LinuxProfileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adminUsername", l.AdminUsername) + populate(objectMap, "ssh", l.SSH) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinuxProfileProperties. +func (l *LinuxProfileProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adminUsername": + err = unpopulate(val, "AdminUsername", &l.AdminUsername) + delete(rawMsg, key) + case "ssh": + err = unpopulate(val, "SSH", &l.SSH) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinuxProfilePropertiesSSH. +func (l LinuxProfilePropertiesSSH) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "publicKeys", l.PublicKeys) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinuxProfilePropertiesSSH. +func (l *LinuxProfilePropertiesSSH) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "publicKeys": + err = unpopulate(val, "PublicKeys", &l.PublicKeys) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LinuxProfilePropertiesSSHPublicKeysItem. +func (l LinuxProfilePropertiesSSHPublicKeysItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "keyData", l.KeyData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LinuxProfilePropertiesSSHPublicKeysItem. +func (l *LinuxProfilePropertiesSSHPublicKeysItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyData": + err = unpopulate(val, "KeyData", &l.KeyData) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type LoadBalancerProfile. +func (l LoadBalancerProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityZones", l.AvailabilityZones) + populate(objectMap, "cloudProviderProfile", l.CloudProviderProfile) + populate(objectMap, "count", l.Count) + populate(objectMap, "linuxProfile", l.LinuxProfile) + populate(objectMap, "maxCount", l.MaxCount) + populate(objectMap, "maxPods", l.MaxPods) + populate(objectMap, "minCount", l.MinCount) + populate(objectMap, "mode", l.Mode) + populate(objectMap, "name", l.Name) + populate(objectMap, "nodeImageVersion", l.NodeImageVersion) + populate(objectMap, "nodeLabels", l.NodeLabels) + populate(objectMap, "nodeTaints", l.NodeTaints) + populate(objectMap, "osType", l.OSType) + populate(objectMap, "vmSize", l.VMSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadBalancerProfile. +func (l *LoadBalancerProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availabilityZones": + err = unpopulate(val, "AvailabilityZones", &l.AvailabilityZones) + delete(rawMsg, key) + case "cloudProviderProfile": + err = unpopulate(val, "CloudProviderProfile", &l.CloudProviderProfile) + delete(rawMsg, key) + case "count": + err = unpopulate(val, "Count", &l.Count) + delete(rawMsg, key) + case "linuxProfile": + err = unpopulate(val, "LinuxProfile", &l.LinuxProfile) + delete(rawMsg, key) + case "maxCount": + err = unpopulate(val, "MaxCount", &l.MaxCount) + delete(rawMsg, key) + case "maxPods": + err = unpopulate(val, "MaxPods", &l.MaxPods) + delete(rawMsg, key) + case "minCount": + err = unpopulate(val, "MinCount", &l.MinCount) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &l.Mode) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &l.Name) + delete(rawMsg, key) + case "nodeImageVersion": + err = unpopulate(val, "NodeImageVersion", &l.NodeImageVersion) + delete(rawMsg, key) + case "nodeLabels": + err = unpopulate(val, "NodeLabels", &l.NodeLabels) + delete(rawMsg, key) + case "nodeTaints": + err = unpopulate(val, "NodeTaints", &l.NodeTaints) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &l.OSType) + delete(rawMsg, key) + case "vmSize": + err = unpopulate(val, "VMSize", &l.VMSize) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NamedAgentPoolProfile. +func (n NamedAgentPoolProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "availabilityZones", n.AvailabilityZones) + populate(objectMap, "cloudProviderProfile", n.CloudProviderProfile) + populate(objectMap, "count", n.Count) + populate(objectMap, "maxCount", n.MaxCount) + populate(objectMap, "maxPods", n.MaxPods) + populate(objectMap, "minCount", n.MinCount) + populate(objectMap, "mode", n.Mode) + populate(objectMap, "name", n.Name) + populate(objectMap, "nodeImageVersion", n.NodeImageVersion) + populate(objectMap, "nodeLabels", n.NodeLabels) + populate(objectMap, "nodeTaints", n.NodeTaints) + populate(objectMap, "osType", n.OSType) + populate(objectMap, "vmSize", n.VMSize) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NamedAgentPoolProfile. +func (n *NamedAgentPoolProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availabilityZones": + err = unpopulate(val, "AvailabilityZones", &n.AvailabilityZones) + delete(rawMsg, key) + case "cloudProviderProfile": + err = unpopulate(val, "CloudProviderProfile", &n.CloudProviderProfile) + delete(rawMsg, key) + case "count": + err = unpopulate(val, "Count", &n.Count) + delete(rawMsg, key) + case "maxCount": + err = unpopulate(val, "MaxCount", &n.MaxCount) + delete(rawMsg, key) + case "maxPods": + err = unpopulate(val, "MaxPods", &n.MaxPods) + delete(rawMsg, key) + case "minCount": + err = unpopulate(val, "MinCount", &n.MinCount) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &n.Mode) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "nodeImageVersion": + err = unpopulate(val, "NodeImageVersion", &n.NodeImageVersion) + delete(rawMsg, key) + case "nodeLabels": + err = unpopulate(val, "NodeLabels", &n.NodeLabels) + delete(rawMsg, key) + case "nodeTaints": + err = unpopulate(val, "NodeTaints", &n.NodeTaints) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &n.OSType) + delete(rawMsg, key) + case "vmSize": + err = unpopulate(val, "VMSize", &n.VMSize) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkProfile. +func (n NetworkProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dnsServiceIP", n.DNSServiceIP) + populate(objectMap, "loadBalancerProfile", n.LoadBalancerProfile) + populate(objectMap, "loadBalancerSku", n.LoadBalancerSKU) + populate(objectMap, "networkPolicy", n.NetworkPolicy) + populate(objectMap, "podCidr", n.PodCidr) + populate(objectMap, "podCidrs", n.PodCidrs) + populate(objectMap, "serviceCidr", n.ServiceCidr) + populate(objectMap, "serviceCidrs", n.ServiceCidrs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkProfile. +func (n *NetworkProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dnsServiceIP": + err = unpopulate(val, "DNSServiceIP", &n.DNSServiceIP) + delete(rawMsg, key) + case "loadBalancerProfile": + err = unpopulate(val, "LoadBalancerProfile", &n.LoadBalancerProfile) + delete(rawMsg, key) + case "loadBalancerSku": + err = unpopulate(val, "LoadBalancerSKU", &n.LoadBalancerSKU) + delete(rawMsg, key) + case "networkPolicy": + err = unpopulate(val, "NetworkPolicy", &n.NetworkPolicy) + delete(rawMsg, key) + case "podCidr": + err = unpopulate(val, "PodCidr", &n.PodCidr) + delete(rawMsg, key) + case "podCidrs": + err = unpopulate(val, "PodCidrs", &n.PodCidrs) + delete(rawMsg, key) + case "serviceCidr": + err = unpopulate(val, "ServiceCidr", &n.ServiceCidr) + delete(rawMsg, key) + case "serviceCidrs": + err = unpopulate(val, "ServiceCidrs", &n.ServiceCidrs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrchestratorProfile. +func (o OrchestratorProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "isPreview", o.IsPreview) + populate(objectMap, "orchestratorType", o.OrchestratorType) + populate(objectMap, "orchestratorVersion", o.OrchestratorVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrchestratorProfile. +func (o *OrchestratorProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "isPreview": + err = unpopulate(val, "IsPreview", &o.IsPreview) + delete(rawMsg, key) + case "orchestratorType": + err = unpopulate(val, "OrchestratorType", &o.OrchestratorType) + delete(rawMsg, key) + case "orchestratorVersion": + err = unpopulate(val, "OrchestratorVersion", &o.OrchestratorVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrchestratorVersionProfile. +func (o OrchestratorVersionProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "default", o.Default) + populate(objectMap, "isPreview", o.IsPreview) + populate(objectMap, "orchestratorType", o.OrchestratorType) + populate(objectMap, "orchestratorVersion", o.OrchestratorVersion) + populate(objectMap, "upgrades", o.Upgrades) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrchestratorVersionProfile. +func (o *OrchestratorVersionProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "default": + err = unpopulate(val, "Default", &o.Default) + delete(rawMsg, key) + case "isPreview": + err = unpopulate(val, "IsPreview", &o.IsPreview) + delete(rawMsg, key) + case "orchestratorType": + err = unpopulate(val, "OrchestratorType", &o.OrchestratorType) + delete(rawMsg, key) + case "orchestratorVersion": + err = unpopulate(val, "OrchestratorVersion", &o.OrchestratorVersion) + delete(rawMsg, key) + case "upgrades": + err = unpopulate(val, "Upgrades", &o.Upgrades) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OrchestratorVersionProfileListResult. +func (o OrchestratorVersionProfileListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "orchestrators", o.Orchestrators) + populate(objectMap, "type", o.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OrchestratorVersionProfileListResult. +func (o *OrchestratorVersionProfileListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "orchestrators": + err = unpopulate(val, "Orchestrators", &o.Orchestrators) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &o.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClusterIdentity. +func (p ProvisionedClusterIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", p.PrincipalID) + populate(objectMap, "tenantId", p.TenantID) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClusterIdentity. +func (p *ProvisionedClusterIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &p.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &p.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClusters. +func (p ProvisionedClusters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", p.ExtendedLocation) + populate(objectMap, "id", p.ID) + populate(objectMap, "identity", p.Identity) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClusters. +func (p *ProvisionedClusters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &p.ExtendedLocation) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &p.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersAllProperties. +func (p ProvisionedClustersAllProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aadProfile", p.AADProfile) + populate(objectMap, "addonProfiles", p.AddonProfiles) + populate(objectMap, "agentPoolProfiles", p.AgentPoolProfiles) + populate(objectMap, "cloudProviderProfile", p.CloudProviderProfile) + populate(objectMap, "controlPlane", p.ControlPlane) + populate(objectMap, "enableRbac", p.EnableRbac) + populate(objectMap, "features", p.Features) + populate(objectMap, "httpProxyConfig", p.HTTPProxyConfig) + populate(objectMap, "kubernetesVersion", p.KubernetesVersion) + populate(objectMap, "linuxProfile", p.LinuxProfile) + populate(objectMap, "networkProfile", p.NetworkProfile) + populate(objectMap, "nodeResourceGroup", p.NodeResourceGroup) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "status", p.Status) + populate(objectMap, "windowsProfile", p.WindowsProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersAllProperties. +func (p *ProvisionedClustersAllProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aadProfile": + err = unpopulate(val, "AADProfile", &p.AADProfile) + delete(rawMsg, key) + case "addonProfiles": + err = unpopulate(val, "AddonProfiles", &p.AddonProfiles) + delete(rawMsg, key) + case "agentPoolProfiles": + err = unpopulate(val, "AgentPoolProfiles", &p.AgentPoolProfiles) + delete(rawMsg, key) + case "cloudProviderProfile": + err = unpopulate(val, "CloudProviderProfile", &p.CloudProviderProfile) + delete(rawMsg, key) + case "controlPlane": + err = unpopulate(val, "ControlPlane", &p.ControlPlane) + delete(rawMsg, key) + case "enableRbac": + err = unpopulate(val, "EnableRbac", &p.EnableRbac) + delete(rawMsg, key) + case "features": + err = unpopulate(val, "Features", &p.Features) + delete(rawMsg, key) + case "httpProxyConfig": + err = unpopulate(val, "HTTPProxyConfig", &p.HTTPProxyConfig) + delete(rawMsg, key) + case "kubernetesVersion": + err = unpopulate(val, "KubernetesVersion", &p.KubernetesVersion) + delete(rawMsg, key) + case "linuxProfile": + err = unpopulate(val, "LinuxProfile", &p.LinuxProfile) + delete(rawMsg, key) + case "networkProfile": + err = unpopulate(val, "NetworkProfile", &p.NetworkProfile) + delete(rawMsg, key) + case "nodeResourceGroup": + err = unpopulate(val, "NodeResourceGroup", &p.NodeResourceGroup) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "windowsProfile": + err = unpopulate(val, "WindowsProfile", &p.WindowsProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersCommonPropertiesFeatures. +func (p ProvisionedClustersCommonPropertiesFeatures) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "arcAgentProfile", p.ArcAgentProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersCommonPropertiesFeatures. +func (p *ProvisionedClustersCommonPropertiesFeatures) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "arcAgentProfile": + err = unpopulate(val, "ArcAgentProfile", &p.ArcAgentProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersCommonPropertiesStatus. +func (p ProvisionedClustersCommonPropertiesStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "addonStatus", p.AddonStatus) + populate(objectMap, "errorMessage", p.ErrorMessage) + populate(objectMap, "featuresStatus", p.FeaturesStatus) + populate(objectMap, "provisioningStatus", p.ProvisioningStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersCommonPropertiesStatus. +func (p *ProvisionedClustersCommonPropertiesStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "addonStatus": + err = unpopulate(val, "AddonStatus", &p.AddonStatus) + delete(rawMsg, key) + case "errorMessage": + err = unpopulate(val, "ErrorMessage", &p.ErrorMessage) + delete(rawMsg, key) + case "featuresStatus": + err = unpopulate(val, "FeaturesStatus", &p.FeaturesStatus) + delete(rawMsg, key) + case "provisioningStatus": + err = unpopulate(val, "ProvisioningStatus", &p.ProvisioningStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersCommonPropertiesStatusFeaturesStatus. +func (p ProvisionedClustersCommonPropertiesStatusFeaturesStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "arcAgentStatus", p.ArcAgentStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersCommonPropertiesStatusFeaturesStatus. +func (p *ProvisionedClustersCommonPropertiesStatusFeaturesStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "arcAgentStatus": + err = unpopulate(val, "ArcAgentStatus", &p.ArcAgentStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersCommonPropertiesStatusProvisioningStatus. +func (p ProvisionedClustersCommonPropertiesStatusProvisioningStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", p.Error) + populate(objectMap, "operationId", p.OperationID) + populate(objectMap, "phase", p.Phase) + populate(objectMap, "status", p.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersCommonPropertiesStatusProvisioningStatus. +func (p *ProvisionedClustersCommonPropertiesStatusProvisioningStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &p.Error) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &p.OperationID) + delete(rawMsg, key) + case "phase": + err = unpopulate(val, "Phase", &p.Phase) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersCommonPropertiesStatusProvisioningStatusError. +func (p ProvisionedClustersCommonPropertiesStatusProvisioningStatusError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", p.Code) + populate(objectMap, "message", p.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersCommonPropertiesStatusProvisioningStatusError. +func (p *ProvisionedClustersCommonPropertiesStatusProvisioningStatusError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &p.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &p.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersExtendedLocation. +func (p ProvisionedClustersExtendedLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersExtendedLocation. +func (p *ProvisionedClustersExtendedLocation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersPatch. +func (p ProvisionedClustersPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersPatch. +func (p *ProvisionedClustersPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersResponse. +func (p ProvisionedClustersResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", p.ExtendedLocation) + populate(objectMap, "id", p.ID) + populate(objectMap, "identity", p.Identity) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersResponse. +func (p *ProvisionedClustersResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &p.ExtendedLocation) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &p.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersResponseExtendedLocation. +func (p ProvisionedClustersResponseExtendedLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersResponseExtendedLocation. +func (p *ProvisionedClustersResponseExtendedLocation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersResponseListResult. +func (p ProvisionedClustersResponseListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersResponseListResult. +func (p *ProvisionedClustersResponseListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProvisionedClustersResponseProperties. +func (p ProvisionedClustersResponseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aadProfile", p.AADProfile) + populate(objectMap, "addonProfiles", p.AddonProfiles) + populate(objectMap, "agentPoolProfiles", p.AgentPoolProfiles) + populate(objectMap, "cloudProviderProfile", p.CloudProviderProfile) + populate(objectMap, "controlPlane", p.ControlPlane) + populate(objectMap, "enableRbac", p.EnableRbac) + populate(objectMap, "features", p.Features) + populate(objectMap, "httpProxyConfig", p.HTTPProxyConfig) + populate(objectMap, "kubernetesVersion", p.KubernetesVersion) + populate(objectMap, "linuxProfile", p.LinuxProfile) + populate(objectMap, "networkProfile", p.NetworkProfile) + populate(objectMap, "nodeResourceGroup", p.NodeResourceGroup) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "status", p.Status) + populate(objectMap, "windowsProfile", p.WindowsProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProvisionedClustersResponseProperties. +func (p *ProvisionedClustersResponseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aadProfile": + err = unpopulate(val, "AADProfile", &p.AADProfile) + delete(rawMsg, key) + case "addonProfiles": + err = unpopulate(val, "AddonProfiles", &p.AddonProfiles) + delete(rawMsg, key) + case "agentPoolProfiles": + err = unpopulate(val, "AgentPoolProfiles", &p.AgentPoolProfiles) + delete(rawMsg, key) + case "cloudProviderProfile": + err = unpopulate(val, "CloudProviderProfile", &p.CloudProviderProfile) + delete(rawMsg, key) + case "controlPlane": + err = unpopulate(val, "ControlPlane", &p.ControlPlane) + delete(rawMsg, key) + case "enableRbac": + err = unpopulate(val, "EnableRbac", &p.EnableRbac) + delete(rawMsg, key) + case "features": + err = unpopulate(val, "Features", &p.Features) + delete(rawMsg, key) + case "httpProxyConfig": + err = unpopulate(val, "HTTPProxyConfig", &p.HTTPProxyConfig) + delete(rawMsg, key) + case "kubernetesVersion": + err = unpopulate(val, "KubernetesVersion", &p.KubernetesVersion) + delete(rawMsg, key) + case "linuxProfile": + err = unpopulate(val, "LinuxProfile", &p.LinuxProfile) + delete(rawMsg, key) + case "networkProfile": + err = unpopulate(val, "NetworkProfile", &p.NetworkProfile) + delete(rawMsg, key) + case "nodeResourceGroup": + err = unpopulate(val, "NodeResourceGroup", &p.NodeResourceGroup) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "windowsProfile": + err = unpopulate(val, "WindowsProfile", &p.WindowsProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperation. +func (r ResourceProviderOperation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "display", r.Display) + populate(objectMap, "isDataAction", r.IsDataAction) + populate(objectMap, "name", r.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperation. +func (r *ResourceProviderOperation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &r.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &r.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationDisplay. +func (r ResourceProviderOperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", r.Description) + populate(objectMap, "operation", r.Operation) + populate(objectMap, "provider", r.Provider) + populate(objectMap, "resource", r.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationDisplay. +func (r *ResourceProviderOperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &r.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &r.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &r.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &r.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceProviderOperationList. +func (r ResourceProviderOperationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceProviderOperationList. +func (r *ResourceProviderOperationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpaces. +func (s StorageSpaces) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", s.ExtendedLocation) + populate(objectMap, "id", s.ID) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpaces. +func (s *StorageSpaces) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &s.ExtendedLocation) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesExtendedLocation. +func (s StorageSpacesExtendedLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", s.Name) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesExtendedLocation. +func (s *StorageSpacesExtendedLocation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesListResult. +func (s StorageSpacesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesListResult. +func (s *StorageSpacesListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesPatch. +func (s StorageSpacesPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesPatch. +func (s *StorageSpacesPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesProperties. +func (s StorageSpacesProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hciStorageProfile", s.HciStorageProfile) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "status", s.Status) + populate(objectMap, "vmwareStorageProfile", s.VmwareStorageProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesProperties. +func (s *StorageSpacesProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hciStorageProfile": + err = unpopulate(val, "HciStorageProfile", &s.HciStorageProfile) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + case "vmwareStorageProfile": + err = unpopulate(val, "VmwareStorageProfile", &s.VmwareStorageProfile) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesPropertiesHciStorageProfile. +func (s StorageSpacesPropertiesHciStorageProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "mocGroup", s.MocGroup) + populate(objectMap, "mocLocation", s.MocLocation) + populate(objectMap, "mocStorageContainer", s.MocStorageContainer) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesPropertiesHciStorageProfile. +func (s *StorageSpacesPropertiesHciStorageProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mocGroup": + err = unpopulate(val, "MocGroup", &s.MocGroup) + delete(rawMsg, key) + case "mocLocation": + err = unpopulate(val, "MocLocation", &s.MocLocation) + delete(rawMsg, key) + case "mocStorageContainer": + err = unpopulate(val, "MocStorageContainer", &s.MocStorageContainer) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesPropertiesStatus. +func (s StorageSpacesPropertiesStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "provisioningStatus", s.ProvisioningStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesPropertiesStatus. +func (s *StorageSpacesPropertiesStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningStatus": + err = unpopulate(val, "ProvisioningStatus", &s.ProvisioningStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesPropertiesStatusProvisioningStatus. +func (s StorageSpacesPropertiesStatusProvisioningStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", s.Error) + populate(objectMap, "operationId", s.OperationID) + populate(objectMap, "phase", s.Phase) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesPropertiesStatusProvisioningStatus. +func (s *StorageSpacesPropertiesStatusProvisioningStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &s.Error) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &s.OperationID) + delete(rawMsg, key) + case "phase": + err = unpopulate(val, "Phase", &s.Phase) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesPropertiesStatusProvisioningStatusError. +func (s StorageSpacesPropertiesStatusProvisioningStatusError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", s.Code) + populate(objectMap, "message", s.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesPropertiesStatusProvisioningStatusError. +func (s *StorageSpacesPropertiesStatusProvisioningStatusError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &s.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &s.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageSpacesPropertiesVmwareStorageProfile. +func (s StorageSpacesPropertiesVmwareStorageProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "datacenter", s.Datacenter) + populate(objectMap, "datastore", s.Datastore) + populate(objectMap, "folder", s.Folder) + populate(objectMap, "resourcePool", s.ResourcePool) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageSpacesPropertiesVmwareStorageProfile. +func (s *StorageSpacesPropertiesVmwareStorageProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "datacenter": + err = unpopulate(val, "Datacenter", &s.Datacenter) + delete(rawMsg, key) + case "datastore": + err = unpopulate(val, "Datastore", &s.Datastore) + delete(rawMsg, key) + case "folder": + err = unpopulate(val, "Folder", &s.Folder) + delete(rawMsg, key) + case "resourcePool": + err = unpopulate(val, "ResourcePool", &s.ResourcePool) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMSKUListResult. +func (v VMSKUListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "type", v.Type) + populate(objectMap, "vmSKUs", v.VMSKUs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMSKUListResult. +func (v *VMSKUListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + case "vmSKUs": + err = unpopulate(val, "VMSKUs", &v.VMSKUs) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworks. +func (v VirtualNetworks) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", v.ExtendedLocation) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworks. +func (v *VirtualNetworks) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "extendedLocation": + err = unpopulate(val, "ExtendedLocation", &v.ExtendedLocation) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &v.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &v.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksExtendedLocation. +func (v VirtualNetworksExtendedLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", v.Name) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksExtendedLocation. +func (v *VirtualNetworksExtendedLocation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksListResult. +func (v VirtualNetworksListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksListResult. +func (v *VirtualNetworksListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPatch. +func (v VirtualNetworksPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", v.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPatch. +func (v *VirtualNetworksPatch) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "tags": + err = unpopulate(val, "Tags", &v.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksProperties. +func (v VirtualNetworksProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dnsServers", v.DNSServers) + populate(objectMap, "dhcpServers", v.DhcpServers) + populate(objectMap, "gateway", v.Gateway) + populate(objectMap, "ipAddressPrefix", v.IPAddressPrefix) + populate(objectMap, "infraVnetProfile", v.InfraVnetProfile) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "status", v.Status) + populate(objectMap, "vipPool", v.VipPool) + populate(objectMap, "vlanID", v.VlanID) + populate(objectMap, "vmipPool", v.VmipPool) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksProperties. +func (v *VirtualNetworksProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dnsServers": + err = unpopulate(val, "DNSServers", &v.DNSServers) + delete(rawMsg, key) + case "dhcpServers": + err = unpopulate(val, "DhcpServers", &v.DhcpServers) + delete(rawMsg, key) + case "gateway": + err = unpopulate(val, "Gateway", &v.Gateway) + delete(rawMsg, key) + case "ipAddressPrefix": + err = unpopulate(val, "IPAddressPrefix", &v.IPAddressPrefix) + delete(rawMsg, key) + case "infraVnetProfile": + err = unpopulate(val, "InfraVnetProfile", &v.InfraVnetProfile) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &v.Status) + delete(rawMsg, key) + case "vipPool": + err = unpopulate(val, "VipPool", &v.VipPool) + delete(rawMsg, key) + case "vlanID": + err = unpopulate(val, "VlanID", &v.VlanID) + delete(rawMsg, key) + case "vmipPool": + err = unpopulate(val, "VmipPool", &v.VmipPool) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesInfraVnetProfile. +func (v VirtualNetworksPropertiesInfraVnetProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hci", v.Hci) + populate(objectMap, "kubevirt", v.Kubevirt) + populate(objectMap, "vmware", v.Vmware) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesInfraVnetProfile. +func (v *VirtualNetworksPropertiesInfraVnetProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "hci": + err = unpopulate(val, "Hci", &v.Hci) + delete(rawMsg, key) + case "kubevirt": + err = unpopulate(val, "Kubevirt", &v.Kubevirt) + delete(rawMsg, key) + case "vmware": + err = unpopulate(val, "Vmware", &v.Vmware) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesInfraVnetProfileHci. +func (v VirtualNetworksPropertiesInfraVnetProfileHci) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "mocGroup", v.MocGroup) + populate(objectMap, "mocLocation", v.MocLocation) + populate(objectMap, "mocVnetName", v.MocVnetName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesInfraVnetProfileHci. +func (v *VirtualNetworksPropertiesInfraVnetProfileHci) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "mocGroup": + err = unpopulate(val, "MocGroup", &v.MocGroup) + delete(rawMsg, key) + case "mocLocation": + err = unpopulate(val, "MocLocation", &v.MocLocation) + delete(rawMsg, key) + case "mocVnetName": + err = unpopulate(val, "MocVnetName", &v.MocVnetName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesInfraVnetProfileKubevirt. +func (v VirtualNetworksPropertiesInfraVnetProfileKubevirt) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "vnetName", v.VnetName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesInfraVnetProfileKubevirt. +func (v *VirtualNetworksPropertiesInfraVnetProfileKubevirt) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "vnetName": + err = unpopulate(val, "VnetName", &v.VnetName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesInfraVnetProfileVmware. +func (v VirtualNetworksPropertiesInfraVnetProfileVmware) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "segmentName", v.SegmentName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesInfraVnetProfileVmware. +func (v *VirtualNetworksPropertiesInfraVnetProfileVmware) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "segmentName": + err = unpopulate(val, "SegmentName", &v.SegmentName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesStatus. +func (v VirtualNetworksPropertiesStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "provisioningStatus", v.ProvisioningStatus) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesStatus. +func (v *VirtualNetworksPropertiesStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningStatus": + err = unpopulate(val, "ProvisioningStatus", &v.ProvisioningStatus) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesStatusProvisioningStatus. +func (v VirtualNetworksPropertiesStatusProvisioningStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", v.Error) + populate(objectMap, "operationId", v.OperationID) + populate(objectMap, "phase", v.Phase) + populate(objectMap, "status", v.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesStatusProvisioningStatus. +func (v *VirtualNetworksPropertiesStatusProvisioningStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &v.Error) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, "OperationID", &v.OperationID) + delete(rawMsg, key) + case "phase": + err = unpopulate(val, "Phase", &v.Phase) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &v.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesStatusProvisioningStatusError. +func (v VirtualNetworksPropertiesStatusProvisioningStatusError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", v.Code) + populate(objectMap, "message", v.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesStatusProvisioningStatusError. +func (v *VirtualNetworksPropertiesStatusProvisioningStatusError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &v.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &v.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesVipPoolItem. +func (v VirtualNetworksPropertiesVipPoolItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "endIP", v.EndIP) + populate(objectMap, "startIP", v.StartIP) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesVipPoolItem. +func (v *VirtualNetworksPropertiesVipPoolItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endIP": + err = unpopulate(val, "EndIP", &v.EndIP) + delete(rawMsg, key) + case "startIP": + err = unpopulate(val, "StartIP", &v.StartIP) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworksPropertiesVmipPoolItem. +func (v VirtualNetworksPropertiesVmipPoolItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "endIP", v.EndIP) + populate(objectMap, "startIP", v.StartIP) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworksPropertiesVmipPoolItem. +func (v *VirtualNetworksPropertiesVmipPoolItem) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endIP": + err = unpopulate(val, "EndIP", &v.EndIP) + delete(rawMsg, key) + case "startIP": + err = unpopulate(val, "StartIP", &v.StartIP) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WindowsProfile. +func (w WindowsProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adminPassword", w.AdminPassword) + populate(objectMap, "adminUsername", w.AdminUsername) + populate(objectMap, "enableCsiProxy", w.EnableCsiProxy) + populate(objectMap, "licenseType", w.LicenseType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WindowsProfile. +func (w *WindowsProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adminPassword": + err = unpopulate(val, "AdminPassword", &w.AdminPassword) + delete(rawMsg, key) + case "adminUsername": + err = unpopulate(val, "AdminUsername", &w.AdminUsername) + delete(rawMsg, key) + case "enableCsiProxy": + err = unpopulate(val, "EnableCsiProxy", &w.EnableCsiProxy) + delete(rawMsg, key) + case "licenseType": + err = unpopulate(val, "LicenseType", &w.LicenseType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WindowsProfileResponse. +func (w WindowsProfileResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adminUsername", w.AdminUsername) + populate(objectMap, "enableCsiProxy", w.EnableCsiProxy) + populate(objectMap, "licenseType", w.LicenseType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WindowsProfileResponse. +func (w *WindowsProfileResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adminUsername": + err = unpopulate(val, "AdminUsername", &w.AdminUsername) + delete(rawMsg, key) + case "enableCsiProxy": + err = unpopulate(val, "EnableCsiProxy", &w.EnableCsiProxy) + delete(rawMsg, key) + case "licenseType": + err = unpopulate(val, "LicenseType", &w.LicenseType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/operations_client.go b/sdk/resourcemanager/hybridaks/armhybridaks/operations_client.go new file mode 100644 index 000000000000..0411441f4550 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/operations_client.go @@ -0,0 +1,102 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.HybridContainerService/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ResourceProviderOperationList); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/operations_client_example_test.go b/sdk/resourcemanager/hybridaks/armhybridaks/operations_client_example_test.go new file mode 100644 index 000000000000..d90f954633c5 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/operations_client_example_test.go @@ -0,0 +1,41 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridaks_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListOperations.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewOperationsClient(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/provisionedclusters_client.go b/sdk/resourcemanager/hybridaks/armhybridaks/provisionedclusters_client.go new file mode 100644 index 000000000000..ca91692fa7a2 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/provisionedclusters_client.go @@ -0,0 +1,413 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ProvisionedClustersClient contains the methods for the ProvisionedClusters group. +// Don't use this type directly, use NewProvisionedClustersClient() instead. +type ProvisionedClustersClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewProvisionedClustersClient creates a new instance of ProvisionedClustersClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewProvisionedClustersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProvisionedClustersClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ProvisionedClustersClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// options - ProvisionedClustersClientBeginCreateOrUpdateOptions contains the optional parameters for the ProvisionedClustersClient.BeginCreateOrUpdate +// method. +func (client *ProvisionedClustersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, provisionedClustersName string, provisionedClusters ProvisionedClusters, options *ProvisionedClustersClientBeginCreateOrUpdateOptions) (*runtime.Poller[ProvisionedClustersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, provisionedClustersName, provisionedClusters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ProvisionedClustersClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ProvisionedClustersClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +func (client *ProvisionedClustersClient) createOrUpdate(ctx context.Context, resourceGroupName string, provisionedClustersName string, provisionedClusters ProvisionedClusters, options *ProvisionedClustersClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, provisionedClustersName, provisionedClusters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProvisionedClustersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, provisionedClusters ProvisionedClusters, options *ProvisionedClustersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, provisionedClusters) +} + +// Delete - Deletes the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// options - ProvisionedClustersClientDeleteOptions contains the optional parameters for the ProvisionedClustersClient.Delete +// method. +func (client *ProvisionedClustersClient) Delete(ctx context.Context, resourceGroupName string, provisionedClustersName string, options *ProvisionedClustersClientDeleteOptions) (ProvisionedClustersClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, provisionedClustersName, options) + if err != nil { + return ProvisionedClustersClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProvisionedClustersClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ProvisionedClustersClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return ProvisionedClustersClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProvisionedClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, options *ProvisionedClustersClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// options - ProvisionedClustersClientGetOptions contains the optional parameters for the ProvisionedClustersClient.Get method. +func (client *ProvisionedClustersClient) Get(ctx context.Context, resourceGroupName string, provisionedClustersName string, options *ProvisionedClustersClientGetOptions) (ProvisionedClustersClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, provisionedClustersName, options) + if err != nil { + return ProvisionedClustersClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProvisionedClustersClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProvisionedClustersClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProvisionedClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, options *ProvisionedClustersClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProvisionedClustersClient) getHandleResponse(resp *http.Response) (ProvisionedClustersClientGetResponse, error) { + result := ProvisionedClustersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProvisionedClustersResponse); err != nil { + return ProvisionedClustersClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets the Hybrid AKS provisioned cluster in a resource group +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - ProvisionedClustersClientListByResourceGroupOptions contains the optional parameters for the ProvisionedClustersClient.ListByResourceGroup +// method. +func (client *ProvisionedClustersClient) NewListByResourceGroupPager(resourceGroupName string, options *ProvisionedClustersClientListByResourceGroupOptions) *runtime.Pager[ProvisionedClustersClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ProvisionedClustersClientListByResourceGroupResponse]{ + More: func(page ProvisionedClustersClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProvisionedClustersClientListByResourceGroupResponse) (ProvisionedClustersClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProvisionedClustersClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProvisionedClustersClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProvisionedClustersClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ProvisionedClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ProvisionedClustersClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ProvisionedClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ProvisionedClustersClientListByResourceGroupResponse, error) { + result := ProvisionedClustersClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProvisionedClustersResponseListResult); err != nil { + return ProvisionedClustersClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets the Hybrid AKS provisioned cluster in a subscription +// Generated from API version 2022-05-01-preview +// options - ProvisionedClustersClientListBySubscriptionOptions contains the optional parameters for the ProvisionedClustersClient.ListBySubscription +// method. +func (client *ProvisionedClustersClient) NewListBySubscriptionPager(options *ProvisionedClustersClientListBySubscriptionOptions) *runtime.Pager[ProvisionedClustersClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ProvisionedClustersClientListBySubscriptionResponse]{ + More: func(page ProvisionedClustersClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProvisionedClustersClientListBySubscriptionResponse) (ProvisionedClustersClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProvisionedClustersClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProvisionedClustersClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProvisionedClustersClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ProvisionedClustersClient) listBySubscriptionCreateRequest(ctx context.Context, options *ProvisionedClustersClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.HybridContainerService/provisionedClusters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ProvisionedClustersClient) listBySubscriptionHandleResponse(resp *http.Response) (ProvisionedClustersClientListBySubscriptionResponse, error) { + result := ProvisionedClustersClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProvisionedClustersResponseListResult); err != nil { + return ProvisionedClustersClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// provisionedClustersName - Parameter for the name of the provisioned cluster +// options - ProvisionedClustersClientBeginUpdateOptions contains the optional parameters for the ProvisionedClustersClient.BeginUpdate +// method. +func (client *ProvisionedClustersClient) BeginUpdate(ctx context.Context, resourceGroupName string, provisionedClustersName string, provisionedClusters ProvisionedClustersPatch, options *ProvisionedClustersClientBeginUpdateOptions) (*runtime.Poller[ProvisionedClustersClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, provisionedClustersName, provisionedClusters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ProvisionedClustersClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ProvisionedClustersClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Updates the Hybrid AKS provisioned cluster +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +func (client *ProvisionedClustersClient) update(ctx context.Context, resourceGroupName string, provisionedClustersName string, provisionedClusters ProvisionedClustersPatch, options *ProvisionedClustersClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, provisionedClustersName, provisionedClusters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ProvisionedClustersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, provisionedClustersName string, provisionedClusters ProvisionedClustersPatch, options *ProvisionedClustersClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/provisionedClusters/{provisionedClustersName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if provisionedClustersName == "" { + return nil, errors.New("parameter provisionedClustersName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{provisionedClustersName}", url.PathEscape(provisionedClustersName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, provisionedClusters) +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/provisionedclusters_client_example_test.go b/sdk/resourcemanager/hybridaks/armhybridaks/provisionedclusters_client_example_test.go new file mode 100644 index 000000000000..d5b196468b97 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/provisionedclusters_client_example_test.go @@ -0,0 +1,217 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridaks_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/GetProvisionedCluster.json +func ExampleProvisionedClustersClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewProvisionedClustersClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Get(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/PutProvisionedCluster.json +func ExampleProvisionedClustersClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewProvisionedClustersClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", armhybridaks.ProvisionedClusters{ + Location: to.Ptr("westus"), + ExtendedLocation: &armhybridaks.ProvisionedClustersExtendedLocation{ + Name: to.Ptr("/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation"), + Type: to.Ptr("CustomLocation"), + }, + Properties: &armhybridaks.ProvisionedClustersAllProperties{ + AgentPoolProfiles: []*armhybridaks.NamedAgentPoolProfile{ + { + Name: to.Ptr("default-nodepool-1"), + Count: to.Ptr[int32](1), + OSType: to.Ptr(armhybridaks.OsTypeLinux), + VMSize: to.Ptr("Standard_A4_v2"), + }}, + CloudProviderProfile: &armhybridaks.CloudProviderProfile{ + InfraNetworkProfile: &armhybridaks.CloudProviderProfileInfraNetworkProfile{ + VnetSubnetIDs: []*string{ + to.Ptr("/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourceGroups/test-arcappliance-resgrp/providers/Microsoft.HybridContainerService/virtualNetworks/test-vnet-static")}, + }, + InfraStorageProfile: &armhybridaks.CloudProviderProfileInfraStorageProfile{ + StorageSpaceIDs: []*string{ + to.Ptr("/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourceGroups/test-arcappliance-resgrp/providers/Microsoft.HybridContainerService/storageSpaces/test-storage")}, + }, + }, + ControlPlane: &armhybridaks.ControlPlaneProfile{ + LinuxProfile: &armhybridaks.LinuxProfileProperties{ + SSH: &armhybridaks.LinuxProfilePropertiesSSH{ + PublicKeys: []*armhybridaks.LinuxProfilePropertiesSSHPublicKeysItem{ + { + KeyData: to.Ptr("ssh-rsa AAAAB1NzaC1yc2EAAAADAQABAAACAQCY......"), + }}, + }, + }, + Count: to.Ptr[int32](1), + OSType: to.Ptr(armhybridaks.OsTypeLinux), + VMSize: to.Ptr("Standard_A4_v2"), + }, + KubernetesVersion: to.Ptr("v1.20.5"), + LinuxProfile: &armhybridaks.LinuxProfileProperties{ + SSH: &armhybridaks.LinuxProfilePropertiesSSH{ + PublicKeys: []*armhybridaks.LinuxProfilePropertiesSSHPublicKeysItem{ + { + KeyData: to.Ptr("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCY......."), + }}, + }, + }, + NetworkProfile: &armhybridaks.NetworkProfile{ + LoadBalancerProfile: &armhybridaks.LoadBalancerProfile{ + LinuxProfile: &armhybridaks.LinuxProfileProperties{ + SSH: &armhybridaks.LinuxProfilePropertiesSSH{ + PublicKeys: []*armhybridaks.LinuxProfilePropertiesSSHPublicKeysItem{ + { + KeyData: to.Ptr("ssh-rsa AAAAB2NzaC1yc2EAAAADAQABAAACAQCY......"), + }}, + }, + }, + Count: to.Ptr[int32](1), + OSType: to.Ptr(armhybridaks.OsTypeLinux), + VMSize: to.Ptr("Standard_K8S3_v1"), + }, + LoadBalancerSKU: to.Ptr(armhybridaks.LoadBalancerSKUUnstackedHaproxy), + NetworkPolicy: to.Ptr(armhybridaks.NetworkPolicyCalico), + PodCidr: to.Ptr("10.244.0.0/16"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/DeleteProvisionedCluster.json +func ExampleProvisionedClustersClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewProvisionedClustersClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = client.Delete(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/UpdateProvisionedCluster.json +func ExampleProvisionedClustersClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewProvisionedClustersClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, "test-arcappliance-resgrp", "test-hybridakscluster", armhybridaks.ProvisionedClustersPatch{ + Tags: map[string]*string{ + "additionalProperties": to.Ptr("sample"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListProvisionedClusterByResourceGroup.json +func ExampleProvisionedClustersClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewProvisionedClustersClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("test-arcappliance-resgrp", nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListProvisionedClusterBySubscription.json +func ExampleProvisionedClustersClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewProvisionedClustersClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/response_types.go b/sdk/resourcemanager/hybridaks/armhybridaks/response_types.go new file mode 100644 index 000000000000..0e976a2dfb4e --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/response_types.go @@ -0,0 +1,160 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +// AgentPoolClientCreateOrUpdateResponse contains the response from method AgentPoolClient.CreateOrUpdate. +type AgentPoolClientCreateOrUpdateResponse struct { + AgentPool +} + +// AgentPoolClientDeleteResponse contains the response from method AgentPoolClient.Delete. +type AgentPoolClientDeleteResponse struct { + // placeholder for future response values +} + +// AgentPoolClientGetResponse contains the response from method AgentPoolClient.Get. +type AgentPoolClientGetResponse struct { + AgentPool +} + +// AgentPoolClientListByProvisionedClusterResponse contains the response from method AgentPoolClient.ListByProvisionedCluster. +type AgentPoolClientListByProvisionedClusterResponse struct { + AgentPoolListResult +} + +// AgentPoolClientUpdateResponse contains the response from method AgentPoolClient.Update. +type AgentPoolClientUpdateResponse struct { + AgentPool +} + +// HybridContainerServiceClientListOrchestratorsResponse contains the response from method HybridContainerServiceClient.ListOrchestrators. +type HybridContainerServiceClientListOrchestratorsResponse struct { + OrchestratorVersionProfileListResult +} + +// HybridContainerServiceClientListVMSKUsResponse contains the response from method HybridContainerServiceClient.ListVMSKUs. +type HybridContainerServiceClientListVMSKUsResponse struct { + VMSKUListResult +} + +// HybridIdentityMetadataClientDeleteResponse contains the response from method HybridIdentityMetadataClient.Delete. +type HybridIdentityMetadataClientDeleteResponse struct { + // placeholder for future response values +} + +// HybridIdentityMetadataClientGetResponse contains the response from method HybridIdentityMetadataClient.Get. +type HybridIdentityMetadataClientGetResponse struct { + HybridIdentityMetadata +} + +// HybridIdentityMetadataClientListByClusterResponse contains the response from method HybridIdentityMetadataClient.ListByCluster. +type HybridIdentityMetadataClientListByClusterResponse struct { + HybridIdentityMetadataList +} + +// HybridIdentityMetadataClientPutResponse contains the response from method HybridIdentityMetadataClient.Put. +type HybridIdentityMetadataClientPutResponse struct { + HybridIdentityMetadata +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + ResourceProviderOperationList +} + +// ProvisionedClustersClientCreateOrUpdateResponse contains the response from method ProvisionedClustersClient.CreateOrUpdate. +type ProvisionedClustersClientCreateOrUpdateResponse struct { + ProvisionedClustersResponse +} + +// ProvisionedClustersClientDeleteResponse contains the response from method ProvisionedClustersClient.Delete. +type ProvisionedClustersClientDeleteResponse struct { + // placeholder for future response values +} + +// ProvisionedClustersClientGetResponse contains the response from method ProvisionedClustersClient.Get. +type ProvisionedClustersClientGetResponse struct { + ProvisionedClustersResponse +} + +// ProvisionedClustersClientListByResourceGroupResponse contains the response from method ProvisionedClustersClient.ListByResourceGroup. +type ProvisionedClustersClientListByResourceGroupResponse struct { + ProvisionedClustersResponseListResult +} + +// ProvisionedClustersClientListBySubscriptionResponse contains the response from method ProvisionedClustersClient.ListBySubscription. +type ProvisionedClustersClientListBySubscriptionResponse struct { + ProvisionedClustersResponseListResult +} + +// ProvisionedClustersClientUpdateResponse contains the response from method ProvisionedClustersClient.Update. +type ProvisionedClustersClientUpdateResponse struct { + ProvisionedClustersResponse +} + +// StorageSpacesClientCreateOrUpdateResponse contains the response from method StorageSpacesClient.CreateOrUpdate. +type StorageSpacesClientCreateOrUpdateResponse struct { + StorageSpaces +} + +// StorageSpacesClientDeleteResponse contains the response from method StorageSpacesClient.Delete. +type StorageSpacesClientDeleteResponse struct { + // placeholder for future response values +} + +// StorageSpacesClientListByResourceGroupResponse contains the response from method StorageSpacesClient.ListByResourceGroup. +type StorageSpacesClientListByResourceGroupResponse struct { + StorageSpacesListResult +} + +// StorageSpacesClientListBySubscriptionResponse contains the response from method StorageSpacesClient.ListBySubscription. +type StorageSpacesClientListBySubscriptionResponse struct { + StorageSpacesListResult +} + +// StorageSpacesClientRetrieveResponse contains the response from method StorageSpacesClient.Retrieve. +type StorageSpacesClientRetrieveResponse struct { + StorageSpaces +} + +// StorageSpacesClientUpdateResponse contains the response from method StorageSpacesClient.Update. +type StorageSpacesClientUpdateResponse struct { + StorageSpaces +} + +// VirtualNetworksClientCreateOrUpdateResponse contains the response from method VirtualNetworksClient.CreateOrUpdate. +type VirtualNetworksClientCreateOrUpdateResponse struct { + VirtualNetworks +} + +// VirtualNetworksClientDeleteResponse contains the response from method VirtualNetworksClient.Delete. +type VirtualNetworksClientDeleteResponse struct { + // placeholder for future response values +} + +// VirtualNetworksClientListByResourceGroupResponse contains the response from method VirtualNetworksClient.ListByResourceGroup. +type VirtualNetworksClientListByResourceGroupResponse struct { + VirtualNetworksListResult +} + +// VirtualNetworksClientListBySubscriptionResponse contains the response from method VirtualNetworksClient.ListBySubscription. +type VirtualNetworksClientListBySubscriptionResponse struct { + VirtualNetworksListResult +} + +// VirtualNetworksClientRetrieveResponse contains the response from method VirtualNetworksClient.Retrieve. +type VirtualNetworksClientRetrieveResponse struct { + VirtualNetworks +} + +// VirtualNetworksClientUpdateResponse contains the response from method VirtualNetworksClient.Update. +type VirtualNetworksClientUpdateResponse struct { + VirtualNetworks +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/storagespaces_client.go b/sdk/resourcemanager/hybridaks/armhybridaks/storagespaces_client.go new file mode 100644 index 000000000000..efc29f572276 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/storagespaces_client.go @@ -0,0 +1,412 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// StorageSpacesClient contains the methods for the StorageSpaces group. +// Don't use this type directly, use NewStorageSpacesClient() instead. +type StorageSpacesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewStorageSpacesClient creates a new instance of StorageSpacesClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewStorageSpacesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StorageSpacesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &StorageSpacesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Puts the Hybrid AKS storage object +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageSpacesName - Parameter for the name of the storage object +// options - StorageSpacesClientBeginCreateOrUpdateOptions contains the optional parameters for the StorageSpacesClient.BeginCreateOrUpdate +// method. +func (client *StorageSpacesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, storageSpacesName string, storageSpaces StorageSpaces, options *StorageSpacesClientBeginCreateOrUpdateOptions) (*runtime.Poller[StorageSpacesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, storageSpacesName, storageSpaces, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageSpacesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[StorageSpacesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Puts the Hybrid AKS storage object +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +func (client *StorageSpacesClient) createOrUpdate(ctx context.Context, resourceGroupName string, storageSpacesName string, storageSpaces StorageSpaces, options *StorageSpacesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, storageSpacesName, storageSpaces, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *StorageSpacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, storageSpacesName string, storageSpaces StorageSpaces, options *StorageSpacesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/storageSpaces/{storageSpacesName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageSpacesName == "" { + return nil, errors.New("parameter storageSpacesName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageSpacesName}", url.PathEscape(storageSpacesName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, storageSpaces) +} + +// Delete - Deletes the Hybrid AKS storage object +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageSpacesName - Parameter for the name of the storage object +// options - StorageSpacesClientDeleteOptions contains the optional parameters for the StorageSpacesClient.Delete method. +func (client *StorageSpacesClient) Delete(ctx context.Context, resourceGroupName string, storageSpacesName string, options *StorageSpacesClientDeleteOptions) (StorageSpacesClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storageSpacesName, options) + if err != nil { + return StorageSpacesClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageSpacesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return StorageSpacesClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return StorageSpacesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *StorageSpacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageSpacesName string, options *StorageSpacesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/storageSpaces/{storageSpacesName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageSpacesName == "" { + return nil, errors.New("parameter storageSpacesName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageSpacesName}", url.PathEscape(storageSpacesName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListByResourceGroupPager - List the Hybrid AKS storage object by resource group +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - StorageSpacesClientListByResourceGroupOptions contains the optional parameters for the StorageSpacesClient.ListByResourceGroup +// method. +func (client *StorageSpacesClient) NewListByResourceGroupPager(resourceGroupName string, options *StorageSpacesClientListByResourceGroupOptions) *runtime.Pager[StorageSpacesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[StorageSpacesClientListByResourceGroupResponse]{ + More: func(page StorageSpacesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StorageSpacesClientListByResourceGroupResponse) (StorageSpacesClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return StorageSpacesClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageSpacesClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageSpacesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *StorageSpacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *StorageSpacesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/storageSpaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *StorageSpacesClient) listByResourceGroupHandleResponse(resp *http.Response) (StorageSpacesClientListByResourceGroupResponse, error) { + result := StorageSpacesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageSpacesListResult); err != nil { + return StorageSpacesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List the Hybrid AKS storage object by subscription +// Generated from API version 2022-05-01-preview +// options - StorageSpacesClientListBySubscriptionOptions contains the optional parameters for the StorageSpacesClient.ListBySubscription +// method. +func (client *StorageSpacesClient) NewListBySubscriptionPager(options *StorageSpacesClientListBySubscriptionOptions) *runtime.Pager[StorageSpacesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[StorageSpacesClientListBySubscriptionResponse]{ + More: func(page StorageSpacesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StorageSpacesClientListBySubscriptionResponse) (StorageSpacesClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return StorageSpacesClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageSpacesClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageSpacesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *StorageSpacesClient) listBySubscriptionCreateRequest(ctx context.Context, options *StorageSpacesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.HybridContainerService/storageSpaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *StorageSpacesClient) listBySubscriptionHandleResponse(resp *http.Response) (StorageSpacesClientListBySubscriptionResponse, error) { + result := StorageSpacesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageSpacesListResult); err != nil { + return StorageSpacesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Retrieve - Gets the Hybrid AKS storage space object +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageSpacesName - Parameter for the name of the storage object +// options - StorageSpacesClientRetrieveOptions contains the optional parameters for the StorageSpacesClient.Retrieve method. +func (client *StorageSpacesClient) Retrieve(ctx context.Context, resourceGroupName string, storageSpacesName string, options *StorageSpacesClientRetrieveOptions) (StorageSpacesClientRetrieveResponse, error) { + req, err := client.retrieveCreateRequest(ctx, resourceGroupName, storageSpacesName, options) + if err != nil { + return StorageSpacesClientRetrieveResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageSpacesClientRetrieveResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageSpacesClientRetrieveResponse{}, runtime.NewResponseError(resp) + } + return client.retrieveHandleResponse(resp) +} + +// retrieveCreateRequest creates the Retrieve request. +func (client *StorageSpacesClient) retrieveCreateRequest(ctx context.Context, resourceGroupName string, storageSpacesName string, options *StorageSpacesClientRetrieveOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/storageSpaces/{storageSpacesName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageSpacesName == "" { + return nil, errors.New("parameter storageSpacesName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageSpacesName}", url.PathEscape(storageSpacesName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// retrieveHandleResponse handles the Retrieve response. +func (client *StorageSpacesClient) retrieveHandleResponse(resp *http.Response) (StorageSpacesClientRetrieveResponse, error) { + result := StorageSpacesClientRetrieveResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageSpaces); err != nil { + return StorageSpacesClientRetrieveResponse{}, err + } + return result, nil +} + +// BeginUpdate - Patches the Hybrid AKS storage object +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageSpacesName - Parameter for the name of the storage object +// options - StorageSpacesClientBeginUpdateOptions contains the optional parameters for the StorageSpacesClient.BeginUpdate +// method. +func (client *StorageSpacesClient) BeginUpdate(ctx context.Context, resourceGroupName string, storageSpacesName string, storageSpaces StorageSpacesPatch, options *StorageSpacesClientBeginUpdateOptions) (*runtime.Poller[StorageSpacesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, storageSpacesName, storageSpaces, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageSpacesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[StorageSpacesClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Patches the Hybrid AKS storage object +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +func (client *StorageSpacesClient) update(ctx context.Context, resourceGroupName string, storageSpacesName string, storageSpaces StorageSpacesPatch, options *StorageSpacesClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, storageSpacesName, storageSpaces, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *StorageSpacesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storageSpacesName string, storageSpaces StorageSpacesPatch, options *StorageSpacesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/storageSpaces/{storageSpacesName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageSpacesName == "" { + return nil, errors.New("parameter storageSpacesName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageSpacesName}", url.PathEscape(storageSpacesName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, storageSpaces) +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/storagespaces_client_example_test.go b/sdk/resourcemanager/hybridaks/armhybridaks/storagespaces_client_example_test.go new file mode 100644 index 000000000000..31ca50fc3b39 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/storagespaces_client_example_test.go @@ -0,0 +1,165 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridaks_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/GetStorageSpace.json +func ExampleStorageSpacesClient_Retrieve() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewStorageSpacesClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Retrieve(ctx, "test-arcappliance-resgrp", "test-storage", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/PutStorageSpace.json +func ExampleStorageSpacesClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewStorageSpacesClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, "test-arcappliance-resgrp", "test-storage", armhybridaks.StorageSpaces{ + Location: to.Ptr("westus"), + ExtendedLocation: &armhybridaks.StorageSpacesExtendedLocation{ + Name: to.Ptr("/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation"), + Type: to.Ptr("CustomLocation"), + }, + Properties: &armhybridaks.StorageSpacesProperties{ + HciStorageProfile: &armhybridaks.StorageSpacesPropertiesHciStorageProfile{ + MocGroup: to.Ptr("target-group"), + MocLocation: to.Ptr("MocLocation"), + MocStorageContainer: to.Ptr("WssdStorageContainer"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/DeleteStorageSpace.json +func ExampleStorageSpacesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewStorageSpacesClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = client.Delete(ctx, "test-arcappliance-resgrp", "test-storage", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/UpdateStorageSpace.json +func ExampleStorageSpacesClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewStorageSpacesClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, "test-arcappliance-resgrp", "test-storage", armhybridaks.StorageSpacesPatch{ + Tags: map[string]*string{ + "additionalProperties": to.Ptr("sample"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListStorageSpaceByResourceGroup.json +func ExampleStorageSpacesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewStorageSpacesClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("test-arcappliance-resgrp", nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListStorageSpaceBySubscription.json +func ExampleStorageSpacesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewStorageSpacesClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/time_rfc3339.go b/sdk/resourcemanager/hybridaks/armhybridaks/time_rfc3339.go new file mode 100644 index 000000000000..acdc900e0660 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/time_rfc3339.go @@ -0,0 +1,87 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/virtualnetworks_client.go b/sdk/resourcemanager/hybridaks/armhybridaks/virtualnetworks_client.go new file mode 100644 index 000000000000..d2cceda7b127 --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/virtualnetworks_client.go @@ -0,0 +1,413 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armhybridaks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// VirtualNetworksClient contains the methods for the VirtualNetworks group. +// Don't use this type directly, use NewVirtualNetworksClient() instead. +type VirtualNetworksClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewVirtualNetworksClient creates a new instance of VirtualNetworksClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewVirtualNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualNetworksClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &VirtualNetworksClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Puts the Hybrid AKS virtual network +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// virtualNetworksName - Parameter for the name of the virtual network +// options - VirtualNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginCreateOrUpdate +// method. +func (client *VirtualNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworksName string, virtualNetworks VirtualNetworks, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[VirtualNetworksClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, virtualNetworksName, virtualNetworks, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualNetworksClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[VirtualNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Puts the Hybrid AKS virtual network +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +func (client *VirtualNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, virtualNetworksName string, virtualNetworks VirtualNetworks, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, virtualNetworksName, virtualNetworks, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *VirtualNetworksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworksName string, virtualNetworks VirtualNetworks, options *VirtualNetworksClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/virtualNetworks/{virtualNetworksName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if virtualNetworksName == "" { + return nil, errors.New("parameter virtualNetworksName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworksName}", url.PathEscape(virtualNetworksName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, virtualNetworks) +} + +// Delete - Deletes the Hybrid AKS virtual network +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// virtualNetworksName - Parameter for the name of the virtual network +// options - VirtualNetworksClientDeleteOptions contains the optional parameters for the VirtualNetworksClient.Delete method. +func (client *VirtualNetworksClient) Delete(ctx context.Context, resourceGroupName string, virtualNetworksName string, options *VirtualNetworksClientDeleteOptions) (VirtualNetworksClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, virtualNetworksName, options) + if err != nil { + return VirtualNetworksClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualNetworksClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return VirtualNetworksClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return VirtualNetworksClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VirtualNetworksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworksName string, options *VirtualNetworksClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/virtualNetworks/{virtualNetworksName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if virtualNetworksName == "" { + return nil, errors.New("parameter virtualNetworksName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworksName}", url.PathEscape(virtualNetworksName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// NewListByResourceGroupPager - Lists the Hybrid AKS virtual networks by resource group +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - VirtualNetworksClientListByResourceGroupOptions contains the optional parameters for the VirtualNetworksClient.ListByResourceGroup +// method. +func (client *VirtualNetworksClient) NewListByResourceGroupPager(resourceGroupName string, options *VirtualNetworksClientListByResourceGroupOptions) *runtime.Pager[VirtualNetworksClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[VirtualNetworksClientListByResourceGroupResponse]{ + More: func(page VirtualNetworksClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualNetworksClientListByResourceGroupResponse) (VirtualNetworksClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualNetworksClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualNetworksClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualNetworksClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *VirtualNetworksClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *VirtualNetworksClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/virtualNetworks" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *VirtualNetworksClient) listByResourceGroupHandleResponse(resp *http.Response) (VirtualNetworksClientListByResourceGroupResponse, error) { + result := VirtualNetworksClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworksListResult); err != nil { + return VirtualNetworksClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists the Hybrid AKS virtual networks by subscription +// Generated from API version 2022-05-01-preview +// options - VirtualNetworksClientListBySubscriptionOptions contains the optional parameters for the VirtualNetworksClient.ListBySubscription +// method. +func (client *VirtualNetworksClient) NewListBySubscriptionPager(options *VirtualNetworksClientListBySubscriptionOptions) *runtime.Pager[VirtualNetworksClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[VirtualNetworksClientListBySubscriptionResponse]{ + More: func(page VirtualNetworksClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VirtualNetworksClientListBySubscriptionResponse) (VirtualNetworksClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return VirtualNetworksClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualNetworksClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualNetworksClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VirtualNetworksClient) listBySubscriptionCreateRequest(ctx context.Context, options *VirtualNetworksClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.HybridContainerService/virtualNetworks" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *VirtualNetworksClient) listBySubscriptionHandleResponse(resp *http.Response) (VirtualNetworksClientListBySubscriptionResponse, error) { + result := VirtualNetworksClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworksListResult); err != nil { + return VirtualNetworksClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Retrieve - Gets the Hybrid AKS virtual network +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// virtualNetworksName - Parameter for the name of the virtual network +// options - VirtualNetworksClientRetrieveOptions contains the optional parameters for the VirtualNetworksClient.Retrieve +// method. +func (client *VirtualNetworksClient) Retrieve(ctx context.Context, resourceGroupName string, virtualNetworksName string, options *VirtualNetworksClientRetrieveOptions) (VirtualNetworksClientRetrieveResponse, error) { + req, err := client.retrieveCreateRequest(ctx, resourceGroupName, virtualNetworksName, options) + if err != nil { + return VirtualNetworksClientRetrieveResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return VirtualNetworksClientRetrieveResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VirtualNetworksClientRetrieveResponse{}, runtime.NewResponseError(resp) + } + return client.retrieveHandleResponse(resp) +} + +// retrieveCreateRequest creates the Retrieve request. +func (client *VirtualNetworksClient) retrieveCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworksName string, options *VirtualNetworksClientRetrieveOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/virtualNetworks/{virtualNetworksName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if virtualNetworksName == "" { + return nil, errors.New("parameter virtualNetworksName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworksName}", url.PathEscape(virtualNetworksName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// retrieveHandleResponse handles the Retrieve response. +func (client *VirtualNetworksClient) retrieveHandleResponse(resp *http.Response) (VirtualNetworksClientRetrieveResponse, error) { + result := VirtualNetworksClientRetrieveResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VirtualNetworks); err != nil { + return VirtualNetworksClientRetrieveResponse{}, err + } + return result, nil +} + +// BeginUpdate - Patches the Hybrid AKS virtual network +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// virtualNetworksName - Parameter for the name of the virtual network +// options - VirtualNetworksClientBeginUpdateOptions contains the optional parameters for the VirtualNetworksClient.BeginUpdate +// method. +func (client *VirtualNetworksClient) BeginUpdate(ctx context.Context, resourceGroupName string, virtualNetworksName string, virtualNetworks VirtualNetworksPatch, options *VirtualNetworksClientBeginUpdateOptions) (*runtime.Poller[VirtualNetworksClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, virtualNetworksName, virtualNetworks, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[VirtualNetworksClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[VirtualNetworksClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Patches the Hybrid AKS virtual network +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01-preview +func (client *VirtualNetworksClient) update(ctx context.Context, resourceGroupName string, virtualNetworksName string, virtualNetworks VirtualNetworksPatch, options *VirtualNetworksClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, virtualNetworksName, virtualNetworks, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VirtualNetworksClient) updateCreateRequest(ctx context.Context, resourceGroupName string, virtualNetworksName string, virtualNetworks VirtualNetworksPatch, options *VirtualNetworksClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridContainerService/virtualNetworks/{virtualNetworksName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if virtualNetworksName == "" { + return nil, errors.New("parameter virtualNetworksName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{virtualNetworksName}", url.PathEscape(virtualNetworksName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, virtualNetworks) +} diff --git a/sdk/resourcemanager/hybridaks/armhybridaks/virtualnetworks_client_example_test.go b/sdk/resourcemanager/hybridaks/armhybridaks/virtualnetworks_client_example_test.go new file mode 100644 index 000000000000..d7da80e7626b --- /dev/null +++ b/sdk/resourcemanager/hybridaks/armhybridaks/virtualnetworks_client_example_test.go @@ -0,0 +1,177 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armhybridaks_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/hybridaks/armhybridaks" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/GetVirtualNetwork.json +func ExampleVirtualNetworksClient_Retrieve() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewVirtualNetworksClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := client.Retrieve(ctx, "test-arcappliance-resgrp", "test-vnet-static", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/PutVirtualNetwork.json +func ExampleVirtualNetworksClient_BeginCreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewVirtualNetworksClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginCreateOrUpdate(ctx, "test-arcappliance-resgrp", "test-vnet-static", armhybridaks.VirtualNetworks{ + Location: to.Ptr("westus"), + ExtendedLocation: &armhybridaks.VirtualNetworksExtendedLocation{ + Name: to.Ptr("/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation"), + Type: to.Ptr("CustomLocation"), + }, + Properties: &armhybridaks.VirtualNetworksProperties{ + InfraVnetProfile: &armhybridaks.VirtualNetworksPropertiesInfraVnetProfile{ + Hci: &armhybridaks.VirtualNetworksPropertiesInfraVnetProfileHci{ + MocGroup: to.Ptr("target-group"), + MocLocation: to.Ptr("MocLocation"), + MocVnetName: to.Ptr("test-vnet"), + }, + }, + VipPool: []*armhybridaks.VirtualNetworksPropertiesVipPoolItem{ + { + EndIP: to.Ptr("192.168.0.50"), + StartIP: to.Ptr("192.168.0.10"), + }}, + VmipPool: []*armhybridaks.VirtualNetworksPropertiesVmipPoolItem{ + { + EndIP: to.Ptr("192.168.0.130"), + StartIP: to.Ptr("192.168.0.110"), + }}, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/DeleteVirtualNetwork.json +func ExampleVirtualNetworksClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewVirtualNetworksClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = client.Delete(ctx, "test-arcappliance-resgrp", "test-vnet-static", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/UpdateVirtualNetwork.json +func ExampleVirtualNetworksClient_BeginUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewVirtualNetworksClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := client.BeginUpdate(ctx, "test-arcappliance-resgrp", "test-vnet-static", armhybridaks.VirtualNetworksPatch{ + Tags: map[string]*string{ + "additionalProperties": to.Ptr("sample"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // TODO: use response item + _ = res +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListVirtualNetworkByResourceGroup.json +func ExampleVirtualNetworksClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewVirtualNetworksClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListByResourceGroupPager("test-arcappliance-resgrp", nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/hybridaks/resource-manager/Microsoft.HybridContainerService/preview/2022-05-01-preview/examples/ListVirtualNetworkBySubscription.json +func ExampleVirtualNetworksClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + client, err := armhybridaks.NewVirtualNetworksClient("a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := client.NewListBySubscriptionPager(nil) + for pager.More() { + nextResult, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range nextResult.Value { + // TODO: use page item + _ = v + } + } +}