diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/CHANGELOG.md b/sdk/resourcemanager/azurestackhci/armazurestackhci/CHANGELOG.md new file mode 100644 index 000000000000..2e68b73b5168 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 0.1.0 (2021-11-25) diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/LICENSE.txt b/sdk/resourcemanager/azurestackhci/armazurestackhci/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/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/azurestackhci/armazurestackhci/README.md b/sdk/resourcemanager/azurestackhci/armazurestackhci/README.md new file mode 100644 index 000000000000..f8882489d58e --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/README.md @@ -0,0 +1,75 @@ +# Azure Azurestackhci Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestackhci/armazurestackhci)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestackhci/armazurestackhci) + +The `armazurestackhci` module provides operations for working with Azure Azurestackhci. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/azurestackhci/armazurestackhci) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 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 Azurestackhci module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestackhci/armazurestackhci +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Azurestackhci. 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 Azurestackhci 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 := armazurestackhci.NewArcSettingsClient(, 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{ + Host: arm.AzureChina, +} +client := armazurestackhci.NewArcSettingsClient(, 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 `Azurestackhci` 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/azurestackhci/armazurestackhci/autorest.md b/sdk/resourcemanager/azurestackhci/armazurestackhci/autorest.md new file mode 100644 index 000000000000..30106fc46a67 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /home/vsts/work/1/s/azure-rest-api-specs/specification/azurestackhci/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/azurestackhci/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/azurestackhci/armazurestackhci/build.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/build.go new file mode 100644 index 000000000000..64a0310cd07a --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/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.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/azurestackhci/armazurestackhci + +package armazurestackhci diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/ci.yml b/sdk/resourcemanager/azurestackhci/armazurestackhci/ci.yml new file mode 100644 index 000000000000..8fff32880abd --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/ci.yml @@ -0,0 +1,27 @@ +# 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/azurestackhci/armazurestackhci/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/azurestackhci/armazurestackhci/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/azurestackhci/armazurestackhci' diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/go.mod b/sdk/resourcemanager/azurestackhci/armazurestackhci/go.mod new file mode 100644 index 000000000000..333f0da6a50a --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestackhci/armazurestackhci + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.3.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/go.sum b/sdk/resourcemanager/azurestackhci/armazurestackhci/go.sum new file mode 100644 index 000000000000..76d3fa8fd576 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.3.0+incompatible h1:dPIm0BO4jsMXFcCI/sLTPkBtE7mk8WMuRHA0JeWhlcQ= +github.com/Azure/azure-sdk-for-go v59.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1 h1:BUYIbDf/mMZ8945v3QkG3OuqGVyS4Iek0AOLwdRAYoc= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/go_mod_tidy_hack.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/go_mod_tidy_hack.go new file mode 100644 index 000000000000..1e750eda29bc --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/go_mod_tidy_hack.go @@ -0,0 +1,13 @@ +//go:build modhack +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armazurestackhci + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_arcsettings_client.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_arcsettings_client.go new file mode 100644 index 000000000000..c791db33b2f8 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_arcsettings_client.go @@ -0,0 +1,323 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ArcSettingsClient contains the methods for the ArcSettings group. +// Don't use this type directly, use NewArcSettingsClient() instead. +type ArcSettingsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewArcSettingsClient creates a new instance of ArcSettingsClient with the specified values. +func NewArcSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ArcSettingsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ArcSettingsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Create - Create ArcSetting for HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ArcSettingsClient) Create(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, arcSetting ArcSetting, options *ArcSettingsCreateOptions) (ArcSettingsCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, arcSetting, options) + if err != nil { + return ArcSettingsCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ArcSettingsCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ArcSettingsCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *ArcSettingsClient) createCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, arcSetting ArcSetting, options *ArcSettingsCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, arcSetting) +} + +// createHandleResponse handles the Create response. +func (client *ArcSettingsClient) createHandleResponse(resp *http.Response) (ArcSettingsCreateResponse, error) { + result := ArcSettingsCreateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ArcSetting); err != nil { + return ArcSettingsCreateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *ArcSettingsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Delete ArcSetting resource details of HCI Cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ArcSettingsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, options *ArcSettingsBeginDeleteOptions) (ArcSettingsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, arcSettingName, options) + if err != nil { + return ArcSettingsDeletePollerResponse{}, err + } + result := ArcSettingsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ArcSettingsClient.Delete", "azure-async-operation", resp, client.pl, client.deleteHandleError) + if err != nil { + return ArcSettingsDeletePollerResponse{}, err + } + result.Poller = &ArcSettingsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete ArcSetting resource details of HCI Cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ArcSettingsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, options *ArcSettingsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, 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, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ArcSettingsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, options *ArcSettingsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ArcSettingsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get ArcSetting resource details of HCI Cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ArcSettingsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, options *ArcSettingsGetOptions) (ArcSettingsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, options) + if err != nil { + return ArcSettingsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ArcSettingsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ArcSettingsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ArcSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, options *ArcSettingsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ArcSettingsClient) getHandleResponse(resp *http.Response) (ArcSettingsGetResponse, error) { + result := ArcSettingsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ArcSetting); err != nil { + return ArcSettingsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ArcSettingsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByCluster - Get ArcSetting resources of HCI Cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ArcSettingsClient) ListByCluster(resourceGroupName string, clusterName string, options *ArcSettingsListByClusterOptions) *ArcSettingsListByClusterPager { + return &ArcSettingsListByClusterPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByClusterCreateRequest(ctx, resourceGroupName, clusterName, options) + }, + advancer: func(ctx context.Context, resp ArcSettingsListByClusterResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ArcSettingList.NextLink) + }, + } +} + +// listByClusterCreateRequest creates the ListByCluster request. +func (client *ArcSettingsClient) listByClusterCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ArcSettingsListByClusterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByClusterHandleResponse handles the ListByCluster response. +func (client *ArcSettingsClient) listByClusterHandleResponse(resp *http.Response) (ArcSettingsListByClusterResponse, error) { + result := ArcSettingsListByClusterResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ArcSettingList); err != nil { + return ArcSettingsListByClusterResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByClusterHandleError handles the ListByCluster error response. +func (client *ArcSettingsClient) listByClusterHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_clusters_client.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_clusters_client.go new file mode 100644 index 000000000000..6947cf9c642d --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_clusters_client.go @@ -0,0 +1,406 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ClustersClient contains the methods for the Clusters group. +// Don't use this type directly, use NewClustersClient() instead. +type ClustersClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewClustersClient creates a new instance of ClustersClient with the specified values. +func NewClustersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ClustersClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ClustersClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// Create - Create an HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) Create(ctx context.Context, resourceGroupName string, clusterName string, cluster Cluster, options *ClustersCreateOptions) (ClustersCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, clusterName, cluster, options) + if err != nil { + return ClustersCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *ClustersClient) createCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, cluster Cluster, options *ClustersCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, cluster) +} + +// createHandleResponse handles the Create response. +func (client *ClustersClient) createHandleResponse(resp *http.Response) (ClustersCreateResponse, error) { + result := ClustersCreateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Cluster); err != nil { + return ClustersCreateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *ClustersClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Delete - Delete an HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersDeleteOptions) (ClustersDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ClustersDeleteResponse{}, client.deleteHandleError(resp) + } + return ClustersDeleteResponse{RawResponse: resp}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ClustersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ClustersClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (ClustersGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, options) + if err != nil { + return ClustersGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ClustersClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ClustersClient) getHandleResponse(resp *http.Response) (ClustersGetResponse, error) { + result := ClustersGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Cluster); err != nil { + return ClustersGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ClustersClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByResourceGroup - List all HCI clusters in a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) ListByResourceGroup(resourceGroupName string, options *ClustersListByResourceGroupOptions) *ClustersListByResourceGroupPager { + return &ClustersListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp ClustersListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ClusterList.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ClustersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClustersListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters" + 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.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ClustersClient) listByResourceGroupHandleResponse(resp *http.Response) (ClustersListByResourceGroupResponse, error) { + result := ClustersListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ClusterList); err != nil { + return ClustersListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *ClustersClient) listByResourceGroupHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListBySubscription - List all HCI clusters in a subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) ListBySubscription(options *ClustersListBySubscriptionOptions) *ClustersListBySubscriptionPager { + return &ClustersListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp ClustersListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ClusterList.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ClustersClient) listBySubscriptionCreateRequest(ctx context.Context, options *ClustersListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStackHCI/clusters" + 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.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ClustersClient) listBySubscriptionHandleResponse(resp *http.Response) (ClustersListBySubscriptionResponse, error) { + result := ClustersListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ClusterList); err != nil { + return ClustersListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *ClustersClient) listBySubscriptionHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Update - Update an HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ClustersClient) Update(ctx context.Context, resourceGroupName string, clusterName string, cluster ClusterPatch, options *ClustersUpdateOptions) (ClustersUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, cluster, options) + if err != nil { + return ClustersUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ClustersUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClustersUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ClustersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, cluster ClusterPatch, options *ClustersUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, cluster) +} + +// updateHandleResponse handles the Update response. +func (client *ClustersClient) updateHandleResponse(resp *http.Response) (ClustersUpdateResponse, error) { + result := ClustersUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Cluster); err != nil { + return ClustersUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ClustersClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_constants.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_constants.go new file mode 100644 index 000000000000..08b861678723 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_constants.go @@ -0,0 +1,376 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +const ( + module = "armazurestackhci" + version = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// ToPtr returns a *ActionType pointing to the current value. +func (c ActionType) ToPtr() *ActionType { + return &c +} + +// ArcSettingAggregateState - Aggregate state of Arc agent across the nodes in this HCI cluster. +type ArcSettingAggregateState string + +const ( + ArcSettingAggregateStateCanceled ArcSettingAggregateState = "Canceled" + ArcSettingAggregateStateConnected ArcSettingAggregateState = "Connected" + ArcSettingAggregateStateCreating ArcSettingAggregateState = "Creating" + ArcSettingAggregateStateDeleted ArcSettingAggregateState = "Deleted" + ArcSettingAggregateStateDeleting ArcSettingAggregateState = "Deleting" + ArcSettingAggregateStateDisconnected ArcSettingAggregateState = "Disconnected" + ArcSettingAggregateStateError ArcSettingAggregateState = "Error" + ArcSettingAggregateStateFailed ArcSettingAggregateState = "Failed" + ArcSettingAggregateStateInProgress ArcSettingAggregateState = "InProgress" + ArcSettingAggregateStateMoving ArcSettingAggregateState = "Moving" + ArcSettingAggregateStateNotSpecified ArcSettingAggregateState = "NotSpecified" + ArcSettingAggregateStatePartiallyConnected ArcSettingAggregateState = "PartiallyConnected" + ArcSettingAggregateStatePartiallySucceeded ArcSettingAggregateState = "PartiallySucceeded" + ArcSettingAggregateStateSucceeded ArcSettingAggregateState = "Succeeded" + ArcSettingAggregateStateUpdating ArcSettingAggregateState = "Updating" +) + +// PossibleArcSettingAggregateStateValues returns the possible values for the ArcSettingAggregateState const type. +func PossibleArcSettingAggregateStateValues() []ArcSettingAggregateState { + return []ArcSettingAggregateState{ + ArcSettingAggregateStateCanceled, + ArcSettingAggregateStateConnected, + ArcSettingAggregateStateCreating, + ArcSettingAggregateStateDeleted, + ArcSettingAggregateStateDeleting, + ArcSettingAggregateStateDisconnected, + ArcSettingAggregateStateError, + ArcSettingAggregateStateFailed, + ArcSettingAggregateStateInProgress, + ArcSettingAggregateStateMoving, + ArcSettingAggregateStateNotSpecified, + ArcSettingAggregateStatePartiallyConnected, + ArcSettingAggregateStatePartiallySucceeded, + ArcSettingAggregateStateSucceeded, + ArcSettingAggregateStateUpdating, + } +} + +// ToPtr returns a *ArcSettingAggregateState pointing to the current value. +func (c ArcSettingAggregateState) ToPtr() *ArcSettingAggregateState { + return &c +} + +// 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, + } +} + +// ToPtr returns a *CreatedByType pointing to the current value. +func (c CreatedByType) ToPtr() *CreatedByType { + return &c +} + +// DiagnosticLevel - Desired level of diagnostic data emitted by the cluster. +type DiagnosticLevel string + +const ( + DiagnosticLevelBasic DiagnosticLevel = "Basic" + DiagnosticLevelEnhanced DiagnosticLevel = "Enhanced" + DiagnosticLevelOff DiagnosticLevel = "Off" +) + +// PossibleDiagnosticLevelValues returns the possible values for the DiagnosticLevel const type. +func PossibleDiagnosticLevelValues() []DiagnosticLevel { + return []DiagnosticLevel{ + DiagnosticLevelBasic, + DiagnosticLevelEnhanced, + DiagnosticLevelOff, + } +} + +// ToPtr returns a *DiagnosticLevel pointing to the current value. +func (c DiagnosticLevel) ToPtr() *DiagnosticLevel { + return &c +} + +// ExtensionAggregateState - Aggregate state of Arc Extensions across the nodes in this HCI cluster. +type ExtensionAggregateState string + +const ( + ExtensionAggregateStateCanceled ExtensionAggregateState = "Canceled" + ExtensionAggregateStateConnected ExtensionAggregateState = "Connected" + ExtensionAggregateStateCreating ExtensionAggregateState = "Creating" + ExtensionAggregateStateDeleted ExtensionAggregateState = "Deleted" + ExtensionAggregateStateDeleting ExtensionAggregateState = "Deleting" + ExtensionAggregateStateDisconnected ExtensionAggregateState = "Disconnected" + ExtensionAggregateStateError ExtensionAggregateState = "Error" + ExtensionAggregateStateFailed ExtensionAggregateState = "Failed" + ExtensionAggregateStateInProgress ExtensionAggregateState = "InProgress" + ExtensionAggregateStateMoving ExtensionAggregateState = "Moving" + ExtensionAggregateStateNotSpecified ExtensionAggregateState = "NotSpecified" + ExtensionAggregateStatePartiallyConnected ExtensionAggregateState = "PartiallyConnected" + ExtensionAggregateStatePartiallySucceeded ExtensionAggregateState = "PartiallySucceeded" + ExtensionAggregateStateSucceeded ExtensionAggregateState = "Succeeded" + ExtensionAggregateStateUpdating ExtensionAggregateState = "Updating" +) + +// PossibleExtensionAggregateStateValues returns the possible values for the ExtensionAggregateState const type. +func PossibleExtensionAggregateStateValues() []ExtensionAggregateState { + return []ExtensionAggregateState{ + ExtensionAggregateStateCanceled, + ExtensionAggregateStateConnected, + ExtensionAggregateStateCreating, + ExtensionAggregateStateDeleted, + ExtensionAggregateStateDeleting, + ExtensionAggregateStateDisconnected, + ExtensionAggregateStateError, + ExtensionAggregateStateFailed, + ExtensionAggregateStateInProgress, + ExtensionAggregateStateMoving, + ExtensionAggregateStateNotSpecified, + ExtensionAggregateStatePartiallyConnected, + ExtensionAggregateStatePartiallySucceeded, + ExtensionAggregateStateSucceeded, + ExtensionAggregateStateUpdating, + } +} + +// ToPtr returns a *ExtensionAggregateState pointing to the current value. +func (c ExtensionAggregateState) ToPtr() *ExtensionAggregateState { + return &c +} + +// ImdsAttestation - IMDS attestation status of the cluster. +type ImdsAttestation string + +const ( + ImdsAttestationDisabled ImdsAttestation = "Disabled" + ImdsAttestationEnabled ImdsAttestation = "Enabled" +) + +// PossibleImdsAttestationValues returns the possible values for the ImdsAttestation const type. +func PossibleImdsAttestationValues() []ImdsAttestation { + return []ImdsAttestation{ + ImdsAttestationDisabled, + ImdsAttestationEnabled, + } +} + +// ToPtr returns a *ImdsAttestation pointing to the current value. +func (c ImdsAttestation) ToPtr() *ImdsAttestation { + return &c +} + +// NodeArcState - State of Arc agent in this node. +type NodeArcState string + +const ( + NodeArcStateCanceled NodeArcState = "Canceled" + NodeArcStateConnected NodeArcState = "Connected" + NodeArcStateCreating NodeArcState = "Creating" + NodeArcStateDeleted NodeArcState = "Deleted" + NodeArcStateDeleting NodeArcState = "Deleting" + NodeArcStateDisconnected NodeArcState = "Disconnected" + NodeArcStateError NodeArcState = "Error" + NodeArcStateFailed NodeArcState = "Failed" + NodeArcStateMoving NodeArcState = "Moving" + NodeArcStateNotSpecified NodeArcState = "NotSpecified" + NodeArcStateSucceeded NodeArcState = "Succeeded" + NodeArcStateUpdating NodeArcState = "Updating" +) + +// PossibleNodeArcStateValues returns the possible values for the NodeArcState const type. +func PossibleNodeArcStateValues() []NodeArcState { + return []NodeArcState{ + NodeArcStateCanceled, + NodeArcStateConnected, + NodeArcStateCreating, + NodeArcStateDeleted, + NodeArcStateDeleting, + NodeArcStateDisconnected, + NodeArcStateError, + NodeArcStateFailed, + NodeArcStateMoving, + NodeArcStateNotSpecified, + NodeArcStateSucceeded, + NodeArcStateUpdating, + } +} + +// ToPtr returns a *NodeArcState pointing to the current value. +func (c NodeArcState) ToPtr() *NodeArcState { + return &c +} + +// NodeExtensionState - State of Arc Extension in this node. +type NodeExtensionState string + +const ( + NodeExtensionStateCanceled NodeExtensionState = "Canceled" + NodeExtensionStateConnected NodeExtensionState = "Connected" + NodeExtensionStateCreating NodeExtensionState = "Creating" + NodeExtensionStateDeleted NodeExtensionState = "Deleted" + NodeExtensionStateDeleting NodeExtensionState = "Deleting" + NodeExtensionStateDisconnected NodeExtensionState = "Disconnected" + NodeExtensionStateError NodeExtensionState = "Error" + NodeExtensionStateFailed NodeExtensionState = "Failed" + NodeExtensionStateMoving NodeExtensionState = "Moving" + NodeExtensionStateNotSpecified NodeExtensionState = "NotSpecified" + NodeExtensionStateSucceeded NodeExtensionState = "Succeeded" + NodeExtensionStateUpdating NodeExtensionState = "Updating" +) + +// PossibleNodeExtensionStateValues returns the possible values for the NodeExtensionState const type. +func PossibleNodeExtensionStateValues() []NodeExtensionState { + return []NodeExtensionState{ + NodeExtensionStateCanceled, + NodeExtensionStateConnected, + NodeExtensionStateCreating, + NodeExtensionStateDeleted, + NodeExtensionStateDeleting, + NodeExtensionStateDisconnected, + NodeExtensionStateError, + NodeExtensionStateFailed, + NodeExtensionStateMoving, + NodeExtensionStateNotSpecified, + NodeExtensionStateSucceeded, + NodeExtensionStateUpdating, + } +} + +// ToPtr returns a *NodeExtensionState pointing to the current value. +func (c NodeExtensionState) ToPtr() *NodeExtensionState { + return &c +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ToPtr returns a *Origin pointing to the current value. +func (c Origin) ToPtr() *Origin { + return &c +} + +// ProvisioningState - Provisioning state of the ArcSetting proxy resource. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + } +} + +// ToPtr returns a *ProvisioningState pointing to the current value. +func (c ProvisioningState) ToPtr() *ProvisioningState { + return &c +} + +// Status - Status of the cluster agent. +type Status string + +const ( + StatusConnectedRecently Status = "ConnectedRecently" + StatusDisconnected Status = "Disconnected" + StatusError Status = "Error" + StatusNotConnectedRecently Status = "NotConnectedRecently" + StatusNotYetRegistered Status = "NotYetRegistered" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusConnectedRecently, + StatusDisconnected, + StatusError, + StatusNotConnectedRecently, + StatusNotYetRegistered, + } +} + +// ToPtr returns a *Status pointing to the current value. +func (c Status) ToPtr() *Status { + return &c +} + +// WindowsServerSubscription - Desired state of Windows Server Subscription. +type WindowsServerSubscription string + +const ( + WindowsServerSubscriptionDisabled WindowsServerSubscription = "Disabled" + WindowsServerSubscriptionEnabled WindowsServerSubscription = "Enabled" +) + +// PossibleWindowsServerSubscriptionValues returns the possible values for the WindowsServerSubscription const type. +func PossibleWindowsServerSubscriptionValues() []WindowsServerSubscription { + return []WindowsServerSubscription{ + WindowsServerSubscriptionDisabled, + WindowsServerSubscriptionEnabled, + } +} + +// ToPtr returns a *WindowsServerSubscription pointing to the current value. +func (c WindowsServerSubscription) ToPtr() *WindowsServerSubscription { + return &c +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_extensions_client.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_extensions_client.go new file mode 100644 index 000000000000..f28bed5ce192 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_extensions_client.go @@ -0,0 +1,434 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "context" + "errors" + "fmt" + "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/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ExtensionsClient contains the methods for the Extensions group. +// Don't use this type directly, use NewExtensionsClient() instead. +type ExtensionsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewExtensionsClient creates a new instance of ExtensionsClient with the specified values. +func NewExtensionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *ExtensionsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &ExtensionsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreate - Create Extension for HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) BeginCreate(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension, options *ExtensionsBeginCreateOptions) (ExtensionsCreatePollerResponse, error) { + resp, err := client.create(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, extension, options) + if err != nil { + return ExtensionsCreatePollerResponse{}, err + } + result := ExtensionsCreatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ExtensionsClient.Create", "azure-async-operation", resp, client.pl, client.createHandleError) + if err != nil { + return ExtensionsCreatePollerResponse{}, err + } + result.Poller = &ExtensionsCreatePoller{ + pt: pt, + } + return result, nil +} + +// Create - Create Extension for HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) create(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension, options *ExtensionsBeginCreateOptions) (*http.Response, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, extension, 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, client.createHandleError(resp) + } + return resp, nil +} + +// createCreateRequest creates the Create request. +func (client *ExtensionsClient) createCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension, options *ExtensionsBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, extension) +} + +// createHandleError handles the Create error response. +func (client *ExtensionsClient) createHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginDelete - Delete particular Arc Extension of HCI Cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) BeginDelete(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, options *ExtensionsBeginDeleteOptions) (ExtensionsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, options) + if err != nil { + return ExtensionsDeletePollerResponse{}, err + } + result := ExtensionsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ExtensionsClient.Delete", "azure-async-operation", resp, client.pl, client.deleteHandleError) + if err != nil { + return ExtensionsDeletePollerResponse{}, err + } + result.Poller = &ExtensionsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Delete particular Arc Extension of HCI Cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, options *ExtensionsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, 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, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, options *ExtensionsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ExtensionsClient) deleteHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// Get - Get particular Arc Extension of HCI Cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, options *ExtensionsGetOptions) (ExtensionsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, options) + if err != nil { + return ExtensionsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ExtensionsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExtensionsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ExtensionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, options *ExtensionsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ExtensionsClient) getHandleResponse(resp *http.Response) (ExtensionsGetResponse, error) { + result := ExtensionsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.Extension); err != nil { + return ExtensionsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ExtensionsClient) getHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// ListByArcSetting - List all Extensions under ArcSetting resource. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) ListByArcSetting(resourceGroupName string, clusterName string, arcSettingName string, options *ExtensionsListByArcSettingOptions) *ExtensionsListByArcSettingPager { + return &ExtensionsListByArcSettingPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByArcSettingCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, options) + }, + advancer: func(ctx context.Context, resp ExtensionsListByArcSettingResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.ExtensionList.NextLink) + }, + } +} + +// listByArcSettingCreateRequest creates the ListByArcSetting request. +func (client *ExtensionsClient) listByArcSettingCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, options *ExtensionsListByArcSettingOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByArcSettingHandleResponse handles the ListByArcSetting response. +func (client *ExtensionsClient) listByArcSettingHandleResponse(resp *http.Response) (ExtensionsListByArcSettingResponse, error) { + result := ExtensionsListByArcSettingResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtensionList); err != nil { + return ExtensionsListByArcSettingResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByArcSettingHandleError handles the ListByArcSetting error response. +func (client *ExtensionsClient) listByArcSettingHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} + +// BeginUpdate - Update Extension for HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension, options *ExtensionsBeginUpdateOptions) (ExtensionsUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, extension, options) + if err != nil { + return ExtensionsUpdatePollerResponse{}, err + } + result := ExtensionsUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("ExtensionsClient.Update", "original-uri", resp, client.pl, client.updateHandleError) + if err != nil { + return ExtensionsUpdatePollerResponse{}, err + } + result.Poller = &ExtensionsUpdatePoller{ + pt: pt, + } + return result, nil +} + +// Update - Update Extension for HCI cluster. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ExtensionsClient) update(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension, options *ExtensionsBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, clusterName, arcSettingName, extensionName, extension, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ExtensionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, clusterName string, arcSettingName string, extensionName string, extension Extension, options *ExtensionsBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHCI/clusters/{clusterName}/arcSettings/{arcSettingName}/extensions/{extensionName}" + 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 clusterName == "" { + return nil, errors.New("parameter clusterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{clusterName}", url.PathEscape(clusterName)) + if arcSettingName == "" { + return nil, errors.New("parameter arcSettingName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{arcSettingName}", url.PathEscape(arcSettingName)) + if extensionName == "" { + return nil, errors.New("parameter extensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{extensionName}", url.PathEscape(extensionName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, extension) +} + +// updateHandleError handles the Update error response. +func (client *ExtensionsClient) updateHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_models.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_models.go new file mode 100644 index 000000000000..988b6560e523 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_models.go @@ -0,0 +1,816 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// ArcSetting details. +type ArcSetting struct { + ProxyResource + // ArcSetting properties. + Properties *ArcSettingProperties `json:"properties,omitempty"` + + // READ-ONLY; System data of ArcSetting resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ArcSetting. +func (a ArcSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + a.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + return json.Marshal(objectMap) +} + +// ArcSettingList - List of ArcSetting proxy resources for the HCI cluster. +type ArcSettingList struct { + // READ-ONLY; Link to the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of ArcSetting proxy resources. + Value []*ArcSetting `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ArcSettingList. +func (a ArcSettingList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// ArcSettingProperties - ArcSetting properties. +type ArcSettingProperties struct { + // READ-ONLY; Aggregate state of Arc agent across the nodes in this HCI cluster. + AggregateState *ArcSettingAggregateState `json:"aggregateState,omitempty" azure:"ro"` + + // READ-ONLY; The resource group that hosts the Arc agents, ie. Hybrid Compute Machine resources. + ArcInstanceResourceGroup *string `json:"arcInstanceResourceGroup,omitempty" azure:"ro"` + + // READ-ONLY; State of Arc agent in each of the nodes. + PerNodeDetails []*PerNodeState `json:"perNodeDetails,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the ArcSetting proxy resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ArcSettingProperties. +func (a ArcSettingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregateState", a.AggregateState) + populate(objectMap, "arcInstanceResourceGroup", a.ArcInstanceResourceGroup) + populate(objectMap, "perNodeDetails", a.PerNodeDetails) + populate(objectMap, "provisioningState", a.ProvisioningState) + return json.Marshal(objectMap) +} + +// ArcSettingsBeginDeleteOptions contains the optional parameters for the ArcSettings.BeginDelete method. +type ArcSettingsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ArcSettingsCreateOptions contains the optional parameters for the ArcSettings.Create method. +type ArcSettingsCreateOptions struct { + // placeholder for future optional parameters +} + +// ArcSettingsGetOptions contains the optional parameters for the ArcSettings.Get method. +type ArcSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// ArcSettingsListByClusterOptions contains the optional parameters for the ArcSettings.ListByCluster method. +type ArcSettingsListByClusterOptions struct { + // placeholder for future optional parameters +} + +// Cluster details. +type Cluster struct { + TrackedResource + // Cluster properties. + Properties *ClusterProperties `json:"properties,omitempty"` + + // READ-ONLY; System data of Cluster resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Cluster. +func (c Cluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + return json.Marshal(objectMap) +} + +// ClusterDesiredProperties - Desired properties of the cluster. +type ClusterDesiredProperties struct { + // Desired level of diagnostic data emitted by the cluster. + DiagnosticLevel *DiagnosticLevel `json:"diagnosticLevel,omitempty"` + + // Desired state of Windows Server Subscription. + WindowsServerSubscription *WindowsServerSubscription `json:"windowsServerSubscription,omitempty"` +} + +// ClusterList - List of clusters. +type ClusterList struct { + // List of clusters. + Value []*Cluster `json:"value,omitempty"` + + // READ-ONLY; Link to the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterList. +func (c ClusterList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ClusterNode - Cluster node details. +type ClusterNode struct { + // READ-ONLY; Number of physical cores on the cluster node. + CoreCount *float32 `json:"coreCount,omitempty" azure:"ro"` + + // READ-ONLY; Id of the node in the cluster. + ID *float32 `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Manufacturer of the cluster node hardware. + Manufacturer *string `json:"manufacturer,omitempty" azure:"ro"` + + // READ-ONLY; Total available memory on the cluster node (in GiB). + MemoryInGiB *float32 `json:"memoryInGiB,omitempty" azure:"ro"` + + // READ-ONLY; Model name of the cluster node hardware. + Model *string `json:"model,omitempty" azure:"ro"` + + // READ-ONLY; Name of the cluster node. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Operating system running on the cluster node. + OSName *string `json:"osName,omitempty" azure:"ro"` + + // READ-ONLY; Version of the operating system running on the cluster node. + OSVersion *string `json:"osVersion,omitempty" azure:"ro"` + + // READ-ONLY; Immutable id of the cluster node. + SerialNumber *string `json:"serialNumber,omitempty" azure:"ro"` + + // READ-ONLY; State of Windows Server Subscription. + WindowsServerSubscription *WindowsServerSubscription `json:"windowsServerSubscription,omitempty" azure:"ro"` +} + +// ClusterPatch - Cluster details to update. +type ClusterPatch struct { + // Cluster properties. + Properties *ClusterPatchProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterPatch. +func (c ClusterPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// ClusterPatchProperties - Cluster properties. +type ClusterPatchProperties struct { + // App id of cluster AAD identity. + AADClientID *string `json:"aadClientId,omitempty"` + + // Tenant id of cluster AAD identity. + AADTenantID *string `json:"aadTenantId,omitempty"` + + // Endpoint configured for management from the Azure portal + CloudManagementEndpoint *string `json:"cloudManagementEndpoint,omitempty"` + + // Desired properties of the cluster. + DesiredProperties *ClusterDesiredProperties `json:"desiredProperties,omitempty"` +} + +// ClusterProperties - Cluster properties. +type ClusterProperties struct { + // REQUIRED; App id of cluster AAD identity. + AADClientID *string `json:"aadClientId,omitempty"` + + // REQUIRED; Tenant id of cluster AAD identity. + AADTenantID *string `json:"aadTenantId,omitempty"` + + // Endpoint configured for management from the Azure portal. + CloudManagementEndpoint *string `json:"cloudManagementEndpoint,omitempty"` + + // Desired properties of the cluster. + DesiredProperties *ClusterDesiredProperties `json:"desiredProperties,omitempty"` + + // READ-ONLY; Type of billing applied to the resource. + BillingModel *string `json:"billingModel,omitempty" azure:"ro"` + + // READ-ONLY; Unique, immutable resource id. + CloudID *string `json:"cloudId,omitempty" azure:"ro"` + + // READ-ONLY; Most recent billing meter timestamp. + LastBillingTimestamp *time.Time `json:"lastBillingTimestamp,omitempty" azure:"ro"` + + // READ-ONLY; Most recent cluster sync timestamp. + LastSyncTimestamp *time.Time `json:"lastSyncTimestamp,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; First cluster sync timestamp. + RegistrationTimestamp *time.Time `json:"registrationTimestamp,omitempty" azure:"ro"` + + // READ-ONLY; Properties reported by cluster agent. + ReportedProperties *ClusterReportedProperties `json:"reportedProperties,omitempty" azure:"ro"` + + // READ-ONLY; Status of the cluster agent. + Status *Status `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; Number of days remaining in the trial period. + TrialDaysRemaining *float32 `json:"trialDaysRemaining,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterProperties. +func (c ClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aadClientId", c.AADClientID) + populate(objectMap, "aadTenantId", c.AADTenantID) + populate(objectMap, "billingModel", c.BillingModel) + populate(objectMap, "cloudId", c.CloudID) + populate(objectMap, "cloudManagementEndpoint", c.CloudManagementEndpoint) + populate(objectMap, "desiredProperties", c.DesiredProperties) + populateTimeRFC3339(objectMap, "lastBillingTimestamp", c.LastBillingTimestamp) + populateTimeRFC3339(objectMap, "lastSyncTimestamp", c.LastSyncTimestamp) + populate(objectMap, "provisioningState", c.ProvisioningState) + populateTimeRFC3339(objectMap, "registrationTimestamp", c.RegistrationTimestamp) + populate(objectMap, "reportedProperties", c.ReportedProperties) + populate(objectMap, "status", c.Status) + populate(objectMap, "trialDaysRemaining", c.TrialDaysRemaining) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterProperties. +func (c *ClusterProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "aadClientId": + err = unpopulate(val, &c.AADClientID) + delete(rawMsg, key) + case "aadTenantId": + err = unpopulate(val, &c.AADTenantID) + delete(rawMsg, key) + case "billingModel": + err = unpopulate(val, &c.BillingModel) + delete(rawMsg, key) + case "cloudId": + err = unpopulate(val, &c.CloudID) + delete(rawMsg, key) + case "cloudManagementEndpoint": + err = unpopulate(val, &c.CloudManagementEndpoint) + delete(rawMsg, key) + case "desiredProperties": + err = unpopulate(val, &c.DesiredProperties) + delete(rawMsg, key) + case "lastBillingTimestamp": + err = unpopulateTimeRFC3339(val, &c.LastBillingTimestamp) + delete(rawMsg, key) + case "lastSyncTimestamp": + err = unpopulateTimeRFC3339(val, &c.LastSyncTimestamp) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &c.ProvisioningState) + delete(rawMsg, key) + case "registrationTimestamp": + err = unpopulateTimeRFC3339(val, &c.RegistrationTimestamp) + delete(rawMsg, key) + case "reportedProperties": + err = unpopulate(val, &c.ReportedProperties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &c.Status) + delete(rawMsg, key) + case "trialDaysRemaining": + err = unpopulate(val, &c.TrialDaysRemaining) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ClusterReportedProperties - Properties reported by cluster agent. +type ClusterReportedProperties struct { + // Level of diagnostic data emitted by the cluster. + DiagnosticLevel *DiagnosticLevel `json:"diagnosticLevel,omitempty"` + + // READ-ONLY; Unique id generated by the on-prem cluster. + ClusterID *string `json:"clusterId,omitempty" azure:"ro"` + + // READ-ONLY; Name of the on-prem cluster connected to this resource. + ClusterName *string `json:"clusterName,omitempty" azure:"ro"` + + // READ-ONLY; Version of the cluster software. + ClusterVersion *string `json:"clusterVersion,omitempty" azure:"ro"` + + // READ-ONLY; IMDS attestation status of the cluster. + ImdsAttestation *ImdsAttestation `json:"imdsAttestation,omitempty" azure:"ro"` + + // READ-ONLY; Last time the cluster reported the data. + LastUpdated *time.Time `json:"lastUpdated,omitempty" azure:"ro"` + + // READ-ONLY; List of nodes reported by the cluster. + Nodes []*ClusterNode `json:"nodes,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ClusterReportedProperties. +func (c ClusterReportedProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clusterId", c.ClusterID) + populate(objectMap, "clusterName", c.ClusterName) + populate(objectMap, "clusterVersion", c.ClusterVersion) + populate(objectMap, "diagnosticLevel", c.DiagnosticLevel) + populate(objectMap, "imdsAttestation", c.ImdsAttestation) + populateTimeRFC3339(objectMap, "lastUpdated", c.LastUpdated) + populate(objectMap, "nodes", c.Nodes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ClusterReportedProperties. +func (c *ClusterReportedProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "clusterId": + err = unpopulate(val, &c.ClusterID) + delete(rawMsg, key) + case "clusterName": + err = unpopulate(val, &c.ClusterName) + delete(rawMsg, key) + case "clusterVersion": + err = unpopulate(val, &c.ClusterVersion) + delete(rawMsg, key) + case "diagnosticLevel": + err = unpopulate(val, &c.DiagnosticLevel) + delete(rawMsg, key) + case "imdsAttestation": + err = unpopulate(val, &c.ImdsAttestation) + delete(rawMsg, key) + case "lastUpdated": + err = unpopulateTimeRFC3339(val, &c.LastUpdated) + delete(rawMsg, key) + case "nodes": + err = unpopulate(val, &c.Nodes) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ClustersCreateOptions contains the optional parameters for the Clusters.Create method. +type ClustersCreateOptions struct { + // placeholder for future optional parameters +} + +// ClustersDeleteOptions contains the optional parameters for the Clusters.Delete method. +type ClustersDeleteOptions struct { + // placeholder for future optional parameters +} + +// ClustersGetOptions contains the optional parameters for the Clusters.Get method. +type ClustersGetOptions struct { + // placeholder for future optional parameters +} + +// ClustersListByResourceGroupOptions contains the optional parameters for the Clusters.ListByResourceGroup method. +type ClustersListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClustersListBySubscriptionOptions contains the optional parameters for the Clusters.ListBySubscription method. +type ClustersListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ClustersUpdateOptions contains the optional parameters for the Clusters.Update method. +type ClustersUpdateOptions struct { + // placeholder for future optional parameters +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData +// error response format.). +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // The error object. + InnerError *ErrorDetail `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// Extension - Details of a particular extension in HCI Cluster. +type Extension struct { + ProxyResource + // Describes Machine Extension Properties. + Properties *ExtensionProperties `json:"properties,omitempty"` + + // READ-ONLY; System data of Extension resource. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Extension. +func (e Extension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + e.ProxyResource.marshalInternal(objectMap) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + return json.Marshal(objectMap) +} + +// ExtensionList - List of Extensions in HCI cluster. +type ExtensionList struct { + // READ-ONLY; Link to the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of Extensions in HCI cluster. + Value []*Extension `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionList. +func (e ExtensionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// ExtensionParameters - Describes the properties of a Machine Extension. This object mirrors the definition in HybridCompute. +type ExtensionParameters struct { + // Indicates whether the extension should use a newer minor version if one is available at deployment time. Once deployed, however, the extension will not + // upgrade minor versions unless redeployed, even + // with this property set to true. + AutoUpgradeMinorVersion *bool `json:"autoUpgradeMinorVersion,omitempty"` + + // How the extension handler should be forced to update even if the extension configuration has not changed. + ForceUpdateTag *string `json:"forceUpdateTag,omitempty"` + + // Protected settings (may contain secrets). + ProtectedSettings map[string]interface{} `json:"protectedSettings,omitempty"` + + // The name of the extension handler publisher. + Publisher *string `json:"publisher,omitempty"` + + // Json formatted public settings for the extension. + Settings map[string]interface{} `json:"settings,omitempty"` + + // Specifies the type of the extension; an example is "CustomScriptExtension". + Type *string `json:"type,omitempty"` + + // Specifies the version of the script handler. + TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` +} + +// ExtensionProperties - Status of Arc Extension for a particular node in HCI Cluster. +type ExtensionProperties struct { + // Parameters specific to this extension type. + ExtensionParameters *ExtensionParameters `json:"extensionParameters,omitempty"` + + // READ-ONLY; Aggregate state of Arc Extensions across the nodes in this HCI cluster. + AggregateState *ExtensionAggregateState `json:"aggregateState,omitempty" azure:"ro"` + + // READ-ONLY; State of Arc Extension in each of the nodes. + PerNodeExtensionDetails []*PerNodeExtensionState `json:"perNodeExtensionDetails,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the Extension proxy resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ExtensionProperties. +func (e ExtensionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregateState", e.AggregateState) + populate(objectMap, "extensionParameters", e.ExtensionParameters) + populate(objectMap, "perNodeExtensionDetails", e.PerNodeExtensionDetails) + populate(objectMap, "provisioningState", e.ProvisioningState) + return json.Marshal(objectMap) +} + +// ExtensionsBeginCreateOptions contains the optional parameters for the Extensions.BeginCreate method. +type ExtensionsBeginCreateOptions struct { + // placeholder for future optional parameters +} + +// ExtensionsBeginDeleteOptions contains the optional parameters for the Extensions.BeginDelete method. +type ExtensionsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// ExtensionsBeginUpdateOptions contains the optional parameters for the Extensions.BeginUpdate method. +type ExtensionsBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// ExtensionsGetOptions contains the optional parameters for the Extensions.Get method. +type ExtensionsGetOptions struct { + // placeholder for future optional parameters +} + +// ExtensionsListByArcSettingOptions contains the optional parameters for the Extensions.ListByArcSetting method. +type ExtensionsListByArcSettingOptions struct { + // placeholder for future optional parameters +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual + // Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationsListOptions contains the optional parameters for the Operations.List method. +type OperationsListOptions struct { + // placeholder for future optional parameters +} + +// PerNodeExtensionState - Status of Arc Extension for a particular node in HCI Cluster. +type PerNodeExtensionState struct { + // READ-ONLY; Fully qualified resource ID for the particular Arc Extension on this node. + Extension *string `json:"extension,omitempty" azure:"ro"` + + // READ-ONLY; Name of the node in HCI Cluster. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; State of Arc Extension in this node. + State *NodeExtensionState `json:"state,omitempty" azure:"ro"` +} + +// PerNodeState - Status of Arc agent for a particular node in HCI Cluster. +type PerNodeState struct { + // READ-ONLY; Fully qualified resource ID for the Arc agent of this node. + ArcInstance *string `json:"arcInstance,omitempty" azure:"ro"` + + // READ-ONLY; Name of the Node in HCI Cluster + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; State of Arc agent in this node. + State *NodeArcState `json:"state,omitempty" azure:"ro"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location +type ProxyResource struct { + Resource +} + +func (p ProxyResource) marshalInternal(objectMap map[string]interface{}) { + p.Resource.marshalInternal(objectMap) +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // 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 type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + r.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal(objectMap map[string]interface{}) { + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) +} + +// 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"` +} + +// 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 err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' +type TrackedResource struct { + Resource + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + t.marshalInternal(objectMap) + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal(objectMap map[string]interface{}) { + t.Resource.marshalInternal(objectMap) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) +} + +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, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_operations_client.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_operations_client.go new file mode 100644 index 000000000000..aa5ee804c40b --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_operations_client.go @@ -0,0 +1,92 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "context" + "fmt" + "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/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 { + ep string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &OperationsClient{ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// List - List all available Microsoft.AzureStackHCI provider operations +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationsListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return OperationsListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsListResponse{}, client.listHandleError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureStackHCI/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.ep, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-09-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsListResponse, error) { + result := OperationsListResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsListResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *OperationsClient) listHandleError(resp *http.Response) error { + body, err := runtime.Payload(resp) + if err != nil { + return runtime.NewResponseError(err, resp) + } + errType := ErrorResponse{raw: string(body)} + if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { + return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) + } + return runtime.NewResponseError(&errType, resp) +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_pagers.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_pagers.go new file mode 100644 index 000000000000..80276ced322a --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_pagers.go @@ -0,0 +1,233 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "reflect" +) + +// ArcSettingsListByClusterPager provides operations for iterating over paged responses. +type ArcSettingsListByClusterPager struct { + client *ArcSettingsClient + current ArcSettingsListByClusterResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ArcSettingsListByClusterResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ArcSettingsListByClusterPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ArcSettingsListByClusterPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ArcSettingList.NextLink == nil || len(*p.current.ArcSettingList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByClusterHandleError(resp) + return false + } + result, err := p.client.listByClusterHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ArcSettingsListByClusterResponse page. +func (p *ArcSettingsListByClusterPager) PageResponse() ArcSettingsListByClusterResponse { + return p.current +} + +// ClustersListByResourceGroupPager provides operations for iterating over paged responses. +type ClustersListByResourceGroupPager struct { + client *ClustersClient + current ClustersListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ClustersListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ClustersListByResourceGroupPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ClustersListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ClusterList.NextLink == nil || len(*p.current.ClusterList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ClustersListByResourceGroupResponse page. +func (p *ClustersListByResourceGroupPager) PageResponse() ClustersListByResourceGroupResponse { + return p.current +} + +// ClustersListBySubscriptionPager provides operations for iterating over paged responses. +type ClustersListBySubscriptionPager struct { + client *ClustersClient + current ClustersListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ClustersListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ClustersListBySubscriptionPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ClustersListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ClusterList.NextLink == nil || len(*p.current.ClusterList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ClustersListBySubscriptionResponse page. +func (p *ClustersListBySubscriptionPager) PageResponse() ClustersListBySubscriptionResponse { + return p.current +} + +// ExtensionsListByArcSettingPager provides operations for iterating over paged responses. +type ExtensionsListByArcSettingPager struct { + client *ExtensionsClient + current ExtensionsListByArcSettingResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, ExtensionsListByArcSettingResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *ExtensionsListByArcSettingPager) Err() error { + return p.err +} + +// NextPage returns true if the pager advanced to the next page. +// Returns false if there are no more pages or an error occurred. +func (p *ExtensionsListByArcSettingPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ExtensionList.NextLink == nil || len(*p.current.ExtensionList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.pl.Do(req) + if err != nil { + p.err = err + return false + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + p.err = p.client.listByArcSettingHandleError(resp) + return false + } + result, err := p.client.listByArcSettingHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current ExtensionsListByArcSettingResponse page. +func (p *ExtensionsListByArcSettingPager) PageResponse() ExtensionsListByArcSettingResponse { + return p.current +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_pollers.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_pollers.go new file mode 100644 index 000000000000..4afea2c40523 --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_pollers.go @@ -0,0 +1,187 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// ArcSettingsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ArcSettingsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ArcSettingsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ArcSettingsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ArcSettingsDeleteResponse will be returned. +func (p *ArcSettingsDeletePoller) FinalResponse(ctx context.Context) (ArcSettingsDeleteResponse, error) { + respType := ArcSettingsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ArcSettingsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ArcSettingsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ExtensionsCreatePoller provides polling facilities until the operation reaches a terminal state. +type ExtensionsCreatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ExtensionsCreatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ExtensionsCreatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ExtensionsCreateResponse will be returned. +func (p *ExtensionsCreatePoller) FinalResponse(ctx context.Context) (ExtensionsCreateResponse, error) { + respType := ExtensionsCreateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Extension) + if err != nil { + return ExtensionsCreateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ExtensionsCreatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ExtensionsDeletePoller provides polling facilities until the operation reaches a terminal state. +type ExtensionsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ExtensionsDeletePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ExtensionsDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ExtensionsDeleteResponse will be returned. +func (p *ExtensionsDeletePoller) FinalResponse(ctx context.Context) (ExtensionsDeleteResponse, error) { + respType := ExtensionsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return ExtensionsDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ExtensionsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// ExtensionsUpdatePoller provides polling facilities until the operation reaches a terminal state. +type ExtensionsUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *ExtensionsUpdatePoller) Done() bool { + return p.pt.Done() +} + +// Poll fetches the latest state of the LRO. It returns an HTTP response or error. +// If the LRO has completed successfully, the poller's state is updated and the HTTP +// response is returned. +// If the LRO has completed with failure or was cancelled, the poller's state is +// updated and the error is returned. +// If the LRO has not reached a terminal state, the poller's state is updated and +// the latest HTTP response is returned. +// If Poll fails, the poller's state is unmodified and the error is returned. +// Calling Poll on an LRO that has reached a terminal state will return the final +// HTTP response or error. +func (p *ExtensionsUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +// FinalResponse performs a final GET to the service and returns the final response +// for the polling operation. If there is an error performing the final GET then an error is returned. +// If the final GET succeeded then the final ExtensionsUpdateResponse will be returned. +func (p *ExtensionsUpdatePoller) FinalResponse(ctx context.Context) (ExtensionsUpdateResponse, error) { + respType := ExtensionsUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.Extension) + if err != nil { + return ExtensionsUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// ResumeToken returns a value representing the poller that can be used to resume +// the LRO at a later time. ResumeTokens are unique per service operation. +func (p *ExtensionsUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_response_types.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_response_types.go new file mode 100644 index 000000000000..b27c2279f67a --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_response_types.go @@ -0,0 +1,350 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// ArcSettingsCreateResponse contains the response from method ArcSettings.Create. +type ArcSettingsCreateResponse struct { + ArcSettingsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ArcSettingsCreateResult contains the result from method ArcSettings.Create. +type ArcSettingsCreateResult struct { + ArcSetting +} + +// ArcSettingsDeletePollerResponse contains the response from method ArcSettings.Delete. +type ArcSettingsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ArcSettingsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ArcSettingsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ArcSettingsDeleteResponse, error) { + respType := ArcSettingsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ArcSettingsDeletePollerResponse from the provided client and resume token. +func (l *ArcSettingsDeletePollerResponse) Resume(ctx context.Context, client *ArcSettingsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ArcSettingsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ArcSettingsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ArcSettingsDeleteResponse contains the response from method ArcSettings.Delete. +type ArcSettingsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ArcSettingsGetResponse contains the response from method ArcSettings.Get. +type ArcSettingsGetResponse struct { + ArcSettingsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ArcSettingsGetResult contains the result from method ArcSettings.Get. +type ArcSettingsGetResult struct { + ArcSetting +} + +// ArcSettingsListByClusterResponse contains the response from method ArcSettings.ListByCluster. +type ArcSettingsListByClusterResponse struct { + ArcSettingsListByClusterResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ArcSettingsListByClusterResult contains the result from method ArcSettings.ListByCluster. +type ArcSettingsListByClusterResult struct { + ArcSettingList +} + +// ClustersCreateResponse contains the response from method Clusters.Create. +type ClustersCreateResponse struct { + ClustersCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersCreateResult contains the result from method Clusters.Create. +type ClustersCreateResult struct { + Cluster +} + +// ClustersDeleteResponse contains the response from method Clusters.Delete. +type ClustersDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersGetResponse contains the response from method Clusters.Get. +type ClustersGetResponse struct { + ClustersGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersGetResult contains the result from method Clusters.Get. +type ClustersGetResult struct { + Cluster +} + +// ClustersListByResourceGroupResponse contains the response from method Clusters.ListByResourceGroup. +type ClustersListByResourceGroupResponse struct { + ClustersListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListByResourceGroupResult contains the result from method Clusters.ListByResourceGroup. +type ClustersListByResourceGroupResult struct { + ClusterList +} + +// ClustersListBySubscriptionResponse contains the response from method Clusters.ListBySubscription. +type ClustersListBySubscriptionResponse struct { + ClustersListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersListBySubscriptionResult contains the result from method Clusters.ListBySubscription. +type ClustersListBySubscriptionResult struct { + ClusterList +} + +// ClustersUpdateResponse contains the response from method Clusters.Update. +type ClustersUpdateResponse struct { + ClustersUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ClustersUpdateResult contains the result from method Clusters.Update. +type ClustersUpdateResult struct { + Cluster +} + +// ExtensionsCreatePollerResponse contains the response from method Extensions.Create. +type ExtensionsCreatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ExtensionsCreatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ExtensionsCreatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ExtensionsCreateResponse, error) { + respType := ExtensionsCreateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Extension) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ExtensionsCreatePollerResponse from the provided client and resume token. +func (l *ExtensionsCreatePollerResponse) Resume(ctx context.Context, client *ExtensionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ExtensionsClient.Create", token, client.pl, client.createHandleError) + if err != nil { + return err + } + poller := &ExtensionsCreatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ExtensionsCreateResponse contains the response from method Extensions.Create. +type ExtensionsCreateResponse struct { + ExtensionsCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExtensionsCreateResult contains the result from method Extensions.Create. +type ExtensionsCreateResult struct { + Extension +} + +// ExtensionsDeletePollerResponse contains the response from method Extensions.Delete. +type ExtensionsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *ExtensionsDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ExtensionsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ExtensionsDeleteResponse, error) { + respType := ExtensionsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ExtensionsDeletePollerResponse from the provided client and resume token. +func (l *ExtensionsDeletePollerResponse) Resume(ctx context.Context, client *ExtensionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ExtensionsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &ExtensionsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ExtensionsDeleteResponse contains the response from method Extensions.Delete. +type ExtensionsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExtensionsGetResponse contains the response from method Extensions.Get. +type ExtensionsGetResponse struct { + ExtensionsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExtensionsGetResult contains the result from method Extensions.Get. +type ExtensionsGetResult struct { + Extension +} + +// ExtensionsListByArcSettingResponse contains the response from method Extensions.ListByArcSetting. +type ExtensionsListByArcSettingResponse struct { + ExtensionsListByArcSettingResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExtensionsListByArcSettingResult contains the result from method Extensions.ListByArcSetting. +type ExtensionsListByArcSettingResult struct { + ExtensionList +} + +// ExtensionsUpdatePollerResponse contains the response from method Extensions.Update. +type ExtensionsUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *ExtensionsUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. +// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. +// A good starting value is 30 seconds. Note that some resources might benefit from a different value. +func (l ExtensionsUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ExtensionsUpdateResponse, error) { + respType := ExtensionsUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.Extension) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a ExtensionsUpdatePollerResponse from the provided client and resume token. +func (l *ExtensionsUpdatePollerResponse) Resume(ctx context.Context, client *ExtensionsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("ExtensionsClient.Update", token, client.pl, client.updateHandleError) + if err != nil { + return err + } + poller := &ExtensionsUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// ExtensionsUpdateResponse contains the response from method Extensions.Update. +type ExtensionsUpdateResponse struct { + ExtensionsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ExtensionsUpdateResult contains the result from method Extensions.Update. +type ExtensionsUpdateResult struct { + Extension +} + +// OperationsListResponse contains the response from method Operations.List. +type OperationsListResponse struct { + OperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationsListResult contains the result from method Operations.List. +type OperationsListResult struct { + OperationListResult +} diff --git a/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_time_rfc3339.go b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..a779a15eba3b --- /dev/null +++ b/sdk/resourcemanager/azurestackhci/armazurestackhci/zz_generated_time_rfc3339.go @@ -0,0 +1,85 @@ +//go:build go1.16 +// +build go1.16 + +// 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 armazurestackhci + +import ( + "encoding/json" + "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, 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 err + } + *t = (*time.Time)(&aux) + return nil +}