From 3a83dbeb4c01a9c21fcf2ed6e6aa3d01effe469c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 25 Jul 2022 02:51:29 +0000 Subject: [PATCH] CodeGen from PR 19906 in Azure/azure-rest-api-specs fix devcenter readme.go.md config (#19906) * fix readme.go.md config * rename to SkuInfo --- .../devcenter/armdevcenter/CHANGELOG.md | 9 + .../devcenter/armdevcenter/LICENSE.txt | 21 + .../devcenter/armdevcenter/README.md | 77 + .../armdevcenter/attachednetworks_client.go | 468 +++ .../devcenter/armdevcenter/autorest.md | 13 + .../devcenter/armdevcenter/build.go | 7 + .../devcenter/armdevcenter/catalogs_client.go | 470 +++ .../devcenter/armdevcenter/ci.yml | 28 + .../devcenter/armdevcenter/constants.go | 258 ++ .../armdevcenter/devboxdefinitions_client.go | 538 +++ .../armdevcenter/devcenters_client.go | 439 +++ .../armdevcenter/environmenttypes_client.go | 368 ++ .../armdevcenter/galleries_client.go | 331 ++ .../devcenter/armdevcenter/go.mod | 13 + .../devcenter/armdevcenter/go.sum | 15 + .../devcenter/armdevcenter/images_client.go | 272 ++ .../armdevcenter/imageversions_client.go | 207 + .../devcenter/armdevcenter/models.go | 1745 +++++++++ .../devcenter/armdevcenter/models_serde.go | 3377 +++++++++++++++++ .../armdevcenter/networkconnections_client.go | 620 +++ .../armdevcenter/operations_client.go | 105 + .../armdevcenter/operationstatuses_client.go | 112 + .../devcenter/armdevcenter/pools_client.go | 400 ++ .../projectenvironmenttypes_client.go | 371 ++ .../devcenter/armdevcenter/projects_client.go | 439 +++ .../devcenter/armdevcenter/response_types.go | 375 ++ .../armdevcenter/schedules_client.go | 437 +++ .../devcenter/armdevcenter/skus_client.go | 119 + .../devcenter/armdevcenter/time_rfc3339.go | 87 + .../devcenter/armdevcenter/usages_client.go | 120 + 30 files changed, 11841 insertions(+) create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/CHANGELOG.md create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/LICENSE.txt create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/README.md create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/attachednetworks_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/autorest.md create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/build.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/catalogs_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/ci.yml create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/constants.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/devboxdefinitions_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/devcenters_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/environmenttypes_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/galleries_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/go.mod create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/go.sum create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/images_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/imageversions_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/models.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/models_serde.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/networkconnections_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/operations_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/operationstatuses_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/pools_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/projectenvironmenttypes_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/projects_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/response_types.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/schedules_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/skus_client.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/time_rfc3339.go create mode 100644 sdk/resourcemanager/devcenter/armdevcenter/usages_client.go diff --git a/sdk/resourcemanager/devcenter/armdevcenter/CHANGELOG.md b/sdk/resourcemanager/devcenter/armdevcenter/CHANGELOG.md new file mode 100644 index 000000000000..51a234675fd2 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/CHANGELOG.md @@ -0,0 +1,9 @@ +# Release History + +## 0.1.0 (2022-07-25) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devcenter/armdevcenter` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.1.0, which contains breaking changes. + +To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/azsdk/go/mgmt/migration). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/devcenter/armdevcenter/LICENSE.txt b/sdk/resourcemanager/devcenter/armdevcenter/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/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/devcenter/armdevcenter/README.md b/sdk/resourcemanager/devcenter/armdevcenter/README.md new file mode 100644 index 000000000000..2c4ac2f2f759 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/README.md @@ -0,0 +1,77 @@ +# Azure Devcenter Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devcenter/armdevcenter)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devcenter/armdevcenter) + +The `armdevcenter` module provides operations for working with Azure Devcenter. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/devcenter/armdevcenter) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Devcenter module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devcenter/armdevcenter +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Devcenter. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure Devcenter modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armdevcenter.NewEnvironmentTypesClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armdevcenter.NewEnvironmentTypesClient(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Devcenter` 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/devcenter/armdevcenter/attachednetworks_client.go b/sdk/resourcemanager/devcenter/armdevcenter/attachednetworks_client.go new file mode 100644 index 000000000000..320ce6e23314 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/attachednetworks_client.go @@ -0,0 +1,468 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// AttachedNetworksClient contains the methods for the AttachedNetworks group. +// Don't use this type directly, use NewAttachedNetworksClient() instead. +type AttachedNetworksClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewAttachedNetworksClient creates a new instance of AttachedNetworksClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewAttachedNetworksClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AttachedNetworksClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &AttachedNetworksClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates an attached NetworkConnection. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// attachedNetworkConnectionName - The name of the attached NetworkConnection. +// body - Represents an attached NetworkConnection. +// options - AttachedNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the AttachedNetworksClient.BeginCreateOrUpdate +// method. +func (client *AttachedNetworksClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, body AttachedNetworkConnection, options *AttachedNetworksClientBeginCreateOrUpdateOptions) (*runtime.Poller[AttachedNetworksClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, devCenterName, attachedNetworkConnectionName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AttachedNetworksClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[AttachedNetworksClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates an attached NetworkConnection. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *AttachedNetworksClient) createOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, body AttachedNetworkConnection, options *AttachedNetworksClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, devCenterName, attachedNetworkConnectionName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AttachedNetworksClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, body AttachedNetworkConnection, options *AttachedNetworksClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks/{attachedNetworkConnectionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if attachedNetworkConnectionName == "" { + return nil, errors.New("parameter attachedNetworkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachedNetworkConnectionName}", url.PathEscape(attachedNetworkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Un-attach a NetworkConnection. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// attachedNetworkConnectionName - The name of the attached NetworkConnection. +// options - AttachedNetworksClientBeginDeleteOptions contains the optional parameters for the AttachedNetworksClient.BeginDelete +// method. +func (client *AttachedNetworksClient) BeginDelete(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, options *AttachedNetworksClientBeginDeleteOptions) (*runtime.Poller[AttachedNetworksClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, devCenterName, attachedNetworkConnectionName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AttachedNetworksClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[AttachedNetworksClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Un-attach a NetworkConnection. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *AttachedNetworksClient) deleteOperation(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, options *AttachedNetworksClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, devCenterName, attachedNetworkConnectionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AttachedNetworksClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, options *AttachedNetworksClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks/{attachedNetworkConnectionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if attachedNetworkConnectionName == "" { + return nil, errors.New("parameter attachedNetworkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachedNetworkConnectionName}", url.PathEscape(attachedNetworkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GetByDevCenter - Gets an attached NetworkConnection. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// attachedNetworkConnectionName - The name of the attached NetworkConnection. +// options - AttachedNetworksClientGetByDevCenterOptions contains the optional parameters for the AttachedNetworksClient.GetByDevCenter +// method. +func (client *AttachedNetworksClient) GetByDevCenter(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, options *AttachedNetworksClientGetByDevCenterOptions) (AttachedNetworksClientGetByDevCenterResponse, error) { + req, err := client.getByDevCenterCreateRequest(ctx, resourceGroupName, devCenterName, attachedNetworkConnectionName, options) + if err != nil { + return AttachedNetworksClientGetByDevCenterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AttachedNetworksClientGetByDevCenterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AttachedNetworksClientGetByDevCenterResponse{}, runtime.NewResponseError(resp) + } + return client.getByDevCenterHandleResponse(resp) +} + +// getByDevCenterCreateRequest creates the GetByDevCenter request. +func (client *AttachedNetworksClient) getByDevCenterCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, attachedNetworkConnectionName string, options *AttachedNetworksClientGetByDevCenterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks/{attachedNetworkConnectionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if attachedNetworkConnectionName == "" { + return nil, errors.New("parameter attachedNetworkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachedNetworkConnectionName}", url.PathEscape(attachedNetworkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByDevCenterHandleResponse handles the GetByDevCenter response. +func (client *AttachedNetworksClient) getByDevCenterHandleResponse(resp *http.Response) (AttachedNetworksClientGetByDevCenterResponse, error) { + result := AttachedNetworksClientGetByDevCenterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AttachedNetworkConnection); err != nil { + return AttachedNetworksClientGetByDevCenterResponse{}, err + } + return result, nil +} + +// GetByProject - Gets an attached NetworkConnection. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// attachedNetworkConnectionName - The name of the attached NetworkConnection. +// options - AttachedNetworksClientGetByProjectOptions contains the optional parameters for the AttachedNetworksClient.GetByProject +// method. +func (client *AttachedNetworksClient) GetByProject(ctx context.Context, resourceGroupName string, projectName string, attachedNetworkConnectionName string, options *AttachedNetworksClientGetByProjectOptions) (AttachedNetworksClientGetByProjectResponse, error) { + req, err := client.getByProjectCreateRequest(ctx, resourceGroupName, projectName, attachedNetworkConnectionName, options) + if err != nil { + return AttachedNetworksClientGetByProjectResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AttachedNetworksClientGetByProjectResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AttachedNetworksClientGetByProjectResponse{}, runtime.NewResponseError(resp) + } + return client.getByProjectHandleResponse(resp) +} + +// getByProjectCreateRequest creates the GetByProject request. +func (client *AttachedNetworksClient) getByProjectCreateRequest(ctx context.Context, resourceGroupName string, projectName string, attachedNetworkConnectionName string, options *AttachedNetworksClientGetByProjectOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/attachednetworks/{attachedNetworkConnectionName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if attachedNetworkConnectionName == "" { + return nil, errors.New("parameter attachedNetworkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachedNetworkConnectionName}", url.PathEscape(attachedNetworkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByProjectHandleResponse handles the GetByProject response. +func (client *AttachedNetworksClient) getByProjectHandleResponse(resp *http.Response) (AttachedNetworksClientGetByProjectResponse, error) { + result := AttachedNetworksClientGetByProjectResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AttachedNetworkConnection); err != nil { + return AttachedNetworksClientGetByProjectResponse{}, err + } + return result, nil +} + +// NewListByDevCenterPager - Lists the attached NetworkConnections for a DevCenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - AttachedNetworksClientListByDevCenterOptions contains the optional parameters for the AttachedNetworksClient.ListByDevCenter +// method. +func (client *AttachedNetworksClient) NewListByDevCenterPager(resourceGroupName string, devCenterName string, options *AttachedNetworksClientListByDevCenterOptions) *runtime.Pager[AttachedNetworksClientListByDevCenterResponse] { + return runtime.NewPager(runtime.PagingHandler[AttachedNetworksClientListByDevCenterResponse]{ + More: func(page AttachedNetworksClientListByDevCenterResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AttachedNetworksClientListByDevCenterResponse) (AttachedNetworksClientListByDevCenterResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDevCenterCreateRequest(ctx, resourceGroupName, devCenterName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AttachedNetworksClientListByDevCenterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AttachedNetworksClientListByDevCenterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AttachedNetworksClientListByDevCenterResponse{}, runtime.NewResponseError(resp) + } + return client.listByDevCenterHandleResponse(resp) + }, + }) +} + +// listByDevCenterCreateRequest creates the ListByDevCenter request. +func (client *AttachedNetworksClient) listByDevCenterCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *AttachedNetworksClientListByDevCenterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/attachednetworks" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDevCenterHandleResponse handles the ListByDevCenter response. +func (client *AttachedNetworksClient) listByDevCenterHandleResponse(resp *http.Response) (AttachedNetworksClientListByDevCenterResponse, error) { + result := AttachedNetworksClientListByDevCenterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AttachedNetworkListResult); err != nil { + return AttachedNetworksClientListByDevCenterResponse{}, err + } + return result, nil +} + +// NewListByProjectPager - Lists the attached NetworkConnections for a Project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// options - AttachedNetworksClientListByProjectOptions contains the optional parameters for the AttachedNetworksClient.ListByProject +// method. +func (client *AttachedNetworksClient) NewListByProjectPager(resourceGroupName string, projectName string, options *AttachedNetworksClientListByProjectOptions) *runtime.Pager[AttachedNetworksClientListByProjectResponse] { + return runtime.NewPager(runtime.PagingHandler[AttachedNetworksClientListByProjectResponse]{ + More: func(page AttachedNetworksClientListByProjectResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AttachedNetworksClientListByProjectResponse) (AttachedNetworksClientListByProjectResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByProjectCreateRequest(ctx, resourceGroupName, projectName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AttachedNetworksClientListByProjectResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AttachedNetworksClientListByProjectResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AttachedNetworksClientListByProjectResponse{}, runtime.NewResponseError(resp) + } + return client.listByProjectHandleResponse(resp) + }, + }) +} + +// listByProjectCreateRequest creates the ListByProject request. +func (client *AttachedNetworksClient) listByProjectCreateRequest(ctx context.Context, resourceGroupName string, projectName string, options *AttachedNetworksClientListByProjectOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/attachednetworks" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProjectHandleResponse handles the ListByProject response. +func (client *AttachedNetworksClient) listByProjectHandleResponse(resp *http.Response) (AttachedNetworksClientListByProjectResponse, error) { + result := AttachedNetworksClientListByProjectResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AttachedNetworkListResult); err != nil { + return AttachedNetworksClientListByProjectResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/autorest.md b/sdk/resourcemanager/devcenter/armdevcenter/autorest.md new file mode 100644 index 000000000000..6bc9e3f0f06c --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/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/devcenter/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/devcenter/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/devcenter/armdevcenter/build.go b/sdk/resourcemanager/devcenter/armdevcenter/build.go new file mode 100644 index 000000000000..f54e462013b7 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/devcenter/armdevcenter + +package armdevcenter diff --git a/sdk/resourcemanager/devcenter/armdevcenter/catalogs_client.go b/sdk/resourcemanager/devcenter/armdevcenter/catalogs_client.go new file mode 100644 index 000000000000..469bcb32b900 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/catalogs_client.go @@ -0,0 +1,470 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// CatalogsClient contains the methods for the Catalogs group. +// Don't use this type directly, use NewCatalogsClient() instead. +type CatalogsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewCatalogsClient creates a new instance of CatalogsClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewCatalogsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CatalogsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &CatalogsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a catalog. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// catalogName - The name of the Catalog. +// body - Represents a catalog. +// options - CatalogsClientBeginCreateOrUpdateOptions contains the optional parameters for the CatalogsClient.BeginCreateOrUpdate +// method. +func (client *CatalogsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, body Catalog, options *CatalogsClientBeginCreateOrUpdateOptions) (*runtime.Poller[CatalogsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, devCenterName, catalogName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CatalogsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[CatalogsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a catalog. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *CatalogsClient) createOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, body Catalog, options *CatalogsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, devCenterName, catalogName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CatalogsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, body Catalog, options *CatalogsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a catalog resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// catalogName - The name of the Catalog. +// options - CatalogsClientBeginDeleteOptions contains the optional parameters for the CatalogsClient.BeginDelete method. +func (client *CatalogsClient) BeginDelete(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientBeginDeleteOptions) (*runtime.Poller[CatalogsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, devCenterName, catalogName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CatalogsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[CatalogsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a catalog resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *CatalogsClient) deleteOperation(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, devCenterName, catalogName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CatalogsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a catalog +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// catalogName - The name of the Catalog. +// options - CatalogsClientGetOptions contains the optional parameters for the CatalogsClient.Get method. +func (client *CatalogsClient) Get(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientGetOptions) (CatalogsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, devCenterName, catalogName, options) + if err != nil { + return CatalogsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CatalogsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CatalogsClient) getCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CatalogsClient) getHandleResponse(resp *http.Response) (CatalogsClientGetResponse, error) { + result := CatalogsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Catalog); err != nil { + return CatalogsClientGetResponse{}, err + } + return result, nil +} + +// NewListByDevCenterPager - Lists catalogs for a devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - CatalogsClientListByDevCenterOptions contains the optional parameters for the CatalogsClient.ListByDevCenter +// method. +func (client *CatalogsClient) NewListByDevCenterPager(resourceGroupName string, devCenterName string, options *CatalogsClientListByDevCenterOptions) *runtime.Pager[CatalogsClientListByDevCenterResponse] { + return runtime.NewPager(runtime.PagingHandler[CatalogsClientListByDevCenterResponse]{ + More: func(page CatalogsClientListByDevCenterResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CatalogsClientListByDevCenterResponse) (CatalogsClientListByDevCenterResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDevCenterCreateRequest(ctx, resourceGroupName, devCenterName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CatalogsClientListByDevCenterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CatalogsClientListByDevCenterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CatalogsClientListByDevCenterResponse{}, runtime.NewResponseError(resp) + } + return client.listByDevCenterHandleResponse(resp) + }, + }) +} + +// listByDevCenterCreateRequest creates the ListByDevCenter request. +func (client *CatalogsClient) listByDevCenterCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *CatalogsClientListByDevCenterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDevCenterHandleResponse handles the ListByDevCenter response. +func (client *CatalogsClient) listByDevCenterHandleResponse(resp *http.Response) (CatalogsClientListByDevCenterResponse, error) { + result := CatalogsClientListByDevCenterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CatalogListResult); err != nil { + return CatalogsClientListByDevCenterResponse{}, err + } + return result, nil +} + +// BeginSync - Syncs templates for a template source. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// catalogName - The name of the Catalog. +// options - CatalogsClientBeginSyncOptions contains the optional parameters for the CatalogsClient.BeginSync method. +func (client *CatalogsClient) BeginSync(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientBeginSyncOptions) (*runtime.Poller[CatalogsClientSyncResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.syncOperation(ctx, resourceGroupName, devCenterName, catalogName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CatalogsClientSyncResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[CatalogsClientSyncResponse](options.ResumeToken, client.pl, nil) + } +} + +// Sync - Syncs templates for a template source. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *CatalogsClient) syncOperation(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientBeginSyncOptions) (*http.Response, error) { + req, err := client.syncCreateRequest(ctx, resourceGroupName, devCenterName, catalogName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// syncCreateRequest creates the Sync request. +func (client *CatalogsClient) syncCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, options *CatalogsClientBeginSyncOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}/sync" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, 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 +} + +// BeginUpdate - Partially updates a catalog. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// catalogName - The name of the Catalog. +// body - Updatable catalog properties. +// options - CatalogsClientBeginUpdateOptions contains the optional parameters for the CatalogsClient.BeginUpdate method. +func (client *CatalogsClient) BeginUpdate(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, body CatalogUpdate, options *CatalogsClientBeginUpdateOptions) (*runtime.Poller[CatalogsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, devCenterName, catalogName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CatalogsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[CatalogsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Partially updates a catalog. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *CatalogsClient) update(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, body CatalogUpdate, options *CatalogsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, devCenterName, catalogName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *CatalogsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, catalogName string, body CatalogUpdate, options *CatalogsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/catalogs/{catalogName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if catalogName == "" { + return nil, errors.New("parameter catalogName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{catalogName}", url.PathEscape(catalogName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/ci.yml b/sdk/resourcemanager/devcenter/armdevcenter/ci.yml new file mode 100644 index 000000000000..fc40fe899caf --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/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/devcenter/armdevcenter/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/devcenter/armdevcenter/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/devcenter/armdevcenter' diff --git a/sdk/resourcemanager/devcenter/armdevcenter/constants.go b/sdk/resourcemanager/devcenter/armdevcenter/constants.go new file mode 100644 index 000000000000..04d413bc9458 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/constants.go @@ -0,0 +1,258 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +const ( + moduleName = "armdevcenter" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// 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, + } +} + +// DomainJoinType - Active Directory join type +type DomainJoinType string + +const ( + DomainJoinTypeAzureADJoin DomainJoinType = "AzureADJoin" + DomainJoinTypeHybridAzureADJoin DomainJoinType = "HybridAzureADJoin" +) + +// PossibleDomainJoinTypeValues returns the possible values for the DomainJoinType const type. +func PossibleDomainJoinTypeValues() []DomainJoinType { + return []DomainJoinType{ + DomainJoinTypeAzureADJoin, + DomainJoinTypeHybridAzureADJoin, + } +} + +// EnableStatus - Enable or disable status. Indicates whether the property applied to is either enabled or disabled. +type EnableStatus string + +const ( + EnableStatusDisabled EnableStatus = "Disabled" + EnableStatusEnabled EnableStatus = "Enabled" +) + +// PossibleEnableStatusValues returns the possible values for the EnableStatus const type. +func PossibleEnableStatusValues() []EnableStatus { + return []EnableStatus{ + EnableStatusDisabled, + EnableStatusEnabled, + } +} + +// HealthCheckStatus - Health check status values +type HealthCheckStatus string + +const ( + HealthCheckStatusFailed HealthCheckStatus = "Failed" + HealthCheckStatusPassed HealthCheckStatus = "Passed" + HealthCheckStatusPending HealthCheckStatus = "Pending" + HealthCheckStatusRunning HealthCheckStatus = "Running" + HealthCheckStatusUnknown HealthCheckStatus = "Unknown" + HealthCheckStatusWarning HealthCheckStatus = "Warning" +) + +// PossibleHealthCheckStatusValues returns the possible values for the HealthCheckStatus const type. +func PossibleHealthCheckStatusValues() []HealthCheckStatus { + return []HealthCheckStatus{ + HealthCheckStatusFailed, + HealthCheckStatusPassed, + HealthCheckStatusPending, + HealthCheckStatusRunning, + HealthCheckStatusUnknown, + HealthCheckStatusWarning, + } +} + +// ImageValidationStatus - Image validation status +type ImageValidationStatus string + +const ( + ImageValidationStatusFailed ImageValidationStatus = "Failed" + ImageValidationStatusPending ImageValidationStatus = "Pending" + ImageValidationStatusSucceeded ImageValidationStatus = "Succeeded" + ImageValidationStatusTimedOut ImageValidationStatus = "TimedOut" + ImageValidationStatusUnknown ImageValidationStatus = "Unknown" +) + +// PossibleImageValidationStatusValues returns the possible values for the ImageValidationStatus const type. +func PossibleImageValidationStatusValues() []ImageValidationStatus { + return []ImageValidationStatus{ + ImageValidationStatusFailed, + ImageValidationStatusPending, + ImageValidationStatusSucceeded, + ImageValidationStatusTimedOut, + ImageValidationStatusUnknown, + } +} + +// LicenseType - License Types +type LicenseType string + +const ( + LicenseTypeWindowsClient LicenseType = "Windows_Client" +) + +// PossibleLicenseTypeValues returns the possible values for the LicenseType const type. +func PossibleLicenseTypeValues() []LicenseType { + return []LicenseType{ + LicenseTypeWindowsClient, + } +} + +type LocalAdminStatus string + +const ( + LocalAdminStatusDisabled LocalAdminStatus = "Disabled" + LocalAdminStatusEnabled LocalAdminStatus = "Enabled" +) + +// PossibleLocalAdminStatusValues returns the possible values for the LocalAdminStatus const type. +func PossibleLocalAdminStatusValues() []LocalAdminStatus { + return []LocalAdminStatus{ + LocalAdminStatusDisabled, + LocalAdminStatusEnabled, + } +} + +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned, UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// SKUTier - This field is required to be implemented by the Resource Provider if the service has more than one tier, but +// is not required on a PUT. +type SKUTier string + +const ( + SKUTierFree SKUTier = "Free" + SKUTierBasic SKUTier = "Basic" + SKUTierStandard SKUTier = "Standard" + SKUTierPremium SKUTier = "Premium" +) + +// PossibleSKUTierValues returns the possible values for the SKUTier const type. +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierFree, + SKUTierBasic, + SKUTierStandard, + SKUTierPremium, + } +} + +// ScheduledFrequency - The frequency of task execution. +type ScheduledFrequency string + +const ( + ScheduledFrequencyDaily ScheduledFrequency = "Daily" +) + +// PossibleScheduledFrequencyValues returns the possible values for the ScheduledFrequency const type. +func PossibleScheduledFrequencyValues() []ScheduledFrequency { + return []ScheduledFrequency{ + ScheduledFrequencyDaily, + } +} + +// ScheduledType - The supported types for a scheduled task. +type ScheduledType string + +const ( + ScheduledTypeStopDevBox ScheduledType = "StopDevBox" +) + +// PossibleScheduledTypeValues returns the possible values for the ScheduledType const type. +func PossibleScheduledTypeValues() []ScheduledType { + return []ScheduledType{ + ScheduledTypeStopDevBox, + } +} + +// UsageUnit - The unit details. +type UsageUnit string + +const ( + UsageUnitCount UsageUnit = "Count" +) + +// PossibleUsageUnitValues returns the possible values for the UsageUnit const type. +func PossibleUsageUnitValues() []UsageUnit { + return []UsageUnit{ + UsageUnitCount, + } +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/devboxdefinitions_client.go b/sdk/resourcemanager/devcenter/armdevcenter/devboxdefinitions_client.go new file mode 100644 index 000000000000..e0bac243ab59 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/devboxdefinitions_client.go @@ -0,0 +1,538 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DevBoxDefinitionsClient contains the methods for the DevBoxDefinitions group. +// Don't use this type directly, use NewDevBoxDefinitionsClient() instead. +type DevBoxDefinitionsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewDevBoxDefinitionsClient creates a new instance of DevBoxDefinitionsClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewDevBoxDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DevBoxDefinitionsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &DevBoxDefinitionsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a Dev Box definition. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// devBoxDefinitionName - The name of the Dev Box definition. +// body - Represents a Dev Box definition. +// options - DevBoxDefinitionsClientBeginCreateOrUpdateOptions contains the optional parameters for the DevBoxDefinitionsClient.BeginCreateOrUpdate +// method. +func (client *DevBoxDefinitionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, body DevBoxDefinition, options *DevBoxDefinitionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[DevBoxDefinitionsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, devCenterName, devBoxDefinitionName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DevBoxDefinitionsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DevBoxDefinitionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a Dev Box definition. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *DevBoxDefinitionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, body DevBoxDefinition, options *DevBoxDefinitionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, devCenterName, devBoxDefinitionName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DevBoxDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, body DevBoxDefinition, options *DevBoxDefinitionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if devBoxDefinitionName == "" { + return nil, errors.New("parameter devBoxDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devBoxDefinitionName}", url.PathEscape(devBoxDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a Dev Box definition +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// devBoxDefinitionName - The name of the Dev Box definition. +// options - DevBoxDefinitionsClientBeginDeleteOptions contains the optional parameters for the DevBoxDefinitionsClient.BeginDelete +// method. +func (client *DevBoxDefinitionsClient) BeginDelete(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, options *DevBoxDefinitionsClientBeginDeleteOptions) (*runtime.Poller[DevBoxDefinitionsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, devCenterName, devBoxDefinitionName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DevBoxDefinitionsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DevBoxDefinitionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a Dev Box definition +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *DevBoxDefinitionsClient) deleteOperation(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, options *DevBoxDefinitionsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, devCenterName, devBoxDefinitionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DevBoxDefinitionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, options *DevBoxDefinitionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if devBoxDefinitionName == "" { + return nil, errors.New("parameter devBoxDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devBoxDefinitionName}", url.PathEscape(devBoxDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a Dev Box definition +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// devBoxDefinitionName - The name of the Dev Box definition. +// options - DevBoxDefinitionsClientGetOptions contains the optional parameters for the DevBoxDefinitionsClient.Get method. +func (client *DevBoxDefinitionsClient) Get(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, options *DevBoxDefinitionsClientGetOptions) (DevBoxDefinitionsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, devCenterName, devBoxDefinitionName, options) + if err != nil { + return DevBoxDefinitionsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DevBoxDefinitionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevBoxDefinitionsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DevBoxDefinitionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, options *DevBoxDefinitionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if devBoxDefinitionName == "" { + return nil, errors.New("parameter devBoxDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devBoxDefinitionName}", url.PathEscape(devBoxDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DevBoxDefinitionsClient) getHandleResponse(resp *http.Response) (DevBoxDefinitionsClientGetResponse, error) { + result := DevBoxDefinitionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DevBoxDefinition); err != nil { + return DevBoxDefinitionsClientGetResponse{}, err + } + return result, nil +} + +// GetByProject - Gets a Dev Box definition configured for a project +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// devBoxDefinitionName - The name of the Dev Box definition. +// options - DevBoxDefinitionsClientGetByProjectOptions contains the optional parameters for the DevBoxDefinitionsClient.GetByProject +// method. +func (client *DevBoxDefinitionsClient) GetByProject(ctx context.Context, resourceGroupName string, projectName string, devBoxDefinitionName string, options *DevBoxDefinitionsClientGetByProjectOptions) (DevBoxDefinitionsClientGetByProjectResponse, error) { + req, err := client.getByProjectCreateRequest(ctx, resourceGroupName, projectName, devBoxDefinitionName, options) + if err != nil { + return DevBoxDefinitionsClientGetByProjectResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DevBoxDefinitionsClientGetByProjectResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevBoxDefinitionsClientGetByProjectResponse{}, runtime.NewResponseError(resp) + } + return client.getByProjectHandleResponse(resp) +} + +// getByProjectCreateRequest creates the GetByProject request. +func (client *DevBoxDefinitionsClient) getByProjectCreateRequest(ctx context.Context, resourceGroupName string, projectName string, devBoxDefinitionName string, options *DevBoxDefinitionsClientGetByProjectOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/devboxdefinitions/{devBoxDefinitionName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if devBoxDefinitionName == "" { + return nil, errors.New("parameter devBoxDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devBoxDefinitionName}", url.PathEscape(devBoxDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByProjectHandleResponse handles the GetByProject response. +func (client *DevBoxDefinitionsClient) getByProjectHandleResponse(resp *http.Response) (DevBoxDefinitionsClientGetByProjectResponse, error) { + result := DevBoxDefinitionsClientGetByProjectResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DevBoxDefinition); err != nil { + return DevBoxDefinitionsClientGetByProjectResponse{}, err + } + return result, nil +} + +// NewListByDevCenterPager - List Dev Box definitions for a devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - DevBoxDefinitionsClientListByDevCenterOptions contains the optional parameters for the DevBoxDefinitionsClient.ListByDevCenter +// method. +func (client *DevBoxDefinitionsClient) NewListByDevCenterPager(resourceGroupName string, devCenterName string, options *DevBoxDefinitionsClientListByDevCenterOptions) *runtime.Pager[DevBoxDefinitionsClientListByDevCenterResponse] { + return runtime.NewPager(runtime.PagingHandler[DevBoxDefinitionsClientListByDevCenterResponse]{ + More: func(page DevBoxDefinitionsClientListByDevCenterResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DevBoxDefinitionsClientListByDevCenterResponse) (DevBoxDefinitionsClientListByDevCenterResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDevCenterCreateRequest(ctx, resourceGroupName, devCenterName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DevBoxDefinitionsClientListByDevCenterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DevBoxDefinitionsClientListByDevCenterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevBoxDefinitionsClientListByDevCenterResponse{}, runtime.NewResponseError(resp) + } + return client.listByDevCenterHandleResponse(resp) + }, + }) +} + +// listByDevCenterCreateRequest creates the ListByDevCenter request. +func (client *DevBoxDefinitionsClient) listByDevCenterCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *DevBoxDefinitionsClientListByDevCenterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDevCenterHandleResponse handles the ListByDevCenter response. +func (client *DevBoxDefinitionsClient) listByDevCenterHandleResponse(resp *http.Response) (DevBoxDefinitionsClientListByDevCenterResponse, error) { + result := DevBoxDefinitionsClientListByDevCenterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DevBoxDefinitionListResult); err != nil { + return DevBoxDefinitionsClientListByDevCenterResponse{}, err + } + return result, nil +} + +// NewListByProjectPager - List Dev Box definitions configured for a project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// options - DevBoxDefinitionsClientListByProjectOptions contains the optional parameters for the DevBoxDefinitionsClient.ListByProject +// method. +func (client *DevBoxDefinitionsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *DevBoxDefinitionsClientListByProjectOptions) *runtime.Pager[DevBoxDefinitionsClientListByProjectResponse] { + return runtime.NewPager(runtime.PagingHandler[DevBoxDefinitionsClientListByProjectResponse]{ + More: func(page DevBoxDefinitionsClientListByProjectResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DevBoxDefinitionsClientListByProjectResponse) (DevBoxDefinitionsClientListByProjectResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByProjectCreateRequest(ctx, resourceGroupName, projectName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DevBoxDefinitionsClientListByProjectResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DevBoxDefinitionsClientListByProjectResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevBoxDefinitionsClientListByProjectResponse{}, runtime.NewResponseError(resp) + } + return client.listByProjectHandleResponse(resp) + }, + }) +} + +// listByProjectCreateRequest creates the ListByProject request. +func (client *DevBoxDefinitionsClient) listByProjectCreateRequest(ctx context.Context, resourceGroupName string, projectName string, options *DevBoxDefinitionsClientListByProjectOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/devboxdefinitions" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProjectHandleResponse handles the ListByProject response. +func (client *DevBoxDefinitionsClient) listByProjectHandleResponse(resp *http.Response) (DevBoxDefinitionsClientListByProjectResponse, error) { + result := DevBoxDefinitionsClientListByProjectResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DevBoxDefinitionListResult); err != nil { + return DevBoxDefinitionsClientListByProjectResponse{}, err + } + return result, nil +} + +// BeginUpdate - Partially updates a Dev Box definition. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// devBoxDefinitionName - The name of the Dev Box definition. +// body - Represents a Dev Box definition. +// options - DevBoxDefinitionsClientBeginUpdateOptions contains the optional parameters for the DevBoxDefinitionsClient.BeginUpdate +// method. +func (client *DevBoxDefinitionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, body DevBoxDefinitionUpdate, options *DevBoxDefinitionsClientBeginUpdateOptions) (*runtime.Poller[DevBoxDefinitionsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, devCenterName, devBoxDefinitionName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DevBoxDefinitionsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DevBoxDefinitionsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Partially updates a Dev Box definition. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *DevBoxDefinitionsClient) update(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, body DevBoxDefinitionUpdate, options *DevBoxDefinitionsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, devCenterName, devBoxDefinitionName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DevBoxDefinitionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, devBoxDefinitionName string, body DevBoxDefinitionUpdate, options *DevBoxDefinitionsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/devboxdefinitions/{devBoxDefinitionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if devBoxDefinitionName == "" { + return nil, errors.New("parameter devBoxDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devBoxDefinitionName}", url.PathEscape(devBoxDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/devcenters_client.go b/sdk/resourcemanager/devcenter/armdevcenter/devcenters_client.go new file mode 100644 index 000000000000..61faeaa65a21 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/devcenters_client.go @@ -0,0 +1,439 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DevCentersClient contains the methods for the DevCenters group. +// Don't use this type directly, use NewDevCentersClient() instead. +type DevCentersClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewDevCentersClient creates a new instance of DevCentersClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewDevCentersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DevCentersClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &DevCentersClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a devcenter resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// body - Represents a devcenter. +// options - DevCentersClientBeginCreateOrUpdateOptions contains the optional parameters for the DevCentersClient.BeginCreateOrUpdate +// method. +func (client *DevCentersClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, body DevCenter, options *DevCentersClientBeginCreateOrUpdateOptions) (*runtime.Poller[DevCentersClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, devCenterName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DevCentersClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DevCentersClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a devcenter resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *DevCentersClient) createOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, body DevCenter, options *DevCentersClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, devCenterName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DevCentersClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, body DevCenter, options *DevCentersClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a devcenter +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - DevCentersClientBeginDeleteOptions contains the optional parameters for the DevCentersClient.BeginDelete method. +func (client *DevCentersClient) BeginDelete(ctx context.Context, resourceGroupName string, devCenterName string, options *DevCentersClientBeginDeleteOptions) (*runtime.Poller[DevCentersClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, devCenterName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DevCentersClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DevCentersClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a devcenter +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *DevCentersClient) deleteOperation(ctx context.Context, resourceGroupName string, devCenterName string, options *DevCentersClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, devCenterName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DevCentersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *DevCentersClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - DevCentersClientGetOptions contains the optional parameters for the DevCentersClient.Get method. +func (client *DevCentersClient) Get(ctx context.Context, resourceGroupName string, devCenterName string, options *DevCentersClientGetOptions) (DevCentersClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, devCenterName, options) + if err != nil { + return DevCentersClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DevCentersClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevCentersClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DevCentersClient) getCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *DevCentersClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DevCentersClient) getHandleResponse(resp *http.Response) (DevCentersClientGetResponse, error) { + result := DevCentersClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DevCenter); err != nil { + return DevCentersClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists all devcenters in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// options - DevCentersClientListByResourceGroupOptions contains the optional parameters for the DevCentersClient.ListByResourceGroup +// method. +func (client *DevCentersClient) NewListByResourceGroupPager(resourceGroupName string, options *DevCentersClientListByResourceGroupOptions) *runtime.Pager[DevCentersClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DevCentersClientListByResourceGroupResponse]{ + More: func(page DevCentersClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DevCentersClientListByResourceGroupResponse) (DevCentersClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DevCentersClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DevCentersClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevCentersClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DevCentersClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DevCentersClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DevCentersClient) listByResourceGroupHandleResponse(resp *http.Response) (DevCentersClientListByResourceGroupResponse, error) { + result := DevCentersClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil { + return DevCentersClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists all devcenters in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// options - DevCentersClientListBySubscriptionOptions contains the optional parameters for the DevCentersClient.ListBySubscription +// method. +func (client *DevCentersClient) NewListBySubscriptionPager(options *DevCentersClientListBySubscriptionOptions) *runtime.Pager[DevCentersClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[DevCentersClientListBySubscriptionResponse]{ + More: func(page DevCentersClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DevCentersClientListBySubscriptionResponse) (DevCentersClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DevCentersClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DevCentersClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DevCentersClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DevCentersClient) listBySubscriptionCreateRequest(ctx context.Context, options *DevCentersClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/devcenters" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DevCentersClient) listBySubscriptionHandleResponse(resp *http.Response) (DevCentersClientListBySubscriptionResponse, error) { + result := DevCentersClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListResult); err != nil { + return DevCentersClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Partially updates a devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// body - Updatable devcenter properties. +// options - DevCentersClientBeginUpdateOptions contains the optional parameters for the DevCentersClient.BeginUpdate method. +func (client *DevCentersClient) BeginUpdate(ctx context.Context, resourceGroupName string, devCenterName string, body Update, options *DevCentersClientBeginUpdateOptions) (*runtime.Poller[DevCentersClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, devCenterName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[DevCentersClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[DevCentersClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Partially updates a devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *DevCentersClient) update(ctx context.Context, resourceGroupName string, devCenterName string, body Update, options *DevCentersClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, devCenterName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DevCentersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, body Update, options *DevCentersClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/environmenttypes_client.go b/sdk/resourcemanager/devcenter/armdevcenter/environmenttypes_client.go new file mode 100644 index 000000000000..bbd0d3b0a9b6 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/environmenttypes_client.go @@ -0,0 +1,368 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// EnvironmentTypesClient contains the methods for the EnvironmentTypes group. +// Don't use this type directly, use NewEnvironmentTypesClient() instead. +type EnvironmentTypesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewEnvironmentTypesClient creates a new instance of EnvironmentTypesClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewEnvironmentTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EnvironmentTypesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &EnvironmentTypesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates an environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// environmentTypeName - The name of the environment type. +// body - Represents an Environment Type. +// options - EnvironmentTypesClientCreateOrUpdateOptions contains the optional parameters for the EnvironmentTypesClient.CreateOrUpdate +// method. +func (client *EnvironmentTypesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, body EnvironmentType, options *EnvironmentTypesClientCreateOrUpdateOptions) (EnvironmentTypesClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, devCenterName, environmentTypeName, body, options) + if err != nil { + return EnvironmentTypesClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EnvironmentTypesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EnvironmentTypesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EnvironmentTypesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, body EnvironmentType, options *EnvironmentTypesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EnvironmentTypesClient) createOrUpdateHandleResponse(resp *http.Response) (EnvironmentTypesClientCreateOrUpdateResponse, error) { + result := EnvironmentTypesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnvironmentType); err != nil { + return EnvironmentTypesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes an environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// environmentTypeName - The name of the environment type. +// options - EnvironmentTypesClientDeleteOptions contains the optional parameters for the EnvironmentTypesClient.Delete method. +func (client *EnvironmentTypesClient) Delete(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, options *EnvironmentTypesClientDeleteOptions) (EnvironmentTypesClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, devCenterName, environmentTypeName, options) + if err != nil { + return EnvironmentTypesClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EnvironmentTypesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return EnvironmentTypesClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return EnvironmentTypesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EnvironmentTypesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, options *EnvironmentTypesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets an environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// environmentTypeName - The name of the environment type. +// options - EnvironmentTypesClientGetOptions contains the optional parameters for the EnvironmentTypesClient.Get method. +func (client *EnvironmentTypesClient) Get(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, options *EnvironmentTypesClientGetOptions) (EnvironmentTypesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, devCenterName, environmentTypeName, options) + if err != nil { + return EnvironmentTypesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EnvironmentTypesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EnvironmentTypesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *EnvironmentTypesClient) getCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, options *EnvironmentTypesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EnvironmentTypesClient) getHandleResponse(resp *http.Response) (EnvironmentTypesClientGetResponse, error) { + result := EnvironmentTypesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnvironmentType); err != nil { + return EnvironmentTypesClientGetResponse{}, err + } + return result, nil +} + +// NewListByDevCenterPager - Lists environment types for the devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - EnvironmentTypesClientListByDevCenterOptions contains the optional parameters for the EnvironmentTypesClient.ListByDevCenter +// method. +func (client *EnvironmentTypesClient) NewListByDevCenterPager(resourceGroupName string, devCenterName string, options *EnvironmentTypesClientListByDevCenterOptions) *runtime.Pager[EnvironmentTypesClientListByDevCenterResponse] { + return runtime.NewPager(runtime.PagingHandler[EnvironmentTypesClientListByDevCenterResponse]{ + More: func(page EnvironmentTypesClientListByDevCenterResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EnvironmentTypesClientListByDevCenterResponse) (EnvironmentTypesClientListByDevCenterResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDevCenterCreateRequest(ctx, resourceGroupName, devCenterName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EnvironmentTypesClientListByDevCenterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EnvironmentTypesClientListByDevCenterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EnvironmentTypesClientListByDevCenterResponse{}, runtime.NewResponseError(resp) + } + return client.listByDevCenterHandleResponse(resp) + }, + }) +} + +// listByDevCenterCreateRequest creates the ListByDevCenter request. +func (client *EnvironmentTypesClient) listByDevCenterCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *EnvironmentTypesClientListByDevCenterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDevCenterHandleResponse handles the ListByDevCenter response. +func (client *EnvironmentTypesClient) listByDevCenterHandleResponse(resp *http.Response) (EnvironmentTypesClientListByDevCenterResponse, error) { + result := EnvironmentTypesClientListByDevCenterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnvironmentTypeListResult); err != nil { + return EnvironmentTypesClientListByDevCenterResponse{}, err + } + return result, nil +} + +// Update - Partially updates an environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// environmentTypeName - The name of the environment type. +// body - Updatable environment type properties. +// options - EnvironmentTypesClientUpdateOptions contains the optional parameters for the EnvironmentTypesClient.Update method. +func (client *EnvironmentTypesClient) Update(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, body EnvironmentTypeUpdate, options *EnvironmentTypesClientUpdateOptions) (EnvironmentTypesClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, devCenterName, environmentTypeName, body, options) + if err != nil { + return EnvironmentTypesClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EnvironmentTypesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EnvironmentTypesClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *EnvironmentTypesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, environmentTypeName string, body EnvironmentTypeUpdate, options *EnvironmentTypesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/environmentTypes/{environmentTypeName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// updateHandleResponse handles the Update response. +func (client *EnvironmentTypesClient) updateHandleResponse(resp *http.Response) (EnvironmentTypesClientUpdateResponse, error) { + result := EnvironmentTypesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EnvironmentType); err != nil { + return EnvironmentTypesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/galleries_client.go b/sdk/resourcemanager/devcenter/armdevcenter/galleries_client.go new file mode 100644 index 000000000000..6cc7bb47967b --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/galleries_client.go @@ -0,0 +1,331 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// GalleriesClient contains the methods for the Galleries group. +// Don't use this type directly, use NewGalleriesClient() instead. +type GalleriesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewGalleriesClient creates a new instance of GalleriesClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewGalleriesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*GalleriesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &GalleriesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a gallery. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// galleryName - The name of the gallery. +// body - Represents a gallery. +// options - GalleriesClientBeginCreateOrUpdateOptions contains the optional parameters for the GalleriesClient.BeginCreateOrUpdate +// method. +func (client *GalleriesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, body Gallery, options *GalleriesClientBeginCreateOrUpdateOptions) (*runtime.Poller[GalleriesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, devCenterName, galleryName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[GalleriesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[GalleriesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a gallery. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *GalleriesClient) createOrUpdate(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, body Gallery, options *GalleriesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, devCenterName, galleryName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GalleriesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, body Gallery, options *GalleriesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if galleryName == "" { + return nil, errors.New("parameter galleryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a gallery resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// galleryName - The name of the gallery. +// options - GalleriesClientBeginDeleteOptions contains the optional parameters for the GalleriesClient.BeginDelete method. +func (client *GalleriesClient) BeginDelete(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, options *GalleriesClientBeginDeleteOptions) (*runtime.Poller[GalleriesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, devCenterName, galleryName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[GalleriesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[GalleriesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a gallery resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *GalleriesClient) deleteOperation(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, options *GalleriesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, devCenterName, galleryName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GalleriesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, options *GalleriesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if galleryName == "" { + return nil, errors.New("parameter galleryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a gallery +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// galleryName - The name of the gallery. +// options - GalleriesClientGetOptions contains the optional parameters for the GalleriesClient.Get method. +func (client *GalleriesClient) Get(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, options *GalleriesClientGetOptions) (GalleriesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, devCenterName, galleryName, options) + if err != nil { + return GalleriesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GalleriesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GalleriesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GalleriesClient) getCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, options *GalleriesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if galleryName == "" { + return nil, errors.New("parameter galleryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GalleriesClient) getHandleResponse(resp *http.Response) (GalleriesClientGetResponse, error) { + result := GalleriesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Gallery); err != nil { + return GalleriesClientGetResponse{}, err + } + return result, nil +} + +// NewListByDevCenterPager - Lists galleries for a devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - GalleriesClientListByDevCenterOptions contains the optional parameters for the GalleriesClient.ListByDevCenter +// method. +func (client *GalleriesClient) NewListByDevCenterPager(resourceGroupName string, devCenterName string, options *GalleriesClientListByDevCenterOptions) *runtime.Pager[GalleriesClientListByDevCenterResponse] { + return runtime.NewPager(runtime.PagingHandler[GalleriesClientListByDevCenterResponse]{ + More: func(page GalleriesClientListByDevCenterResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *GalleriesClientListByDevCenterResponse) (GalleriesClientListByDevCenterResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDevCenterCreateRequest(ctx, resourceGroupName, devCenterName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return GalleriesClientListByDevCenterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return GalleriesClientListByDevCenterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return GalleriesClientListByDevCenterResponse{}, runtime.NewResponseError(resp) + } + return client.listByDevCenterHandleResponse(resp) + }, + }) +} + +// listByDevCenterCreateRequest creates the ListByDevCenter request. +func (client *GalleriesClient) listByDevCenterCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *GalleriesClientListByDevCenterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDevCenterHandleResponse handles the ListByDevCenter response. +func (client *GalleriesClient) listByDevCenterHandleResponse(resp *http.Response) (GalleriesClientListByDevCenterResponse, error) { + result := GalleriesClientListByDevCenterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GalleryListResult); err != nil { + return GalleriesClientListByDevCenterResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/go.mod b/sdk/resourcemanager/devcenter/armdevcenter/go.mod new file mode 100644 index 000000000000..d4b5f68c68cf --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/devcenter/armdevcenter + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/devcenter/armdevcenter/go.sum b/sdk/resourcemanager/devcenter/armdevcenter/go.sum new file mode 100644 index 000000000000..3afb578030a5 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +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.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/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/devcenter/armdevcenter/images_client.go b/sdk/resourcemanager/devcenter/armdevcenter/images_client.go new file mode 100644 index 000000000000..e167f61bd106 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/images_client.go @@ -0,0 +1,272 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ImagesClient contains the methods for the Images group. +// Don't use this type directly, use NewImagesClient() instead. +type ImagesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewImagesClient creates a new instance of ImagesClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewImagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ImagesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ImagesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Gets a gallery image. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// galleryName - The name of the gallery. +// imageName - The name of the image. +// options - ImagesClientGetOptions contains the optional parameters for the ImagesClient.Get method. +func (client *ImagesClient) Get(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, imageName string, options *ImagesClientGetOptions) (ImagesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, devCenterName, galleryName, imageName, options) + if err != nil { + return ImagesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImagesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ImagesClient) getCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, imageName string, options *ImagesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images/{imageName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if galleryName == "" { + return nil, errors.New("parameter galleryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ImagesClient) getHandleResponse(resp *http.Response) (ImagesClientGetResponse, error) { + result := ImagesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Image); err != nil { + return ImagesClientGetResponse{}, err + } + return result, nil +} + +// NewListByDevCenterPager - Lists images for a devcenter. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// options - ImagesClientListByDevCenterOptions contains the optional parameters for the ImagesClient.ListByDevCenter method. +func (client *ImagesClient) NewListByDevCenterPager(resourceGroupName string, devCenterName string, options *ImagesClientListByDevCenterOptions) *runtime.Pager[ImagesClientListByDevCenterResponse] { + return runtime.NewPager(runtime.PagingHandler[ImagesClientListByDevCenterResponse]{ + More: func(page ImagesClientListByDevCenterResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ImagesClientListByDevCenterResponse) (ImagesClientListByDevCenterResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByDevCenterCreateRequest(ctx, resourceGroupName, devCenterName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ImagesClientListByDevCenterResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImagesClientListByDevCenterResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesClientListByDevCenterResponse{}, runtime.NewResponseError(resp) + } + return client.listByDevCenterHandleResponse(resp) + }, + }) +} + +// listByDevCenterCreateRequest creates the ListByDevCenter request. +func (client *ImagesClient) listByDevCenterCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, options *ImagesClientListByDevCenterOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/images" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDevCenterHandleResponse handles the ListByDevCenter response. +func (client *ImagesClient) listByDevCenterHandleResponse(resp *http.Response) (ImagesClientListByDevCenterResponse, error) { + result := ImagesClientListByDevCenterResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ImageListResult); err != nil { + return ImagesClientListByDevCenterResponse{}, err + } + return result, nil +} + +// NewListByGalleryPager - Lists images for a gallery. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// galleryName - The name of the gallery. +// options - ImagesClientListByGalleryOptions contains the optional parameters for the ImagesClient.ListByGallery method. +func (client *ImagesClient) NewListByGalleryPager(resourceGroupName string, devCenterName string, galleryName string, options *ImagesClientListByGalleryOptions) *runtime.Pager[ImagesClientListByGalleryResponse] { + return runtime.NewPager(runtime.PagingHandler[ImagesClientListByGalleryResponse]{ + More: func(page ImagesClientListByGalleryResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ImagesClientListByGalleryResponse) (ImagesClientListByGalleryResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByGalleryCreateRequest(ctx, resourceGroupName, devCenterName, galleryName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ImagesClientListByGalleryResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImagesClientListByGalleryResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImagesClientListByGalleryResponse{}, runtime.NewResponseError(resp) + } + return client.listByGalleryHandleResponse(resp) + }, + }) +} + +// listByGalleryCreateRequest creates the ListByGallery request. +func (client *ImagesClient) listByGalleryCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, options *ImagesClientListByGalleryOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if galleryName == "" { + return nil, errors.New("parameter galleryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByGalleryHandleResponse handles the ListByGallery response. +func (client *ImagesClient) listByGalleryHandleResponse(resp *http.Response) (ImagesClientListByGalleryResponse, error) { + result := ImagesClientListByGalleryResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ImageListResult); err != nil { + return ImagesClientListByGalleryResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/imageversions_client.go b/sdk/resourcemanager/devcenter/armdevcenter/imageversions_client.go new file mode 100644 index 000000000000..86f528ed832a --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/imageversions_client.go @@ -0,0 +1,207 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ImageVersionsClient contains the methods for the ImageVersions group. +// Don't use this type directly, use NewImageVersionsClient() instead. +type ImageVersionsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewImageVersionsClient creates a new instance of ImageVersionsClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewImageVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ImageVersionsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ImageVersionsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Gets an image version. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// galleryName - The name of the gallery. +// imageName - The name of the image. +// versionName - The version of the image. +// options - ImageVersionsClientGetOptions contains the optional parameters for the ImageVersionsClient.Get method. +func (client *ImageVersionsClient) Get(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, imageName string, versionName string, options *ImageVersionsClientGetOptions) (ImageVersionsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, devCenterName, galleryName, imageName, versionName, options) + if err != nil { + return ImageVersionsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImageVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImageVersionsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ImageVersionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, imageName string, versionName string, options *ImageVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images/{imageName}/versions/{versionName}" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if galleryName == "" { + return nil, errors.New("parameter galleryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + if versionName == "" { + return nil, errors.New("parameter versionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionName}", url.PathEscape(versionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ImageVersionsClient) getHandleResponse(resp *http.Response) (ImageVersionsClientGetResponse, error) { + result := ImageVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ImageVersion); err != nil { + return ImageVersionsClientGetResponse{}, err + } + return result, nil +} + +// NewListByImagePager - Lists versions for an image. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// devCenterName - The name of the devcenter. +// galleryName - The name of the gallery. +// imageName - The name of the image. +// options - ImageVersionsClientListByImageOptions contains the optional parameters for the ImageVersionsClient.ListByImage +// method. +func (client *ImageVersionsClient) NewListByImagePager(resourceGroupName string, devCenterName string, galleryName string, imageName string, options *ImageVersionsClientListByImageOptions) *runtime.Pager[ImageVersionsClientListByImageResponse] { + return runtime.NewPager(runtime.PagingHandler[ImageVersionsClientListByImageResponse]{ + More: func(page ImageVersionsClientListByImageResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ImageVersionsClientListByImageResponse) (ImageVersionsClientListByImageResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByImageCreateRequest(ctx, resourceGroupName, devCenterName, galleryName, imageName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ImageVersionsClientListByImageResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ImageVersionsClientListByImageResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ImageVersionsClientListByImageResponse{}, runtime.NewResponseError(resp) + } + return client.listByImageHandleResponse(resp) + }, + }) +} + +// listByImageCreateRequest creates the ListByImage request. +func (client *ImageVersionsClient) listByImageCreateRequest(ctx context.Context, resourceGroupName string, devCenterName string, galleryName string, imageName string, options *ImageVersionsClientListByImageOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/devcenters/{devCenterName}/galleries/{galleryName}/images/{imageName}/versions" + 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 devCenterName == "" { + return nil, errors.New("parameter devCenterName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{devCenterName}", url.PathEscape(devCenterName)) + if galleryName == "" { + return nil, errors.New("parameter galleryName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{galleryName}", url.PathEscape(galleryName)) + if imageName == "" { + return nil, errors.New("parameter imageName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{imageName}", url.PathEscape(imageName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByImageHandleResponse handles the ListByImage response. +func (client *ImageVersionsClient) listByImageHandleResponse(resp *http.Response) (ImageVersionsClientListByImageResponse, error) { + result := ImageVersionsClientListByImageResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ImageVersionListResult); err != nil { + return ImageVersionsClientListByImageResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/models.go b/sdk/resourcemanager/devcenter/armdevcenter/models.go new file mode 100644 index 000000000000..8be72bac5bb3 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/models.go @@ -0,0 +1,1745 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import "time" + +// AttachedNetworkConnection - Represents an attached NetworkConnection. +type AttachedNetworkConnection struct { + // Attached NetworkConnection properties. + Properties *AttachedNetworkConnectionProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// AttachedNetworkConnectionProperties - Properties of an attached NetworkConnection. +type AttachedNetworkConnectionProperties struct { + // REQUIRED; The resource ID of the NetworkConnection you want to attach. + NetworkConnectionID *string `json:"networkConnectionId,omitempty"` + + // READ-ONLY; AAD Join type of the network. This is populated based on the referenced Network Connection. + DomainJoinType *DomainJoinType `json:"domainJoinType,omitempty" azure:"ro"` + + // READ-ONLY; Health check status values + HealthCheckStatus *HealthCheckStatus `json:"healthCheckStatus,omitempty" azure:"ro"` + + // READ-ONLY; The geo-location where the NetworkConnection resource specified in 'networkConnectionResourceId' property lives. + NetworkConnectionLocation *string `json:"networkConnectionLocation,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// AttachedNetworkListResult - Results of the Attached Networks list operation. +type AttachedNetworkListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*AttachedNetworkConnection `json:"value,omitempty" azure:"ro"` +} + +// AttachedNetworksClientBeginCreateOrUpdateOptions contains the optional parameters for the AttachedNetworksClient.BeginCreateOrUpdate +// method. +type AttachedNetworksClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AttachedNetworksClientBeginDeleteOptions contains the optional parameters for the AttachedNetworksClient.BeginDelete method. +type AttachedNetworksClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AttachedNetworksClientGetByDevCenterOptions contains the optional parameters for the AttachedNetworksClient.GetByDevCenter +// method. +type AttachedNetworksClientGetByDevCenterOptions struct { + // placeholder for future optional parameters +} + +// AttachedNetworksClientGetByProjectOptions contains the optional parameters for the AttachedNetworksClient.GetByProject +// method. +type AttachedNetworksClientGetByProjectOptions struct { + // placeholder for future optional parameters +} + +// AttachedNetworksClientListByDevCenterOptions contains the optional parameters for the AttachedNetworksClient.ListByDevCenter +// method. +type AttachedNetworksClientListByDevCenterOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// AttachedNetworksClientListByProjectOptions contains the optional parameters for the AttachedNetworksClient.ListByProject +// method. +type AttachedNetworksClientListByProjectOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// Capability - A name/value pair to describe a capability. +type Capability struct { + // READ-ONLY; Name of the capability. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Value of the capability. + Value *string `json:"value,omitempty" azure:"ro"` +} + +// Catalog - Represents a catalog. +type Catalog struct { + // Catalog properties. + Properties *CatalogProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// CatalogListResult - Results of the catalog list operation. +type CatalogListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*Catalog `json:"value,omitempty" azure:"ro"` +} + +// CatalogProperties - Properties of a catalog. +type CatalogProperties struct { + // Properties for an Azure DevOps catalog type. + AdoGit *GitCatalog `json:"adoGit,omitempty"` + + // Properties for a GitHub catalog type. + GitHub *GitCatalog `json:"gitHub,omitempty"` + + // READ-ONLY; When the catalog was last synced. + LastSyncTime *time.Time `json:"lastSyncTime,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// CatalogUpdate - The catalog's properties for partial update. Properties not provided in the update request will not be +// changed. +type CatalogUpdate struct { + // Catalog properties for update. + Properties *CatalogUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// CatalogUpdateProperties - Properties of a catalog. These properties can be updated after the resource has been created. +type CatalogUpdateProperties struct { + // Properties for an Azure DevOps catalog type. + AdoGit *GitCatalog `json:"adoGit,omitempty"` + + // Properties for a GitHub catalog type. + GitHub *GitCatalog `json:"gitHub,omitempty"` +} + +// CatalogsClientBeginCreateOrUpdateOptions contains the optional parameters for the CatalogsClient.BeginCreateOrUpdate method. +type CatalogsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CatalogsClientBeginDeleteOptions contains the optional parameters for the CatalogsClient.BeginDelete method. +type CatalogsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CatalogsClientBeginSyncOptions contains the optional parameters for the CatalogsClient.BeginSync method. +type CatalogsClientBeginSyncOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CatalogsClientBeginUpdateOptions contains the optional parameters for the CatalogsClient.BeginUpdate method. +type CatalogsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CatalogsClientGetOptions contains the optional parameters for the CatalogsClient.Get method. +type CatalogsClientGetOptions struct { + // placeholder for future optional parameters +} + +// CatalogsClientListByDevCenterOptions contains the optional parameters for the CatalogsClient.ListByDevCenter method. +type CatalogsClientListByDevCenterOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// CloudError - An error response from the DevCenter service. +type CloudError struct { + // REQUIRED; Error body + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody - An error response from the DevCenter service. +type CloudErrorBody struct { + // REQUIRED; An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + + // REQUIRED; A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + + // A list of additional details about the error. + Details []*CloudErrorBody `json:"details,omitempty"` + + // The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// DevBoxDefinition - Represents a definition for a Developer Machine. +type DevBoxDefinition struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Dev Box definition properties + Properties *DevBoxDefinitionProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// DevBoxDefinitionListResult - Results of the Dev Box definition list operation. +type DevBoxDefinitionListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*DevBoxDefinition `json:"value,omitempty" azure:"ro"` +} + +// DevBoxDefinitionProperties - Properties of a Dev Box definition. +type DevBoxDefinitionProperties struct { + // Image reference information. + ImageReference *ImageReference `json:"imageReference,omitempty"` + + // The storage type used for the Operating System disk of Dev Boxes created using this definition. + OSStorageType *string `json:"osStorageType,omitempty"` + + // The SKU for Dev Boxes created using this definition. + SKU *SKU `json:"sku,omitempty"` + + // READ-ONLY; Image reference information for the currently active image (only populated during updates). + ActiveImageReference *ImageReference `json:"activeImageReference,omitempty" azure:"ro"` + + // READ-ONLY; Details for image validator error. Populated when the image validation is not successful. + ImageValidationErrorDetails *ImageValidationErrorDetails `json:"imageValidationErrorDetails,omitempty" azure:"ro"` + + // READ-ONLY; Validation status of the configured image. + ImageValidationStatus *ImageValidationStatus `json:"imageValidationStatus,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// DevBoxDefinitionUpdate - Partial update of a Dev Box definition resource. +type DevBoxDefinitionUpdate struct { + // The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a Dev Box definition to be updated. + Properties *DevBoxDefinitionUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// DevBoxDefinitionUpdateProperties - Properties of a Dev Box definition. These properties can be updated after the resource +// has been created. +type DevBoxDefinitionUpdateProperties struct { + // Image reference information. + ImageReference *ImageReference `json:"imageReference,omitempty"` + + // The storage type used for the Operating System disk of Dev Boxes created using this definition. + OSStorageType *string `json:"osStorageType,omitempty"` + + // The SKU for Dev Boxes created using this definition. + SKU *SKU `json:"sku,omitempty"` +} + +// DevBoxDefinitionsClientBeginCreateOrUpdateOptions contains the optional parameters for the DevBoxDefinitionsClient.BeginCreateOrUpdate +// method. +type DevBoxDefinitionsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevBoxDefinitionsClientBeginDeleteOptions contains the optional parameters for the DevBoxDefinitionsClient.BeginDelete +// method. +type DevBoxDefinitionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevBoxDefinitionsClientBeginUpdateOptions contains the optional parameters for the DevBoxDefinitionsClient.BeginUpdate +// method. +type DevBoxDefinitionsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevBoxDefinitionsClientGetByProjectOptions contains the optional parameters for the DevBoxDefinitionsClient.GetByProject +// method. +type DevBoxDefinitionsClientGetByProjectOptions struct { + // placeholder for future optional parameters +} + +// DevBoxDefinitionsClientGetOptions contains the optional parameters for the DevBoxDefinitionsClient.Get method. +type DevBoxDefinitionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DevBoxDefinitionsClientListByDevCenterOptions contains the optional parameters for the DevBoxDefinitionsClient.ListByDevCenter +// method. +type DevBoxDefinitionsClientListByDevCenterOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// DevBoxDefinitionsClientListByProjectOptions contains the optional parameters for the DevBoxDefinitionsClient.ListByProject +// method. +type DevBoxDefinitionsClientListByProjectOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// DevCenter - Represents a devcenter resource. +type DevCenter struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Managed identity properties + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // DevCenter properties + Properties *Properties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// DevCentersClientBeginCreateOrUpdateOptions contains the optional parameters for the DevCentersClient.BeginCreateOrUpdate +// method. +type DevCentersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevCentersClientBeginDeleteOptions contains the optional parameters for the DevCentersClient.BeginDelete method. +type DevCentersClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevCentersClientBeginUpdateOptions contains the optional parameters for the DevCentersClient.BeginUpdate method. +type DevCentersClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DevCentersClientGetOptions contains the optional parameters for the DevCentersClient.Get method. +type DevCentersClientGetOptions struct { + // placeholder for future optional parameters +} + +// DevCentersClientListByResourceGroupOptions contains the optional parameters for the DevCentersClient.ListByResourceGroup +// method. +type DevCentersClientListByResourceGroupOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// DevCentersClientListBySubscriptionOptions contains the optional parameters for the DevCentersClient.ListBySubscription +// method. +type DevCentersClientListBySubscriptionOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// EnvironmentRole - A role that can be assigned to a user. +type EnvironmentRole struct { + // READ-ONLY; This is a description of the Role Assignment. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The common name of the Role Assignment. This is a descriptive name such as 'AcrPush'. + RoleName *string `json:"roleName,omitempty" azure:"ro"` +} + +// EnvironmentType - Represents an environment type. +type EnvironmentType struct { + // Properties of an environment type. + Properties *EnvironmentTypeProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// EnvironmentTypeListResult - Result of the environment type list operation. +type EnvironmentTypeListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*EnvironmentType `json:"value,omitempty" azure:"ro"` +} + +// EnvironmentTypeProperties - Properties of an environment type. +type EnvironmentTypeProperties struct { + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// EnvironmentTypeUpdate - The environment type for partial update. Properties not provided in the update request will not +// be changed. +type EnvironmentTypeUpdate struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// EnvironmentTypesClientCreateOrUpdateOptions contains the optional parameters for the EnvironmentTypesClient.CreateOrUpdate +// method. +type EnvironmentTypesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentTypesClientDeleteOptions contains the optional parameters for the EnvironmentTypesClient.Delete method. +type EnvironmentTypesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentTypesClientGetOptions contains the optional parameters for the EnvironmentTypesClient.Get method. +type EnvironmentTypesClientGetOptions struct { + // placeholder for future optional parameters +} + +// EnvironmentTypesClientListByDevCenterOptions contains the optional parameters for the EnvironmentTypesClient.ListByDevCenter +// method. +type EnvironmentTypesClientListByDevCenterOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// EnvironmentTypesClientUpdateOptions contains the optional parameters for the EnvironmentTypesClient.Update method. +type EnvironmentTypesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// GalleriesClientBeginCreateOrUpdateOptions contains the optional parameters for the GalleriesClient.BeginCreateOrUpdate +// method. +type GalleriesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GalleriesClientBeginDeleteOptions contains the optional parameters for the GalleriesClient.BeginDelete method. +type GalleriesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GalleriesClientGetOptions contains the optional parameters for the GalleriesClient.Get method. +type GalleriesClientGetOptions struct { + // placeholder for future optional parameters +} + +// GalleriesClientListByDevCenterOptions contains the optional parameters for the GalleriesClient.ListByDevCenter method. +type GalleriesClientListByDevCenterOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// Gallery - Represents a gallery. +type Gallery struct { + // Gallery properties. + Properties *GalleryProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// GalleryListResult - Results of the gallery list operation. +type GalleryListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*Gallery `json:"value,omitempty" azure:"ro"` +} + +// GalleryProperties - Properties of a gallery. +type GalleryProperties struct { + // REQUIRED; The resource ID of the backing Azure Compute Gallery. + GalleryResourceID *string `json:"galleryResourceId,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// GitCatalog - Properties for a Git repository catalog. +type GitCatalog struct { + // Git branch. + Branch *string `json:"branch,omitempty"` + + // The folder where the catalog items can be found inside the repository. + Path *string `json:"path,omitempty"` + + // A reference to the Key Vault secret containing a security token to authenticate to a Git repository. + SecretIdentifier *string `json:"secretIdentifier,omitempty"` + + // Git URI. + URI *string `json:"uri,omitempty"` +} + +// HealthCheck - An individual health check item +type HealthCheck struct { + // READ-ONLY; Additional details about the health check or the recommended action. + AdditionalDetails *string `json:"additionalDetails,omitempty" azure:"ro"` + + // READ-ONLY; The display name of this health check item. + DisplayName *string `json:"displayName,omitempty" azure:"ro"` + + // READ-ONLY; End time of the health check item. + EndDateTime *time.Time `json:"endDateTime,omitempty" azure:"ro"` + + // READ-ONLY; The type of error that occurred during this health check. + ErrorType *string `json:"errorType,omitempty" azure:"ro"` + + // READ-ONLY; The recommended action to fix the corresponding error. + RecommendedAction *string `json:"recommendedAction,omitempty" azure:"ro"` + + // READ-ONLY; Start time of health check item. + StartDateTime *time.Time `json:"startDateTime,omitempty" azure:"ro"` + + // READ-ONLY; The status of the health check item. + Status *HealthCheckStatus `json:"status,omitempty" azure:"ro"` +} + +// HealthCheckStatusDetails - Health Check details. +type HealthCheckStatusDetails struct { + // Health check status details properties. + Properties *HealthCheckStatusDetailsProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// HealthCheckStatusDetailsListResult - Result of the network health check list operation. +type HealthCheckStatusDetailsListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*HealthCheckStatusDetails `json:"value,omitempty" azure:"ro"` +} + +// HealthCheckStatusDetailsProperties - Health Check properties. +type HealthCheckStatusDetailsProperties struct { + // READ-ONLY; End time of last execution of the health checks. + EndDateTime *time.Time `json:"endDateTime,omitempty" azure:"ro"` + + // READ-ONLY; Details for each health check item. + HealthChecks []*HealthCheck `json:"healthChecks,omitempty" azure:"ro"` + + // READ-ONLY; Start time of last execution of the health checks. + StartDateTime *time.Time `json:"startDateTime,omitempty" azure:"ro"` +} + +// Image - Represents an image. +type Image struct { + // Image properties. + Properties *ImageProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ImageListResult - Results of the image list operation. +type ImageListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*Image `json:"value,omitempty" azure:"ro"` +} + +// ImageProperties - Properties of an image. +type ImageProperties struct { + // READ-ONLY; The description of the image. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The name of the image offer. + Offer *string `json:"offer,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The publisher of the image. + Publisher *string `json:"publisher,omitempty" azure:"ro"` + + // READ-ONLY; The recommended machine configuration to use with the image. + RecommendedMachineConfiguration *RecommendedMachineConfiguration `json:"recommendedMachineConfiguration,omitempty" azure:"ro"` + + // READ-ONLY; The SKU name for the image. + SKU *string `json:"sku,omitempty" azure:"ro"` +} + +// ImageReference - Image reference information +type ImageReference struct { + // Image ID, or Image version ID. When Image ID is provided, its latest version will be used. + ID *string `json:"id,omitempty"` + + // The image offer. + Offer *string `json:"offer,omitempty"` + + // The image publisher. + Publisher *string `json:"publisher,omitempty"` + + // The image sku. + SKU *string `json:"sku,omitempty"` + + // READ-ONLY; The actual version of the image after use. When id references a gallery image latest version, this will indicate + // the actual version in use. + ExactVersion *string `json:"exactVersion,omitempty" azure:"ro"` +} + +// ImageValidationErrorDetails - Image validation error details +type ImageValidationErrorDetails struct { + // An identifier for the error. + Code *string `json:"code,omitempty"` + + // A message describing the error. + Message *string `json:"message,omitempty"` +} + +// ImageVersion - Represents an image version. +type ImageVersion struct { + // Image version properties. + Properties *ImageVersionProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ImageVersionListResult - Results of the image version list operation. +type ImageVersionListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*ImageVersion `json:"value,omitempty" azure:"ro"` +} + +// ImageVersionProperties - Properties of an image version. +type ImageVersionProperties struct { + // READ-ONLY; If the version should be excluded from being treated as the latest version. + ExcludeFromLatest *bool `json:"excludeFromLatest,omitempty" azure:"ro"` + + // READ-ONLY; The semantic version string. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The size of the OS disk image, in GB. + OSDiskImageSizeInGb *int32 `json:"osDiskImageSizeInGb,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The datetime that the backing image version was published. + PublishedDate *time.Time `json:"publishedDate,omitempty" azure:"ro"` +} + +// ImageVersionsClientGetOptions contains the optional parameters for the ImageVersionsClient.Get method. +type ImageVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ImageVersionsClientListByImageOptions contains the optional parameters for the ImageVersionsClient.ListByImage method. +type ImageVersionsClientListByImageOptions struct { + // placeholder for future optional parameters +} + +// ImagesClientGetOptions contains the optional parameters for the ImagesClient.Get method. +type ImagesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ImagesClientListByDevCenterOptions contains the optional parameters for the ImagesClient.ListByDevCenter method. +type ImagesClientListByDevCenterOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// ImagesClientListByGalleryOptions contains the optional parameters for the ImagesClient.ListByGallery method. +type ImagesClientListByGalleryOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// ListResult - Result of the list devcenters operation +type ListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*DevCenter `json:"value,omitempty" azure:"ro"` +} + +// ListUsagesResult - List of Core Usages. +type ListUsagesResult struct { + // READ-ONLY; The link to get the next page of Usage result. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The array page of Usages. + Value []*Usage `json:"value,omitempty" azure:"ro"` +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType `json:"type,omitempty"` + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// NetworkConnection - Network related settings +type NetworkConnection struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a Network Connection + Properties *NetworkProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// NetworkConnectionListResult - Result of the network connection list operation. +type NetworkConnectionListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*NetworkConnection `json:"value,omitempty" azure:"ro"` +} + +// NetworkConnectionUpdate - The network connection properties for partial update. Properties not provided in the update request +// will not be changed. +type NetworkConnectionUpdate struct { + // The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a network connection resource to be updated. + Properties *NetworkConnectionUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// NetworkConnectionUpdateProperties - Properties of network connection. These properties can be updated after the resource +// has been created. +type NetworkConnectionUpdateProperties struct { + // Active Directory domain name + DomainName *string `json:"domainName,omitempty"` + + // The password for the account used to join domain + DomainPassword *string `json:"domainPassword,omitempty"` + + // The username of an Active Directory account (user or service account) that has permissions to create computer objects in + // Active Directory. Required format: admin@contoso.com. + DomainUsername *string `json:"domainUsername,omitempty"` + + // Active Directory domain Organization Unit (OU) + OrganizationUnit *string `json:"organizationUnit,omitempty"` + + // The subnet to attach Virtual Machines to + SubnetID *string `json:"subnetId,omitempty"` +} + +// NetworkConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the NetworkConnectionsClient.BeginCreateOrUpdate +// method. +type NetworkConnectionsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// NetworkConnectionsClientBeginDeleteOptions contains the optional parameters for the NetworkConnectionsClient.BeginDelete +// method. +type NetworkConnectionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// NetworkConnectionsClientBeginUpdateOptions contains the optional parameters for the NetworkConnectionsClient.BeginUpdate +// method. +type NetworkConnectionsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// NetworkConnectionsClientGetHealthDetailsOptions contains the optional parameters for the NetworkConnectionsClient.GetHealthDetails +// method. +type NetworkConnectionsClientGetHealthDetailsOptions struct { + // placeholder for future optional parameters +} + +// NetworkConnectionsClientGetOptions contains the optional parameters for the NetworkConnectionsClient.Get method. +type NetworkConnectionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// NetworkConnectionsClientListByResourceGroupOptions contains the optional parameters for the NetworkConnectionsClient.ListByResourceGroup +// method. +type NetworkConnectionsClientListByResourceGroupOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// NetworkConnectionsClientListBySubscriptionOptions contains the optional parameters for the NetworkConnectionsClient.ListBySubscription +// method. +type NetworkConnectionsClientListBySubscriptionOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// NetworkConnectionsClientListHealthDetailsOptions contains the optional parameters for the NetworkConnectionsClient.ListHealthDetails +// method. +type NetworkConnectionsClientListHealthDetailsOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// NetworkConnectionsClientRunHealthChecksOptions contains the optional parameters for the NetworkConnectionsClient.RunHealthChecks +// method. +type NetworkConnectionsClientRunHealthChecksOptions struct { + // placeholder for future optional parameters +} + +// NetworkProperties - Network properties +type NetworkProperties struct { + // REQUIRED; AAD Join type. + DomainJoinType *DomainJoinType `json:"domainJoinType,omitempty"` + + // Active Directory domain name + DomainName *string `json:"domainName,omitempty"` + + // The password for the account used to join domain + DomainPassword *string `json:"domainPassword,omitempty"` + + // The username of an Active Directory account (user or service account) that has permissions to create computer objects in + // Active Directory. Required format: admin@contoso.com. + DomainUsername *string `json:"domainUsername,omitempty"` + + // The name for resource group where NICs will be placed. + NetworkingResourceGroupName *string `json:"networkingResourceGroupName,omitempty"` + + // Active Directory domain Organization Unit (OU) + OrganizationUnit *string `json:"organizationUnit,omitempty"` + + // The subnet to attach Virtual Machines to + SubnetID *string `json:"subnetId,omitempty"` + + // READ-ONLY; Overall health status of the network connection. Health checks are run on creation, update, and periodically + // to validate the network connection. + HealthCheckStatus *HealthCheckStatus `json:"healthCheckStatus,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// OperationStatus - The current status of an async operation +type OperationStatus struct { + // Operation Error message + Error *OperationStatusError `json:"error,omitempty"` + + // READ-ONLY; The end time of the operation + EndTime *time.Time `json:"endTime,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified ID for the operation status. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The operation id name + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Percent of the operation that is complete + PercentComplete *float32 `json:"percentComplete,omitempty" azure:"ro"` + + // READ-ONLY; Custom operation properties, populated only for a successful operation. + Properties interface{} `json:"properties,omitempty" azure:"ro"` + + // READ-ONLY; The start time of the operation + StartTime *time.Time `json:"startTime,omitempty" azure:"ro"` + + // READ-ONLY; Provisioning state of the resource. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// OperationStatusError - Operation Error message +type OperationStatusError struct { + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` +} + +// OperationStatusesClientGetOptions contains the optional parameters for the OperationStatusesClient.Get method. +type OperationStatusesClientGetOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// Pool - A pool of Virtual Machines. +type Pool struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Pool properties + Properties *PoolProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// PoolListResult - Results of the machine pool list operation. +type PoolListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*Pool `json:"value,omitempty" azure:"ro"` +} + +// PoolProperties - Properties of a Pool +type PoolProperties struct { + // Name of a Dev Box definition in parent Project of this Pool + DevBoxDefinitionName *string `json:"devBoxDefinitionName,omitempty"` + + // Specifies the license type indicating the caller has already acquired licenses for the Dev Boxes that will be created. + LicenseType *LicenseType `json:"licenseType,omitempty"` + + // Indicates whether owners of Dev Boxes in this pool are added as local administrators on the Dev Box. + LocalAdministrator *LocalAdminStatus `json:"localAdministrator,omitempty"` + + // Name of a Network Connection in parent Project of this Pool + NetworkConnectionName *string `json:"networkConnectionName,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// PoolUpdate - The pool properties for partial update. Properties not provided in the update request will not be changed. +type PoolUpdate struct { + // The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a pool to be updated. + Properties *PoolUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// PoolUpdateProperties - Properties of a Pool. These properties can be updated after the resource has been created. +type PoolUpdateProperties struct { + // Name of a Dev Box definition in parent Project of this Pool + DevBoxDefinitionName *string `json:"devBoxDefinitionName,omitempty"` + + // Specifies the license type indicating the caller has already acquired licenses for the Dev Boxes that will be created. + LicenseType *LicenseType `json:"licenseType,omitempty"` + + // Indicates whether owners of Dev Boxes in this pool are added as local administrators on the Dev Box. + LocalAdministrator *LocalAdminStatus `json:"localAdministrator,omitempty"` + + // Name of a Network Connection in parent Project of this Pool + NetworkConnectionName *string `json:"networkConnectionName,omitempty"` +} + +// PoolsClientBeginCreateOrUpdateOptions contains the optional parameters for the PoolsClient.BeginCreateOrUpdate method. +type PoolsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientBeginDeleteOptions contains the optional parameters for the PoolsClient.BeginDelete method. +type PoolsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientBeginUpdateOptions contains the optional parameters for the PoolsClient.BeginUpdate method. +type PoolsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PoolsClientGetOptions contains the optional parameters for the PoolsClient.Get method. +type PoolsClientGetOptions struct { + // placeholder for future optional parameters +} + +// PoolsClientListByProjectOptions contains the optional parameters for the PoolsClient.ListByProject method. +type PoolsClientListByProjectOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// Project - Represents a project resource. +type Project struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a project. + Properties *ProjectProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ProjectEnvironmentType - Represents an environment type. +type ProjectEnvironmentType struct { + // Managed identity properties + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // The geo-location for the environment type + Location *string `json:"location,omitempty"` + + // Properties of an environment type. + Properties *ProjectEnvironmentTypeProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ProjectEnvironmentTypeListResult - Result of the project environment type list operation. +type ProjectEnvironmentTypeListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*ProjectEnvironmentType `json:"value,omitempty" azure:"ro"` +} + +// ProjectEnvironmentTypeProperties - Properties of a project environment type. +type ProjectEnvironmentTypeProperties struct { + // The role definition assigned to the environment creator on backing resources. + CreatorRoleAssignment *ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment `json:"creatorRoleAssignment,omitempty"` + + // Id of a subscription that the environment type will be mapped to. The environment's resources will be deployed into this + // subscription. + DeploymentTargetID *string `json:"deploymentTargetId,omitempty"` + + // Defines whether this Environment Type can be used in this Project. + Status *EnableStatus `json:"status,omitempty"` + + // Role Assignments created on environment backing resources. This is a mapping from a user object ID to an object of role + // definition IDs. + UserRoleAssignments map[string]*UserRoleAssignmentValue `json:"userRoleAssignments,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// ProjectEnvironmentTypeUpdate - The project environment type for partial update. Properties not provided in the update request +// will not be changed. +type ProjectEnvironmentTypeUpdate struct { + // Managed identity properties + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // Properties to configure an environment type. + Properties *ProjectEnvironmentTypeUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// ProjectEnvironmentTypeUpdateProperties - Properties of a project environment type. These properties can be updated after +// the resource has been created. +type ProjectEnvironmentTypeUpdateProperties struct { + // The role definition assigned to the environment creator on backing resources. + CreatorRoleAssignment *ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment `json:"creatorRoleAssignment,omitempty"` + + // Id of a subscription that the environment type will be mapped to. The environment's resources will be deployed into this + // subscription. + DeploymentTargetID *string `json:"deploymentTargetId,omitempty"` + + // Defines whether this Environment Type can be used in this Project. + Status *EnableStatus `json:"status,omitempty"` + + // Role Assignments created on environment backing resources. This is a mapping from a user object ID to an object of role + // definition IDs. + UserRoleAssignments map[string]*UserRoleAssignmentValue `json:"userRoleAssignments,omitempty"` +} + +// ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment - The role definition assigned to the environment creator on +// backing resources. +type ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment struct { + // A map of roles to assign to the environment creator. + Roles map[string]*EnvironmentRole `json:"roles,omitempty"` +} + +// ProjectEnvironmentTypesClientCreateOrUpdateOptions contains the optional parameters for the ProjectEnvironmentTypesClient.CreateOrUpdate +// method. +type ProjectEnvironmentTypesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProjectEnvironmentTypesClientDeleteOptions contains the optional parameters for the ProjectEnvironmentTypesClient.Delete +// method. +type ProjectEnvironmentTypesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProjectEnvironmentTypesClientGetOptions contains the optional parameters for the ProjectEnvironmentTypesClient.Get method. +type ProjectEnvironmentTypesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProjectEnvironmentTypesClientListOptions contains the optional parameters for the ProjectEnvironmentTypesClient.List method. +type ProjectEnvironmentTypesClientListOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// ProjectEnvironmentTypesClientUpdateOptions contains the optional parameters for the ProjectEnvironmentTypesClient.Update +// method. +type ProjectEnvironmentTypesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProjectListResult - Results of the project list operation. +type ProjectListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*Project `json:"value,omitempty" azure:"ro"` +} + +// ProjectProperties - Properties of a project. +type ProjectProperties struct { + // Description of the project. + Description *string `json:"description,omitempty"` + + // Resource Id of an associated DevCenter + DevCenterID *string `json:"devCenterId,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// ProjectUpdate - The project properties for partial update. Properties not provided in the update request will not be changed. +type ProjectUpdate struct { + // The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a project to be updated. + Properties *ProjectUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// ProjectUpdateProperties - Properties of a project. These properties can be updated after the resource has been created. +type ProjectUpdateProperties struct { + // Description of the project. + Description *string `json:"description,omitempty"` + + // Resource Id of an associated DevCenter + DevCenterID *string `json:"devCenterId,omitempty"` +} + +// ProjectsClientBeginCreateOrUpdateOptions contains the optional parameters for the ProjectsClient.BeginCreateOrUpdate method. +type ProjectsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProjectsClientBeginDeleteOptions contains the optional parameters for the ProjectsClient.BeginDelete method. +type ProjectsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProjectsClientBeginUpdateOptions contains the optional parameters for the ProjectsClient.BeginUpdate method. +type ProjectsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. +type ProjectsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProjectsClientListByResourceGroupOptions contains the optional parameters for the ProjectsClient.ListByResourceGroup method. +type ProjectsClientListByResourceGroupOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// ProjectsClientListBySubscriptionOptions contains the optional parameters for the ProjectsClient.ListBySubscription method. +type ProjectsClientListBySubscriptionOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// Properties of the devcenter. +type Properties struct { + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// RecommendedMachineConfiguration - Properties for a recommended machine configuration. +type RecommendedMachineConfiguration struct { + // READ-ONLY; Recommended memory range. + Memory *ResourceRange `json:"memory,omitempty" azure:"ro"` + + // READ-ONLY; Recommended vCPU range. + VCPUs *ResourceRange `json:"vCPUs,omitempty" azure:"ro"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ResourceRange - Properties for a range of values. +type ResourceRange struct { + // READ-ONLY; Maximum value. + Max *int32 `json:"max,omitempty" azure:"ro"` + + // READ-ONLY; Minimum value. + Min *int32 `json:"min,omitempty" azure:"ro"` +} + +// SKU - The resource model definition representing SKU +type SKU struct { + // REQUIRED; The name of the SKU. Ex - P3. It is typically a letter+number code + Name *string `json:"name,omitempty"` + + // If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the + // resource this may be omitted. + Capacity *int32 `json:"capacity,omitempty"` + + // If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + + // The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string `json:"size,omitempty"` + + // This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required + // on a PUT. + Tier *SKUTier `json:"tier,omitempty"` +} + +// SKUInfo - The resource model definition representing SKU for DevCenter resources +type SKUInfo struct { + // REQUIRED; The name of the SKU. Ex - P3. It is typically a letter+number code + Name *string `json:"name,omitempty"` + + // If the SKU supports scale out/in then the capacity integer should be included. If scale out/in is not possible for the + // resource this may be omitted. + Capacity *int32 `json:"capacity,omitempty"` + + // If the service has different generations of hardware, for the same SKU, then that can be captured here. + Family *string `json:"family,omitempty"` + + // The SKU size. When the name field is the combination of tier and some other value, this would be the standalone code. + Size *string `json:"size,omitempty"` + + // This field is required to be implemented by the Resource Provider if the service has more than one tier, but is not required + // on a PUT. + Tier *SKUTier `json:"tier,omitempty"` + + // READ-ONLY; Collection of name/value pairs to describe the SKU capabilities. + Capabilities []*Capability `json:"capabilities,omitempty" azure:"ro"` + + // READ-ONLY; SKU supported locations. + Locations []*string `json:"locations,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource type + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` +} + +// SKUListResult - Results of the Microsoft.DevCenter SKU list operation. +type SKUListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*SKUInfo `json:"value,omitempty" azure:"ro"` +} + +// SKUsClientListBySubscriptionOptions contains the optional parameters for the SKUsClient.ListBySubscription method. +type SKUsClientListBySubscriptionOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// Schedule - Represents a Schedule to execute a task. +type Schedule struct { + // Properties of a Schedule resource + Properties *ScheduleProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ScheduleListResult - Result of the schedule list operation. +type ScheduleListResult struct { + // READ-ONLY; URL to get the next set of results if there are any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Current page of results. + Value []*Schedule `json:"value,omitempty" azure:"ro"` +} + +// ScheduleProperties - The Schedule properties defining when and what to execute. +type ScheduleProperties struct { + // The frequency of this scheduled task. + Frequency *ScheduledFrequency `json:"frequency,omitempty"` + + // Indicates whether or not this scheduled task is enabled. + State *EnableStatus `json:"state,omitempty"` + + // The target time to trigger the action. The format is HH:MM. + Time *string `json:"time,omitempty"` + + // The IANA timezone id at which the schedule should execute. + TimeZone *string `json:"timeZone,omitempty"` + + // Supported type this scheduled task represents. + Type *ScheduledType `json:"type,omitempty"` + + // READ-ONLY; The provisioning state of the resource. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` +} + +// ScheduleUpdate - The schedule properties for partial update. Properties not provided in the update request will not be +// changed. +type ScheduleUpdate struct { + // The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Properties of a schedule resource to be updated. + Properties *ScheduleUpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// ScheduleUpdateProperties - Updatable properties of a Schedule. +type ScheduleUpdateProperties struct { + // The frequency of this scheduled task. + Frequency *ScheduledFrequency `json:"frequency,omitempty"` + + // Indicates whether or not this scheduled task is enabled. + State *EnableStatus `json:"state,omitempty"` + + // The target time to trigger the action. The format is HH:MM. + Time *string `json:"time,omitempty"` + + // The IANA timezone id at which the schedule should execute. + TimeZone *string `json:"timeZone,omitempty"` + + // Supported type this scheduled task represents. + Type *ScheduledType `json:"type,omitempty"` +} + +// SchedulesClientBeginCreateOrUpdateOptions contains the optional parameters for the SchedulesClient.BeginCreateOrUpdate +// method. +type SchedulesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// SchedulesClientBeginDeleteOptions contains the optional parameters for the SchedulesClient.BeginDelete method. +type SchedulesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// SchedulesClientBeginUpdateOptions contains the optional parameters for the SchedulesClient.BeginUpdate method. +type SchedulesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// SchedulesClientGetOptions contains the optional parameters for the SchedulesClient.Get method. +type SchedulesClientGetOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// SchedulesClientListByPoolOptions contains the optional parameters for the SchedulesClient.ListByPool method. +type SchedulesClientListByPoolOptions struct { + // The maximum number of resources to return from the operation. Example: '$top=10'. + Top *int32 +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' +type TrackedResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// TrackedResourceUpdate - Base tracked resource type for PATCH updates +type TrackedResourceUpdate struct { + // The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// Update - The devcenter resource for partial updates. Properties not provided in the update request will not be changed. +type Update struct { + // Managed identity properties + Identity *ManagedServiceIdentity `json:"identity,omitempty"` + + // The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// Usage - The core usage details. +type Usage struct { + // The current usage. + CurrentValue *int64 `json:"currentValue,omitempty"` + + // The limit integer. + Limit *int64 `json:"limit,omitempty"` + + // The name. + Name *UsageName `json:"name,omitempty"` + + // The unit details. + Unit *UsageUnit `json:"unit,omitempty"` +} + +// UsageName - The Usage Names. +type UsageName struct { + // The localized name of the resource. + LocalizedValue *string `json:"localizedValue,omitempty"` + + // The name of the resource. + Value *string `json:"value,omitempty"` +} + +// UsagesClientListByLocationOptions contains the optional parameters for the UsagesClient.ListByLocation method. +type UsagesClientListByLocationOptions struct { + // placeholder for future optional parameters +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` +} + +// UserRoleAssignmentValue - Mapping of user object ID to role assignments. +type UserRoleAssignmentValue struct { + // A map of roles to assign to the parent user. + Roles map[string]*EnvironmentRole `json:"roles,omitempty"` +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/models_serde.go b/sdk/resourcemanager/devcenter/armdevcenter/models_serde.go new file mode 100644 index 000000000000..088318ec213f --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/models_serde.go @@ -0,0 +1,3377 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AttachedNetworkConnection. +func (a AttachedNetworkConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AttachedNetworkConnection. +func (a *AttachedNetworkConnection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AttachedNetworkConnectionProperties. +func (a AttachedNetworkConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "domainJoinType", a.DomainJoinType) + populate(objectMap, "healthCheckStatus", a.HealthCheckStatus) + populate(objectMap, "networkConnectionId", a.NetworkConnectionID) + populate(objectMap, "networkConnectionLocation", a.NetworkConnectionLocation) + populate(objectMap, "provisioningState", a.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AttachedNetworkConnectionProperties. +func (a *AttachedNetworkConnectionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "domainJoinType": + err = unpopulate(val, "DomainJoinType", &a.DomainJoinType) + delete(rawMsg, key) + case "healthCheckStatus": + err = unpopulate(val, "HealthCheckStatus", &a.HealthCheckStatus) + delete(rawMsg, key) + case "networkConnectionId": + err = unpopulate(val, "NetworkConnectionID", &a.NetworkConnectionID) + delete(rawMsg, key) + case "networkConnectionLocation": + err = unpopulate(val, "NetworkConnectionLocation", &a.NetworkConnectionLocation) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AttachedNetworkListResult. +func (a AttachedNetworkListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AttachedNetworkListResult. +func (a *AttachedNetworkListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Capability. +func (c Capability) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", c.Name) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Capability. +func (c *Capability) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Catalog. +func (c Catalog) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Catalog. +func (c *Catalog) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CatalogListResult. +func (c CatalogListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogListResult. +func (c *CatalogListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CatalogProperties. +func (c CatalogProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adoGit", c.AdoGit) + populate(objectMap, "gitHub", c.GitHub) + populateTimeRFC3339(objectMap, "lastSyncTime", c.LastSyncTime) + populate(objectMap, "provisioningState", c.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogProperties. +func (c *CatalogProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adoGit": + err = unpopulate(val, "AdoGit", &c.AdoGit) + delete(rawMsg, key) + case "gitHub": + err = unpopulate(val, "GitHub", &c.GitHub) + delete(rawMsg, key) + case "lastSyncTime": + err = unpopulateTimeRFC3339(val, "LastSyncTime", &c.LastSyncTime) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CatalogUpdate. +func (c CatalogUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogUpdate. +func (c *CatalogUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CatalogUpdateProperties. +func (c CatalogUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "adoGit", c.AdoGit) + populate(objectMap, "gitHub", c.GitHub) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogUpdateProperties. +func (c *CatalogUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "adoGit": + err = unpopulate(val, "AdoGit", &c.AdoGit) + delete(rawMsg, key) + case "gitHub": + err = unpopulate(val, "GitHub", &c.GitHub) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CloudError. +func (c CloudError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", c.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudError. +func (c *CloudError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &c.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudErrorBody. +func (c *CloudErrorBody) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &c.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &c.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &c.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DevBoxDefinition. +func (d DevBoxDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + 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 DevBoxDefinition. +func (d *DevBoxDefinition) 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 DevBoxDefinitionListResult. +func (d DevBoxDefinitionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DevBoxDefinitionListResult. +func (d *DevBoxDefinitionListResult) 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 DevBoxDefinitionProperties. +func (d DevBoxDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "activeImageReference", d.ActiveImageReference) + populate(objectMap, "imageReference", d.ImageReference) + populate(objectMap, "imageValidationErrorDetails", d.ImageValidationErrorDetails) + populate(objectMap, "imageValidationStatus", d.ImageValidationStatus) + populate(objectMap, "osStorageType", d.OSStorageType) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "sku", d.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DevBoxDefinitionProperties. +func (d *DevBoxDefinitionProperties) 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 "activeImageReference": + err = unpopulate(val, "ActiveImageReference", &d.ActiveImageReference) + delete(rawMsg, key) + case "imageReference": + err = unpopulate(val, "ImageReference", &d.ImageReference) + delete(rawMsg, key) + case "imageValidationErrorDetails": + err = unpopulate(val, "ImageValidationErrorDetails", &d.ImageValidationErrorDetails) + delete(rawMsg, key) + case "imageValidationStatus": + err = unpopulate(val, "ImageValidationStatus", &d.ImageValidationStatus) + delete(rawMsg, key) + case "osStorageType": + err = unpopulate(val, "OSStorageType", &d.OSStorageType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &d.SKU) + 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 DevBoxDefinitionUpdate. +func (d DevBoxDefinitionUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", d.Location) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DevBoxDefinitionUpdate. +func (d *DevBoxDefinitionUpdate) 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 "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + 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 DevBoxDefinitionUpdateProperties. +func (d DevBoxDefinitionUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "imageReference", d.ImageReference) + populate(objectMap, "osStorageType", d.OSStorageType) + populate(objectMap, "sku", d.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DevBoxDefinitionUpdateProperties. +func (d *DevBoxDefinitionUpdateProperties) 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 "imageReference": + err = unpopulate(val, "ImageReference", &d.ImageReference) + delete(rawMsg, key) + case "osStorageType": + err = unpopulate(val, "OSStorageType", &d.OSStorageType) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &d.SKU) + 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 DevCenter. +func (d DevCenter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", d.ID) + populate(objectMap, "identity", d.Identity) + 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 DevCenter. +func (d *DevCenter) 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 "identity": + err = unpopulate(val, "Identity", &d.Identity) + 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 EnvironmentRole. +func (e EnvironmentRole) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", e.Description) + populate(objectMap, "roleName", e.RoleName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentRole. +func (e *EnvironmentRole) 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 "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "roleName": + err = unpopulate(val, "RoleName", &e.RoleName) + 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 EnvironmentType. +func (e EnvironmentType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "tags", e.Tags) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentType. +func (e *EnvironmentType) 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 "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 EnvironmentTypeListResult. +func (e EnvironmentTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentTypeListResult. +func (e *EnvironmentTypeListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + 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 EnvironmentTypeProperties. +func (e EnvironmentTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "provisioningState", e.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentTypeProperties. +func (e *EnvironmentTypeProperties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + 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 EnvironmentTypeUpdate. +func (e EnvironmentTypeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", e.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EnvironmentTypeUpdate. +func (e *EnvironmentTypeUpdate) 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 "tags": + err = unpopulate(val, "Tags", &e.Tags) + 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 Gallery. +func (g Gallery) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "systemData", g.SystemData) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Gallery. +func (g *Gallery) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GalleryListResult. +func (g GalleryListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GalleryListResult. +func (g *GalleryListResult) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &g.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &g.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GalleryProperties. +func (g GalleryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "galleryResourceId", g.GalleryResourceID) + populate(objectMap, "provisioningState", g.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GalleryProperties. +func (g *GalleryProperties) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "galleryResourceId": + err = unpopulate(val, "GalleryResourceID", &g.GalleryResourceID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &g.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GitCatalog. +func (g GitCatalog) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "branch", g.Branch) + populate(objectMap, "path", g.Path) + populate(objectMap, "secretIdentifier", g.SecretIdentifier) + populate(objectMap, "uri", g.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GitCatalog. +func (g *GitCatalog) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "branch": + err = unpopulate(val, "Branch", &g.Branch) + delete(rawMsg, key) + case "path": + err = unpopulate(val, "Path", &g.Path) + delete(rawMsg, key) + case "secretIdentifier": + err = unpopulate(val, "SecretIdentifier", &g.SecretIdentifier) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &g.URI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthCheck. +func (h HealthCheck) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalDetails", h.AdditionalDetails) + populate(objectMap, "displayName", h.DisplayName) + populateTimeRFC3339(objectMap, "endDateTime", h.EndDateTime) + populate(objectMap, "errorType", h.ErrorType) + populate(objectMap, "recommendedAction", h.RecommendedAction) + populateTimeRFC3339(objectMap, "startDateTime", h.StartDateTime) + populate(objectMap, "status", h.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthCheck. +func (h *HealthCheck) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalDetails": + err = unpopulate(val, "AdditionalDetails", &h.AdditionalDetails) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &h.DisplayName) + delete(rawMsg, key) + case "endDateTime": + err = unpopulateTimeRFC3339(val, "EndDateTime", &h.EndDateTime) + delete(rawMsg, key) + case "errorType": + err = unpopulate(val, "ErrorType", &h.ErrorType) + delete(rawMsg, key) + case "recommendedAction": + err = unpopulate(val, "RecommendedAction", &h.RecommendedAction) + delete(rawMsg, key) + case "startDateTime": + err = unpopulateTimeRFC3339(val, "StartDateTime", &h.StartDateTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &h.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthCheckStatusDetails. +func (h HealthCheckStatusDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", h.ID) + populate(objectMap, "name", h.Name) + populate(objectMap, "properties", h.Properties) + populate(objectMap, "systemData", h.SystemData) + populate(objectMap, "type", h.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthCheckStatusDetails. +func (h *HealthCheckStatusDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &h.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &h.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &h.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &h.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &h.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthCheckStatusDetailsListResult. +func (h HealthCheckStatusDetailsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", h.NextLink) + populate(objectMap, "value", h.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthCheckStatusDetailsListResult. +func (h *HealthCheckStatusDetailsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &h.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &h.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthCheckStatusDetailsProperties. +func (h HealthCheckStatusDetailsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "endDateTime", h.EndDateTime) + populate(objectMap, "healthChecks", h.HealthChecks) + populateTimeRFC3339(objectMap, "startDateTime", h.StartDateTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthCheckStatusDetailsProperties. +func (h *HealthCheckStatusDetailsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endDateTime": + err = unpopulateTimeRFC3339(val, "EndDateTime", &h.EndDateTime) + delete(rawMsg, key) + case "healthChecks": + err = unpopulate(val, "HealthChecks", &h.HealthChecks) + delete(rawMsg, key) + case "startDateTime": + err = unpopulateTimeRFC3339(val, "StartDateTime", &h.StartDateTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Image. +func (i Image) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Image. +func (i *Image) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageListResult. +func (i ImageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageListResult. +func (i *ImageListResult) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageProperties. +func (i ImageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", i.Description) + populate(objectMap, "offer", i.Offer) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "publisher", i.Publisher) + populate(objectMap, "recommendedMachineConfiguration", i.RecommendedMachineConfiguration) + populate(objectMap, "sku", i.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageProperties. +func (i *ImageProperties) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &i.Description) + delete(rawMsg, key) + case "offer": + err = unpopulate(val, "Offer", &i.Offer) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &i.Publisher) + delete(rawMsg, key) + case "recommendedMachineConfiguration": + err = unpopulate(val, "RecommendedMachineConfiguration", &i.RecommendedMachineConfiguration) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &i.SKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageReference. +func (i ImageReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "exactVersion", i.ExactVersion) + populate(objectMap, "id", i.ID) + populate(objectMap, "offer", i.Offer) + populate(objectMap, "publisher", i.Publisher) + populate(objectMap, "sku", i.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageReference. +func (i *ImageReference) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "exactVersion": + err = unpopulate(val, "ExactVersion", &i.ExactVersion) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "offer": + err = unpopulate(val, "Offer", &i.Offer) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &i.Publisher) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &i.SKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageValidationErrorDetails. +func (i ImageValidationErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", i.Code) + populate(objectMap, "message", i.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageValidationErrorDetails. +func (i *ImageValidationErrorDetails) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &i.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &i.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageVersion. +func (i ImageVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageVersion. +func (i *ImageVersion) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageVersionListResult. +func (i ImageVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageVersionListResult. +func (i *ImageVersionListResult) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ImageVersionProperties. +func (i ImageVersionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "excludeFromLatest", i.ExcludeFromLatest) + populate(objectMap, "name", i.Name) + populate(objectMap, "osDiskImageSizeInGb", i.OSDiskImageSizeInGb) + populate(objectMap, "provisioningState", i.ProvisioningState) + populateTimeRFC3339(objectMap, "publishedDate", i.PublishedDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImageVersionProperties. +func (i *ImageVersionProperties) 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", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "excludeFromLatest": + err = unpopulate(val, "ExcludeFromLatest", &i.ExcludeFromLatest) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "osDiskImageSizeInGb": + err = unpopulate(val, "OSDiskImageSizeInGb", &i.OSDiskImageSizeInGb) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "publishedDate": + err = unpopulateTimeRFC3339(val, "PublishedDate", &i.PublishedDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListResult. +func (l ListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListResult. +func (l *ListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListUsagesResult. +func (l ListUsagesResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListUsagesResult. +func (l *ListUsagesResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) 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 "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + 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 NetworkConnection. +func (n NetworkConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", n.ID) + populate(objectMap, "location", n.Location) + populate(objectMap, "name", n.Name) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "systemData", n.SystemData) + populate(objectMap, "tags", n.Tags) + populate(objectMap, "type", n.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkConnection. +func (n *NetworkConnection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &n.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &n.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &n.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &n.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkConnectionListResult. +func (n NetworkConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkConnectionListResult. +func (n *NetworkConnectionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &n.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &n.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkConnectionUpdate. +func (n NetworkConnectionUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", n.Location) + populate(objectMap, "properties", n.Properties) + populate(objectMap, "tags", n.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkConnectionUpdate. +func (n *NetworkConnectionUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &n.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &n.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &n.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkConnectionUpdateProperties. +func (n NetworkConnectionUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "domainName", n.DomainName) + populate(objectMap, "domainPassword", n.DomainPassword) + populate(objectMap, "domainUsername", n.DomainUsername) + populate(objectMap, "organizationUnit", n.OrganizationUnit) + populate(objectMap, "subnetId", n.SubnetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkConnectionUpdateProperties. +func (n *NetworkConnectionUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "domainName": + err = unpopulate(val, "DomainName", &n.DomainName) + delete(rawMsg, key) + case "domainPassword": + err = unpopulate(val, "DomainPassword", &n.DomainPassword) + delete(rawMsg, key) + case "domainUsername": + err = unpopulate(val, "DomainUsername", &n.DomainUsername) + delete(rawMsg, key) + case "organizationUnit": + err = unpopulate(val, "OrganizationUnit", &n.OrganizationUnit) + delete(rawMsg, key) + case "subnetId": + err = unpopulate(val, "SubnetID", &n.SubnetID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkProperties. +func (n NetworkProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "domainJoinType", n.DomainJoinType) + populate(objectMap, "domainName", n.DomainName) + populate(objectMap, "domainPassword", n.DomainPassword) + populate(objectMap, "domainUsername", n.DomainUsername) + populate(objectMap, "healthCheckStatus", n.HealthCheckStatus) + populate(objectMap, "networkingResourceGroupName", n.NetworkingResourceGroupName) + populate(objectMap, "organizationUnit", n.OrganizationUnit) + populate(objectMap, "provisioningState", n.ProvisioningState) + populate(objectMap, "subnetId", n.SubnetID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkProperties. +func (n *NetworkProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "domainJoinType": + err = unpopulate(val, "DomainJoinType", &n.DomainJoinType) + delete(rawMsg, key) + case "domainName": + err = unpopulate(val, "DomainName", &n.DomainName) + delete(rawMsg, key) + case "domainPassword": + err = unpopulate(val, "DomainPassword", &n.DomainPassword) + delete(rawMsg, key) + case "domainUsername": + err = unpopulate(val, "DomainUsername", &n.DomainUsername) + delete(rawMsg, key) + case "healthCheckStatus": + err = unpopulate(val, "HealthCheckStatus", &n.HealthCheckStatus) + delete(rawMsg, key) + case "networkingResourceGroupName": + err = unpopulate(val, "NetworkingResourceGroupName", &n.NetworkingResourceGroupName) + delete(rawMsg, key) + case "organizationUnit": + err = unpopulate(val, "OrganizationUnit", &n.OrganizationUnit) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) + delete(rawMsg, key) + case "subnetId": + err = unpopulate(val, "SubnetID", &n.SubnetID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationStatus. +func (o OperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "percentComplete", o.PercentComplete) + populate(objectMap, "properties", &o.Properties) + populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatus. +func (o *OperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "percentComplete": + err = unpopulate(val, "PercentComplete", &o.PercentComplete) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationStatusError. +func (o OperationStatusError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", o.Code) + populate(objectMap, "message", o.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatusError. +func (o *OperationStatusError) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &o.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &o.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Pool. +func (p Pool) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Pool. +func (p *Pool) 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 "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolListResult. +func (p PoolListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolListResult. +func (p *PoolListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolProperties. +func (p PoolProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "devBoxDefinitionName", p.DevBoxDefinitionName) + populate(objectMap, "licenseType", p.LicenseType) + populate(objectMap, "localAdministrator", p.LocalAdministrator) + populate(objectMap, "networkConnectionName", p.NetworkConnectionName) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolProperties. +func (p *PoolProperties) 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 "devBoxDefinitionName": + err = unpopulate(val, "DevBoxDefinitionName", &p.DevBoxDefinitionName) + delete(rawMsg, key) + case "licenseType": + err = unpopulate(val, "LicenseType", &p.LicenseType) + delete(rawMsg, key) + case "localAdministrator": + err = unpopulate(val, "LocalAdministrator", &p.LocalAdministrator) + delete(rawMsg, key) + case "networkConnectionName": + err = unpopulate(val, "NetworkConnectionName", &p.NetworkConnectionName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + 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 PoolUpdate. +func (p PoolUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", p.Location) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolUpdate. +func (p *PoolUpdate) 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 "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PoolUpdateProperties. +func (p PoolUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "devBoxDefinitionName", p.DevBoxDefinitionName) + populate(objectMap, "licenseType", p.LicenseType) + populate(objectMap, "localAdministrator", p.LocalAdministrator) + populate(objectMap, "networkConnectionName", p.NetworkConnectionName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PoolUpdateProperties. +func (p *PoolUpdateProperties) 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 "devBoxDefinitionName": + err = unpopulate(val, "DevBoxDefinitionName", &p.DevBoxDefinitionName) + delete(rawMsg, key) + case "licenseType": + err = unpopulate(val, "LicenseType", &p.LicenseType) + delete(rawMsg, key) + case "localAdministrator": + err = unpopulate(val, "LocalAdministrator", &p.LocalAdministrator) + delete(rawMsg, key) + case "networkConnectionName": + err = unpopulate(val, "NetworkConnectionName", &p.NetworkConnectionName) + 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 Project. +func (p Project) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Project. +func (p *Project) 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 "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectEnvironmentType. +func (p ProjectEnvironmentType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "identity", p.Identity) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectEnvironmentType. +func (p *ProjectEnvironmentType) 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 "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &p.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectEnvironmentTypeListResult. +func (p ProjectEnvironmentTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectEnvironmentTypeListResult. +func (p *ProjectEnvironmentTypeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectEnvironmentTypeProperties. +func (p ProjectEnvironmentTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "creatorRoleAssignment", p.CreatorRoleAssignment) + populate(objectMap, "deploymentTargetId", p.DeploymentTargetID) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "status", p.Status) + populate(objectMap, "userRoleAssignments", p.UserRoleAssignments) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectEnvironmentTypeProperties. +func (p *ProjectEnvironmentTypeProperties) 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 "creatorRoleAssignment": + err = unpopulate(val, "CreatorRoleAssignment", &p.CreatorRoleAssignment) + delete(rawMsg, key) + case "deploymentTargetId": + err = unpopulate(val, "DeploymentTargetID", &p.DeploymentTargetID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "userRoleAssignments": + err = unpopulate(val, "UserRoleAssignments", &p.UserRoleAssignments) + 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 ProjectEnvironmentTypeUpdate. +func (p ProjectEnvironmentTypeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", p.Identity) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectEnvironmentTypeUpdate. +func (p *ProjectEnvironmentTypeUpdate) 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 "identity": + err = unpopulate(val, "Identity", &p.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectEnvironmentTypeUpdateProperties. +func (p ProjectEnvironmentTypeUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "creatorRoleAssignment", p.CreatorRoleAssignment) + populate(objectMap, "deploymentTargetId", p.DeploymentTargetID) + populate(objectMap, "status", p.Status) + populate(objectMap, "userRoleAssignments", p.UserRoleAssignments) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectEnvironmentTypeUpdateProperties. +func (p *ProjectEnvironmentTypeUpdateProperties) 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 "creatorRoleAssignment": + err = unpopulate(val, "CreatorRoleAssignment", &p.CreatorRoleAssignment) + delete(rawMsg, key) + case "deploymentTargetId": + err = unpopulate(val, "DeploymentTargetID", &p.DeploymentTargetID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "userRoleAssignments": + err = unpopulate(val, "UserRoleAssignments", &p.UserRoleAssignments) + 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 ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment. +func (p ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "roles", p.Roles) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment. +func (p *ProjectEnvironmentTypeUpdatePropertiesCreatorRoleAssignment) 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 "roles": + err = unpopulate(val, "Roles", &p.Roles) + 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 ProjectListResult. +func (p ProjectListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectListResult. +func (p *ProjectListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectProperties. +func (p ProjectProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "devCenterId", p.DevCenterID) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectProperties. +func (p *ProjectProperties) 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 "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "devCenterId": + err = unpopulate(val, "DevCenterID", &p.DevCenterID) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + 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 ProjectUpdate. +func (p ProjectUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", p.Location) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectUpdate. +func (p *ProjectUpdate) 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 "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectUpdateProperties. +func (p ProjectUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "devCenterId", p.DevCenterID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectUpdateProperties. +func (p *ProjectUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "devCenterId": + err = unpopulate(val, "DevCenterID", &p.DevCenterID) + 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 Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Properties. +func (p *Properties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + 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 ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) 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 "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecommendedMachineConfiguration. +func (r RecommendedMachineConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "memory", r.Memory) + populate(objectMap, "vCPUs", r.VCPUs) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecommendedMachineConfiguration. +func (r *RecommendedMachineConfiguration) 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 "memory": + err = unpopulate(val, "Memory", &r.Memory) + delete(rawMsg, key) + case "vCPUs": + err = unpopulate(val, "VCPUs", &r.VCPUs) + 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 Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) 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) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + 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 ResourceRange. +func (r ResourceRange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "max", r.Max) + populate(objectMap, "min", r.Min) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceRange. +func (r *ResourceRange) 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 "max": + err = unpopulate(val, "Max", &r.Max) + delete(rawMsg, key) + case "min": + err = unpopulate(val, "Min", &r.Min) + 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 SKU. +func (s SKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) + populate(objectMap, "name", s.Name) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKU. +func (s *SKU) 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 "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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 SKUInfo. +func (s SKUInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capabilities", s.Capabilities) + populate(objectMap, "capacity", s.Capacity) + populate(objectMap, "family", s.Family) + populate(objectMap, "locations", s.Locations) + populate(objectMap, "name", s.Name) + populate(objectMap, "resourceType", s.ResourceType) + populate(objectMap, "size", s.Size) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUInfo. +func (s *SKUInfo) 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 "capabilities": + err = unpopulate(val, "Capabilities", &s.Capabilities) + delete(rawMsg, key) + case "capacity": + err = unpopulate(val, "Capacity", &s.Capacity) + delete(rawMsg, key) + case "family": + err = unpopulate(val, "Family", &s.Family) + delete(rawMsg, key) + case "locations": + err = unpopulate(val, "Locations", &s.Locations) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &s.ResourceType) + delete(rawMsg, key) + case "size": + err = unpopulate(val, "Size", &s.Size) + delete(rawMsg, key) + case "tier": + err = unpopulate(val, "Tier", &s.Tier) + 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 SKUListResult. +func (s SKUListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SKUListResult. +func (s *SKUListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Schedule. +func (s Schedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Schedule. +func (s *Schedule) 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 "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleListResult. +func (s ScheduleListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleListResult. +func (s *ScheduleListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &s.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleProperties. +func (s ScheduleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "frequency", s.Frequency) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "state", s.State) + populate(objectMap, "time", s.Time) + populate(objectMap, "timeZone", s.TimeZone) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleProperties. +func (s *ScheduleProperties) 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 "frequency": + err = unpopulate(val, "Frequency", &s.Frequency) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &s.State) + delete(rawMsg, key) + case "time": + err = unpopulate(val, "Time", &s.Time) + delete(rawMsg, key) + case "timeZone": + err = unpopulate(val, "TimeZone", &s.TimeZone) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleUpdate. +func (s ScheduleUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", s.Location) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleUpdate. +func (s *ScheduleUpdate) 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 "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ScheduleUpdateProperties. +func (s ScheduleUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "frequency", s.Frequency) + populate(objectMap, "state", s.State) + populate(objectMap, "time", s.Time) + populate(objectMap, "timeZone", s.TimeZone) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ScheduleUpdateProperties. +func (s *ScheduleUpdateProperties) 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 "frequency": + err = unpopulate(val, "Frequency", &s.Frequency) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &s.State) + delete(rawMsg, key) + case "time": + err = unpopulate(val, "Time", &s.Time) + delete(rawMsg, key) + case "timeZone": + err = unpopulate(val, "TimeZone", &s.TimeZone) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) 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 "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResourceUpdate. +func (t TrackedResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResourceUpdate. +func (t *TrackedResourceUpdate) 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 "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Update. +func (u Update) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", u.Identity) + populate(objectMap, "location", u.Location) + populate(objectMap, "tags", u.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Update. +func (u *Update) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &u.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &u.Location) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &u.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Usage. +func (u Usage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "currentValue", u.CurrentValue) + populate(objectMap, "limit", u.Limit) + populate(objectMap, "name", u.Name) + populate(objectMap, "unit", u.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Usage. +func (u *Usage) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currentValue": + err = unpopulate(val, "CurrentValue", &u.CurrentValue) + delete(rawMsg, key) + case "limit": + err = unpopulate(val, "Limit", &u.Limit) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &u.Name) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &u.Unit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UsageName. +func (u UsageName) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "localizedValue", u.LocalizedValue) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UsageName. +func (u *UsageName) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "localizedValue": + err = unpopulate(val, "LocalizedValue", &u.LocalizedValue) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &u.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserRoleAssignmentValue. +func (u UserRoleAssignmentValue) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "roles", u.Roles) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserRoleAssignmentValue. +func (u *UserRoleAssignmentValue) 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", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "roles": + err = unpopulate(val, "Roles", &u.Roles) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/networkconnections_client.go b/sdk/resourcemanager/devcenter/armdevcenter/networkconnections_client.go new file mode 100644 index 000000000000..bbe116d29fe0 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/networkconnections_client.go @@ -0,0 +1,620 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// NetworkConnectionsClient contains the methods for the NetworkConnections group. +// Don't use this type directly, use NewNetworkConnectionsClient() instead. +type NetworkConnectionsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewNetworkConnectionsClient creates a new instance of NetworkConnectionsClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewNetworkConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*NetworkConnectionsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &NetworkConnectionsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a Network Connections resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// networkConnectionName - Name of the Network Connection that can be applied to a Pool. +// body - Represents network connection +// options - NetworkConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the NetworkConnectionsClient.BeginCreateOrUpdate +// method. +func (client *NetworkConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, networkConnectionName string, body NetworkConnection, options *NetworkConnectionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[NetworkConnectionsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, networkConnectionName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[NetworkConnectionsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[NetworkConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a Network Connections resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *NetworkConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, networkConnectionName string, body NetworkConnection, options *NetworkConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, networkConnectionName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *NetworkConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, networkConnectionName string, body NetworkConnection, options *NetworkConnectionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}" + 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 networkConnectionName == "" { + return nil, errors.New("parameter networkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkConnectionName}", url.PathEscape(networkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a Network Connections resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// networkConnectionName - Name of the Network Connection that can be applied to a Pool. +// options - NetworkConnectionsClientBeginDeleteOptions contains the optional parameters for the NetworkConnectionsClient.BeginDelete +// method. +func (client *NetworkConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientBeginDeleteOptions) (*runtime.Poller[NetworkConnectionsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, networkConnectionName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[NetworkConnectionsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[NetworkConnectionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a Network Connections resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *NetworkConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, networkConnectionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *NetworkConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}" + 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 networkConnectionName == "" { + return nil, errors.New("parameter networkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkConnectionName}", url.PathEscape(networkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a network connection resource +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// networkConnectionName - Name of the Network Connection that can be applied to a Pool. +// options - NetworkConnectionsClientGetOptions contains the optional parameters for the NetworkConnectionsClient.Get method. +func (client *NetworkConnectionsClient) Get(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientGetOptions) (NetworkConnectionsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, networkConnectionName, options) + if err != nil { + return NetworkConnectionsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NetworkConnectionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NetworkConnectionsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *NetworkConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}" + 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 networkConnectionName == "" { + return nil, errors.New("parameter networkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkConnectionName}", url.PathEscape(networkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *NetworkConnectionsClient) getHandleResponse(resp *http.Response) (NetworkConnectionsClientGetResponse, error) { + result := NetworkConnectionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NetworkConnection); err != nil { + return NetworkConnectionsClientGetResponse{}, err + } + return result, nil +} + +// GetHealthDetails - Gets health check status details. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// networkConnectionName - Name of the Network Connection that can be applied to a Pool. +// options - NetworkConnectionsClientGetHealthDetailsOptions contains the optional parameters for the NetworkConnectionsClient.GetHealthDetails +// method. +func (client *NetworkConnectionsClient) GetHealthDetails(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientGetHealthDetailsOptions) (NetworkConnectionsClientGetHealthDetailsResponse, error) { + req, err := client.getHealthDetailsCreateRequest(ctx, resourceGroupName, networkConnectionName, options) + if err != nil { + return NetworkConnectionsClientGetHealthDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NetworkConnectionsClientGetHealthDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NetworkConnectionsClientGetHealthDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.getHealthDetailsHandleResponse(resp) +} + +// getHealthDetailsCreateRequest creates the GetHealthDetails request. +func (client *NetworkConnectionsClient) getHealthDetailsCreateRequest(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientGetHealthDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}/healthChecks/latest" + 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 networkConnectionName == "" { + return nil, errors.New("parameter networkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkConnectionName}", url.PathEscape(networkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHealthDetailsHandleResponse handles the GetHealthDetails response. +func (client *NetworkConnectionsClient) getHealthDetailsHandleResponse(resp *http.Response) (NetworkConnectionsClientGetHealthDetailsResponse, error) { + result := NetworkConnectionsClientGetHealthDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HealthCheckStatusDetails); err != nil { + return NetworkConnectionsClientGetHealthDetailsResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists network connections in a resource group +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// options - NetworkConnectionsClientListByResourceGroupOptions contains the optional parameters for the NetworkConnectionsClient.ListByResourceGroup +// method. +func (client *NetworkConnectionsClient) NewListByResourceGroupPager(resourceGroupName string, options *NetworkConnectionsClientListByResourceGroupOptions) *runtime.Pager[NetworkConnectionsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[NetworkConnectionsClientListByResourceGroupResponse]{ + More: func(page NetworkConnectionsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *NetworkConnectionsClientListByResourceGroupResponse) (NetworkConnectionsClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return NetworkConnectionsClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NetworkConnectionsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NetworkConnectionsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *NetworkConnectionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *NetworkConnectionsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *NetworkConnectionsClient) listByResourceGroupHandleResponse(resp *http.Response) (NetworkConnectionsClientListByResourceGroupResponse, error) { + result := NetworkConnectionsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NetworkConnectionListResult); err != nil { + return NetworkConnectionsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists network connections in a subscription +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// options - NetworkConnectionsClientListBySubscriptionOptions contains the optional parameters for the NetworkConnectionsClient.ListBySubscription +// method. +func (client *NetworkConnectionsClient) NewListBySubscriptionPager(options *NetworkConnectionsClientListBySubscriptionOptions) *runtime.Pager[NetworkConnectionsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[NetworkConnectionsClientListBySubscriptionResponse]{ + More: func(page NetworkConnectionsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *NetworkConnectionsClientListBySubscriptionResponse) (NetworkConnectionsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return NetworkConnectionsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NetworkConnectionsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NetworkConnectionsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *NetworkConnectionsClient) listBySubscriptionCreateRequest(ctx context.Context, options *NetworkConnectionsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/networkConnections" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *NetworkConnectionsClient) listBySubscriptionHandleResponse(resp *http.Response) (NetworkConnectionsClientListBySubscriptionResponse, error) { + result := NetworkConnectionsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.NetworkConnectionListResult); err != nil { + return NetworkConnectionsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// NewListHealthDetailsPager - Lists health check status details +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// networkConnectionName - Name of the Network Connection that can be applied to a Pool. +// options - NetworkConnectionsClientListHealthDetailsOptions contains the optional parameters for the NetworkConnectionsClient.ListHealthDetails +// method. +func (client *NetworkConnectionsClient) NewListHealthDetailsPager(resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientListHealthDetailsOptions) *runtime.Pager[NetworkConnectionsClientListHealthDetailsResponse] { + return runtime.NewPager(runtime.PagingHandler[NetworkConnectionsClientListHealthDetailsResponse]{ + More: func(page NetworkConnectionsClientListHealthDetailsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *NetworkConnectionsClientListHealthDetailsResponse) (NetworkConnectionsClientListHealthDetailsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listHealthDetailsCreateRequest(ctx, resourceGroupName, networkConnectionName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return NetworkConnectionsClientListHealthDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NetworkConnectionsClientListHealthDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NetworkConnectionsClientListHealthDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.listHealthDetailsHandleResponse(resp) + }, + }) +} + +// listHealthDetailsCreateRequest creates the ListHealthDetails request. +func (client *NetworkConnectionsClient) listHealthDetailsCreateRequest(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientListHealthDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}/healthChecks" + 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 networkConnectionName == "" { + return nil, errors.New("parameter networkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkConnectionName}", url.PathEscape(networkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHealthDetailsHandleResponse handles the ListHealthDetails response. +func (client *NetworkConnectionsClient) listHealthDetailsHandleResponse(resp *http.Response) (NetworkConnectionsClientListHealthDetailsResponse, error) { + result := NetworkConnectionsClientListHealthDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.HealthCheckStatusDetailsListResult); err != nil { + return NetworkConnectionsClientListHealthDetailsResponse{}, err + } + return result, nil +} + +// RunHealthChecks - Triggers a new health check run. The execution and health check result can be tracked via the network +// Connection health check details +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// networkConnectionName - Name of the Network Connection that can be applied to a Pool. +// options - NetworkConnectionsClientRunHealthChecksOptions contains the optional parameters for the NetworkConnectionsClient.RunHealthChecks +// method. +func (client *NetworkConnectionsClient) RunHealthChecks(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientRunHealthChecksOptions) (NetworkConnectionsClientRunHealthChecksResponse, error) { + req, err := client.runHealthChecksCreateRequest(ctx, resourceGroupName, networkConnectionName, options) + if err != nil { + return NetworkConnectionsClientRunHealthChecksResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return NetworkConnectionsClientRunHealthChecksResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return NetworkConnectionsClientRunHealthChecksResponse{}, runtime.NewResponseError(resp) + } + return NetworkConnectionsClientRunHealthChecksResponse{}, nil +} + +// runHealthChecksCreateRequest creates the RunHealthChecks request. +func (client *NetworkConnectionsClient) runHealthChecksCreateRequest(ctx context.Context, resourceGroupName string, networkConnectionName string, options *NetworkConnectionsClientRunHealthChecksOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}/runHealthChecks" + 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 networkConnectionName == "" { + return nil, errors.New("parameter networkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkConnectionName}", url.PathEscape(networkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, 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 +} + +// BeginUpdate - Partially updates a Network Connection +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// networkConnectionName - Name of the Network Connection that can be applied to a Pool. +// body - Represents network connection +// options - NetworkConnectionsClientBeginUpdateOptions contains the optional parameters for the NetworkConnectionsClient.BeginUpdate +// method. +func (client *NetworkConnectionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, networkConnectionName string, body NetworkConnectionUpdate, options *NetworkConnectionsClientBeginUpdateOptions) (*runtime.Poller[NetworkConnectionsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, networkConnectionName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[NetworkConnectionsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[NetworkConnectionsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Partially updates a Network Connection +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *NetworkConnectionsClient) update(ctx context.Context, resourceGroupName string, networkConnectionName string, body NetworkConnectionUpdate, options *NetworkConnectionsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, networkConnectionName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *NetworkConnectionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, networkConnectionName string, body NetworkConnectionUpdate, options *NetworkConnectionsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/networkConnections/{networkConnectionName}" + 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 networkConnectionName == "" { + return nil, errors.New("parameter networkConnectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{networkConnectionName}", url.PathEscape(networkConnectionName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/operations_client.go b/sdk/resourcemanager/devcenter/armdevcenter/operations_client.go new file mode 100644 index 000000000000..c976596e75d3 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/operations_client.go @@ -0,0 +1,105 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - Lists all of the available resource provider operations. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.DevCenter/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/operationstatuses_client.go b/sdk/resourcemanager/devcenter/armdevcenter/operationstatuses_client.go new file mode 100644 index 000000000000..06068350c597 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/operationstatuses_client.go @@ -0,0 +1,112 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// OperationStatusesClient contains the methods for the OperationStatuses group. +// Don't use this type directly, use NewOperationStatusesClient() instead. +type OperationStatusesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewOperationStatusesClient creates a new instance of OperationStatusesClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationStatusesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationStatusesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Gets the current status of an async operation. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// location - The Azure region +// operationID - The ID of an ongoing async operation +// options - OperationStatusesClientGetOptions contains the optional parameters for the OperationStatusesClient.Get method. +func (client *OperationStatusesClient) Get(ctx context.Context, location string, operationID string, options *OperationStatusesClientGetOptions) (OperationStatusesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, location, operationID, options) + if err != nil { + return OperationStatusesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationStatusesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return OperationStatusesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *OperationStatusesClient) getCreateRequest(ctx context.Context, location string, operationID string, options *OperationStatusesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/locations/{location}/operationStatuses/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OperationStatusesClient) getHandleResponse(resp *http.Response) (OperationStatusesClientGetResponse, error) { + result := OperationStatusesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return OperationStatusesClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/pools_client.go b/sdk/resourcemanager/devcenter/armdevcenter/pools_client.go new file mode 100644 index 000000000000..f5dd11d03521 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/pools_client.go @@ -0,0 +1,400 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// PoolsClient contains the methods for the Pools group. +// Don't use this type directly, use NewPoolsClient() instead. +type PoolsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewPoolsClient creates a new instance of PoolsClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewPoolsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PoolsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &PoolsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a machine pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// body - Represents a machine pool +// options - PoolsClientBeginCreateOrUpdateOptions contains the optional parameters for the PoolsClient.BeginCreateOrUpdate +// method. +func (client *PoolsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, projectName string, poolName string, body Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*runtime.Poller[PoolsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, projectName, poolName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PoolsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[PoolsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a machine pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *PoolsClient) createOrUpdate(ctx context.Context, resourceGroupName string, projectName string, poolName string, body Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, projectName, poolName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PoolsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, body Pool, options *PoolsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a machine pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// options - PoolsClientBeginDeleteOptions contains the optional parameters for the PoolsClient.BeginDelete method. +func (client *PoolsClient) BeginDelete(ctx context.Context, resourceGroupName string, projectName string, poolName string, options *PoolsClientBeginDeleteOptions) (*runtime.Poller[PoolsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, projectName, poolName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PoolsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[PoolsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a machine pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *PoolsClient) deleteOperation(ctx context.Context, resourceGroupName string, projectName string, poolName string, options *PoolsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, poolName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PoolsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, options *PoolsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a machine pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// options - PoolsClientGetOptions contains the optional parameters for the PoolsClient.Get method. +func (client *PoolsClient) Get(ctx context.Context, resourceGroupName string, projectName string, poolName string, options *PoolsClientGetOptions) (PoolsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, poolName, options) + if err != nil { + return PoolsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PoolsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PoolsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PoolsClient) getCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, options *PoolsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PoolsClient) getHandleResponse(resp *http.Response) (PoolsClientGetResponse, error) { + result := PoolsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Pool); err != nil { + return PoolsClientGetResponse{}, err + } + return result, nil +} + +// NewListByProjectPager - Lists pools for a project +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// options - PoolsClientListByProjectOptions contains the optional parameters for the PoolsClient.ListByProject method. +func (client *PoolsClient) NewListByProjectPager(resourceGroupName string, projectName string, options *PoolsClientListByProjectOptions) *runtime.Pager[PoolsClientListByProjectResponse] { + return runtime.NewPager(runtime.PagingHandler[PoolsClientListByProjectResponse]{ + More: func(page PoolsClientListByProjectResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PoolsClientListByProjectResponse) (PoolsClientListByProjectResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByProjectCreateRequest(ctx, resourceGroupName, projectName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return PoolsClientListByProjectResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return PoolsClientListByProjectResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PoolsClientListByProjectResponse{}, runtime.NewResponseError(resp) + } + return client.listByProjectHandleResponse(resp) + }, + }) +} + +// listByProjectCreateRequest creates the ListByProject request. +func (client *PoolsClient) listByProjectCreateRequest(ctx context.Context, resourceGroupName string, projectName string, options *PoolsClientListByProjectOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByProjectHandleResponse handles the ListByProject response. +func (client *PoolsClient) listByProjectHandleResponse(resp *http.Response) (PoolsClientListByProjectResponse, error) { + result := PoolsClientListByProjectResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PoolListResult); err != nil { + return PoolsClientListByProjectResponse{}, err + } + return result, nil +} + +// BeginUpdate - Partially updates a machine pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// body - Represents a machine pool +// options - PoolsClientBeginUpdateOptions contains the optional parameters for the PoolsClient.BeginUpdate method. +func (client *PoolsClient) BeginUpdate(ctx context.Context, resourceGroupName string, projectName string, poolName string, body PoolUpdate, options *PoolsClientBeginUpdateOptions) (*runtime.Poller[PoolsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, projectName, poolName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[PoolsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[PoolsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Partially updates a machine pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *PoolsClient) update(ctx context.Context, resourceGroupName string, projectName string, poolName string, body PoolUpdate, options *PoolsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, projectName, poolName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *PoolsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, body PoolUpdate, options *PoolsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/projectenvironmenttypes_client.go b/sdk/resourcemanager/devcenter/armdevcenter/projectenvironmenttypes_client.go new file mode 100644 index 000000000000..932580ce05ee --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/projectenvironmenttypes_client.go @@ -0,0 +1,371 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ProjectEnvironmentTypesClient contains the methods for the ProjectEnvironmentTypes group. +// Don't use this type directly, use NewProjectEnvironmentTypesClient() instead. +type ProjectEnvironmentTypesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewProjectEnvironmentTypesClient creates a new instance of ProjectEnvironmentTypesClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewProjectEnvironmentTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProjectEnvironmentTypesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ProjectEnvironmentTypesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a project environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// environmentTypeName - The name of the environment type. +// body - Represents a Project Environment Type. +// options - ProjectEnvironmentTypesClientCreateOrUpdateOptions contains the optional parameters for the ProjectEnvironmentTypesClient.CreateOrUpdate +// method. +func (client *ProjectEnvironmentTypesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, body ProjectEnvironmentType, options *ProjectEnvironmentTypesClientCreateOrUpdateOptions) (ProjectEnvironmentTypesClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, projectName, environmentTypeName, body, options) + if err != nil { + return ProjectEnvironmentTypesClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectEnvironmentTypesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectEnvironmentTypesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProjectEnvironmentTypesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, body ProjectEnvironmentType, options *ProjectEnvironmentTypesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProjectEnvironmentTypesClient) createOrUpdateHandleResponse(resp *http.Response) (ProjectEnvironmentTypesClientCreateOrUpdateResponse, error) { + result := ProjectEnvironmentTypesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProjectEnvironmentType); err != nil { + return ProjectEnvironmentTypesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a project environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// environmentTypeName - The name of the environment type. +// options - ProjectEnvironmentTypesClientDeleteOptions contains the optional parameters for the ProjectEnvironmentTypesClient.Delete +// method. +func (client *ProjectEnvironmentTypesClient) Delete(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, options *ProjectEnvironmentTypesClientDeleteOptions) (ProjectEnvironmentTypesClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, environmentTypeName, options) + if err != nil { + return ProjectEnvironmentTypesClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectEnvironmentTypesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return ProjectEnvironmentTypesClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return ProjectEnvironmentTypesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProjectEnvironmentTypesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, options *ProjectEnvironmentTypesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a project environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// environmentTypeName - The name of the environment type. +// options - ProjectEnvironmentTypesClientGetOptions contains the optional parameters for the ProjectEnvironmentTypesClient.Get +// method. +func (client *ProjectEnvironmentTypesClient) Get(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, options *ProjectEnvironmentTypesClientGetOptions) (ProjectEnvironmentTypesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, environmentTypeName, options) + if err != nil { + return ProjectEnvironmentTypesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectEnvironmentTypesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectEnvironmentTypesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProjectEnvironmentTypesClient) getCreateRequest(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, options *ProjectEnvironmentTypesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProjectEnvironmentTypesClient) getHandleResponse(resp *http.Response) (ProjectEnvironmentTypesClientGetResponse, error) { + result := ProjectEnvironmentTypesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProjectEnvironmentType); err != nil { + return ProjectEnvironmentTypesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists environment types for a project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// options - ProjectEnvironmentTypesClientListOptions contains the optional parameters for the ProjectEnvironmentTypesClient.List +// method. +func (client *ProjectEnvironmentTypesClient) NewListPager(resourceGroupName string, projectName string, options *ProjectEnvironmentTypesClientListOptions) *runtime.Pager[ProjectEnvironmentTypesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ProjectEnvironmentTypesClientListResponse]{ + More: func(page ProjectEnvironmentTypesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProjectEnvironmentTypesClientListResponse) (ProjectEnvironmentTypesClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, projectName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProjectEnvironmentTypesClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectEnvironmentTypesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectEnvironmentTypesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ProjectEnvironmentTypesClient) listCreateRequest(ctx context.Context, resourceGroupName string, projectName string, options *ProjectEnvironmentTypesClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ProjectEnvironmentTypesClient) listHandleResponse(resp *http.Response) (ProjectEnvironmentTypesClientListResponse, error) { + result := ProjectEnvironmentTypesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProjectEnvironmentTypeListResult); err != nil { + return ProjectEnvironmentTypesClientListResponse{}, err + } + return result, nil +} + +// Update - Partially updates a project environment type. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// environmentTypeName - The name of the environment type. +// body - Updatable project environment type properties. +// options - ProjectEnvironmentTypesClientUpdateOptions contains the optional parameters for the ProjectEnvironmentTypesClient.Update +// method. +func (client *ProjectEnvironmentTypesClient) Update(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, body ProjectEnvironmentTypeUpdate, options *ProjectEnvironmentTypesClientUpdateOptions) (ProjectEnvironmentTypesClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, projectName, environmentTypeName, body, options) + if err != nil { + return ProjectEnvironmentTypesClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectEnvironmentTypesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectEnvironmentTypesClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ProjectEnvironmentTypesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, environmentTypeName string, body ProjectEnvironmentTypeUpdate, options *ProjectEnvironmentTypesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/environmentTypes/{environmentTypeName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if environmentTypeName == "" { + return nil, errors.New("parameter environmentTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{environmentTypeName}", url.PathEscape(environmentTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// updateHandleResponse handles the Update response. +func (client *ProjectEnvironmentTypesClient) updateHandleResponse(resp *http.Response) (ProjectEnvironmentTypesClientUpdateResponse, error) { + result := ProjectEnvironmentTypesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProjectEnvironmentType); err != nil { + return ProjectEnvironmentTypesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/projects_client.go b/sdk/resourcemanager/devcenter/armdevcenter/projects_client.go new file mode 100644 index 000000000000..702a975aad65 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/projects_client.go @@ -0,0 +1,439 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ProjectsClient contains the methods for the Projects group. +// Don't use this type directly, use NewProjectsClient() instead. +type ProjectsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewProjectsClient creates a new instance of ProjectsClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewProjectsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProjectsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ProjectsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// body - Represents a project. +// options - ProjectsClientBeginCreateOrUpdateOptions contains the optional parameters for the ProjectsClient.BeginCreateOrUpdate +// method. +func (client *ProjectsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, projectName string, body Project, options *ProjectsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ProjectsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, projectName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ProjectsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ProjectsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *ProjectsClient) createOrUpdate(ctx context.Context, resourceGroupName string, projectName string, body Project, options *ProjectsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, projectName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProjectsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, body Project, options *ProjectsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a project resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// options - ProjectsClientBeginDeleteOptions contains the optional parameters for the ProjectsClient.BeginDelete method. +func (client *ProjectsClient) BeginDelete(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientBeginDeleteOptions) (*runtime.Poller[ProjectsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, projectName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ProjectsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ProjectsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a project resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *ProjectsClient) deleteOperation(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProjectsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a specific project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// options - ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. +func (client *ProjectsClient) Get(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientGetOptions) (ProjectsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, options) + if err != nil { + return ProjectsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProjectsClient) getCreateRequest(ctx context.Context, resourceGroupName string, projectName string, options *ProjectsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProjectsClient) getHandleResponse(resp *http.Response) (ProjectsClientGetResponse, error) { + result := ProjectsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Project); err != nil { + return ProjectsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Lists all projects in the resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// options - ProjectsClientListByResourceGroupOptions contains the optional parameters for the ProjectsClient.ListByResourceGroup +// method. +func (client *ProjectsClient) NewListByResourceGroupPager(resourceGroupName string, options *ProjectsClientListByResourceGroupOptions) *runtime.Pager[ProjectsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ProjectsClientListByResourceGroupResponse]{ + More: func(page ProjectsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProjectsClientListByResourceGroupResponse) (ProjectsClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProjectsClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ProjectsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ProjectsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ProjectsClient) listByResourceGroupHandleResponse(resp *http.Response) (ProjectsClientListByResourceGroupResponse, error) { + result := ProjectsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProjectListResult); err != nil { + return ProjectsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists all projects in the subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// options - ProjectsClientListBySubscriptionOptions contains the optional parameters for the ProjectsClient.ListBySubscription +// method. +func (client *ProjectsClient) NewListBySubscriptionPager(options *ProjectsClientListBySubscriptionOptions) *runtime.Pager[ProjectsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ProjectsClientListBySubscriptionResponse]{ + More: func(page ProjectsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProjectsClientListBySubscriptionResponse) (ProjectsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProjectsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ProjectsClient) listBySubscriptionCreateRequest(ctx context.Context, options *ProjectsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/projects" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ProjectsClient) listBySubscriptionHandleResponse(resp *http.Response) (ProjectsClientListBySubscriptionResponse, error) { + result := ProjectsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProjectListResult); err != nil { + return ProjectsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Partially updates a project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// body - Updatable project properties. +// options - ProjectsClientBeginUpdateOptions contains the optional parameters for the ProjectsClient.BeginUpdate method. +func (client *ProjectsClient) BeginUpdate(ctx context.Context, resourceGroupName string, projectName string, body ProjectUpdate, options *ProjectsClientBeginUpdateOptions) (*runtime.Poller[ProjectsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, projectName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ProjectsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[ProjectsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Partially updates a project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *ProjectsClient) update(ctx context.Context, resourceGroupName string, projectName string, body ProjectUpdate, options *ProjectsClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, projectName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *ProjectsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, body ProjectUpdate, options *ProjectsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/response_types.go b/sdk/resourcemanager/devcenter/armdevcenter/response_types.go new file mode 100644 index 000000000000..90effaec0994 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/response_types.go @@ -0,0 +1,375 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +// AttachedNetworksClientCreateOrUpdateResponse contains the response from method AttachedNetworksClient.CreateOrUpdate. +type AttachedNetworksClientCreateOrUpdateResponse struct { + AttachedNetworkConnection +} + +// AttachedNetworksClientDeleteResponse contains the response from method AttachedNetworksClient.Delete. +type AttachedNetworksClientDeleteResponse struct { + // placeholder for future response values +} + +// AttachedNetworksClientGetByDevCenterResponse contains the response from method AttachedNetworksClient.GetByDevCenter. +type AttachedNetworksClientGetByDevCenterResponse struct { + AttachedNetworkConnection +} + +// AttachedNetworksClientGetByProjectResponse contains the response from method AttachedNetworksClient.GetByProject. +type AttachedNetworksClientGetByProjectResponse struct { + AttachedNetworkConnection +} + +// AttachedNetworksClientListByDevCenterResponse contains the response from method AttachedNetworksClient.ListByDevCenter. +type AttachedNetworksClientListByDevCenterResponse struct { + AttachedNetworkListResult +} + +// AttachedNetworksClientListByProjectResponse contains the response from method AttachedNetworksClient.ListByProject. +type AttachedNetworksClientListByProjectResponse struct { + AttachedNetworkListResult +} + +// CatalogsClientCreateOrUpdateResponse contains the response from method CatalogsClient.CreateOrUpdate. +type CatalogsClientCreateOrUpdateResponse struct { + Catalog +} + +// CatalogsClientDeleteResponse contains the response from method CatalogsClient.Delete. +type CatalogsClientDeleteResponse struct { + // placeholder for future response values +} + +// CatalogsClientGetResponse contains the response from method CatalogsClient.Get. +type CatalogsClientGetResponse struct { + Catalog +} + +// CatalogsClientListByDevCenterResponse contains the response from method CatalogsClient.ListByDevCenter. +type CatalogsClientListByDevCenterResponse struct { + CatalogListResult +} + +// CatalogsClientSyncResponse contains the response from method CatalogsClient.Sync. +type CatalogsClientSyncResponse struct { + // placeholder for future response values +} + +// CatalogsClientUpdateResponse contains the response from method CatalogsClient.Update. +type CatalogsClientUpdateResponse struct { + Catalog +} + +// DevBoxDefinitionsClientCreateOrUpdateResponse contains the response from method DevBoxDefinitionsClient.CreateOrUpdate. +type DevBoxDefinitionsClientCreateOrUpdateResponse struct { + DevBoxDefinition +} + +// DevBoxDefinitionsClientDeleteResponse contains the response from method DevBoxDefinitionsClient.Delete. +type DevBoxDefinitionsClientDeleteResponse struct { + // placeholder for future response values +} + +// DevBoxDefinitionsClientGetByProjectResponse contains the response from method DevBoxDefinitionsClient.GetByProject. +type DevBoxDefinitionsClientGetByProjectResponse struct { + DevBoxDefinition +} + +// DevBoxDefinitionsClientGetResponse contains the response from method DevBoxDefinitionsClient.Get. +type DevBoxDefinitionsClientGetResponse struct { + DevBoxDefinition +} + +// DevBoxDefinitionsClientListByDevCenterResponse contains the response from method DevBoxDefinitionsClient.ListByDevCenter. +type DevBoxDefinitionsClientListByDevCenterResponse struct { + DevBoxDefinitionListResult +} + +// DevBoxDefinitionsClientListByProjectResponse contains the response from method DevBoxDefinitionsClient.ListByProject. +type DevBoxDefinitionsClientListByProjectResponse struct { + DevBoxDefinitionListResult +} + +// DevBoxDefinitionsClientUpdateResponse contains the response from method DevBoxDefinitionsClient.Update. +type DevBoxDefinitionsClientUpdateResponse struct { + DevBoxDefinition +} + +// DevCentersClientCreateOrUpdateResponse contains the response from method DevCentersClient.CreateOrUpdate. +type DevCentersClientCreateOrUpdateResponse struct { + DevCenter +} + +// DevCentersClientDeleteResponse contains the response from method DevCentersClient.Delete. +type DevCentersClientDeleteResponse struct { + // placeholder for future response values +} + +// DevCentersClientGetResponse contains the response from method DevCentersClient.Get. +type DevCentersClientGetResponse struct { + DevCenter +} + +// DevCentersClientListByResourceGroupResponse contains the response from method DevCentersClient.ListByResourceGroup. +type DevCentersClientListByResourceGroupResponse struct { + ListResult +} + +// DevCentersClientListBySubscriptionResponse contains the response from method DevCentersClient.ListBySubscription. +type DevCentersClientListBySubscriptionResponse struct { + ListResult +} + +// DevCentersClientUpdateResponse contains the response from method DevCentersClient.Update. +type DevCentersClientUpdateResponse struct { + DevCenter +} + +// EnvironmentTypesClientCreateOrUpdateResponse contains the response from method EnvironmentTypesClient.CreateOrUpdate. +type EnvironmentTypesClientCreateOrUpdateResponse struct { + EnvironmentType +} + +// EnvironmentTypesClientDeleteResponse contains the response from method EnvironmentTypesClient.Delete. +type EnvironmentTypesClientDeleteResponse struct { + // placeholder for future response values +} + +// EnvironmentTypesClientGetResponse contains the response from method EnvironmentTypesClient.Get. +type EnvironmentTypesClientGetResponse struct { + EnvironmentType +} + +// EnvironmentTypesClientListByDevCenterResponse contains the response from method EnvironmentTypesClient.ListByDevCenter. +type EnvironmentTypesClientListByDevCenterResponse struct { + EnvironmentTypeListResult +} + +// EnvironmentTypesClientUpdateResponse contains the response from method EnvironmentTypesClient.Update. +type EnvironmentTypesClientUpdateResponse struct { + EnvironmentType +} + +// GalleriesClientCreateOrUpdateResponse contains the response from method GalleriesClient.CreateOrUpdate. +type GalleriesClientCreateOrUpdateResponse struct { + Gallery +} + +// GalleriesClientDeleteResponse contains the response from method GalleriesClient.Delete. +type GalleriesClientDeleteResponse struct { + // placeholder for future response values +} + +// GalleriesClientGetResponse contains the response from method GalleriesClient.Get. +type GalleriesClientGetResponse struct { + Gallery +} + +// GalleriesClientListByDevCenterResponse contains the response from method GalleriesClient.ListByDevCenter. +type GalleriesClientListByDevCenterResponse struct { + GalleryListResult +} + +// ImageVersionsClientGetResponse contains the response from method ImageVersionsClient.Get. +type ImageVersionsClientGetResponse struct { + ImageVersion +} + +// ImageVersionsClientListByImageResponse contains the response from method ImageVersionsClient.ListByImage. +type ImageVersionsClientListByImageResponse struct { + ImageVersionListResult +} + +// ImagesClientGetResponse contains the response from method ImagesClient.Get. +type ImagesClientGetResponse struct { + Image +} + +// ImagesClientListByDevCenterResponse contains the response from method ImagesClient.ListByDevCenter. +type ImagesClientListByDevCenterResponse struct { + ImageListResult +} + +// ImagesClientListByGalleryResponse contains the response from method ImagesClient.ListByGallery. +type ImagesClientListByGalleryResponse struct { + ImageListResult +} + +// NetworkConnectionsClientCreateOrUpdateResponse contains the response from method NetworkConnectionsClient.CreateOrUpdate. +type NetworkConnectionsClientCreateOrUpdateResponse struct { + NetworkConnection +} + +// NetworkConnectionsClientDeleteResponse contains the response from method NetworkConnectionsClient.Delete. +type NetworkConnectionsClientDeleteResponse struct { + // placeholder for future response values +} + +// NetworkConnectionsClientGetHealthDetailsResponse contains the response from method NetworkConnectionsClient.GetHealthDetails. +type NetworkConnectionsClientGetHealthDetailsResponse struct { + HealthCheckStatusDetails +} + +// NetworkConnectionsClientGetResponse contains the response from method NetworkConnectionsClient.Get. +type NetworkConnectionsClientGetResponse struct { + NetworkConnection +} + +// NetworkConnectionsClientListByResourceGroupResponse contains the response from method NetworkConnectionsClient.ListByResourceGroup. +type NetworkConnectionsClientListByResourceGroupResponse struct { + NetworkConnectionListResult +} + +// NetworkConnectionsClientListBySubscriptionResponse contains the response from method NetworkConnectionsClient.ListBySubscription. +type NetworkConnectionsClientListBySubscriptionResponse struct { + NetworkConnectionListResult +} + +// NetworkConnectionsClientListHealthDetailsResponse contains the response from method NetworkConnectionsClient.ListHealthDetails. +type NetworkConnectionsClientListHealthDetailsResponse struct { + HealthCheckStatusDetailsListResult +} + +// NetworkConnectionsClientRunHealthChecksResponse contains the response from method NetworkConnectionsClient.RunHealthChecks. +type NetworkConnectionsClientRunHealthChecksResponse struct { + // placeholder for future response values +} + +// NetworkConnectionsClientUpdateResponse contains the response from method NetworkConnectionsClient.Update. +type NetworkConnectionsClientUpdateResponse struct { + NetworkConnection +} + +// OperationStatusesClientGetResponse contains the response from method OperationStatusesClient.Get. +type OperationStatusesClientGetResponse struct { + OperationStatus +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationListResult +} + +// PoolsClientCreateOrUpdateResponse contains the response from method PoolsClient.CreateOrUpdate. +type PoolsClientCreateOrUpdateResponse struct { + Pool +} + +// PoolsClientDeleteResponse contains the response from method PoolsClient.Delete. +type PoolsClientDeleteResponse struct { + // placeholder for future response values +} + +// PoolsClientGetResponse contains the response from method PoolsClient.Get. +type PoolsClientGetResponse struct { + Pool +} + +// PoolsClientListByProjectResponse contains the response from method PoolsClient.ListByProject. +type PoolsClientListByProjectResponse struct { + PoolListResult +} + +// PoolsClientUpdateResponse contains the response from method PoolsClient.Update. +type PoolsClientUpdateResponse struct { + Pool +} + +// ProjectEnvironmentTypesClientCreateOrUpdateResponse contains the response from method ProjectEnvironmentTypesClient.CreateOrUpdate. +type ProjectEnvironmentTypesClientCreateOrUpdateResponse struct { + ProjectEnvironmentType +} + +// ProjectEnvironmentTypesClientDeleteResponse contains the response from method ProjectEnvironmentTypesClient.Delete. +type ProjectEnvironmentTypesClientDeleteResponse struct { + // placeholder for future response values +} + +// ProjectEnvironmentTypesClientGetResponse contains the response from method ProjectEnvironmentTypesClient.Get. +type ProjectEnvironmentTypesClientGetResponse struct { + ProjectEnvironmentType +} + +// ProjectEnvironmentTypesClientListResponse contains the response from method ProjectEnvironmentTypesClient.List. +type ProjectEnvironmentTypesClientListResponse struct { + ProjectEnvironmentTypeListResult +} + +// ProjectEnvironmentTypesClientUpdateResponse contains the response from method ProjectEnvironmentTypesClient.Update. +type ProjectEnvironmentTypesClientUpdateResponse struct { + ProjectEnvironmentType +} + +// ProjectsClientCreateOrUpdateResponse contains the response from method ProjectsClient.CreateOrUpdate. +type ProjectsClientCreateOrUpdateResponse struct { + Project +} + +// ProjectsClientDeleteResponse contains the response from method ProjectsClient.Delete. +type ProjectsClientDeleteResponse struct { + // placeholder for future response values +} + +// ProjectsClientGetResponse contains the response from method ProjectsClient.Get. +type ProjectsClientGetResponse struct { + Project +} + +// ProjectsClientListByResourceGroupResponse contains the response from method ProjectsClient.ListByResourceGroup. +type ProjectsClientListByResourceGroupResponse struct { + ProjectListResult +} + +// ProjectsClientListBySubscriptionResponse contains the response from method ProjectsClient.ListBySubscription. +type ProjectsClientListBySubscriptionResponse struct { + ProjectListResult +} + +// ProjectsClientUpdateResponse contains the response from method ProjectsClient.Update. +type ProjectsClientUpdateResponse struct { + Project +} + +// SKUsClientListBySubscriptionResponse contains the response from method SKUsClient.ListBySubscription. +type SKUsClientListBySubscriptionResponse struct { + SKUListResult +} + +// SchedulesClientCreateOrUpdateResponse contains the response from method SchedulesClient.CreateOrUpdate. +type SchedulesClientCreateOrUpdateResponse struct { + Schedule +} + +// SchedulesClientDeleteResponse contains the response from method SchedulesClient.Delete. +type SchedulesClientDeleteResponse struct { + // placeholder for future response values +} + +// SchedulesClientGetResponse contains the response from method SchedulesClient.Get. +type SchedulesClientGetResponse struct { + Schedule +} + +// SchedulesClientListByPoolResponse contains the response from method SchedulesClient.ListByPool. +type SchedulesClientListByPoolResponse struct { + ScheduleListResult +} + +// SchedulesClientUpdateResponse contains the response from method SchedulesClient.Update. +type SchedulesClientUpdateResponse struct { + // placeholder for future response values +} + +// UsagesClientListByLocationResponse contains the response from method UsagesClient.ListByLocation. +type UsagesClientListByLocationResponse struct { + ListUsagesResult +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/schedules_client.go b/sdk/resourcemanager/devcenter/armdevcenter/schedules_client.go new file mode 100644 index 000000000000..764fbf36805b --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/schedules_client.go @@ -0,0 +1,437 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// SchedulesClient contains the methods for the Schedules group. +// Don't use this type directly, use NewSchedulesClient() instead. +type SchedulesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewSchedulesClient creates a new instance of SchedulesClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewSchedulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SchedulesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &SchedulesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates a Schedule. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// scheduleName - The name of the schedule that uniquely identifies it. +// body - Represents a scheduled task +// options - SchedulesClientBeginCreateOrUpdateOptions contains the optional parameters for the SchedulesClient.BeginCreateOrUpdate +// method. +func (client *SchedulesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, body Schedule, options *SchedulesClientBeginCreateOrUpdateOptions) (*runtime.Poller[SchedulesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, projectName, poolName, scheduleName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SchedulesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[SchedulesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates a Schedule. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *SchedulesClient) createOrUpdate(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, body Schedule, options *SchedulesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, projectName, poolName, scheduleName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SchedulesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, body Schedule, options *SchedulesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginDelete - Deletes a Scheduled. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// scheduleName - The name of the schedule that uniquely identifies it. +// options - SchedulesClientBeginDeleteOptions contains the optional parameters for the SchedulesClient.BeginDelete method. +func (client *SchedulesClient) BeginDelete(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, options *SchedulesClientBeginDeleteOptions) (*runtime.Poller[SchedulesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, projectName, poolName, scheduleName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SchedulesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[SchedulesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a Scheduled. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *SchedulesClient) deleteOperation(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, options *SchedulesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, projectName, poolName, scheduleName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SchedulesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, options *SchedulesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a schedule resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// scheduleName - The name of the schedule that uniquely identifies it. +// options - SchedulesClientGetOptions contains the optional parameters for the SchedulesClient.Get method. +func (client *SchedulesClient) Get(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, options *SchedulesClientGetOptions) (SchedulesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, projectName, poolName, scheduleName, options) + if err != nil { + return SchedulesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SchedulesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SchedulesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SchedulesClient) getCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, options *SchedulesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SchedulesClient) getHandleResponse(resp *http.Response) (SchedulesClientGetResponse, error) { + result := SchedulesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Schedule); err != nil { + return SchedulesClientGetResponse{}, err + } + return result, nil +} + +// NewListByPoolPager - Lists schedules for a pool +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// options - SchedulesClientListByPoolOptions contains the optional parameters for the SchedulesClient.ListByPool method. +func (client *SchedulesClient) NewListByPoolPager(resourceGroupName string, projectName string, poolName string, options *SchedulesClientListByPoolOptions) *runtime.Pager[SchedulesClientListByPoolResponse] { + return runtime.NewPager(runtime.PagingHandler[SchedulesClientListByPoolResponse]{ + More: func(page SchedulesClientListByPoolResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SchedulesClientListByPoolResponse) (SchedulesClientListByPoolResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByPoolCreateRequest(ctx, resourceGroupName, projectName, poolName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SchedulesClientListByPoolResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SchedulesClientListByPoolResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SchedulesClientListByPoolResponse{}, runtime.NewResponseError(resp) + } + return client.listByPoolHandleResponse(resp) + }, + }) +} + +// listByPoolCreateRequest creates the ListByPool request. +func (client *SchedulesClient) listByPoolCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, options *SchedulesClientListByPoolOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByPoolHandleResponse handles the ListByPool response. +func (client *SchedulesClient) listByPoolHandleResponse(resp *http.Response) (SchedulesClientListByPoolResponse, error) { + result := SchedulesClientListByPoolResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ScheduleListResult); err != nil { + return SchedulesClientListByPoolResponse{}, err + } + return result, nil +} + +// BeginUpdate - Partially updates a Scheduled. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// resourceGroupName - Name of the resource group within the Azure subscription. +// projectName - The name of the project. +// poolName - Name of the pool. +// scheduleName - The name of the schedule that uniquely identifies it. +// body - Represents a scheduled task. +// options - SchedulesClientBeginUpdateOptions contains the optional parameters for the SchedulesClient.BeginUpdate method. +func (client *SchedulesClient) BeginUpdate(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, body ScheduleUpdate, options *SchedulesClientBeginUpdateOptions) (*runtime.Poller[SchedulesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, projectName, poolName, scheduleName, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[SchedulesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[SchedulesClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Partially updates a Scheduled. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +func (client *SchedulesClient) update(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, body ScheduleUpdate, options *SchedulesClientBeginUpdateOptions) (*http.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, projectName, poolName, scheduleName, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *SchedulesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, projectName string, poolName string, scheduleName string, body ScheduleUpdate, options *SchedulesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevCenter/projects/{projectName}/pools/{poolName}/schedules/{scheduleName}" + 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 projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if poolName == "" { + return nil, errors.New("parameter poolName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{poolName}", url.PathEscape(poolName)) + if scheduleName == "" { + return nil, errors.New("parameter scheduleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scheduleName}", url.PathEscape(scheduleName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/skus_client.go b/sdk/resourcemanager/devcenter/armdevcenter/skus_client.go new file mode 100644 index 000000000000..e4f996000abd --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/skus_client.go @@ -0,0 +1,119 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// SKUsClient contains the methods for the SKUs group. +// Don't use this type directly, use NewSKUsClient() instead. +type SKUsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewSKUsClient creates a new instance of SKUsClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &SKUsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListBySubscriptionPager - Lists the Microsoft.DevCenter SKUs available in a subscription +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// options - SKUsClientListBySubscriptionOptions contains the optional parameters for the SKUsClient.ListBySubscription method. +func (client *SKUsClient) NewListBySubscriptionPager(options *SKUsClientListBySubscriptionOptions) *runtime.Pager[SKUsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[SKUsClientListBySubscriptionResponse]{ + More: func(page SKUsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SKUsClientListBySubscriptionResponse) (SKUsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return SKUsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return SKUsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SKUsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *SKUsClient) listBySubscriptionCreateRequest(ctx context.Context, options *SKUsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/skus" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *SKUsClient) listBySubscriptionHandleResponse(resp *http.Response) (SKUsClientListBySubscriptionResponse, error) { + result := SKUsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SKUListResult); err != nil { + return SKUsClientListBySubscriptionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/time_rfc3339.go b/sdk/resourcemanager/devcenter/armdevcenter/time_rfc3339.go new file mode 100644 index 000000000000..38cf1ddfbb72 --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/time_rfc3339.go @@ -0,0 +1,87 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/devcenter/armdevcenter/usages_client.go b/sdk/resourcemanager/devcenter/armdevcenter/usages_client.go new file mode 100644 index 000000000000..84ddc861fa9e --- /dev/null +++ b/sdk/resourcemanager/devcenter/armdevcenter/usages_client.go @@ -0,0 +1,120 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armdevcenter + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// UsagesClient contains the methods for the Usages group. +// Don't use this type directly, use NewUsagesClient() instead. +type UsagesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewUsagesClient creates a new instance of UsagesClient with the specified values. +// subscriptionID - Unique identifier of the Azure subscription. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewUsagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsagesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &UsagesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// NewListByLocationPager - Lists the current usages and limits in this location for the provided subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-08-01-preview +// location - The Azure region +// options - UsagesClientListByLocationOptions contains the optional parameters for the UsagesClient.ListByLocation method. +func (client *UsagesClient) NewListByLocationPager(location string, options *UsagesClientListByLocationOptions) *runtime.Pager[UsagesClientListByLocationResponse] { + return runtime.NewPager(runtime.PagingHandler[UsagesClientListByLocationResponse]{ + More: func(page UsagesClientListByLocationResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *UsagesClientListByLocationResponse) (UsagesClientListByLocationResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByLocationCreateRequest(ctx, location, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return UsagesClientListByLocationResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return UsagesClientListByLocationResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return UsagesClientListByLocationResponse{}, runtime.NewResponseError(resp) + } + return client.listByLocationHandleResponse(resp) + }, + }) +} + +// listByLocationCreateRequest creates the ListByLocation request. +func (client *UsagesClient) listByLocationCreateRequest(ctx context.Context, location string, options *UsagesClientListByLocationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DevCenter/locations/{location}/usages" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-08-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByLocationHandleResponse handles the ListByLocation response. +func (client *UsagesClient) listByLocationHandleResponse(resp *http.Response) (UsagesClientListByLocationResponse, error) { + result := UsagesClientListByLocationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListUsagesResult); err != nil { + return UsagesClientListByLocationResponse{}, err + } + return result, nil +}