diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md new file mode 100644 index 000000000000..33ff48dccdb4 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2021-12-01) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/LICENSE.txt b/sdk/resourcemanager/extendedlocation/armextendedlocation/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/armextendedlocation/README.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/README.md new file mode 100644 index 000000000000..6cd80656fc69 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/README.md @@ -0,0 +1,75 @@ +# Azure Extendedlocation Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/armextendedlocation)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/armextendedlocation) + +The `armextendedlocation` module provides operations for working with Azure Extendedlocation. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/extendedlocation/armextendedlocation) + +# 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 Extendedlocation module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/armextendedlocation +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Extendedlocation. 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 Extendedlocation 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 := armextendedlocation.NewCustomLocationsClient(, 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 := armextendedlocation.NewCustomLocationsClient(, 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 `Extendedlocation` 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/extendedlocation/armextendedlocation/autorest.md b/sdk/resourcemanager/extendedlocation/armextendedlocation/autorest.md new file mode 100644 index 000000000000..d9e81c5c6651 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/resource-manager/readme.md +- /home/vsts/work/1/s/azure-rest-api-specs/specification/extendedlocation/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/extendedlocation/armextendedlocation/build.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/build.go new file mode 100644 index 000000000000..95dc5b6d9b69 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/armextendedlocation + +package armextendedlocation diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/ci.yml b/sdk/resourcemanager/extendedlocation/armextendedlocation/ci.yml new file mode 100644 index 000000000000..212769101e2d --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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/extendedlocation/armextendedlocation/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/extendedlocation/armextendedlocation/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/extendedlocation/armextendedlocation' diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod new file mode 100644 index 000000000000..91eecc6d79d6 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.mod @@ -0,0 +1,8 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/extendedlocation/armextendedlocation + +go 1.16 + +require ( + github.com/Azure/azure-sdk-for-go v59.4.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 +) diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum new file mode 100644 index 000000000000..aa6cc05eede2 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/go.sum @@ -0,0 +1,37 @@ +github.com/Azure/azure-sdk-for-go v59.4.0+incompatible h1:gDA8odnngdNd3KYHL2NoK1j9vpWBgEnFSjKKLpkC8Aw= +github.com/Azure/azure-sdk-for-go v59.4.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/extendedlocation/armextendedlocation/go_mod_tidy_hack.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/go_mod_tidy_hack.go new file mode 100644 index 000000000000..5f44367982c4 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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 armextendedlocation + +// 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/extendedlocation/armextendedlocation/zz_generated_constants.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_constants.go new file mode 100644 index 000000000000..1d65e59fc571 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_constants.go @@ -0,0 +1,79 @@ +//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 armextendedlocation + +const ( + module = "armextendedlocation" + version = "v0.1.0" +) + +// 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 +} + +// HostType - Type of host the Custom Locations is referencing (Kubernetes, etc…). +type HostType string + +const ( + HostTypeKubernetes HostType = "Kubernetes" +) + +// PossibleHostTypeValues returns the possible values for the HostType const type. +func PossibleHostTypeValues() []HostType { + return []HostType{ + HostTypeKubernetes, + } +} + +// ToPtr returns a *HostType pointing to the current value. +func (c HostType) ToPtr() *HostType { + return &c +} + +// ResourceIdentityType - The identity type. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeNone ResourceIdentityType = "None" + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeNone, + ResourceIdentityTypeSystemAssigned, + } +} + +// ToPtr returns a *ResourceIdentityType pointing to the current value. +func (c ResourceIdentityType) ToPtr() *ResourceIdentityType { + return &c +} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_customlocations_client.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_customlocations_client.go new file mode 100644 index 000000000000..101747545f61 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_customlocations_client.go @@ -0,0 +1,550 @@ +//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 armextendedlocation + +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" +) + +// CustomLocationsClient contains the methods for the CustomLocations group. +// Don't use this type directly, use NewCustomLocationsClient() instead. +type CustomLocationsClient struct { + ep string + pl runtime.Pipeline + subscriptionID string +} + +// NewCustomLocationsClient creates a new instance of CustomLocationsClient with the specified values. +func NewCustomLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *CustomLocationsClient { + cp := arm.ClientOptions{} + if options != nil { + cp = *options + } + if len(cp.Host) == 0 { + cp.Host = arm.AzurePublicCloud + } + return &CustomLocationsClient{subscriptionID: subscriptionID, ep: string(cp.Host), pl: armruntime.NewPipeline(module, version, credential, &cp)} +} + +// BeginCreateOrUpdate - Creates or updates a Custom Location in the specified Subscription and Resource Group +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocation, options *CustomLocationsBeginCreateOrUpdateOptions) (CustomLocationsCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return CustomLocationsCreateOrUpdatePollerResponse{}, err + } + result := CustomLocationsCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CustomLocationsClient.CreateOrUpdate", "azure-async-operation", resp, client.pl, client.createOrUpdateHandleError) + if err != nil { + return CustomLocationsCreateOrUpdatePollerResponse{}, err + } + result.Poller = &CustomLocationsCreateOrUpdatePoller{ + pt: pt, + } + return result, nil +} + +// CreateOrUpdate - Creates or updates a Custom Location in the specified Subscription and Resource Group +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocation, options *CustomLocationsBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, parameters, 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.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CustomLocationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters CustomLocation, options *CustomLocationsBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" + 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 resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *CustomLocationsClient) createOrUpdateHandleError(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 - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription Id. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsBeginDeleteOptions) (CustomLocationsDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) + if err != nil { + return CustomLocationsDeletePollerResponse{}, err + } + result := CustomLocationsDeletePollerResponse{ + RawResponse: resp, + } + pt, err := armruntime.NewPoller("CustomLocationsClient.Delete", "azure-async-operation", resp, client.pl, client.deleteHandleError) + if err != nil { + return CustomLocationsDeletePollerResponse{}, err + } + result.Poller = &CustomLocationsDeletePoller{ + pt: pt, + } + return result, nil +} + +// Delete - Deletes the Custom Location with the specified Resource Name, Resource Group, and Subscription Id. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CustomLocationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" + 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 resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *CustomLocationsClient) 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 - Gets the details of the customLocation with a specified resource group and name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsGetOptions) (CustomLocationsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return CustomLocationsGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CustomLocationsGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CustomLocationsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CustomLocationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" + 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 resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CustomLocationsClient) getHandleResponse(resp *http.Response) (CustomLocationsGetResponse, error) { + result := CustomLocationsGetResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomLocation); err != nil { + return CustomLocationsGetResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CustomLocationsClient) 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 - Gets a list of Custom Locations in the specified subscription and resource group. The operation returns properties of each Custom +// Location. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) ListByResourceGroup(resourceGroupName string, options *CustomLocationsListByResourceGroupOptions) *CustomLocationsListByResourceGroupPager { + return &CustomLocationsListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp CustomLocationsListByResourceGroupResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CustomLocationListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *CustomLocationsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *CustomLocationsListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations" + 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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *CustomLocationsClient) listByResourceGroupHandleResponse(resp *http.Response) (CustomLocationsListByResourceGroupResponse, error) { + result := CustomLocationsListByResourceGroupResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomLocationListResult); err != nil { + return CustomLocationsListByResourceGroupResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *CustomLocationsClient) 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 - Gets a list of Custom Locations in the specified subscription. The operation returns properties of each Custom Location +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) ListBySubscription(options *CustomLocationsListBySubscriptionOptions) *CustomLocationsListBySubscriptionPager { + return &CustomLocationsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp CustomLocationsListBySubscriptionResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CustomLocationListResult.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *CustomLocationsClient) listBySubscriptionCreateRequest(ctx context.Context, options *CustomLocationsListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ExtendedLocation/customLocations" + 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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *CustomLocationsClient) listBySubscriptionHandleResponse(resp *http.Response) (CustomLocationsListBySubscriptionResponse, error) { + result := CustomLocationsListBySubscriptionResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomLocationListResult); err != nil { + return CustomLocationsListBySubscriptionResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *CustomLocationsClient) 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) +} + +// ListEnabledResourceTypes - Gets the list of the Enabled Resource Types. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) ListEnabledResourceTypes(resourceGroupName string, resourceName string, options *CustomLocationsListEnabledResourceTypesOptions) *CustomLocationsListEnabledResourceTypesPager { + return &CustomLocationsListEnabledResourceTypesPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listEnabledResourceTypesCreateRequest(ctx, resourceGroupName, resourceName, options) + }, + advancer: func(ctx context.Context, resp CustomLocationsListEnabledResourceTypesResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.EnabledResourceTypesListResult.NextLink) + }, + } +} + +// listEnabledResourceTypesCreateRequest creates the ListEnabledResourceTypes request. +func (client *CustomLocationsClient) listEnabledResourceTypesCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *CustomLocationsListEnabledResourceTypesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}/enabledResourceTypes" + 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 resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listEnabledResourceTypesHandleResponse handles the ListEnabledResourceTypes response. +func (client *CustomLocationsClient) listEnabledResourceTypesHandleResponse(resp *http.Response) (CustomLocationsListEnabledResourceTypesResponse, error) { + result := CustomLocationsListEnabledResourceTypesResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.EnabledResourceTypesListResult); err != nil { + return CustomLocationsListEnabledResourceTypesResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listEnabledResourceTypesHandleError handles the ListEnabledResourceTypes error response. +func (client *CustomLocationsClient) listEnabledResourceTypesHandleError(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) +} + +// ListOperations - Lists all available Custom Locations operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) ListOperations(options *CustomLocationsListOperationsOptions) *CustomLocationsListOperationsPager { + return &CustomLocationsListOperationsPager{ + client: client, + requester: func(ctx context.Context) (*policy.Request, error) { + return client.listOperationsCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp CustomLocationsListOperationsResponse) (*policy.Request, error) { + return runtime.NewRequest(ctx, http.MethodGet, *resp.CustomLocationOperationsList.NextLink) + }, + } +} + +// listOperationsCreateRequest creates the ListOperations request. +func (client *CustomLocationsClient) listOperationsCreateRequest(ctx context.Context, options *CustomLocationsListOperationsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ExtendedLocation/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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, nil +} + +// listOperationsHandleResponse handles the ListOperations response. +func (client *CustomLocationsClient) listOperationsHandleResponse(resp *http.Response) (CustomLocationsListOperationsResponse, error) { + result := CustomLocationsListOperationsResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomLocationOperationsList); err != nil { + return CustomLocationsListOperationsResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// listOperationsHandleError handles the ListOperations error response. +func (client *CustomLocationsClient) listOperationsHandleError(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 - Updates a Custom Location with the specified Resource Name in the specified Resource Group and Subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CustomLocationsClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters PatchableCustomLocations, options *CustomLocationsUpdateOptions) (CustomLocationsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return CustomLocationsUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CustomLocationsUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CustomLocationsUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *CustomLocationsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters PatchableCustomLocations, options *CustomLocationsUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ExtendedLocation/customLocations/{resourceName}" + 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 resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + 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-08-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header.Set("Accept", "application/json") + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *CustomLocationsClient) updateHandleResponse(resp *http.Response) (CustomLocationsUpdateResponse, error) { + result := CustomLocationsUpdateResponse{RawResponse: resp} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomLocation); err != nil { + return CustomLocationsUpdateResponse{}, runtime.NewResponseError(err, resp) + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *CustomLocationsClient) 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/extendedlocation/armextendedlocation/zz_generated_models.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_models.go new file mode 100644 index 000000000000..fba2c12dca6f --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_models.go @@ -0,0 +1,486 @@ +//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 armextendedlocation + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// CustomLocation - Custom Locations definition. +type CustomLocation struct { + TrackedResource + // Identity for the resource. + Identity *Identity `json:"identity,omitempty"` + + // The set of properties specific to a Custom Location + Properties *CustomLocationProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CustomLocation. +func (c CustomLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + c.TrackedResource.marshalInternal(objectMap) + populate(objectMap, "identity", c.Identity) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + return json.Marshal(objectMap) +} + +// CustomLocationListResult - The List Custom Locations operation response. +type CustomLocationListResult struct { + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of Custom Locations. + Value []*CustomLocation `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type CustomLocationListResult. +func (c CustomLocationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CustomLocationOperation - Custom Locations operation. +type CustomLocationOperation struct { + // Describes the properties of a Custom Locations Operation Value Display. + Display *CustomLocationOperationValueDisplay `json:"display,omitempty"` + + // READ-ONLY; Is this Operation a data plane operation + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the compute operation. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The origin of the compute operation. + Origin *string `json:"origin,omitempty" azure:"ro"` +} + +// CustomLocationOperationValueDisplay - Describes the properties of a Custom Locations Operation Value Display. +type CustomLocationOperationValueDisplay struct { + // READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The display name of the compute operation. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The resource provider for the operation. + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The display name of the resource the operation applies to. + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// CustomLocationOperationsList - Lists of Custom Locations operations. +type CustomLocationOperationsList struct { + // REQUIRED; Array of customLocationOperation + Value []*CustomLocationOperation `json:"value,omitempty"` + + // Next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CustomLocationOperationsList. +func (c CustomLocationOperationsList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CustomLocationProperties - Properties for a custom location. +type CustomLocationProperties struct { + // This is optional input that contains the authentication that should be used to generate the namespace. + Authentication *CustomLocationPropertiesAuthentication `json:"authentication,omitempty"` + + // Contains the reference to the add-on that contains charts to deploy CRDs and operators. + ClusterExtensionIDs []*string `json:"clusterExtensionIds,omitempty"` + + // Display name for the Custom Locations location. + DisplayName *string `json:"displayName,omitempty"` + + // Connected Cluster or AKS Cluster. The Custom Locations RP will perform a checkAccess API for listAdminCredentials permissions. + HostResourceID *string `json:"hostResourceId,omitempty"` + + // Type of host the Custom Locations is referencing (Kubernetes, etc…). + HostType *HostType `json:"hostType,omitempty"` + + // Kubernetes namespace that will be created on the specified cluster. + Namespace *string `json:"namespace,omitempty"` + + // Provisioning State for the Custom Location. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CustomLocationProperties. +func (c CustomLocationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authentication", c.Authentication) + populate(objectMap, "clusterExtensionIds", c.ClusterExtensionIDs) + populate(objectMap, "displayName", c.DisplayName) + populate(objectMap, "hostResourceId", c.HostResourceID) + populate(objectMap, "hostType", c.HostType) + populate(objectMap, "namespace", c.Namespace) + populate(objectMap, "provisioningState", c.ProvisioningState) + return json.Marshal(objectMap) +} + +// CustomLocationPropertiesAuthentication - This is optional input that contains the authentication that should be used to generate the namespace. +type CustomLocationPropertiesAuthentication struct { + // The type of the Custom Locations authentication + Type *string `json:"type,omitempty"` + + // The kubeconfig value. + Value *string `json:"value,omitempty"` +} + +// CustomLocationsBeginCreateOrUpdateOptions contains the optional parameters for the CustomLocations.BeginCreateOrUpdate method. +type CustomLocationsBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// CustomLocationsBeginDeleteOptions contains the optional parameters for the CustomLocations.BeginDelete method. +type CustomLocationsBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// CustomLocationsGetOptions contains the optional parameters for the CustomLocations.Get method. +type CustomLocationsGetOptions struct { + // placeholder for future optional parameters +} + +// CustomLocationsListByResourceGroupOptions contains the optional parameters for the CustomLocations.ListByResourceGroup method. +type CustomLocationsListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// CustomLocationsListBySubscriptionOptions contains the optional parameters for the CustomLocations.ListBySubscription method. +type CustomLocationsListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// CustomLocationsListEnabledResourceTypesOptions contains the optional parameters for the CustomLocations.ListEnabledResourceTypes method. +type CustomLocationsListEnabledResourceTypesOptions struct { + // placeholder for future optional parameters +} + +// CustomLocationsListOperationsOptions contains the optional parameters for the CustomLocations.ListOperations method. +type CustomLocationsListOperationsOptions struct { + // placeholder for future optional parameters +} + +// CustomLocationsUpdateOptions contains the optional parameters for the CustomLocations.Update method. +type CustomLocationsUpdateOptions struct { + // placeholder for future optional parameters +} + +// EnabledResourceType definition. +type EnabledResourceType struct { + ProxyResource + // The set of properties for EnabledResourceType specific to a Custom Location + Properties *EnabledResourceTypeProperties `json:"properties,omitempty"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type EnabledResourceType. +func (e EnabledResourceType) 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) +} + +// EnabledResourceTypeProperties - Properties for EnabledResourceType of a custom location. +type EnabledResourceTypeProperties struct { + // Cluster Extension ID + ClusterExtensionID *string `json:"clusterExtensionId,omitempty"` + + // Cluster Extension Type + ExtensionType *string `json:"extensionType,omitempty"` + + // Metadata of the Resource Type + TypesMetadata []*EnabledResourceTypePropertiesTypesMetadataItem `json:"typesMetadata,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EnabledResourceTypeProperties. +func (e EnabledResourceTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clusterExtensionId", e.ClusterExtensionID) + populate(objectMap, "extensionType", e.ExtensionType) + populate(objectMap, "typesMetadata", e.TypesMetadata) + return json.Marshal(objectMap) +} + +// EnabledResourceTypePropertiesTypesMetadataItem - Metadata of the Resource Type. +type EnabledResourceTypePropertiesTypesMetadataItem struct { + // Api Version of Resource Type + APIVersion *string `json:"apiVersion,omitempty"` + + // Resource Provider Namespace of Resource Type + ResourceProviderNamespace *string `json:"resourceProviderNamespace,omitempty"` + + // Resource Type + ResourceType *string `json:"resourceType,omitempty"` +} + +// EnabledResourceTypesListResult - List of EnabledResourceTypes definition. +type EnabledResourceTypesListResult struct { + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of EnabledResourceTypes available for a customLocation. + Value []*EnabledResourceType `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type EnabledResourceTypesListResult. +func (e EnabledResourceTypesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// 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 +} + +// Identity for the resource. +type Identity struct { + // The identity type. + Type *ResourceIdentityType `json:"type,omitempty"` + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// PatchableCustomLocations - The Custom Locations patchable resource definition. +type PatchableCustomLocations struct { + // Identity for the resource. + Identity *Identity `json:"identity,omitempty"` + + // The Custom Locations patchable properties. + Properties *CustomLocationProperties `json:"properties,omitempty"` + + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PatchableCustomLocations. +func (p PatchableCustomLocations) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", p.Identity) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// 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/extendedlocation/armextendedlocation/zz_generated_pagers.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_pagers.go new file mode 100644 index 000000000000..618fce582250 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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 armextendedlocation + +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" +) + +// CustomLocationsListByResourceGroupPager provides operations for iterating over paged responses. +type CustomLocationsListByResourceGroupPager struct { + client *CustomLocationsClient + current CustomLocationsListByResourceGroupResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CustomLocationsListByResourceGroupResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CustomLocationsListByResourceGroupPager) 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 *CustomLocationsListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CustomLocationListResult.NextLink == nil || len(*p.current.CustomLocationListResult.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 CustomLocationsListByResourceGroupResponse page. +func (p *CustomLocationsListByResourceGroupPager) PageResponse() CustomLocationsListByResourceGroupResponse { + return p.current +} + +// CustomLocationsListBySubscriptionPager provides operations for iterating over paged responses. +type CustomLocationsListBySubscriptionPager struct { + client *CustomLocationsClient + current CustomLocationsListBySubscriptionResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CustomLocationsListBySubscriptionResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CustomLocationsListBySubscriptionPager) 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 *CustomLocationsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CustomLocationListResult.NextLink == nil || len(*p.current.CustomLocationListResult.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 CustomLocationsListBySubscriptionResponse page. +func (p *CustomLocationsListBySubscriptionPager) PageResponse() CustomLocationsListBySubscriptionResponse { + return p.current +} + +// CustomLocationsListEnabledResourceTypesPager provides operations for iterating over paged responses. +type CustomLocationsListEnabledResourceTypesPager struct { + client *CustomLocationsClient + current CustomLocationsListEnabledResourceTypesResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CustomLocationsListEnabledResourceTypesResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CustomLocationsListEnabledResourceTypesPager) 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 *CustomLocationsListEnabledResourceTypesPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.EnabledResourceTypesListResult.NextLink == nil || len(*p.current.EnabledResourceTypesListResult.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.listEnabledResourceTypesHandleError(resp) + return false + } + result, err := p.client.listEnabledResourceTypesHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current CustomLocationsListEnabledResourceTypesResponse page. +func (p *CustomLocationsListEnabledResourceTypesPager) PageResponse() CustomLocationsListEnabledResourceTypesResponse { + return p.current +} + +// CustomLocationsListOperationsPager provides operations for iterating over paged responses. +type CustomLocationsListOperationsPager struct { + client *CustomLocationsClient + current CustomLocationsListOperationsResponse + err error + requester func(context.Context) (*policy.Request, error) + advancer func(context.Context, CustomLocationsListOperationsResponse) (*policy.Request, error) +} + +// Err returns the last error encountered while paging. +func (p *CustomLocationsListOperationsPager) 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 *CustomLocationsListOperationsPager) NextPage(ctx context.Context) bool { + var req *policy.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CustomLocationOperationsList.NextLink == nil || len(*p.current.CustomLocationOperationsList.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.listOperationsHandleError(resp) + return false + } + result, err := p.client.listOperationsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +// PageResponse returns the current CustomLocationsListOperationsResponse page. +func (p *CustomLocationsListOperationsPager) PageResponse() CustomLocationsListOperationsResponse { + return p.current +} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_pollers.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_pollers.go new file mode 100644 index 000000000000..760ea5447a93 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_pollers.go @@ -0,0 +1,101 @@ +//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 armextendedlocation + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// CustomLocationsCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type CustomLocationsCreateOrUpdatePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CustomLocationsCreateOrUpdatePoller) 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 *CustomLocationsCreateOrUpdatePoller) 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 CustomLocationsCreateOrUpdateResponse will be returned. +func (p *CustomLocationsCreateOrUpdatePoller) FinalResponse(ctx context.Context) (CustomLocationsCreateOrUpdateResponse, error) { + respType := CustomLocationsCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.CustomLocation) + if err != nil { + return CustomLocationsCreateOrUpdateResponse{}, 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 *CustomLocationsCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +// CustomLocationsDeletePoller provides polling facilities until the operation reaches a terminal state. +type CustomLocationsDeletePoller struct { + pt *azcore.Poller +} + +// Done returns true if the LRO has reached a terminal state. +func (p *CustomLocationsDeletePoller) 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 *CustomLocationsDeletePoller) 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 CustomLocationsDeleteResponse will be returned. +func (p *CustomLocationsDeletePoller) FinalResponse(ctx context.Context) (CustomLocationsDeleteResponse, error) { + respType := CustomLocationsDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, nil) + if err != nil { + return CustomLocationsDeleteResponse{}, 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 *CustomLocationsDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_response_types.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_response_types.go new file mode 100644 index 000000000000..7fb182745006 --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_response_types.go @@ -0,0 +1,186 @@ +//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 armextendedlocation + +import ( + "context" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "net/http" + "time" +) + +// CustomLocationsCreateOrUpdatePollerResponse contains the response from method CustomLocations.CreateOrUpdate. +type CustomLocationsCreateOrUpdatePollerResponse struct { + // Poller contains an initialized poller. + Poller *CustomLocationsCreateOrUpdatePoller + + // 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 CustomLocationsCreateOrUpdatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CustomLocationsCreateOrUpdateResponse, error) { + respType := CustomLocationsCreateOrUpdateResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.CustomLocation) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CustomLocationsCreateOrUpdatePollerResponse from the provided client and resume token. +func (l *CustomLocationsCreateOrUpdatePollerResponse) Resume(ctx context.Context, client *CustomLocationsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CustomLocationsClient.CreateOrUpdate", token, client.pl, client.createOrUpdateHandleError) + if err != nil { + return err + } + poller := &CustomLocationsCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CustomLocationsCreateOrUpdateResponse contains the response from method CustomLocations.CreateOrUpdate. +type CustomLocationsCreateOrUpdateResponse struct { + CustomLocationsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsCreateOrUpdateResult contains the result from method CustomLocations.CreateOrUpdate. +type CustomLocationsCreateOrUpdateResult struct { + CustomLocation +} + +// CustomLocationsDeletePollerResponse contains the response from method CustomLocations.Delete. +type CustomLocationsDeletePollerResponse struct { + // Poller contains an initialized poller. + Poller *CustomLocationsDeletePoller + + // 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 CustomLocationsDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (CustomLocationsDeleteResponse, error) { + respType := CustomLocationsDeleteResponse{} + resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) + if err != nil { + return respType, err + } + respType.RawResponse = resp + return respType, nil +} + +// Resume rehydrates a CustomLocationsDeletePollerResponse from the provided client and resume token. +func (l *CustomLocationsDeletePollerResponse) Resume(ctx context.Context, client *CustomLocationsClient, token string) error { + pt, err := armruntime.NewPollerFromResumeToken("CustomLocationsClient.Delete", token, client.pl, client.deleteHandleError) + if err != nil { + return err + } + poller := &CustomLocationsDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return err + } + l.Poller = poller + l.RawResponse = resp + return nil +} + +// CustomLocationsDeleteResponse contains the response from method CustomLocations.Delete. +type CustomLocationsDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsGetResponse contains the response from method CustomLocations.Get. +type CustomLocationsGetResponse struct { + CustomLocationsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsGetResult contains the result from method CustomLocations.Get. +type CustomLocationsGetResult struct { + CustomLocation +} + +// CustomLocationsListByResourceGroupResponse contains the response from method CustomLocations.ListByResourceGroup. +type CustomLocationsListByResourceGroupResponse struct { + CustomLocationsListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsListByResourceGroupResult contains the result from method CustomLocations.ListByResourceGroup. +type CustomLocationsListByResourceGroupResult struct { + CustomLocationListResult +} + +// CustomLocationsListBySubscriptionResponse contains the response from method CustomLocations.ListBySubscription. +type CustomLocationsListBySubscriptionResponse struct { + CustomLocationsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsListBySubscriptionResult contains the result from method CustomLocations.ListBySubscription. +type CustomLocationsListBySubscriptionResult struct { + CustomLocationListResult +} + +// CustomLocationsListEnabledResourceTypesResponse contains the response from method CustomLocations.ListEnabledResourceTypes. +type CustomLocationsListEnabledResourceTypesResponse struct { + CustomLocationsListEnabledResourceTypesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsListEnabledResourceTypesResult contains the result from method CustomLocations.ListEnabledResourceTypes. +type CustomLocationsListEnabledResourceTypesResult struct { + EnabledResourceTypesListResult +} + +// CustomLocationsListOperationsResponse contains the response from method CustomLocations.ListOperations. +type CustomLocationsListOperationsResponse struct { + CustomLocationsListOperationsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsListOperationsResult contains the result from method CustomLocations.ListOperations. +type CustomLocationsListOperationsResult struct { + CustomLocationOperationsList +} + +// CustomLocationsUpdateResponse contains the response from method CustomLocations.Update. +type CustomLocationsUpdateResponse struct { + CustomLocationsUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CustomLocationsUpdateResult contains the result from method CustomLocations.Update. +type CustomLocationsUpdateResult struct { + CustomLocation +} diff --git a/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_time_rfc3339.go b/sdk/resourcemanager/extendedlocation/armextendedlocation/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..c14a97b6af6e --- /dev/null +++ b/sdk/resourcemanager/extendedlocation/armextendedlocation/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 armextendedlocation + +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 +}