diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md b/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md new file mode 100644 index 000000000000..0aaf4c70bb22 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-08-24) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentstacks` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/LICENSE.txt b/sdk/resourcemanager/resources/armdeploymentstacks/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/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/resources/armdeploymentstacks/README.md b/sdk/resourcemanager/resources/armdeploymentstacks/README.md new file mode 100644 index 000000000000..747e6800e691 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/README.md @@ -0,0 +1,85 @@ +# Azure Resources Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentstacks)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentstacks) + +The `armdeploymentstacks` module provides operations for working with Azure Resources. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/resources/armdeploymentstacks) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Resources module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentstacks +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Resources. 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). + +## Client Factory + +Azure Resources module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armdeploymentstacks.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armdeploymentstacks.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewClient() +``` + +## 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 `Resources` 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/resources/armdeploymentstacks/autorest.md b/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md new file mode 100644 index 000000000000..919f7ff897b7 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resources/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +package-deploymentstacks: true +``` \ No newline at end of file diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/build.go b/sdk/resourcemanager/resources/armdeploymentstacks/build.go new file mode 100644 index 000000000000..02579ad033d0 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/resources/armdeploymentstacks + +package armdeploymentstacks diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/ci.yml b/sdk/resourcemanager/resources/armdeploymentstacks/ci.yml new file mode 100644 index 000000000000..b412dd838a6b --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/resources/armdeploymentstacks/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/resources/armdeploymentstacks/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/resources/armdeploymentstacks' diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/client.go b/sdk/resourcemanager/resources/armdeploymentstacks/client.go new file mode 100644 index 000000000000..b31d20c51267 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/client.go @@ -0,0 +1,1014 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "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" +) + +// Client contains the methods for the DeploymentStacks group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client + subscriptionID string +} + +// NewClient creates a new instance of Client with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdateAtManagementGroup - Creates or updates a Deployment Stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - managementGroupID - Management Group. +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment Stack supplied to the operation. +// - options - ClientBeginCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtManagementGroup +// method. +func (client *Client) BeginCreateOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtManagementGroupOptions) (*runtime.Poller[ClientCreateOrUpdateAtManagementGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateAtManagementGroup(ctx, managementGroupID, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtManagementGroupResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ClientCreateOrUpdateAtManagementGroupResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdateAtManagementGroup - Creates or updates a Deployment Stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +func (client *Client) createOrUpdateAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtManagementGroupOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateAtManagementGroupCreateRequest creates the CreateOrUpdateAtManagementGroup request. +func (client *Client) createOrUpdateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdateAtResourceGroup - Creates or updates a Deployment Stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment Stack supplied to the operation. +// - options - ClientBeginCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtResourceGroup +// method. +func (client *Client) BeginCreateOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtResourceGroupOptions) (*runtime.Poller[ClientCreateOrUpdateAtResourceGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateAtResourceGroup(ctx, resourceGroupName, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtResourceGroupResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ClientCreateOrUpdateAtResourceGroupResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdateAtResourceGroup - Creates or updates a Deployment Stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +func (client *Client) createOrUpdateAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtResourceGroupOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateAtResourceGroupCreateRequest creates the CreateOrUpdateAtResourceGroup request. +func (client *Client) createOrUpdateAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + 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 deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdateAtSubscription - Creates or updates a Deployment Stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - deploymentStackName - Name of the deployment stack. +// - deploymentStack - Deployment Stack supplied to the operation. +// - options - ClientBeginCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtSubscription +// method. +func (client *Client) BeginCreateOrUpdateAtSubscription(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtSubscriptionOptions) (*runtime.Poller[ClientCreateOrUpdateAtSubscriptionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateAtSubscription(ctx, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientCreateOrUpdateAtSubscriptionResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ClientCreateOrUpdateAtSubscriptionResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdateAtSubscription - Creates or updates a Deployment Stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +func (client *Client) createOrUpdateAtSubscription(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtSubscriptionOptions) (*http.Response, error) { + var err error + req, err := client.createOrUpdateAtSubscriptionCreateRequest(ctx, deploymentStackName, deploymentStack, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateAtSubscriptionCreateRequest creates the CreateOrUpdateAtSubscription request. +func (client *Client) createOrUpdateAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, deploymentStack DeploymentStack, options *ClientBeginCreateOrUpdateAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, deploymentStack); err != nil { + return nil, err + } + return req, nil +} + +// BeginDeleteAtManagementGroup - Deletes a Deployment Stack by name. When operation completes, status code 200 returned without +// content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - managementGroupID - Management Group. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientBeginDeleteAtManagementGroupOptions contains the optional parameters for the Client.BeginDeleteAtManagementGroup +// method. +func (client *Client) BeginDeleteAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientBeginDeleteAtManagementGroupOptions) (*runtime.Poller[ClientDeleteAtManagementGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAtManagementGroup(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtManagementGroupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ClientDeleteAtManagementGroupResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// DeleteAtManagementGroup - Deletes a Deployment Stack by name. When operation completes, status code 200 returned without +// content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +func (client *Client) deleteAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientBeginDeleteAtManagementGroupOptions) (*http.Response, error) { + var err error + req, err := client.deleteAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteAtManagementGroupCreateRequest creates the DeleteAtManagementGroup request. +func (client *Client) deleteAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientBeginDeleteAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } + if options != nil && options.UnmanageActionResourceGroups != nil { + reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) + } + if options != nil && options.UnmanageActionManagementGroups != nil { + reqQP.Set("unmanageAction.ManagementGroups", string(*options.UnmanageActionManagementGroups)) + } + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDeleteAtResourceGroup - Deletes a Deployment Stack by name. When operation completes, status code 200 returned without +// content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientBeginDeleteAtResourceGroupOptions contains the optional parameters for the Client.BeginDeleteAtResourceGroup +// method. +func (client *Client) BeginDeleteAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientBeginDeleteAtResourceGroupOptions) (*runtime.Poller[ClientDeleteAtResourceGroupResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAtResourceGroup(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtResourceGroupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ClientDeleteAtResourceGroupResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// DeleteAtResourceGroup - Deletes a Deployment Stack by name. When operation completes, status code 200 returned without +// content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +func (client *Client) deleteAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientBeginDeleteAtResourceGroupOptions) (*http.Response, error) { + var err error + req, err := client.deleteAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteAtResourceGroupCreateRequest creates the DeleteAtResourceGroup request. +func (client *Client) deleteAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientBeginDeleteAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + 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 deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } + if options != nil && options.UnmanageActionResourceGroups != nil { + reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) + } + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDeleteAtSubscription - Deletes a Deployment Stack by name. When operation completes, status code 200 returned without +// content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - deploymentStackName - Name of the deployment stack. +// - options - ClientBeginDeleteAtSubscriptionOptions contains the optional parameters for the Client.BeginDeleteAtSubscription +// method. +func (client *Client) BeginDeleteAtSubscription(ctx context.Context, deploymentStackName string, options *ClientBeginDeleteAtSubscriptionOptions) (*runtime.Poller[ClientDeleteAtSubscriptionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteAtSubscription(ctx, deploymentStackName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientDeleteAtSubscriptionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ClientDeleteAtSubscriptionResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// DeleteAtSubscription - Deletes a Deployment Stack by name. When operation completes, status code 200 returned without content. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +func (client *Client) deleteAtSubscription(ctx context.Context, deploymentStackName string, options *ClientBeginDeleteAtSubscriptionOptions) (*http.Response, error) { + var err error + req, err := client.deleteAtSubscriptionCreateRequest(ctx, deploymentStackName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteAtSubscriptionCreateRequest creates the DeleteAtSubscription request. +func (client *Client) deleteAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, options *ClientBeginDeleteAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.UnmanageActionResources != nil { + reqQP.Set("unmanageAction.Resources", string(*options.UnmanageActionResources)) + } + if options != nil && options.UnmanageActionResourceGroups != nil { + reqQP.Set("unmanageAction.ResourceGroups", string(*options.UnmanageActionResourceGroups)) + } + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// ExportTemplateAtManagementGroup - Exports the template used to create the deployment stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - managementGroupID - Management Group. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientExportTemplateAtManagementGroupOptions contains the optional parameters for the Client.ExportTemplateAtManagementGroup +// method. +func (client *Client) ExportTemplateAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientExportTemplateAtManagementGroupOptions) (ClientExportTemplateAtManagementGroupResponse, error) { + var err error + req, err := client.exportTemplateAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return ClientExportTemplateAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientExportTemplateAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientExportTemplateAtManagementGroupResponse{}, err + } + resp, err := client.exportTemplateAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// exportTemplateAtManagementGroupCreateRequest creates the ExportTemplateAtManagementGroup request. +func (client *Client) exportTemplateAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientExportTemplateAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/exportTemplate" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// exportTemplateAtManagementGroupHandleResponse handles the ExportTemplateAtManagementGroup response. +func (client *Client) exportTemplateAtManagementGroupHandleResponse(resp *http.Response) (ClientExportTemplateAtManagementGroupResponse, error) { + result := ClientExportTemplateAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackTemplateDefinition); err != nil { + return ClientExportTemplateAtManagementGroupResponse{}, err + } + return result, nil +} + +// ExportTemplateAtResourceGroup - Exports the template used to create the deployment stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientExportTemplateAtResourceGroupOptions contains the optional parameters for the Client.ExportTemplateAtResourceGroup +// method. +func (client *Client) ExportTemplateAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientExportTemplateAtResourceGroupOptions) (ClientExportTemplateAtResourceGroupResponse, error) { + var err error + req, err := client.exportTemplateAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return ClientExportTemplateAtResourceGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientExportTemplateAtResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientExportTemplateAtResourceGroupResponse{}, err + } + resp, err := client.exportTemplateAtResourceGroupHandleResponse(httpResp) + return resp, err +} + +// exportTemplateAtResourceGroupCreateRequest creates the ExportTemplateAtResourceGroup request. +func (client *Client) exportTemplateAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientExportTemplateAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/exportTemplate" + 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 deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// exportTemplateAtResourceGroupHandleResponse handles the ExportTemplateAtResourceGroup response. +func (client *Client) exportTemplateAtResourceGroupHandleResponse(resp *http.Response) (ClientExportTemplateAtResourceGroupResponse, error) { + result := ClientExportTemplateAtResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackTemplateDefinition); err != nil { + return ClientExportTemplateAtResourceGroupResponse{}, err + } + return result, nil +} + +// ExportTemplateAtSubscription - Exports the template used to create the deployment stack. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - deploymentStackName - Name of the deployment stack. +// - options - ClientExportTemplateAtSubscriptionOptions contains the optional parameters for the Client.ExportTemplateAtSubscription +// method. +func (client *Client) ExportTemplateAtSubscription(ctx context.Context, deploymentStackName string, options *ClientExportTemplateAtSubscriptionOptions) (ClientExportTemplateAtSubscriptionResponse, error) { + var err error + req, err := client.exportTemplateAtSubscriptionCreateRequest(ctx, deploymentStackName, options) + if err != nil { + return ClientExportTemplateAtSubscriptionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientExportTemplateAtSubscriptionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientExportTemplateAtSubscriptionResponse{}, err + } + resp, err := client.exportTemplateAtSubscriptionHandleResponse(httpResp) + return resp, err +} + +// exportTemplateAtSubscriptionCreateRequest creates the ExportTemplateAtSubscription request. +func (client *Client) exportTemplateAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, options *ClientExportTemplateAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}/exportTemplate" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// exportTemplateAtSubscriptionHandleResponse handles the ExportTemplateAtSubscription response. +func (client *Client) exportTemplateAtSubscriptionHandleResponse(resp *http.Response) (ClientExportTemplateAtSubscriptionResponse, error) { + result := ClientExportTemplateAtSubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackTemplateDefinition); err != nil { + return ClientExportTemplateAtSubscriptionResponse{}, err + } + return result, nil +} + +// GetAtManagementGroup - Gets a Deployment Stack with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - managementGroupID - Management Group. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientGetAtManagementGroupOptions contains the optional parameters for the Client.GetAtManagementGroup method. +func (client *Client) GetAtManagementGroup(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientGetAtManagementGroupOptions) (ClientGetAtManagementGroupResponse, error) { + var err error + req, err := client.getAtManagementGroupCreateRequest(ctx, managementGroupID, deploymentStackName, options) + if err != nil { + return ClientGetAtManagementGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetAtManagementGroupResponse{}, err + } + resp, err := client.getAtManagementGroupHandleResponse(httpResp) + return resp, err +} + +// getAtManagementGroupCreateRequest creates the GetAtManagementGroup request. +func (client *Client) getAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, deploymentStackName string, options *ClientGetAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtManagementGroupHandleResponse handles the GetAtManagementGroup response. +func (client *Client) getAtManagementGroupHandleResponse(resp *http.Response) (ClientGetAtManagementGroupResponse, error) { + result := ClientGetAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStack); err != nil { + return ClientGetAtManagementGroupResponse{}, err + } + return result, nil +} + +// GetAtResourceGroup - Gets a Deployment Stack with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentStackName - Name of the deployment stack. +// - options - ClientGetAtResourceGroupOptions contains the optional parameters for the Client.GetAtResourceGroup method. +func (client *Client) GetAtResourceGroup(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientGetAtResourceGroupOptions) (ClientGetAtResourceGroupResponse, error) { + var err error + req, err := client.getAtResourceGroupCreateRequest(ctx, resourceGroupName, deploymentStackName, options) + if err != nil { + return ClientGetAtResourceGroupResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetAtResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetAtResourceGroupResponse{}, err + } + resp, err := client.getAtResourceGroupHandleResponse(httpResp) + return resp, err +} + +// getAtResourceGroupCreateRequest creates the GetAtResourceGroup request. +func (client *Client) getAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, deploymentStackName string, options *ClientGetAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + 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 deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtResourceGroupHandleResponse handles the GetAtResourceGroup response. +func (client *Client) getAtResourceGroupHandleResponse(resp *http.Response) (ClientGetAtResourceGroupResponse, error) { + result := ClientGetAtResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStack); err != nil { + return ClientGetAtResourceGroupResponse{}, err + } + return result, nil +} + +// GetAtSubscription - Gets a Deployment Stack with a given name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2022-08-01-preview +// - deploymentStackName - Name of the deployment stack. +// - options - ClientGetAtSubscriptionOptions contains the optional parameters for the Client.GetAtSubscription method. +func (client *Client) GetAtSubscription(ctx context.Context, deploymentStackName string, options *ClientGetAtSubscriptionOptions) (ClientGetAtSubscriptionResponse, error) { + var err error + req, err := client.getAtSubscriptionCreateRequest(ctx, deploymentStackName, options) + if err != nil { + return ClientGetAtSubscriptionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientGetAtSubscriptionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetAtSubscriptionResponse{}, err + } + resp, err := client.getAtSubscriptionHandleResponse(httpResp) + return resp, err +} + +// getAtSubscriptionCreateRequest creates the GetAtSubscription request. +func (client *Client) getAtSubscriptionCreateRequest(ctx context.Context, deploymentStackName string, options *ClientGetAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks/{deploymentStackName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if deploymentStackName == "" { + return nil, errors.New("parameter deploymentStackName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentStackName}", url.PathEscape(deploymentStackName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getAtSubscriptionHandleResponse handles the GetAtSubscription response. +func (client *Client) getAtSubscriptionHandleResponse(resp *http.Response) (ClientGetAtSubscriptionResponse, error) { + result := ClientGetAtSubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStack); err != nil { + return ClientGetAtSubscriptionResponse{}, err + } + return result, nil +} + +// NewListAtManagementGroupPager - Lists all the Deployment Stacks within the specified management group. +// +// Generated from API version 2022-08-01-preview +// - managementGroupID - Management Group. +// - options - ClientListAtManagementGroupOptions contains the optional parameters for the Client.NewListAtManagementGroupPager +// method. +func (client *Client) NewListAtManagementGroupPager(managementGroupID string, options *ClientListAtManagementGroupOptions) *runtime.Pager[ClientListAtManagementGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtManagementGroupResponse]{ + More: func(page ClientListAtManagementGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListAtManagementGroupResponse) (ClientListAtManagementGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listAtManagementGroupCreateRequest(ctx, managementGroupID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListAtManagementGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientListAtManagementGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListAtManagementGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listAtManagementGroupHandleResponse(resp) + }, + }) +} + +// listAtManagementGroupCreateRequest creates the ListAtManagementGroup request. +func (client *Client) listAtManagementGroupCreateRequest(ctx context.Context, managementGroupID string, options *ClientListAtManagementGroupOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Resources/deploymentStacks" + if managementGroupID == "" { + return nil, errors.New("parameter managementGroupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{managementGroupId}", url.PathEscape(managementGroupID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAtManagementGroupHandleResponse handles the ListAtManagementGroup response. +func (client *Client) listAtManagementGroupHandleResponse(resp *http.Response) (ClientListAtManagementGroupResponse, error) { + result := ClientListAtManagementGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackListResult); err != nil { + return ClientListAtManagementGroupResponse{}, err + } + return result, nil +} + +// NewListAtResourceGroupPager - Lists all the Deployment Stacks within the specified resource group. +// +// Generated from API version 2022-08-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ClientListAtResourceGroupOptions contains the optional parameters for the Client.NewListAtResourceGroupPager +// method. +func (client *Client) NewListAtResourceGroupPager(resourceGroupName string, options *ClientListAtResourceGroupOptions) *runtime.Pager[ClientListAtResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtResourceGroupResponse]{ + More: func(page ClientListAtResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListAtResourceGroupResponse) (ClientListAtResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listAtResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListAtResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientListAtResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListAtResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listAtResourceGroupHandleResponse(resp) + }, + }) +} + +// listAtResourceGroupCreateRequest creates the ListAtResourceGroup request. +func (client *Client) listAtResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ClientListAtResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Resources/deploymentStacks" + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAtResourceGroupHandleResponse handles the ListAtResourceGroup response. +func (client *Client) listAtResourceGroupHandleResponse(resp *http.Response) (ClientListAtResourceGroupResponse, error) { + result := ClientListAtResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackListResult); err != nil { + return ClientListAtResourceGroupResponse{}, err + } + return result, nil +} + +// NewListAtSubscriptionPager - Lists all the Deployment Stacks within the specified subscription. +// +// Generated from API version 2022-08-01-preview +// - options - ClientListAtSubscriptionOptions contains the optional parameters for the Client.NewListAtSubscriptionPager method. +func (client *Client) NewListAtSubscriptionPager(options *ClientListAtSubscriptionOptions) *runtime.Pager[ClientListAtSubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ClientListAtSubscriptionResponse]{ + More: func(page ClientListAtSubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClientListAtSubscriptionResponse) (ClientListAtSubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listAtSubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ClientListAtSubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientListAtSubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ClientListAtSubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listAtSubscriptionHandleResponse(resp) + }, + }) +} + +// listAtSubscriptionCreateRequest creates the ListAtSubscription request. +func (client *Client) listAtSubscriptionCreateRequest(ctx context.Context, options *ClientListAtSubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Resources/deploymentStacks" + 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.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listAtSubscriptionHandleResponse handles the ListAtSubscription response. +func (client *Client) listAtSubscriptionHandleResponse(resp *http.Response) (ClientListAtSubscriptionResponse, error) { + result := ClientListAtSubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentStackListResult); err != nil { + return ClientListAtSubscriptionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/client_factory.go b/sdk/resourcemanager/resources/armdeploymentstacks/client_factory.go new file mode 100644 index 000000000000..fbdc410e270e --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/client_factory.go @@ -0,0 +1,43 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/constants.go b/sdk/resourcemanager/resources/armdeploymentstacks/constants.go new file mode 100644 index 000000000000..ae8d34caec53 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/constants.go @@ -0,0 +1,208 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +const ( + moduleName = "armdeploymentstacks" + moduleVersion = "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, + } +} + +// DenySettingsMode - denySettings Mode. +type DenySettingsMode string + +const ( + // DenySettingsModeDenyDelete - Authorized users are able to read and modify the resources, but cannot delete. + DenySettingsModeDenyDelete DenySettingsMode = "denyDelete" + // DenySettingsModeDenyWriteAndDelete - Authorized users can only read from a resource, but cannot modify or delete it. + DenySettingsModeDenyWriteAndDelete DenySettingsMode = "denyWriteAndDelete" + // DenySettingsModeNone - No denyAssignments have been applied. + DenySettingsModeNone DenySettingsMode = "none" +) + +// PossibleDenySettingsModeValues returns the possible values for the DenySettingsMode const type. +func PossibleDenySettingsModeValues() []DenySettingsMode { + return []DenySettingsMode{ + DenySettingsModeDenyDelete, + DenySettingsModeDenyWriteAndDelete, + DenySettingsModeNone, + } +} + +// DenyStatusMode - denyAssignment settings applied to the resource. +type DenyStatusMode string + +const ( + // DenyStatusModeDenyDelete - Authorized users are able to read and modify the resources, but cannot delete. + DenyStatusModeDenyDelete DenyStatusMode = "denyDelete" + // DenyStatusModeDenyWriteAndDelete - Authorized users can only read from a resource, but cannot modify or delete it. + DenyStatusModeDenyWriteAndDelete DenyStatusMode = "denyWriteAndDelete" + // DenyStatusModeInapplicable - denyAssignments are not supported on resources outside the scope of the deployment stack. + DenyStatusModeInapplicable DenyStatusMode = "inapplicable" + // DenyStatusModeNone - No denyAssignments have been applied. + DenyStatusModeNone DenyStatusMode = "None" + // DenyStatusModeNotSupported - Resource type does not support denyAssignments. + DenyStatusModeNotSupported DenyStatusMode = "notSupported" + // DenyStatusModeRemovedBySystem - Deny assignment has been removed by Azure due to a resource management change (management + // group move, etc.) + DenyStatusModeRemovedBySystem DenyStatusMode = "removedBySystem" +) + +// PossibleDenyStatusModeValues returns the possible values for the DenyStatusMode const type. +func PossibleDenyStatusModeValues() []DenyStatusMode { + return []DenyStatusMode{ + DenyStatusModeDenyDelete, + DenyStatusModeDenyWriteAndDelete, + DenyStatusModeInapplicable, + DenyStatusModeNone, + DenyStatusModeNotSupported, + DenyStatusModeRemovedBySystem, + } +} + +// DeploymentStackProvisioningState - State of the deployment stack. +type DeploymentStackProvisioningState string + +const ( + DeploymentStackProvisioningStateCanceled DeploymentStackProvisioningState = "Canceled" + DeploymentStackProvisioningStateCanceling DeploymentStackProvisioningState = "Canceling" + DeploymentStackProvisioningStateCreating DeploymentStackProvisioningState = "Creating" + DeploymentStackProvisioningStateDeleting DeploymentStackProvisioningState = "Deleting" + DeploymentStackProvisioningStateDeletingResources DeploymentStackProvisioningState = "DeletingResources" + DeploymentStackProvisioningStateDeploying DeploymentStackProvisioningState = "Deploying" + DeploymentStackProvisioningStateFailed DeploymentStackProvisioningState = "Failed" + DeploymentStackProvisioningStateLocking DeploymentStackProvisioningState = "Locking" + DeploymentStackProvisioningStateSucceeded DeploymentStackProvisioningState = "Succeeded" + DeploymentStackProvisioningStateValidating DeploymentStackProvisioningState = "Validating" + DeploymentStackProvisioningStateWaiting DeploymentStackProvisioningState = "Waiting" +) + +// PossibleDeploymentStackProvisioningStateValues returns the possible values for the DeploymentStackProvisioningState const type. +func PossibleDeploymentStackProvisioningStateValues() []DeploymentStackProvisioningState { + return []DeploymentStackProvisioningState{ + DeploymentStackProvisioningStateCanceled, + DeploymentStackProvisioningStateCanceling, + DeploymentStackProvisioningStateCreating, + DeploymentStackProvisioningStateDeleting, + DeploymentStackProvisioningStateDeletingResources, + DeploymentStackProvisioningStateDeploying, + DeploymentStackProvisioningStateFailed, + DeploymentStackProvisioningStateLocking, + DeploymentStackProvisioningStateSucceeded, + DeploymentStackProvisioningStateValidating, + DeploymentStackProvisioningStateWaiting, + } +} + +// DeploymentStacksDeleteDetachEnum - Specifies the action that should be taken on the resource when the deployment stack +// is deleted. Delete will attempt to delete the resource from Azure. Detach will leave the resource in it's current +// state. +type DeploymentStacksDeleteDetachEnum string + +const ( + DeploymentStacksDeleteDetachEnumDelete DeploymentStacksDeleteDetachEnum = "delete" + DeploymentStacksDeleteDetachEnumDetach DeploymentStacksDeleteDetachEnum = "detach" +) + +// PossibleDeploymentStacksDeleteDetachEnumValues returns the possible values for the DeploymentStacksDeleteDetachEnum const type. +func PossibleDeploymentStacksDeleteDetachEnumValues() []DeploymentStacksDeleteDetachEnum { + return []DeploymentStacksDeleteDetachEnum{ + DeploymentStacksDeleteDetachEnumDelete, + DeploymentStacksDeleteDetachEnumDetach, + } +} + +// ResourceStatusMode - Current management state of the resource in the deployment stack. +type ResourceStatusMode string + +const ( + // ResourceStatusModeDeleteFailed - Unable to delete the resource from Azure. The delete will be retried on the next stack + // deployment, or can be deleted manually. + ResourceStatusModeDeleteFailed ResourceStatusMode = "deleteFailed" + // ResourceStatusModeManaged - This resource is managed by the deployment stack. + ResourceStatusModeManaged ResourceStatusMode = "Managed" + // ResourceStatusModeNone - No denyAssignments have been applied. + ResourceStatusModeNone ResourceStatusMode = "None" + // ResourceStatusModeRemoveDenyFailed - Unable to remove the deny assignment on resource. + ResourceStatusModeRemoveDenyFailed ResourceStatusMode = "removeDenyFailed" +) + +// PossibleResourceStatusModeValues returns the possible values for the ResourceStatusMode const type. +func PossibleResourceStatusModeValues() []ResourceStatusMode { + return []ResourceStatusMode{ + ResourceStatusModeDeleteFailed, + ResourceStatusModeManaged, + ResourceStatusModeNone, + ResourceStatusModeRemoveDenyFailed, + } +} + +type UnmanageActionManagementGroupMode string + +const ( + UnmanageActionManagementGroupModeDelete UnmanageActionManagementGroupMode = "delete" + UnmanageActionManagementGroupModeDetach UnmanageActionManagementGroupMode = "detach" +) + +// PossibleUnmanageActionManagementGroupModeValues returns the possible values for the UnmanageActionManagementGroupMode const type. +func PossibleUnmanageActionManagementGroupModeValues() []UnmanageActionManagementGroupMode { + return []UnmanageActionManagementGroupMode{ + UnmanageActionManagementGroupModeDelete, + UnmanageActionManagementGroupModeDetach, + } +} + +type UnmanageActionResourceGroupMode string + +const ( + UnmanageActionResourceGroupModeDelete UnmanageActionResourceGroupMode = "delete" + UnmanageActionResourceGroupModeDetach UnmanageActionResourceGroupMode = "detach" +) + +// PossibleUnmanageActionResourceGroupModeValues returns the possible values for the UnmanageActionResourceGroupMode const type. +func PossibleUnmanageActionResourceGroupModeValues() []UnmanageActionResourceGroupMode { + return []UnmanageActionResourceGroupMode{ + UnmanageActionResourceGroupModeDelete, + UnmanageActionResourceGroupModeDetach, + } +} + +type UnmanageActionResourceMode string + +const ( + UnmanageActionResourceModeDelete UnmanageActionResourceMode = "delete" + UnmanageActionResourceModeDetach UnmanageActionResourceMode = "detach" +) + +// PossibleUnmanageActionResourceModeValues returns the possible values for the UnmanageActionResourceMode const type. +func PossibleUnmanageActionResourceModeValues() []UnmanageActionResourceMode { + return []UnmanageActionResourceMode{ + UnmanageActionResourceModeDelete, + UnmanageActionResourceModeDetach, + } +} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/go.mod b/sdk/resourcemanager/resources/armdeploymentstacks/go.mod new file mode 100644 index 000000000000..2786648da31c --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armdeploymentstacks + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/go.sum b/sdk/resourcemanager/resources/armdeploymentstacks/go.sum new file mode 100644 index 000000000000..5c6bee428364 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/models.go b/sdk/resourcemanager/resources/armdeploymentstacks/models.go new file mode 100644 index 000000000000..cd7db5a0b046 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/models.go @@ -0,0 +1,284 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +import "time" + +// DebugSetting - The debug setting. +type DebugSetting struct { + // Specifies the type of information to log for debugging. The permitted values are none, requestContent, responseContent, + // or both requestContent and responseContent separated by a comma. The default is + // none. When setting this value, carefully consider the type of information that is being passed in during deployment. By + // logging information about the request or response, sensitive data that is + // retrieved through the deployment operations could potentially be exposed. + DetailLevel *string +} + +// DenySettings - Defines how resources deployed by the deployment stack are locked. +type DenySettings struct { + // REQUIRED; denySettings Mode. + Mode *DenySettingsMode + + // DenySettings will be applied to child scopes. + ApplyToChildScopes *bool + + // List of role-based management operations that are excluded from the denySettings. Up to 200 actions are permitted. If the + // denySetting mode is set to 'denyWriteAndDelete', then the following actions + // are automatically appended to 'excludedActions': '*/read' and 'Microsoft.Authorization/locks/delete'. If the denySetting + // mode is set to 'denyDelete', then the following actions are automatically + // appended to 'excludedActions': 'Microsoft.Authorization/locks/delete'. Duplicate actions will be removed. + ExcludedActions []*string + + // List of AAD principal IDs excluded from the lock. Up to 5 principals are permitted. + ExcludedPrincipals []*string +} + +// DeploymentStack - Deployment stack object. +type DeploymentStack struct { + // The location of the deployment stack. It cannot be changed after creation. It must be one of the supported Azure locations. + Location *string + + // Deployment stack properties. + Properties *DeploymentStackProperties + + // Deployment stack resource tags. + Tags map[string]*string + + // READ-ONLY; String Id used to locate any resource on Azure. + ID *string + + // READ-ONLY; Name of this resource. + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; Type of this resource. + Type *string +} + +// DeploymentStackListResult - List of deployment stacks. +type DeploymentStackListResult struct { + // An array of deployment stacks. + Value []*DeploymentStack + + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string +} + +// DeploymentStackProperties - Deployment stack properties. +type DeploymentStackProperties struct { + // REQUIRED; Defines the behavior of resources that are not managed immediately after the stack is updated. + ActionOnUnmanage *DeploymentStackPropertiesActionOnUnmanage + + // REQUIRED; Defines how resources deployed by the stack are locked. + DenySettings *DenySettings + + // The debug setting of the deployment. + DebugSetting *DebugSetting + + // The scope at which the initial deployment should be created. If a scope is not specified, it will default to the scope + // of the deployment stack. Valid scopes are: management group (format: + // '/providers/Microsoft.Management/managementGroups/{managementGroupId}'), subscription (format: '/subscriptions/{subscriptionId}'), + // resource group (format: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}'). + DeploymentScope *string + + // Deployment stack description. + Description *string + + // Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows + // the OData error response format.). + Error *ErrorResponse + + // Name and value pairs that define the deployment parameters for the template. Use this element when providing the parameter + // values directly in the request, rather than linking to an existing parameter + // file. Use either the parametersLink property or the parameters property, but not both. It can be a JObject or a well formed + // JSON string. + Parameters any + + // The URI of parameters file. Use this element to link to an existing parameters file. Use either the parametersLink property + // or the parameters property, but not both. + ParametersLink *ParametersLink + + // The template content. You use this element when you want to pass the template syntax directly in the request rather than + // link to an existing template. It can be a JObject or well-formed JSON string. + // Use either the templateLink property or the template property, but not both. + Template any + + // The URI of the template. Use either the templateLink property or the template property, but not both. + TemplateLink *TemplateLink + + // READ-ONLY; An array of resources that were deleted during the most recent update. + DeletedResources []*ResourceReference + + // READ-ONLY; The resourceId of the deployment resource created by the deployment stack. + DeploymentID *string + + // READ-ONLY; An array of resources that were detached during the most recent update. + DetachedResources []*ResourceReference + + // READ-ONLY; The duration of the deployment stack update. + Duration *string + + // READ-ONLY; An array of resources that failed to reach goal state during the most recent update. + FailedResources []*ResourceReferenceExtended + + // READ-ONLY; The outputs of the underlying deployment. + Outputs any + + // READ-ONLY; State of the deployment stack. + ProvisioningState *DeploymentStackProvisioningState + + // READ-ONLY; An array of resources currently managed by the deployment stack. + Resources []*ManagedResourceReference +} + +// DeploymentStackPropertiesActionOnUnmanage - Defines the behavior of resources that are not managed immediately after the +// stack is updated. +type DeploymentStackPropertiesActionOnUnmanage struct { + // REQUIRED; Specifies the action that should be taken on the resource when the deployment stack is deleted. Delete will attempt + // to delete the resource from Azure. Detach will leave the resource in it's current + // state. + Resources *DeploymentStacksDeleteDetachEnum + + // Specifies the action that should be taken on the resource when the deployment stack is deleted. Delete will attempt to + // delete the resource from Azure. Detach will leave the resource in it's current + // state. + ManagementGroups *DeploymentStacksDeleteDetachEnum + + // Specifies the action that should be taken on the resource when the deployment stack is deleted. Delete will attempt to + // delete the resource from Azure. Detach will leave the resource in it's current + // state. + ResourceGroups *DeploymentStacksDeleteDetachEnum +} + +// DeploymentStackTemplateDefinition - Export Template specific properties of the Stack. +type DeploymentStackTemplateDefinition struct { + // The template content. Use this element to pass the template syntax directly in the request rather than link to an existing + // template. It can be a JObject or well-formed JSON string. Use either the + // templateLink property or the template property, but not both. + Template any + + // The URI of the template. Use either the templateLink property or the template property, but not both. + TemplateLink *TemplateLink +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// 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.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail +} + +// ManagedResourceReference - The managed resource model. +type ManagedResourceReference struct { + // denyAssignment settings applied to the resource. + DenyStatus *DenyStatusMode + + // Current management state of the resource in the deployment stack. + Status *ResourceStatusMode + + // READ-ONLY; The resourceId of a resource managed by the deployment stack. + ID *string +} + +// ParametersLink - Entity representing the reference to the deployment parameters. +type ParametersLink struct { + // REQUIRED; The URI of the parameters file. + URI *string + + // If included, must match the ContentVersion in the template. + ContentVersion *string +} + +// ResourceReference - The resource Id model. +type ResourceReference struct { + // READ-ONLY; The resourceId of a resource managed by the deployment stack. + ID *string +} + +// ResourceReferenceExtended - The resource Id extended model. +type ResourceReferenceExtended struct { + // Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows + // the OData error response format.). + Error *ErrorResponse + + // READ-ONLY; The resourceId of a resource managed by the deployment stack. + ID *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// TemplateLink - Entity representing the reference to the template. +type TemplateLink struct { + // If included, must match the ContentVersion in the template. + ContentVersion *string + + // The resource id of a Template Spec. Use either the id or uri property, but not both. + ID *string + + // The query string (for example, a SAS token) to be used with the templateLink URI. + QueryString *string + + // The relativePath property can be used to deploy a linked template at a location relative to the parent. If the parent template + // was linked with a TemplateSpec, this will reference an artifact in the + // TemplateSpec. If the parent was linked with a URI, the child deployment will be a combination of the parent and relativePath + // URIs + RelativePath *string + + // The URI of the template to deploy. Use either the uri or id property, but not both. + URI *string +} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/models_serde.go b/sdk/resourcemanager/resources/armdeploymentstacks/models_serde.go new file mode 100644 index 000000000000..f3dec6bfbb9e --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/models_serde.go @@ -0,0 +1,670 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type DebugSetting. +func (d DebugSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "detailLevel", d.DetailLevel) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DebugSetting. +func (d *DebugSetting) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "detailLevel": + err = unpopulate(val, "DetailLevel", &d.DetailLevel) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DenySettings. +func (d DenySettings) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applyToChildScopes", d.ApplyToChildScopes) + populate(objectMap, "excludedActions", d.ExcludedActions) + populate(objectMap, "excludedPrincipals", d.ExcludedPrincipals) + populate(objectMap, "mode", d.Mode) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DenySettings. +func (d *DenySettings) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "applyToChildScopes": + err = unpopulate(val, "ApplyToChildScopes", &d.ApplyToChildScopes) + delete(rawMsg, key) + case "excludedActions": + err = unpopulate(val, "ExcludedActions", &d.ExcludedActions) + delete(rawMsg, key) + case "excludedPrincipals": + err = unpopulate(val, "ExcludedPrincipals", &d.ExcludedPrincipals) + delete(rawMsg, key) + case "mode": + err = unpopulate(val, "Mode", &d.Mode) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentStack. +func (d DeploymentStack) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStack. +func (d *DeploymentStack) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentStackListResult. +func (d DeploymentStackListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackListResult. +func (d *DeploymentStackListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentStackProperties. +func (d DeploymentStackProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionOnUnmanage", d.ActionOnUnmanage) + populate(objectMap, "debugSetting", d.DebugSetting) + populate(objectMap, "deletedResources", d.DeletedResources) + populate(objectMap, "denySettings", d.DenySettings) + populate(objectMap, "deploymentId", d.DeploymentID) + populate(objectMap, "deploymentScope", d.DeploymentScope) + populate(objectMap, "description", d.Description) + populate(objectMap, "detachedResources", d.DetachedResources) + populate(objectMap, "duration", d.Duration) + populate(objectMap, "error", d.Error) + populate(objectMap, "failedResources", d.FailedResources) + populateAny(objectMap, "outputs", d.Outputs) + populateAny(objectMap, "parameters", d.Parameters) + populate(objectMap, "parametersLink", d.ParametersLink) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "resources", d.Resources) + populateAny(objectMap, "template", d.Template) + populate(objectMap, "templateLink", d.TemplateLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackProperties. +func (d *DeploymentStackProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionOnUnmanage": + err = unpopulate(val, "ActionOnUnmanage", &d.ActionOnUnmanage) + delete(rawMsg, key) + case "debugSetting": + err = unpopulate(val, "DebugSetting", &d.DebugSetting) + delete(rawMsg, key) + case "deletedResources": + err = unpopulate(val, "DeletedResources", &d.DeletedResources) + delete(rawMsg, key) + case "denySettings": + err = unpopulate(val, "DenySettings", &d.DenySettings) + delete(rawMsg, key) + case "deploymentId": + err = unpopulate(val, "DeploymentID", &d.DeploymentID) + delete(rawMsg, key) + case "deploymentScope": + err = unpopulate(val, "DeploymentScope", &d.DeploymentScope) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "detachedResources": + err = unpopulate(val, "DetachedResources", &d.DetachedResources) + delete(rawMsg, key) + case "duration": + err = unpopulate(val, "Duration", &d.Duration) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &d.Error) + delete(rawMsg, key) + case "failedResources": + err = unpopulate(val, "FailedResources", &d.FailedResources) + delete(rawMsg, key) + case "outputs": + err = unpopulate(val, "Outputs", &d.Outputs) + delete(rawMsg, key) + case "parameters": + err = unpopulate(val, "Parameters", &d.Parameters) + delete(rawMsg, key) + case "parametersLink": + err = unpopulate(val, "ParametersLink", &d.ParametersLink) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &d.Resources) + delete(rawMsg, key) + case "template": + err = unpopulate(val, "Template", &d.Template) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentStackPropertiesActionOnUnmanage. +func (d DeploymentStackPropertiesActionOnUnmanage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "managementGroups", d.ManagementGroups) + populate(objectMap, "resourceGroups", d.ResourceGroups) + populate(objectMap, "resources", d.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackPropertiesActionOnUnmanage. +func (d *DeploymentStackPropertiesActionOnUnmanage) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "managementGroups": + err = unpopulate(val, "ManagementGroups", &d.ManagementGroups) + delete(rawMsg, key) + case "resourceGroups": + err = unpopulate(val, "ResourceGroups", &d.ResourceGroups) + delete(rawMsg, key) + case "resources": + err = unpopulate(val, "Resources", &d.Resources) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentStackTemplateDefinition. +func (d DeploymentStackTemplateDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "template", d.Template) + populate(objectMap, "templateLink", d.TemplateLink) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentStackTemplateDefinition. +func (d *DeploymentStackTemplateDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "template": + err = unpopulate(val, "Template", &d.Template) + delete(rawMsg, key) + case "templateLink": + err = unpopulate(val, "TemplateLink", &d.TemplateLink) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedResourceReference. +func (m ManagedResourceReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "denyStatus", m.DenyStatus) + populate(objectMap, "id", m.ID) + populate(objectMap, "status", m.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedResourceReference. +func (m *ManagedResourceReference) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "denyStatus": + err = unpopulate(val, "DenyStatus", &m.DenyStatus) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &m.ID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &m.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ParametersLink. +func (p ParametersLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentVersion", p.ContentVersion) + populate(objectMap, "uri", p.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ParametersLink. +func (p *ParametersLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contentVersion": + err = unpopulate(val, "ContentVersion", &p.ContentVersion) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &p.URI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReference. +func (r ResourceReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReference. +func (r *ResourceReference) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceReferenceExtended. +func (r ResourceReferenceExtended) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "error", r.Error) + populate(objectMap, "id", r.ID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceReferenceExtended. +func (r *ResourceReferenceExtended) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &r.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TemplateLink. +func (t TemplateLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "contentVersion", t.ContentVersion) + populate(objectMap, "id", t.ID) + populate(objectMap, "queryString", t.QueryString) + populate(objectMap, "relativePath", t.RelativePath) + populate(objectMap, "uri", t.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TemplateLink. +func (t *TemplateLink) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "contentVersion": + err = unpopulate(val, "ContentVersion", &t.ContentVersion) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "queryString": + err = unpopulate(val, "QueryString", &t.QueryString) + delete(rawMsg, key) + case "relativePath": + err = unpopulate(val, "RelativePath", &t.RelativePath) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &t.URI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/options.go b/sdk/resourcemanager/resources/armdeploymentstacks/options.go new file mode 100644 index 000000000000..16ba046aeab2 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/options.go @@ -0,0 +1,118 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +// ClientBeginCreateOrUpdateAtManagementGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtManagementGroup +// method. +type ClientBeginCreateOrUpdateAtManagementGroupOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateAtResourceGroupOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtResourceGroup +// method. +type ClientBeginCreateOrUpdateAtResourceGroupOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClientBeginCreateOrUpdateAtSubscriptionOptions contains the optional parameters for the Client.BeginCreateOrUpdateAtSubscription +// method. +type ClientBeginCreateOrUpdateAtSubscriptionOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ClientBeginDeleteAtManagementGroupOptions contains the optional parameters for the Client.BeginDeleteAtManagementGroup +// method. +type ClientBeginDeleteAtManagementGroupOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + + // Flag to indicate delete rather than detach for the management groups. + UnmanageActionManagementGroups *UnmanageActionManagementGroupMode + + // Flag to indicate delete rather than detach for the resource groups. + UnmanageActionResourceGroups *UnmanageActionResourceGroupMode + + // Flag to indicate delete rather than detach for the resources. + UnmanageActionResources *UnmanageActionResourceMode +} + +// ClientBeginDeleteAtResourceGroupOptions contains the optional parameters for the Client.BeginDeleteAtResourceGroup method. +type ClientBeginDeleteAtResourceGroupOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + + // Flag to indicate delete rather than detach for the resource groups. + UnmanageActionResourceGroups *UnmanageActionResourceGroupMode + + // Flag to indicate delete rather than detach for the resources. + UnmanageActionResources *UnmanageActionResourceMode +} + +// ClientBeginDeleteAtSubscriptionOptions contains the optional parameters for the Client.BeginDeleteAtSubscription method. +type ClientBeginDeleteAtSubscriptionOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + + // Flag to indicate delete rather than detach for the resource groups. + UnmanageActionResourceGroups *UnmanageActionResourceGroupMode + + // Flag to indicate delete rather than detach for the resources. + UnmanageActionResources *UnmanageActionResourceMode +} + +// ClientExportTemplateAtManagementGroupOptions contains the optional parameters for the Client.ExportTemplateAtManagementGroup +// method. +type ClientExportTemplateAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtResourceGroupOptions contains the optional parameters for the Client.ExportTemplateAtResourceGroup +// method. +type ClientExportTemplateAtResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientExportTemplateAtSubscriptionOptions contains the optional parameters for the Client.ExportTemplateAtSubscription +// method. +type ClientExportTemplateAtSubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtManagementGroupOptions contains the optional parameters for the Client.GetAtManagementGroup method. +type ClientGetAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtResourceGroupOptions contains the optional parameters for the Client.GetAtResourceGroup method. +type ClientGetAtResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientGetAtSubscriptionOptions contains the optional parameters for the Client.GetAtSubscription method. +type ClientGetAtSubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ClientListAtManagementGroupOptions contains the optional parameters for the Client.NewListAtManagementGroupPager method. +type ClientListAtManagementGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListAtResourceGroupOptions contains the optional parameters for the Client.NewListAtResourceGroupPager method. +type ClientListAtResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ClientListAtSubscriptionOptions contains the optional parameters for the Client.NewListAtSubscriptionPager method. +type ClientListAtSubscriptionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/response_types.go b/sdk/resourcemanager/resources/armdeploymentstacks/response_types.go new file mode 100644 index 000000000000..4e6160268a04 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/response_types.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +// ClientCreateOrUpdateAtManagementGroupResponse contains the response from method Client.BeginCreateOrUpdateAtManagementGroup. +type ClientCreateOrUpdateAtManagementGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientCreateOrUpdateAtResourceGroupResponse contains the response from method Client.BeginCreateOrUpdateAtResourceGroup. +type ClientCreateOrUpdateAtResourceGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientCreateOrUpdateAtSubscriptionResponse contains the response from method Client.BeginCreateOrUpdateAtSubscription. +type ClientCreateOrUpdateAtSubscriptionResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientDeleteAtManagementGroupResponse contains the response from method Client.BeginDeleteAtManagementGroup. +type ClientDeleteAtManagementGroupResponse struct { + // placeholder for future response values +} + +// ClientDeleteAtResourceGroupResponse contains the response from method Client.BeginDeleteAtResourceGroup. +type ClientDeleteAtResourceGroupResponse struct { + // placeholder for future response values +} + +// ClientDeleteAtSubscriptionResponse contains the response from method Client.BeginDeleteAtSubscription. +type ClientDeleteAtSubscriptionResponse struct { + // placeholder for future response values +} + +// ClientExportTemplateAtManagementGroupResponse contains the response from method Client.ExportTemplateAtManagementGroup. +type ClientExportTemplateAtManagementGroupResponse struct { + // Export Template specific properties of the Stack. + DeploymentStackTemplateDefinition +} + +// ClientExportTemplateAtResourceGroupResponse contains the response from method Client.ExportTemplateAtResourceGroup. +type ClientExportTemplateAtResourceGroupResponse struct { + // Export Template specific properties of the Stack. + DeploymentStackTemplateDefinition +} + +// ClientExportTemplateAtSubscriptionResponse contains the response from method Client.ExportTemplateAtSubscription. +type ClientExportTemplateAtSubscriptionResponse struct { + // Export Template specific properties of the Stack. + DeploymentStackTemplateDefinition +} + +// ClientGetAtManagementGroupResponse contains the response from method Client.GetAtManagementGroup. +type ClientGetAtManagementGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientGetAtResourceGroupResponse contains the response from method Client.GetAtResourceGroup. +type ClientGetAtResourceGroupResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientGetAtSubscriptionResponse contains the response from method Client.GetAtSubscription. +type ClientGetAtSubscriptionResponse struct { + // Deployment stack object. + DeploymentStack +} + +// ClientListAtManagementGroupResponse contains the response from method Client.NewListAtManagementGroupPager. +type ClientListAtManagementGroupResponse struct { + // List of deployment stacks. + DeploymentStackListResult +} + +// ClientListAtResourceGroupResponse contains the response from method Client.NewListAtResourceGroupPager. +type ClientListAtResourceGroupResponse struct { + // List of deployment stacks. + DeploymentStackListResult +} + +// ClientListAtSubscriptionResponse contains the response from method Client.NewListAtSubscriptionPager. +type ClientListAtSubscriptionResponse struct { + // List of deployment stacks. + DeploymentStackListResult +} diff --git a/sdk/resourcemanager/resources/armdeploymentstacks/time_rfc3339.go b/sdk/resourcemanager/resources/armdeploymentstacks/time_rfc3339.go new file mode 100644 index 000000000000..ef75a16bd863 --- /dev/null +++ b/sdk/resourcemanager/resources/armdeploymentstacks/time_rfc3339.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armdeploymentstacks + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}