diff --git a/sdk/resourcemanager/azurestack/armazurestack/CHANGELOG.md b/sdk/resourcemanager/azurestack/armazurestack/CHANGELOG.md new file mode 100644 index 000000000000..28fc969317c9 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/CHANGELOG.md @@ -0,0 +1,9 @@ +# Release History + +## 0.1.0 (2022-07-19) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestack/armazurestack` 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/azurestack/armazurestack/LICENSE.txt b/sdk/resourcemanager/azurestack/armazurestack/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/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/azurestack/armazurestack/README.md b/sdk/resourcemanager/azurestack/armazurestack/README.md new file mode 100644 index 000000000000..44022bbf874c --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/README.md @@ -0,0 +1,77 @@ +# Azure Azurestack Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestack/armazurestack)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestack/armazurestack) + +The `armazurestack` module provides operations for working with Azure Azurestack. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/azurestack/armazurestack) + +# 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 Azurestack module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestack/armazurestack +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Azurestack. 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 Azurestack 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 := armazurestack.NewDeploymentLicenseClient(, 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 := armazurestack.NewDeploymentLicenseClient(, 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 `Azurestack` 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/azurestack/armazurestack/autorest.md b/sdk/resourcemanager/azurestack/armazurestack/autorest.md new file mode 100644 index 000000000000..4046a26d1232 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/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/azurestack/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/azurestack/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/azurestack/armazurestack/build.go b/sdk/resourcemanager/azurestack/armazurestack/build.go new file mode 100644 index 000000000000..3f2474d5bf80 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/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/azurestack/armazurestack + +package armazurestack diff --git a/sdk/resourcemanager/azurestack/armazurestack/ci.yml b/sdk/resourcemanager/azurestack/armazurestack/ci.yml new file mode 100644 index 000000000000..a801dea40128 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/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/azurestack/armazurestack/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/azurestack/armazurestack/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/azurestack/armazurestack' diff --git a/sdk/resourcemanager/azurestack/armazurestack/cloudmanifestfile_client.go b/sdk/resourcemanager/azurestack/armazurestack/cloudmanifestfile_client.go new file mode 100644 index 000000000000..24254c81e797 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/cloudmanifestfile_client.go @@ -0,0 +1,145 @@ +//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 armazurestack + +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" +) + +// CloudManifestFileClient contains the methods for the CloudManifestFile group. +// Don't use this type directly, use NewCloudManifestFileClient() instead. +type CloudManifestFileClient struct { + host string + pl runtime.Pipeline +} + +// NewCloudManifestFileClient creates a new instance of CloudManifestFileClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewCloudManifestFileClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*CloudManifestFileClient, 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 := &CloudManifestFileClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Returns a cloud specific manifest JSON file. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// verificationVersion - Signing verification key version. +// options - CloudManifestFileClientGetOptions contains the optional parameters for the CloudManifestFileClient.Get method. +func (client *CloudManifestFileClient) Get(ctx context.Context, verificationVersion string, options *CloudManifestFileClientGetOptions) (CloudManifestFileClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, verificationVersion, options) + if err != nil { + return CloudManifestFileClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CloudManifestFileClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CloudManifestFileClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CloudManifestFileClient) getCreateRequest(ctx context.Context, verificationVersion string, options *CloudManifestFileClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureStack/cloudManifestFiles/{verificationVersion}" + if verificationVersion == "" { + return nil, errors.New("parameter verificationVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{verificationVersion}", url.PathEscape(verificationVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.VersionCreationDate != nil { + reqQP.Set("versionCreationDate", *options.VersionCreationDate) + } + reqQP.Set("api-version", "2022-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CloudManifestFileClient) getHandleResponse(resp *http.Response) (CloudManifestFileClientGetResponse, error) { + result := CloudManifestFileClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CloudManifestFileResponse); err != nil { + return CloudManifestFileClientGetResponse{}, err + } + return result, nil +} + +// List - Returns a cloud specific manifest JSON file with latest version. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// options - CloudManifestFileClientListOptions contains the optional parameters for the CloudManifestFileClient.List method. +func (client *CloudManifestFileClient) List(ctx context.Context, options *CloudManifestFileClientListOptions) (CloudManifestFileClientListResponse, error) { + req, err := client.listCreateRequest(ctx, options) + if err != nil { + return CloudManifestFileClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CloudManifestFileClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CloudManifestFileClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) +} + +// listCreateRequest creates the List request. +func (client *CloudManifestFileClient) listCreateRequest(ctx context.Context, options *CloudManifestFileClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureStack/cloudManifestFiles" + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CloudManifestFileClient) listHandleResponse(resp *http.Response) (CloudManifestFileClientListResponse, error) { + result := CloudManifestFileClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CloudManifestFileResponse); err != nil { + return CloudManifestFileClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/constants.go b/sdk/resourcemanager/azurestack/armazurestack/constants.go new file mode 100644 index 000000000000..9864049d2f62 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/constants.go @@ -0,0 +1,133 @@ +//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 armazurestack + +const ( + moduleName = "armazurestack" + moduleVersion = "v0.1.0" +) + +// Category - Identity system of the device. +type Category string + +const ( + CategoryADFS Category = "ADFS" + CategoryAzureAD Category = "AzureAD" +) + +// PossibleCategoryValues returns the possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{ + CategoryADFS, + CategoryAzureAD, + } +} + +// CompatibilityIssue - Compatibility issue +type CompatibilityIssue string + +const ( + CompatibilityIssueADFSIdentitySystemRequired CompatibilityIssue = "ADFSIdentitySystemRequired" + CompatibilityIssueAzureADIdentitySystemRequired CompatibilityIssue = "AzureADIdentitySystemRequired" + CompatibilityIssueCapacityBillingModelRequired CompatibilityIssue = "CapacityBillingModelRequired" + CompatibilityIssueConnectionToAzureRequired CompatibilityIssue = "ConnectionToAzureRequired" + CompatibilityIssueConnectionToInternetRequired CompatibilityIssue = "ConnectionToInternetRequired" + CompatibilityIssueDevelopmentBillingModelRequired CompatibilityIssue = "DevelopmentBillingModelRequired" + CompatibilityIssueDisconnectedEnvironmentRequired CompatibilityIssue = "DisconnectedEnvironmentRequired" + CompatibilityIssueHigherDeviceVersionRequired CompatibilityIssue = "HigherDeviceVersionRequired" + CompatibilityIssueLowerDeviceVersionRequired CompatibilityIssue = "LowerDeviceVersionRequired" + CompatibilityIssuePayAsYouGoBillingModelRequired CompatibilityIssue = "PayAsYouGoBillingModelRequired" +) + +// PossibleCompatibilityIssueValues returns the possible values for the CompatibilityIssue const type. +func PossibleCompatibilityIssueValues() []CompatibilityIssue { + return []CompatibilityIssue{ + CompatibilityIssueADFSIdentitySystemRequired, + CompatibilityIssueAzureADIdentitySystemRequired, + CompatibilityIssueCapacityBillingModelRequired, + CompatibilityIssueConnectionToAzureRequired, + CompatibilityIssueConnectionToInternetRequired, + CompatibilityIssueDevelopmentBillingModelRequired, + CompatibilityIssueDisconnectedEnvironmentRequired, + CompatibilityIssueHigherDeviceVersionRequired, + CompatibilityIssueLowerDeviceVersionRequired, + CompatibilityIssuePayAsYouGoBillingModelRequired, + } +} + +// ComputeRole - Compute role type (IaaS or PaaS). +type ComputeRole string + +const ( + ComputeRoleIaaS ComputeRole = "IaaS" + ComputeRoleNone ComputeRole = "None" + ComputeRolePaaS ComputeRole = "PaaS" +) + +// PossibleComputeRoleValues returns the possible values for the ComputeRole const type. +func PossibleComputeRoleValues() []ComputeRole { + return []ComputeRole{ + ComputeRoleIaaS, + ComputeRoleNone, + ComputeRolePaaS, + } +} + +// Location - Location of the resource. +type Location string + +const ( + LocationGlobal Location = "global" +) + +// PossibleLocationValues returns the possible values for the Location const type. +func PossibleLocationValues() []Location { + return []Location{ + LocationGlobal, + } +} + +// OperatingSystem - Operating system type (Windows or Linux). +type OperatingSystem string + +const ( + OperatingSystemLinux OperatingSystem = "Linux" + OperatingSystemNone OperatingSystem = "None" + OperatingSystemWindows OperatingSystem = "Windows" +) + +// PossibleOperatingSystemValues returns the possible values for the OperatingSystem const type. +func PossibleOperatingSystemValues() []OperatingSystem { + return []OperatingSystem{ + OperatingSystemLinux, + OperatingSystemNone, + OperatingSystemWindows, + } +} + +// ProvisioningState - The provisioning state of the resource. +type ProvisioningState string + +const ( + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateCanceled ProvisioningState = "Canceled" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCreating, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateCanceled, + } +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/customersubscriptions_client.go b/sdk/resourcemanager/azurestack/armazurestack/customersubscriptions_client.go new file mode 100644 index 000000000000..22600b5cc5f4 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/customersubscriptions_client.go @@ -0,0 +1,305 @@ +//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 armazurestack + +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" +) + +// CustomerSubscriptionsClient contains the methods for the CustomerSubscriptions group. +// Don't use this type directly, use NewCustomerSubscriptionsClient() instead. +type CustomerSubscriptionsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewCustomerSubscriptionsClient creates a new instance of CustomerSubscriptionsClient with the specified values. +// subscriptionID - Subscription credentials that uniquely identify Microsoft Azure subscription. The subscription ID forms +// part of the URI for every service call. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewCustomerSubscriptionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CustomerSubscriptionsClient, 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 := &CustomerSubscriptionsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Create - Creates a new customer subscription under a registration. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// customerSubscriptionName - Name of the product. +// customerCreationParameters - Parameters use to create a customer subscription. +// options - CustomerSubscriptionsClientCreateOptions contains the optional parameters for the CustomerSubscriptionsClient.Create +// method. +func (client *CustomerSubscriptionsClient) Create(ctx context.Context, resourceGroup string, registrationName string, customerSubscriptionName string, customerCreationParameters CustomerSubscription, options *CustomerSubscriptionsClientCreateOptions) (CustomerSubscriptionsClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroup, registrationName, customerSubscriptionName, customerCreationParameters, options) + if err != nil { + return CustomerSubscriptionsClientCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CustomerSubscriptionsClientCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CustomerSubscriptionsClientCreateResponse{}, runtime.NewResponseError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *CustomerSubscriptionsClient) createCreateRequest(ctx context.Context, resourceGroup string, registrationName string, customerSubscriptionName string, customerCreationParameters CustomerSubscription, options *CustomerSubscriptionsClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if customerSubscriptionName == "" { + return nil, errors.New("parameter customerSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerSubscriptionName}", url.PathEscape(customerSubscriptionName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, customerCreationParameters) +} + +// createHandleResponse handles the Create response. +func (client *CustomerSubscriptionsClient) createHandleResponse(resp *http.Response) (CustomerSubscriptionsClientCreateResponse, error) { + result := CustomerSubscriptionsClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomerSubscription); err != nil { + return CustomerSubscriptionsClientCreateResponse{}, err + } + return result, nil +} + +// Delete - Deletes a customer subscription under a registration. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// customerSubscriptionName - Name of the product. +// options - CustomerSubscriptionsClientDeleteOptions contains the optional parameters for the CustomerSubscriptionsClient.Delete +// method. +func (client *CustomerSubscriptionsClient) Delete(ctx context.Context, resourceGroup string, registrationName string, customerSubscriptionName string, options *CustomerSubscriptionsClientDeleteOptions) (CustomerSubscriptionsClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroup, registrationName, customerSubscriptionName, options) + if err != nil { + return CustomerSubscriptionsClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CustomerSubscriptionsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return CustomerSubscriptionsClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return CustomerSubscriptionsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CustomerSubscriptionsClient) deleteCreateRequest(ctx context.Context, resourceGroup string, registrationName string, customerSubscriptionName string, options *CustomerSubscriptionsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if customerSubscriptionName == "" { + return nil, errors.New("parameter customerSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerSubscriptionName}", url.PathEscape(customerSubscriptionName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// customerSubscriptionName - Name of the product. +// options - CustomerSubscriptionsClientGetOptions contains the optional parameters for the CustomerSubscriptionsClient.Get +// method. +func (client *CustomerSubscriptionsClient) Get(ctx context.Context, resourceGroup string, registrationName string, customerSubscriptionName string, options *CustomerSubscriptionsClientGetOptions) (CustomerSubscriptionsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroup, registrationName, customerSubscriptionName, options) + if err != nil { + return CustomerSubscriptionsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CustomerSubscriptionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CustomerSubscriptionsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CustomerSubscriptionsClient) getCreateRequest(ctx context.Context, resourceGroup string, registrationName string, customerSubscriptionName string, options *CustomerSubscriptionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions/{customerSubscriptionName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if customerSubscriptionName == "" { + return nil, errors.New("parameter customerSubscriptionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{customerSubscriptionName}", url.PathEscape(customerSubscriptionName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CustomerSubscriptionsClient) getHandleResponse(resp *http.Response) (CustomerSubscriptionsClientGetResponse, error) { + result := CustomerSubscriptionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomerSubscription); err != nil { + return CustomerSubscriptionsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Returns a list of products. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// options - CustomerSubscriptionsClientListOptions contains the optional parameters for the CustomerSubscriptionsClient.List +// method. +func (client *CustomerSubscriptionsClient) NewListPager(resourceGroup string, registrationName string, options *CustomerSubscriptionsClientListOptions) *runtime.Pager[CustomerSubscriptionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[CustomerSubscriptionsClientListResponse]{ + More: func(page CustomerSubscriptionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CustomerSubscriptionsClientListResponse) (CustomerSubscriptionsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroup, registrationName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CustomerSubscriptionsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return CustomerSubscriptionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CustomerSubscriptionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *CustomerSubscriptionsClient) listCreateRequest(ctx context.Context, resourceGroup string, registrationName string, options *CustomerSubscriptionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/customerSubscriptions" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CustomerSubscriptionsClient) listHandleResponse(resp *http.Response) (CustomerSubscriptionsClientListResponse, error) { + result := CustomerSubscriptionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CustomerSubscriptionList); err != nil { + return CustomerSubscriptionsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/deploymentlicense_client.go b/sdk/resourcemanager/azurestack/armazurestack/deploymentlicense_client.go new file mode 100644 index 000000000000..c15ce0203eb0 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/deploymentlicense_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 armazurestack + +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" +) + +// DeploymentLicenseClient contains the methods for the DeploymentLicense group. +// Don't use this type directly, use NewDeploymentLicenseClient() instead. +type DeploymentLicenseClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewDeploymentLicenseClient creates a new instance of DeploymentLicenseClient with the specified values. +// subscriptionID - Subscription credentials that uniquely identify Microsoft Azure subscription. The subscription ID forms +// part of the URI for every service call. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewDeploymentLicenseClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeploymentLicenseClient, 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 := &DeploymentLicenseClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Create - Creates a license that can be used to deploy an Azure Stack device. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// deploymentLicenseRequest - Request body for creating a deployment license. +// options - DeploymentLicenseClientCreateOptions contains the optional parameters for the DeploymentLicenseClient.Create +// method. +func (client *DeploymentLicenseClient) Create(ctx context.Context, deploymentLicenseRequest DeploymentLicenseRequest, options *DeploymentLicenseClientCreateOptions) (DeploymentLicenseClientCreateResponse, error) { + req, err := client.createCreateRequest(ctx, deploymentLicenseRequest, options) + if err != nil { + return DeploymentLicenseClientCreateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return DeploymentLicenseClientCreateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DeploymentLicenseClientCreateResponse{}, runtime.NewResponseError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *DeploymentLicenseClient) createCreateRequest(ctx context.Context, deploymentLicenseRequest DeploymentLicenseRequest, options *DeploymentLicenseClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/generateDeploymentLicense" + 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.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, deploymentLicenseRequest) +} + +// createHandleResponse handles the Create response. +func (client *DeploymentLicenseClient) createHandleResponse(resp *http.Response) (DeploymentLicenseClientCreateResponse, error) { + result := DeploymentLicenseClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentLicenseResponse); err != nil { + return DeploymentLicenseClientCreateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/go.mod b/sdk/resourcemanager/azurestack/armazurestack/go.mod new file mode 100644 index 000000000000..3eac91992090 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azurestack/armazurestack + +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/azurestack/armazurestack/go.sum b/sdk/resourcemanager/azurestack/armazurestack/go.sum new file mode 100644 index 000000000000..3afb578030a5 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/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/azurestack/armazurestack/models.go b/sdk/resourcemanager/azurestack/armazurestack/models.go new file mode 100644 index 000000000000..c7202a3ac7a5 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/models.go @@ -0,0 +1,682 @@ +//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 armazurestack + +// ActivationKeyResult - The resource containing the Azure Stack activation key. +type ActivationKeyResult struct { + // Azure Stack activation key. + ActivationKey *string `json:"activationKey,omitempty"` +} + +// CloudManifestFileClientGetOptions contains the optional parameters for the CloudManifestFileClient.Get method. +type CloudManifestFileClientGetOptions struct { + // Signing verification key version creation date. + VersionCreationDate *string +} + +// CloudManifestFileClientListOptions contains the optional parameters for the CloudManifestFileClient.List method. +type CloudManifestFileClientListOptions struct { + // placeholder for future optional parameters +} + +// CloudManifestFileDeploymentData - Cloud specific manifest data for AzureStack deployment. +type CloudManifestFileDeploymentData struct { + // Signing verification public key. + CustomCloudVerificationKey *string `json:"customCloudVerificationKey,omitempty"` + + // Environment endpoints. + CustomEnvironmentEndpoints *CloudManifestFileEnvironmentEndpoints `json:"customEnvironmentEndpoints,omitempty"` + + // Dsms external certificates. + ExternalDsmsCertificates *string `json:"externalDsmsCertificates,omitempty"` +} + +// CloudManifestFileEnvironmentEndpoints - Cloud specific environment endpoints for AzureStack deployment. +type CloudManifestFileEnvironmentEndpoints struct { + // ARM endpoint. + CustomCloudArmEndpoint *string `json:"customCloudArmEndpoint,omitempty"` + + // Dsms endpoint. + ExternalDsmsEndpoint *string `json:"externalDsmsEndpoint,omitempty"` +} + +// CloudManifestFileProperties - Cloud specific manifest JSON properties. +type CloudManifestFileProperties struct { + // Cloud specific manifest data. + DeploymentData *CloudManifestFileDeploymentData `json:"deploymentData,omitempty"` + + // Signature of the cloud specific manifest data. + Signature *string `json:"signature,omitempty"` +} + +// CloudManifestFileResponse - Cloud specific manifest GET response. +type CloudManifestFileResponse struct { + // The entity tag used for optimistic concurrency when modifying the resource. + Etag *string `json:"etag,omitempty"` + + // Cloud specific manifest data. + Properties *CloudManifestFileProperties `json:"properties,omitempty"` + + // READ-ONLY; ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of Resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// Compatibility - Product compatibility +type Compatibility struct { + // Full error message if any compatibility issues are found + Description *string `json:"description,omitempty"` + + // Tells if product is compatible with current device + IsCompatible *bool `json:"isCompatible,omitempty"` + + // List of all issues found + Issues []*CompatibilityIssue `json:"issues,omitempty"` + + // Short error message if any compatibility issues are found + Message *string `json:"message,omitempty"` +} + +// CustomerSubscription - Customer subscription. +type CustomerSubscription struct { + // The entity tag used for optimistic concurrency when modifying the resource. + Etag *string `json:"etag,omitempty"` + + // Customer subscription properties. + Properties *CustomerSubscriptionProperties `json:"properties,omitempty"` + + // READ-ONLY; ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of Resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// CustomerSubscriptionList - Pageable list of customer subscriptions. +type CustomerSubscriptionList struct { + // URI to the next page. + NextLink *string `json:"nextLink,omitempty"` + + // List of customer subscriptions. + Value []*CustomerSubscription `json:"value,omitempty"` +} + +// CustomerSubscriptionProperties - Customer subscription properties. +type CustomerSubscriptionProperties struct { + // Tenant Id. + TenantID *string `json:"tenantId,omitempty"` +} + +// CustomerSubscriptionsClientCreateOptions contains the optional parameters for the CustomerSubscriptionsClient.Create method. +type CustomerSubscriptionsClientCreateOptions struct { + // placeholder for future optional parameters +} + +// CustomerSubscriptionsClientDeleteOptions contains the optional parameters for the CustomerSubscriptionsClient.Delete method. +type CustomerSubscriptionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// CustomerSubscriptionsClientGetOptions contains the optional parameters for the CustomerSubscriptionsClient.Get method. +type CustomerSubscriptionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// CustomerSubscriptionsClientListOptions contains the optional parameters for the CustomerSubscriptionsClient.List method. +type CustomerSubscriptionsClientListOptions struct { + // placeholder for future optional parameters +} + +// DataDiskImage - Data disk image. +type DataDiskImage struct { + // READ-ONLY; The LUN. + Lun *int32 `json:"lun,omitempty" azure:"ro"` + + // READ-ONLY; SAS key for source blob. + SourceBlobSasURI *string `json:"sourceBlobSasUri,omitempty" azure:"ro"` +} + +// DeploymentLicenseClientCreateOptions contains the optional parameters for the DeploymentLicenseClient.Create method. +type DeploymentLicenseClientCreateOptions struct { + // placeholder for future optional parameters +} + +// DeploymentLicenseRequest - Request details for generating a deployment license. +type DeploymentLicenseRequest struct { + // Signing verification public key version. + VerificationVersion *string `json:"verificationVersion,omitempty"` +} + +// DeploymentLicenseResponse - A license that can be used to deploy an Azure Stack device. +type DeploymentLicenseResponse struct { + // Signature of the license chain. + Signature *string `json:"signature,omitempty"` + + // A license chain that can be used to temporarily activate an Azure Stack device. + TemporaryLicenseChain []*string `json:"temporaryLicenseChain,omitempty"` +} + +// DeviceConfiguration - Device Configuration. +type DeviceConfiguration struct { + // READ-ONLY; Version of the device. + DeviceVersion *string `json:"deviceVersion,omitempty" azure:"ro"` + + // READ-ONLY; Identity system of the device. + IdentitySystem *Category `json:"identitySystem,omitempty" azure:"ro"` +} + +// Display - Contains the localized display information for this particular operation or action. +type Display struct { + // The localized, friendly description for the operation. The description will be displayed to the user. It should be thorough + // and concise for used in both tooltips and detailed views. + Description *string `json:"description,omitempty"` + + // The localized, friendly name for the operation. Use the name as it will displayed to the user. + Operation *string `json:"operation,omitempty"` + + // The localized, friendly version of the resource provider name. + Provider *string `json:"provider,omitempty"` + + // The localized, friendly version of the resource type related to this action or operation; the resource type should match + // the public documentation for the resource provider. + Resource *string `json:"resource,omitempty"` +} + +// ErrorDetails - The details of the error. +type ErrorDetails struct { + // READ-ONLY; Error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The target of the particular error. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorResponse - Error response indicates that the service is not able to process the incoming request. The reason is provided +// in the error message. +type ErrorResponse struct { + // The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// ExtendedProduct - Extended description about the product required for installing it into Azure Stack. +type ExtendedProduct struct { + // READ-ONLY; The URI to the .azpkg file that provides information required for showing product in the gallery. + GalleryPackageBlobSasURI *string `json:"galleryPackageBlobSasUri,omitempty" azure:"ro"` + + // READ-ONLY; Specifies the kind of the product (virtualMachine or virtualMachineExtension). + ProductKind *string `json:"productKind,omitempty" azure:"ro"` + + // READ-ONLY; Specifies additional properties describing the product. + Properties *ExtendedProductProperties `json:"properties,omitempty" azure:"ro"` +} + +// ExtendedProductProperties - Product information. +type ExtendedProductProperties struct { + // READ-ONLY; Specifies kind of compute role included in the package. + ComputeRole *ComputeRole `json:"computeRole,omitempty" azure:"ro"` + + // READ-ONLY; List of attached data disks. + DataDiskImages []*DataDiskImage `json:"dataDiskImages,omitempty" azure:"ro"` + + // READ-ONLY; Specifies if product is a Virtual Machine Extension. + IsSystemExtension *bool `json:"isSystemExtension,omitempty" azure:"ro"` + + // READ-ONLY; OS disk image used by product. + OSDiskImage *OsDiskImage `json:"osDiskImage,omitempty" azure:"ro"` + + // READ-ONLY; Specifies a download location where content can be downloaded from. + SourceBlob *URI `json:"sourceBlob,omitempty" azure:"ro"` + + // READ-ONLY; Indicates if specified product supports multiple extensions. + SupportMultipleExtensions *bool `json:"supportMultipleExtensions,omitempty" azure:"ro"` + + // READ-ONLY; Specifies operating system used by the product. + VMOsType *OperatingSystem `json:"vmOsType,omitempty" azure:"ro"` + + // READ-ONLY; Indicates if virtual machine Scale Set is enabled in the specified product. + VMScaleSetEnabled *bool `json:"vmScaleSetEnabled,omitempty" azure:"ro"` + + // READ-ONLY; Specifies product version. + Version *string `json:"version,omitempty" azure:"ro"` +} + +// IconUris - Links to product icons. +type IconUris struct { + // URI to hero icon. + Hero *string `json:"hero,omitempty"` + + // URI to large icon. + Large *string `json:"large,omitempty"` + + // URI to medium icon. + Medium *string `json:"medium,omitempty"` + + // URI to small icon. + Small *string `json:"small,omitempty"` + + // URI to wide icon. + Wide *string `json:"wide,omitempty"` +} + +// MarketplaceProductLogUpdate - Update details for product log. +type MarketplaceProductLogUpdate struct { + // READ-ONLY; Error details related to operation. + Details *string `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; Error related to the operation. + Error *string `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; Operation to log. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Operation status to log. + Status *string `json:"status,omitempty" azure:"ro"` +} + +// Operation - Describes the supported REST operation. +type Operation struct { + // Contains the localized display information for this particular operation or action. + Display *Display `json:"display,omitempty"` + + // The name of the operation being performed on this particular object. + Name *string `json:"name,omitempty"` + + // The intended executor of the operation. + Origin *string `json:"origin,omitempty"` +} + +// OperationList - List of Operations +type OperationList struct { + // URI to the next page of operations. + NextLink *string `json:"nextLink,omitempty"` + + // Array of operations + Value []*Operation `json:"value,omitempty"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OsDiskImage - OS disk image. +type OsDiskImage struct { + // READ-ONLY; OS operating system type. + OperatingSystem *OperatingSystem `json:"operatingSystem,omitempty" azure:"ro"` + + // READ-ONLY; SAS key for source blob. + SourceBlobSasURI *string `json:"sourceBlobSasUri,omitempty" azure:"ro"` +} + +// Product information. +type Product struct { + // The entity tag used for optimistic concurrency when modifying the resource. + Etag *string `json:"etag,omitempty"` + + // Properties of the product resource. + Properties *ProductNestedProperties `json:"properties,omitempty"` + + // READ-ONLY; ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of Resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ProductLink - Link with additional information about a product. +type ProductLink struct { + // The description of the link. + DisplayName *string `json:"displayName,omitempty"` + + // The URI corresponding to the link. + URI *string `json:"uri,omitempty"` +} + +// ProductList - Pageable list of products. +type ProductList struct { + // URI to the next page. + NextLink *string `json:"nextLink,omitempty"` + + // List of products. + Value []*Product `json:"value,omitempty"` +} + +// ProductLog - Product action log. +type ProductLog struct { + // READ-ONLY; Operation error details. + Details *string `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; Operation end datetime. + EndDate *string `json:"endDate,omitempty" azure:"ro"` + + // READ-ONLY; Operation error data. + Error *string `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; Log ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Logged operation. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; Logged product ID. + ProductID *string `json:"productId,omitempty" azure:"ro"` + + // READ-ONLY; Logged registration name. + RegistrationName *string `json:"registrationName,omitempty" azure:"ro"` + + // READ-ONLY; Logged resource group name. + ResourceGroupName *string `json:"resourceGroupName,omitempty" azure:"ro"` + + // READ-ONLY; Operation start datetime. + StartDate *string `json:"startDate,omitempty" azure:"ro"` + + // READ-ONLY; Operation status. + Status *string `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; Logged subscription ID. + SubscriptionID *string `json:"subscriptionId,omitempty" azure:"ro"` +} + +// ProductNestedProperties - Properties portion of the product resource. +type ProductNestedProperties struct { + // The part number used for billing purposes. + BillingPartNumber *string `json:"billingPartNumber,omitempty"` + + // Product compatibility with current device. + Compatibility *Compatibility `json:"compatibility,omitempty"` + + // The description of the product. + Description *string `json:"description,omitempty"` + + // The display name of the product. + DisplayName *string `json:"displayName,omitempty"` + + // The identifier of the gallery item corresponding to the product. + GalleryItemIdentity *string `json:"galleryItemIdentity,omitempty"` + + // Additional links available for this product. + IconUris *IconUris `json:"iconUris,omitempty"` + + // The legal terms. + LegalTerms *string `json:"legalTerms,omitempty"` + + // Additional links available for this product. + Links []*ProductLink `json:"links,omitempty"` + + // The offer representing the product. + Offer *string `json:"offer,omitempty"` + + // The version of the product offer. + OfferVersion *string `json:"offerVersion,omitempty"` + + // The length of product content. + PayloadLength *int64 `json:"payloadLength,omitempty"` + + // The privacy policy. + PrivacyPolicy *string `json:"privacyPolicy,omitempty"` + + // The kind of the product (virtualMachine or virtualMachineExtension) + ProductKind *string `json:"productKind,omitempty"` + + // Additional properties for the product. + ProductProperties *ProductProperties `json:"productProperties,omitempty"` + + // The user-friendly name of the product publisher. + PublisherDisplayName *string `json:"publisherDisplayName,omitempty"` + + // Publisher identifier. + PublisherIdentifier *string `json:"publisherIdentifier,omitempty"` + + // The product SKU. + SKU *string `json:"sku,omitempty"` + + // The type of the Virtual Machine Extension. + VMExtensionType *string `json:"vmExtensionType,omitempty"` +} + +// ProductProperties - Additional properties of the product +type ProductProperties struct { + // The version. + Version *string `json:"version,omitempty"` +} + +// ProductsClientGetOptions contains the optional parameters for the ProductsClient.Get method. +type ProductsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientGetProductOptions contains the optional parameters for the ProductsClient.GetProduct method. +type ProductsClientGetProductOptions struct { + // Device configuration. + DeviceConfiguration *DeviceConfiguration +} + +// ProductsClientGetProductsOptions contains the optional parameters for the ProductsClient.GetProducts method. +type ProductsClientGetProductsOptions struct { + // Device configuration. + DeviceConfiguration *DeviceConfiguration +} + +// ProductsClientListDetailsOptions contains the optional parameters for the ProductsClient.ListDetails method. +type ProductsClientListDetailsOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientListOptions contains the optional parameters for the ProductsClient.List method. +type ProductsClientListOptions struct { + // placeholder for future optional parameters +} + +// ProductsClientListProductsOptions contains the optional parameters for the ProductsClient.ListProducts method. +type ProductsClientListProductsOptions struct { + // Device configuration. + DeviceConfiguration *DeviceConfiguration +} + +// ProductsClientUploadLogOptions contains the optional parameters for the ProductsClient.UploadLog method. +type ProductsClientUploadLogOptions struct { + // Update details for product log. + MarketplaceProductLogUpdate *MarketplaceProductLogUpdate +} + +// Registration information. +type Registration struct { + // REQUIRED; Location of the resource. + Location *Location `json:"location,omitempty"` + + // The entity tag used for optimistic concurrency when modifying the resource. + Etag *string `json:"etag,omitempty"` + + // Registration resource. + Properties *RegistrationProperties `json:"properties,omitempty"` + + // Custom tags for the resource. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of Resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// RegistrationList - Pageable list of registrations. +type RegistrationList struct { + // URI to the next page. + NextLink *string `json:"nextLink,omitempty"` + + // List of Registrations + Value []*Registration `json:"value,omitempty"` +} + +// RegistrationParameter - Registration resource +type RegistrationParameter struct { + // REQUIRED; Location of the resource. + Location *Location `json:"location,omitempty"` + + // REQUIRED; Properties of the Azure Stack registration resource + Properties *RegistrationParameterProperties `json:"properties,omitempty"` +} + +// RegistrationParameterProperties - Properties of the Azure Stack registration resource +type RegistrationParameterProperties struct { + // REQUIRED; The token identifying registered Azure Stack + RegistrationToken *string `json:"registrationToken,omitempty"` +} + +// RegistrationProperties - Properties portion of the registration resource. +type RegistrationProperties struct { + // Specifies the billing mode for the Azure Stack registration. + BillingModel *string `json:"billingModel,omitempty"` + + // The identifier of the registered Azure Stack. + CloudID *string `json:"cloudId,omitempty"` + + // The object identifier associated with the Azure Stack connecting to Azure. + ObjectID *string `json:"objectId,omitempty"` +} + +// RegistrationsClientCreateOrUpdateOptions contains the optional parameters for the RegistrationsClient.CreateOrUpdate method. +type RegistrationsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// RegistrationsClientDeleteOptions contains the optional parameters for the RegistrationsClient.Delete method. +type RegistrationsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// RegistrationsClientEnableRemoteManagementOptions contains the optional parameters for the RegistrationsClient.EnableRemoteManagement +// method. +type RegistrationsClientEnableRemoteManagementOptions struct { + // placeholder for future optional parameters +} + +// RegistrationsClientGetActivationKeyOptions contains the optional parameters for the RegistrationsClient.GetActivationKey +// method. +type RegistrationsClientGetActivationKeyOptions struct { + // placeholder for future optional parameters +} + +// RegistrationsClientGetOptions contains the optional parameters for the RegistrationsClient.Get method. +type RegistrationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// RegistrationsClientListBySubscriptionOptions contains the optional parameters for the RegistrationsClient.ListBySubscription +// method. +type RegistrationsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// RegistrationsClientListOptions contains the optional parameters for the RegistrationsClient.List method. +type RegistrationsClientListOptions struct { + // placeholder for future optional parameters +} + +// RegistrationsClientUpdateOptions contains the optional parameters for the RegistrationsClient.Update method. +type RegistrationsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// Resource - Base resource object. +type Resource struct { + // The entity tag used for optimistic concurrency when modifying the resource. + Etag *string `json:"etag,omitempty"` + + // READ-ONLY; ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of Resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// TrackedResource - Base resource object. +type TrackedResource struct { + // REQUIRED; Location of the resource. + Location *Location `json:"location,omitempty"` + + // The entity tag used for optimistic concurrency when modifying the resource. + Etag *string `json:"etag,omitempty"` + + // Custom tags for the resource. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; ID of the resource. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Name of the resource. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Type of Resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// URI - The URI. +type URI struct { + // READ-ONLY; The URI. + URI *string `json:"uri,omitempty" azure:"ro"` +} + +// VirtualMachineExtensionProductProperties - Product information. +type VirtualMachineExtensionProductProperties struct { + // READ-ONLY; Specifies kind of compute role included in the package. + ComputeRole *ComputeRole `json:"computeRole,omitempty" azure:"ro"` + + // READ-ONLY; Specifies if product is a Virtual Machine Extension. + IsSystemExtension *bool `json:"isSystemExtension,omitempty" azure:"ro"` + + // READ-ONLY; Specifies a download location where content can be downloaded from. + SourceBlob *URI `json:"sourceBlob,omitempty" azure:"ro"` + + // READ-ONLY; Indicates if specified product supports multiple extensions. + SupportMultipleExtensions *bool `json:"supportMultipleExtensions,omitempty" azure:"ro"` + + // READ-ONLY; Specifies operating system used by the product. + VMOsType *OperatingSystem `json:"vmOsType,omitempty" azure:"ro"` + + // READ-ONLY; Indicates if virtual machine Scale Set is enabled in the specified product. + VMScaleSetEnabled *bool `json:"vmScaleSetEnabled,omitempty" azure:"ro"` + + // READ-ONLY; Specifies product version. + Version *string `json:"version,omitempty" azure:"ro"` +} + +// VirtualMachineProductProperties - Product information. +type VirtualMachineProductProperties struct { + // READ-ONLY; List of attached data disks. + DataDiskImages []*DataDiskImage `json:"dataDiskImages,omitempty" azure:"ro"` + + // READ-ONLY; OS disk image used by product. + OSDiskImage *OsDiskImage `json:"osDiskImage,omitempty" azure:"ro"` + + // READ-ONLY; Specifies product version. + Version *string `json:"version,omitempty" azure:"ro"` +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/models_serde.go b/sdk/resourcemanager/azurestack/armazurestack/models_serde.go new file mode 100644 index 000000000000..12a3a7e15a06 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/models_serde.go @@ -0,0 +1,1506 @@ +//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 armazurestack + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ActivationKeyResult. +func (a ActivationKeyResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "activationKey", a.ActivationKey) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ActivationKeyResult. +func (a *ActivationKeyResult) 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 "activationKey": + err = unpopulate(val, "ActivationKey", &a.ActivationKey) + 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 CloudManifestFileDeploymentData. +func (c CloudManifestFileDeploymentData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "customCloudVerificationKey", c.CustomCloudVerificationKey) + populate(objectMap, "customEnvironmentEndpoints", c.CustomEnvironmentEndpoints) + populate(objectMap, "externalDsmsCertificates", c.ExternalDsmsCertificates) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudManifestFileDeploymentData. +func (c *CloudManifestFileDeploymentData) 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 "customCloudVerificationKey": + err = unpopulate(val, "CustomCloudVerificationKey", &c.CustomCloudVerificationKey) + delete(rawMsg, key) + case "customEnvironmentEndpoints": + err = unpopulate(val, "CustomEnvironmentEndpoints", &c.CustomEnvironmentEndpoints) + delete(rawMsg, key) + case "externalDsmsCertificates": + err = unpopulate(val, "ExternalDsmsCertificates", &c.ExternalDsmsCertificates) + 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 CloudManifestFileEnvironmentEndpoints. +func (c CloudManifestFileEnvironmentEndpoints) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "customCloudArmEndpoint", c.CustomCloudArmEndpoint) + populate(objectMap, "externalDsmsEndpoint", c.ExternalDsmsEndpoint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudManifestFileEnvironmentEndpoints. +func (c *CloudManifestFileEnvironmentEndpoints) 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 "customCloudArmEndpoint": + err = unpopulate(val, "CustomCloudArmEndpoint", &c.CustomCloudArmEndpoint) + delete(rawMsg, key) + case "externalDsmsEndpoint": + err = unpopulate(val, "ExternalDsmsEndpoint", &c.ExternalDsmsEndpoint) + 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 CloudManifestFileProperties. +func (c CloudManifestFileProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "deploymentData", c.DeploymentData) + populate(objectMap, "signature", c.Signature) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudManifestFileProperties. +func (c *CloudManifestFileProperties) 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 "deploymentData": + err = unpopulate(val, "DeploymentData", &c.DeploymentData) + delete(rawMsg, key) + case "signature": + err = unpopulate(val, "Signature", &c.Signature) + 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 CloudManifestFileResponse. +func (c CloudManifestFileResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", c.Etag) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CloudManifestFileResponse. +func (c *CloudManifestFileResponse) 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 "etag": + err = unpopulate(val, "Etag", &c.Etag) + delete(rawMsg, 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 "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 Compatibility. +func (c Compatibility) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", c.Description) + populate(objectMap, "isCompatible", c.IsCompatible) + populate(objectMap, "issues", c.Issues) + populate(objectMap, "message", c.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Compatibility. +func (c *Compatibility) 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 "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "isCompatible": + err = unpopulate(val, "IsCompatible", &c.IsCompatible) + delete(rawMsg, key) + case "issues": + err = unpopulate(val, "Issues", &c.Issues) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &c.Message) + 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 CustomerSubscription. +func (c CustomerSubscription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", c.Etag) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerSubscription. +func (c *CustomerSubscription) 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 "etag": + err = unpopulate(val, "Etag", &c.Etag) + delete(rawMsg, 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 "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 CustomerSubscriptionList. +func (c CustomerSubscriptionList) 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 CustomerSubscriptionList. +func (c *CustomerSubscriptionList) 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 CustomerSubscriptionProperties. +func (c CustomerSubscriptionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tenantId", c.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CustomerSubscriptionProperties. +func (c *CustomerSubscriptionProperties) 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 "tenantId": + err = unpopulate(val, "TenantID", &c.TenantID) + 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 DataDiskImage. +func (d DataDiskImage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "lun", d.Lun) + populate(objectMap, "sourceBlobSasUri", d.SourceBlobSasURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataDiskImage. +func (d *DataDiskImage) 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 "lun": + err = unpopulate(val, "Lun", &d.Lun) + delete(rawMsg, key) + case "sourceBlobSasUri": + err = unpopulate(val, "SourceBlobSasURI", &d.SourceBlobSasURI) + 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 DeploymentLicenseRequest. +func (d DeploymentLicenseRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "verificationVersion", d.VerificationVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentLicenseRequest. +func (d *DeploymentLicenseRequest) 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 "verificationVersion": + err = unpopulate(val, "VerificationVersion", &d.VerificationVersion) + 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 DeploymentLicenseResponse. +func (d DeploymentLicenseResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "signature", d.Signature) + populate(objectMap, "temporaryLicenseChain", d.TemporaryLicenseChain) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentLicenseResponse. +func (d *DeploymentLicenseResponse) 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 "signature": + err = unpopulate(val, "Signature", &d.Signature) + delete(rawMsg, key) + case "temporaryLicenseChain": + err = unpopulate(val, "TemporaryLicenseChain", &d.TemporaryLicenseChain) + 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 DeviceConfiguration. +func (d DeviceConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "deviceVersion", d.DeviceVersion) + populate(objectMap, "identitySystem", d.IdentitySystem) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeviceConfiguration. +func (d *DeviceConfiguration) 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 "deviceVersion": + err = unpopulate(val, "DeviceVersion", &d.DeviceVersion) + delete(rawMsg, key) + case "identitySystem": + err = unpopulate(val, "IdentitySystem", &d.IdentitySystem) + 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 Display. +func (d Display) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", d.Description) + populate(objectMap, "operation", d.Operation) + populate(objectMap, "provider", d.Provider) + populate(objectMap, "resource", d.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Display. +func (d *Display) 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 "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &d.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &d.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &d.Resource) + 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 ErrorDetails. +func (e ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetails. +func (e *ErrorDetails) 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 "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExtendedProduct. +func (e ExtendedProduct) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "galleryPackageBlobSasUri", e.GalleryPackageBlobSasURI) + populate(objectMap, "productKind", e.ProductKind) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedProduct. +func (e *ExtendedProduct) 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 "galleryPackageBlobSasUri": + err = unpopulate(val, "GalleryPackageBlobSasURI", &e.GalleryPackageBlobSasURI) + delete(rawMsg, key) + case "productKind": + err = unpopulate(val, "ProductKind", &e.ProductKind) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + 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 ExtendedProductProperties. +func (e ExtendedProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "computeRole", e.ComputeRole) + populate(objectMap, "dataDiskImages", e.DataDiskImages) + populate(objectMap, "isSystemExtension", e.IsSystemExtension) + populate(objectMap, "osDiskImage", e.OSDiskImage) + populate(objectMap, "sourceBlob", e.SourceBlob) + populate(objectMap, "supportMultipleExtensions", e.SupportMultipleExtensions) + populate(objectMap, "vmOsType", e.VMOsType) + populate(objectMap, "vmScaleSetEnabled", e.VMScaleSetEnabled) + populate(objectMap, "version", e.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExtendedProductProperties. +func (e *ExtendedProductProperties) 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 "computeRole": + err = unpopulate(val, "ComputeRole", &e.ComputeRole) + delete(rawMsg, key) + case "dataDiskImages": + err = unpopulate(val, "DataDiskImages", &e.DataDiskImages) + delete(rawMsg, key) + case "isSystemExtension": + err = unpopulate(val, "IsSystemExtension", &e.IsSystemExtension) + delete(rawMsg, key) + case "osDiskImage": + err = unpopulate(val, "OSDiskImage", &e.OSDiskImage) + delete(rawMsg, key) + case "sourceBlob": + err = unpopulate(val, "SourceBlob", &e.SourceBlob) + delete(rawMsg, key) + case "supportMultipleExtensions": + err = unpopulate(val, "SupportMultipleExtensions", &e.SupportMultipleExtensions) + delete(rawMsg, key) + case "vmOsType": + err = unpopulate(val, "VMOsType", &e.VMOsType) + delete(rawMsg, key) + case "vmScaleSetEnabled": + err = unpopulate(val, "VMScaleSetEnabled", &e.VMScaleSetEnabled) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &e.Version) + 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 IconUris. +func (i IconUris) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hero", i.Hero) + populate(objectMap, "large", i.Large) + populate(objectMap, "medium", i.Medium) + populate(objectMap, "small", i.Small) + populate(objectMap, "wide", i.Wide) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IconUris. +func (i *IconUris) 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 "hero": + err = unpopulate(val, "Hero", &i.Hero) + delete(rawMsg, key) + case "large": + err = unpopulate(val, "Large", &i.Large) + delete(rawMsg, key) + case "medium": + err = unpopulate(val, "Medium", &i.Medium) + delete(rawMsg, key) + case "small": + err = unpopulate(val, "Small", &i.Small) + delete(rawMsg, key) + case "wide": + err = unpopulate(val, "Wide", &i.Wide) + 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 MarketplaceProductLogUpdate. +func (m MarketplaceProductLogUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "details", m.Details) + populate(objectMap, "error", m.Error) + populate(objectMap, "operation", m.Operation) + populate(objectMap, "status", m.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MarketplaceProductLogUpdate. +func (m *MarketplaceProductLogUpdate) 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 "details": + err = unpopulate(val, "Details", &m.Details) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &m.Error) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &m.Operation) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &m.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "display", o.Display) + 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 "display": + err = unpopulate(val, "Display", &o.Display) + 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 OperationList. +func (o OperationList) 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 OperationList. +func (o *OperationList) 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 OsDiskImage. +func (o OsDiskImage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "operatingSystem", o.OperatingSystem) + populate(objectMap, "sourceBlobSasUri", o.SourceBlobSasURI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OsDiskImage. +func (o *OsDiskImage) 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 "operatingSystem": + err = unpopulate(val, "OperatingSystem", &o.OperatingSystem) + delete(rawMsg, key) + case "sourceBlobSasUri": + err = unpopulate(val, "SourceBlobSasURI", &o.SourceBlobSasURI) + 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 Product. +func (p Product) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", p.Etag) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Product. +func (p *Product) 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 "etag": + err = unpopulate(val, "Etag", &p.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + 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 "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 ProductLink. +func (p ProductLink) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "uri", p.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductLink. +func (p *ProductLink) 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 "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "uri": + err = unpopulate(val, "URI", &p.URI) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProductList. +func (p ProductList) 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 ProductList. +func (p *ProductList) 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 ProductLog. +func (p ProductLog) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "details", p.Details) + populate(objectMap, "endDate", p.EndDate) + populate(objectMap, "error", p.Error) + populate(objectMap, "id", p.ID) + populate(objectMap, "operation", p.Operation) + populate(objectMap, "productId", p.ProductID) + populate(objectMap, "registrationName", p.RegistrationName) + populate(objectMap, "resourceGroupName", p.ResourceGroupName) + populate(objectMap, "startDate", p.StartDate) + populate(objectMap, "status", p.Status) + populate(objectMap, "subscriptionId", p.SubscriptionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductLog. +func (p *ProductLog) 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 "details": + err = unpopulate(val, "Details", &p.Details) + delete(rawMsg, key) + case "endDate": + err = unpopulate(val, "EndDate", &p.EndDate) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &p.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &p.Operation) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &p.ProductID) + delete(rawMsg, key) + case "registrationName": + err = unpopulate(val, "RegistrationName", &p.RegistrationName) + delete(rawMsg, key) + case "resourceGroupName": + err = unpopulate(val, "ResourceGroupName", &p.ResourceGroupName) + delete(rawMsg, key) + case "startDate": + err = unpopulate(val, "StartDate", &p.StartDate) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &p.SubscriptionID) + 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 ProductNestedProperties. +func (p ProductNestedProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingPartNumber", p.BillingPartNumber) + populate(objectMap, "compatibility", p.Compatibility) + populate(objectMap, "description", p.Description) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "galleryItemIdentity", p.GalleryItemIdentity) + populate(objectMap, "iconUris", p.IconUris) + populate(objectMap, "legalTerms", p.LegalTerms) + populate(objectMap, "links", p.Links) + populate(objectMap, "offer", p.Offer) + populate(objectMap, "offerVersion", p.OfferVersion) + populate(objectMap, "payloadLength", p.PayloadLength) + populate(objectMap, "privacyPolicy", p.PrivacyPolicy) + populate(objectMap, "productKind", p.ProductKind) + populate(objectMap, "productProperties", p.ProductProperties) + populate(objectMap, "publisherDisplayName", p.PublisherDisplayName) + populate(objectMap, "publisherIdentifier", p.PublisherIdentifier) + populate(objectMap, "sku", p.SKU) + populate(objectMap, "vmExtensionType", p.VMExtensionType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductNestedProperties. +func (p *ProductNestedProperties) 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 "billingPartNumber": + err = unpopulate(val, "BillingPartNumber", &p.BillingPartNumber) + delete(rawMsg, key) + case "compatibility": + err = unpopulate(val, "Compatibility", &p.Compatibility) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "galleryItemIdentity": + err = unpopulate(val, "GalleryItemIdentity", &p.GalleryItemIdentity) + delete(rawMsg, key) + case "iconUris": + err = unpopulate(val, "IconUris", &p.IconUris) + delete(rawMsg, key) + case "legalTerms": + err = unpopulate(val, "LegalTerms", &p.LegalTerms) + delete(rawMsg, key) + case "links": + err = unpopulate(val, "Links", &p.Links) + delete(rawMsg, key) + case "offer": + err = unpopulate(val, "Offer", &p.Offer) + delete(rawMsg, key) + case "offerVersion": + err = unpopulate(val, "OfferVersion", &p.OfferVersion) + delete(rawMsg, key) + case "payloadLength": + err = unpopulate(val, "PayloadLength", &p.PayloadLength) + delete(rawMsg, key) + case "privacyPolicy": + err = unpopulate(val, "PrivacyPolicy", &p.PrivacyPolicy) + delete(rawMsg, key) + case "productKind": + err = unpopulate(val, "ProductKind", &p.ProductKind) + delete(rawMsg, key) + case "productProperties": + err = unpopulate(val, "ProductProperties", &p.ProductProperties) + delete(rawMsg, key) + case "publisherDisplayName": + err = unpopulate(val, "PublisherDisplayName", &p.PublisherDisplayName) + delete(rawMsg, key) + case "publisherIdentifier": + err = unpopulate(val, "PublisherIdentifier", &p.PublisherIdentifier) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &p.SKU) + delete(rawMsg, key) + case "vmExtensionType": + err = unpopulate(val, "VMExtensionType", &p.VMExtensionType) + 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 ProductProperties. +func (p ProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProductProperties. +func (p *ProductProperties) 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 "version": + err = unpopulate(val, "Version", &p.Version) + 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 Registration. +func (r Registration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Registration. +func (r *Registration) 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 "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + 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 RegistrationList. +func (r RegistrationList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegistrationList. +func (r *RegistrationList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RegistrationParameter. +func (r RegistrationParameter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", r.Location) + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegistrationParameter. +func (r *RegistrationParameter) 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 "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &r.Properties) + 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 RegistrationParameterProperties. +func (r RegistrationParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "registrationToken", r.RegistrationToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegistrationParameterProperties. +func (r *RegistrationParameterProperties) 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 "registrationToken": + err = unpopulate(val, "RegistrationToken", &r.RegistrationToken) + 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 RegistrationProperties. +func (r RegistrationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingModel", r.BillingModel) + populate(objectMap, "cloudId", r.CloudID) + populate(objectMap, "objectId", r.ObjectID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RegistrationProperties. +func (r *RegistrationProperties) 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 "billingModel": + err = unpopulate(val, "BillingModel", &r.BillingModel) + delete(rawMsg, key) + case "cloudId": + err = unpopulate(val, "CloudID", &r.CloudID) + delete(rawMsg, key) + case "objectId": + err = unpopulate(val, "ObjectID", &r.ObjectID) + 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, "etag", r.Etag) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + 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 "etag": + err = unpopulate(val, "Etag", &r.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + 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 TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", t.Etag) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + 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 "etag": + err = unpopulate(val, "Etag", &t.Etag) + delete(rawMsg, 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 "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 URI. +func (u URI) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "uri", u.URI) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type URI. +func (u *URI) 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 "uri": + err = unpopulate(val, "URI", &u.URI) + 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 VirtualMachineExtensionProductProperties. +func (v VirtualMachineExtensionProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "computeRole", v.ComputeRole) + populate(objectMap, "isSystemExtension", v.IsSystemExtension) + populate(objectMap, "sourceBlob", v.SourceBlob) + populate(objectMap, "supportMultipleExtensions", v.SupportMultipleExtensions) + populate(objectMap, "vmOsType", v.VMOsType) + populate(objectMap, "vmScaleSetEnabled", v.VMScaleSetEnabled) + populate(objectMap, "version", v.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineExtensionProductProperties. +func (v *VirtualMachineExtensionProductProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "computeRole": + err = unpopulate(val, "ComputeRole", &v.ComputeRole) + delete(rawMsg, key) + case "isSystemExtension": + err = unpopulate(val, "IsSystemExtension", &v.IsSystemExtension) + delete(rawMsg, key) + case "sourceBlob": + err = unpopulate(val, "SourceBlob", &v.SourceBlob) + delete(rawMsg, key) + case "supportMultipleExtensions": + err = unpopulate(val, "SupportMultipleExtensions", &v.SupportMultipleExtensions) + delete(rawMsg, key) + case "vmOsType": + err = unpopulate(val, "VMOsType", &v.VMOsType) + delete(rawMsg, key) + case "vmScaleSetEnabled": + err = unpopulate(val, "VMScaleSetEnabled", &v.VMScaleSetEnabled) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &v.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualMachineProductProperties. +func (v VirtualMachineProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataDiskImages", v.DataDiskImages) + populate(objectMap, "osDiskImage", v.OSDiskImage) + populate(objectMap, "version", v.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualMachineProductProperties. +func (v *VirtualMachineProductProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataDiskImages": + err = unpopulate(val, "DataDiskImages", &v.DataDiskImages) + delete(rawMsg, key) + case "osDiskImage": + err = unpopulate(val, "OSDiskImage", &v.OSDiskImage) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &v.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, 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/azurestack/armazurestack/operations_client.go b/sdk/resourcemanager/azurestack/armazurestack/operations_client.go new file mode 100644 index 000000000000..7f70472cadc7 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/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 armazurestack + +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 - Returns the list of supported REST operations. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// 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.AzureStack/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-06-01") + 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.OperationList); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/products_client.go b/sdk/resourcemanager/azurestack/armazurestack/products_client.go new file mode 100644 index 000000000000..7a38995e7c01 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/products_client.go @@ -0,0 +1,504 @@ +//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 armazurestack + +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" +) + +// ProductsClient contains the methods for the Products group. +// Don't use this type directly, use NewProductsClient() instead. +type ProductsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewProductsClient creates a new instance of ProductsClient with the specified values. +// subscriptionID - Subscription credentials that uniquely identify Microsoft Azure subscription. The subscription ID forms +// part of the URI for every service call. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewProductsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProductsClient, 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 := &ProductsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Returns the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// productName - Name of the product. +// options - ProductsClientGetOptions contains the optional parameters for the ProductsClient.Get method. +func (client *ProductsClient) Get(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientGetOptions) (ProductsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroup, registrationName, productName, options) + if err != nil { + return ProductsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProductsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProductsClient) getCreateRequest(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProductsClient) getHandleResponse(resp *http.Response) (ProductsClientGetResponse, error) { + result := ProductsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Product); err != nil { + return ProductsClientGetResponse{}, err + } + return result, nil +} + +// GetProduct - Returns the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// productName - Name of the product. +// options - ProductsClientGetProductOptions contains the optional parameters for the ProductsClient.GetProduct method. +func (client *ProductsClient) GetProduct(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientGetProductOptions) (ProductsClientGetProductResponse, error) { + req, err := client.getProductCreateRequest(ctx, resourceGroup, registrationName, productName, options) + if err != nil { + return ProductsClientGetProductResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProductsClientGetProductResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientGetProductResponse{}, runtime.NewResponseError(resp) + } + return client.getProductHandleResponse(resp) +} + +// getProductCreateRequest creates the GetProduct request. +func (client *ProductsClient) getProductCreateRequest(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientGetProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProduct" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.DeviceConfiguration != nil { + return req, runtime.MarshalAsJSON(req, *options.DeviceConfiguration) + } + return req, nil +} + +// getProductHandleResponse handles the GetProduct response. +func (client *ProductsClient) getProductHandleResponse(resp *http.Response) (ProductsClientGetProductResponse, error) { + result := ProductsClientGetProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Product); err != nil { + return ProductsClientGetProductResponse{}, err + } + return result, nil +} + +// GetProducts - Returns a list of products. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// productName - Name of the product. +// options - ProductsClientGetProductsOptions contains the optional parameters for the ProductsClient.GetProducts method. +func (client *ProductsClient) GetProducts(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientGetProductsOptions) (ProductsClientGetProductsResponse, error) { + req, err := client.getProductsCreateRequest(ctx, resourceGroup, registrationName, productName, options) + if err != nil { + return ProductsClientGetProductsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProductsClientGetProductsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientGetProductsResponse{}, runtime.NewResponseError(resp) + } + return client.getProductsHandleResponse(resp) +} + +// getProductsCreateRequest creates the GetProducts request. +func (client *ProductsClient) getProductsCreateRequest(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientGetProductsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/getProducts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.DeviceConfiguration != nil { + return req, runtime.MarshalAsJSON(req, *options.DeviceConfiguration) + } + return req, nil +} + +// getProductsHandleResponse handles the GetProducts response. +func (client *ProductsClient) getProductsHandleResponse(resp *http.Response) (ProductsClientGetProductsResponse, error) { + result := ProductsClientGetProductsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductList); err != nil { + return ProductsClientGetProductsResponse{}, err + } + return result, nil +} + +// NewListPager - Returns a list of products. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// options - ProductsClientListOptions contains the optional parameters for the ProductsClient.List method. +func (client *ProductsClient) NewListPager(resourceGroup string, registrationName string, options *ProductsClientListOptions) *runtime.Pager[ProductsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ProductsClientListResponse]{ + More: func(page ProductsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProductsClientListResponse) (ProductsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroup, registrationName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProductsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProductsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ProductsClient) listCreateRequest(ctx context.Context, resourceGroup string, registrationName string, options *ProductsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ProductsClient) listHandleResponse(resp *http.Response) (ProductsClientListResponse, error) { + result := ProductsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductList); err != nil { + return ProductsClientListResponse{}, err + } + return result, nil +} + +// ListDetails - Returns the extended properties of a product. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// productName - Name of the product. +// options - ProductsClientListDetailsOptions contains the optional parameters for the ProductsClient.ListDetails method. +func (client *ProductsClient) ListDetails(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientListDetailsOptions) (ProductsClientListDetailsResponse, error) { + req, err := client.listDetailsCreateRequest(ctx, resourceGroup, registrationName, productName, options) + if err != nil { + return ProductsClientListDetailsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProductsClientListDetailsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientListDetailsResponse{}, runtime.NewResponseError(resp) + } + return client.listDetailsHandleResponse(resp) +} + +// listDetailsCreateRequest creates the ListDetails request. +func (client *ProductsClient) listDetailsCreateRequest(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientListDetailsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listDetails" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listDetailsHandleResponse handles the ListDetails response. +func (client *ProductsClient) listDetailsHandleResponse(resp *http.Response) (ProductsClientListDetailsResponse, error) { + result := ProductsClientListDetailsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ExtendedProduct); err != nil { + return ProductsClientListDetailsResponse{}, err + } + return result, nil +} + +// ListProducts - Returns a list of products. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// productName - Name of the product. +// options - ProductsClientListProductsOptions contains the optional parameters for the ProductsClient.ListProducts method. +func (client *ProductsClient) ListProducts(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientListProductsOptions) (ProductsClientListProductsResponse, error) { + req, err := client.listProductsCreateRequest(ctx, resourceGroup, registrationName, productName, options) + if err != nil { + return ProductsClientListProductsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProductsClientListProductsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientListProductsResponse{}, runtime.NewResponseError(resp) + } + return client.listProductsHandleResponse(resp) +} + +// listProductsCreateRequest creates the ListProducts request. +func (client *ProductsClient) listProductsCreateRequest(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientListProductsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/listProducts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.DeviceConfiguration != nil { + return req, runtime.MarshalAsJSON(req, *options.DeviceConfiguration) + } + return req, nil +} + +// listProductsHandleResponse handles the ListProducts response. +func (client *ProductsClient) listProductsHandleResponse(resp *http.Response) (ProductsClientListProductsResponse, error) { + result := ProductsClientListProductsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductList); err != nil { + return ProductsClientListProductsResponse{}, err + } + return result, nil +} + +// UploadLog - Returns the specified product. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// productName - Name of the product. +// options - ProductsClientUploadLogOptions contains the optional parameters for the ProductsClient.UploadLog method. +func (client *ProductsClient) UploadLog(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientUploadLogOptions) (ProductsClientUploadLogResponse, error) { + req, err := client.uploadLogCreateRequest(ctx, resourceGroup, registrationName, productName, options) + if err != nil { + return ProductsClientUploadLogResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProductsClientUploadLogResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProductsClientUploadLogResponse{}, runtime.NewResponseError(resp) + } + return client.uploadLogHandleResponse(resp) +} + +// uploadLogCreateRequest creates the UploadLog request. +func (client *ProductsClient) uploadLogCreateRequest(ctx context.Context, resourceGroup string, registrationName string, productName string, options *ProductsClientUploadLogOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/products/{productName}/uploadProductLog" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + if productName == "" { + return nil, errors.New("parameter productName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productName}", url.PathEscape(productName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.MarketplaceProductLogUpdate != nil { + return req, runtime.MarshalAsJSON(req, *options.MarketplaceProductLogUpdate) + } + return req, nil +} + +// uploadLogHandleResponse handles the UploadLog response. +func (client *ProductsClient) uploadLogHandleResponse(resp *http.Response) (ProductsClientUploadLogResponse, error) { + result := ProductsClientUploadLogResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProductLog); err != nil { + return ProductsClientUploadLogResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/registrations_client.go b/sdk/resourcemanager/azurestack/armazurestack/registrations_client.go new file mode 100644 index 000000000000..dc4118636da1 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/registrations_client.go @@ -0,0 +1,501 @@ +//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 armazurestack + +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" +) + +// RegistrationsClient contains the methods for the Registrations group. +// Don't use this type directly, use NewRegistrationsClient() instead. +type RegistrationsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewRegistrationsClient creates a new instance of RegistrationsClient with the specified values. +// subscriptionID - Subscription credentials that uniquely identify Microsoft Azure subscription. The subscription ID forms +// part of the URI for every service call. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewRegistrationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RegistrationsClient, 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 := &RegistrationsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Create or update an Azure Stack registration. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// tokenParam - Registration token +// options - RegistrationsClientCreateOrUpdateOptions contains the optional parameters for the RegistrationsClient.CreateOrUpdate +// method. +func (client *RegistrationsClient) CreateOrUpdate(ctx context.Context, resourceGroup string, registrationName string, tokenParam RegistrationParameter, options *RegistrationsClientCreateOrUpdateOptions) (RegistrationsClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroup, registrationName, tokenParam, options) + if err != nil { + return RegistrationsClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return RegistrationsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *RegistrationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroup string, registrationName string, tokenParam RegistrationParameter, options *RegistrationsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, tokenParam) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *RegistrationsClient) createOrUpdateHandleResponse(resp *http.Response) (RegistrationsClientCreateOrUpdateResponse, error) { + result := RegistrationsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Registration); err != nil { + return RegistrationsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete the requested Azure Stack registration. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// options - RegistrationsClientDeleteOptions contains the optional parameters for the RegistrationsClient.Delete method. +func (client *RegistrationsClient) Delete(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientDeleteOptions) (RegistrationsClientDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroup, registrationName, options) + if err != nil { + return RegistrationsClientDeleteResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { + return RegistrationsClientDeleteResponse{}, runtime.NewResponseError(resp) + } + return RegistrationsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *RegistrationsClient) deleteCreateRequest(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// EnableRemoteManagement - Enables remote management for device under the Azure Stack registration. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// options - RegistrationsClientEnableRemoteManagementOptions contains the optional parameters for the RegistrationsClient.EnableRemoteManagement +// method. +func (client *RegistrationsClient) EnableRemoteManagement(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientEnableRemoteManagementOptions) (RegistrationsClientEnableRemoteManagementResponse, error) { + req, err := client.enableRemoteManagementCreateRequest(ctx, resourceGroup, registrationName, options) + if err != nil { + return RegistrationsClientEnableRemoteManagementResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientEnableRemoteManagementResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationsClientEnableRemoteManagementResponse{}, runtime.NewResponseError(resp) + } + return RegistrationsClientEnableRemoteManagementResponse{}, nil +} + +// enableRemoteManagementCreateRequest creates the EnableRemoteManagement request. +func (client *RegistrationsClient) enableRemoteManagementCreateRequest(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientEnableRemoteManagementOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/enableRemoteManagement" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Returns the properties of an Azure Stack registration. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// options - RegistrationsClientGetOptions contains the optional parameters for the RegistrationsClient.Get method. +func (client *RegistrationsClient) Get(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientGetOptions) (RegistrationsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroup, registrationName, options) + if err != nil { + return RegistrationsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *RegistrationsClient) getCreateRequest(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RegistrationsClient) getHandleResponse(resp *http.Response) (RegistrationsClientGetResponse, error) { + result := RegistrationsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Registration); err != nil { + return RegistrationsClientGetResponse{}, err + } + return result, nil +} + +// GetActivationKey - Returns Azure Stack Activation Key. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// options - RegistrationsClientGetActivationKeyOptions contains the optional parameters for the RegistrationsClient.GetActivationKey +// method. +func (client *RegistrationsClient) GetActivationKey(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientGetActivationKeyOptions) (RegistrationsClientGetActivationKeyResponse, error) { + req, err := client.getActivationKeyCreateRequest(ctx, resourceGroup, registrationName, options) + if err != nil { + return RegistrationsClientGetActivationKeyResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientGetActivationKeyResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationsClientGetActivationKeyResponse{}, runtime.NewResponseError(resp) + } + return client.getActivationKeyHandleResponse(resp) +} + +// getActivationKeyCreateRequest creates the GetActivationKey request. +func (client *RegistrationsClient) getActivationKeyCreateRequest(ctx context.Context, resourceGroup string, registrationName string, options *RegistrationsClientGetActivationKeyOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}/getactivationkey" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getActivationKeyHandleResponse handles the GetActivationKey response. +func (client *RegistrationsClient) getActivationKeyHandleResponse(resp *http.Response) (RegistrationsClientGetActivationKeyResponse, error) { + result := RegistrationsClientGetActivationKeyResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ActivationKeyResult); err != nil { + return RegistrationsClientGetActivationKeyResponse{}, err + } + return result, nil +} + +// NewListPager - Returns a list of all registrations. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// options - RegistrationsClientListOptions contains the optional parameters for the RegistrationsClient.List method. +func (client *RegistrationsClient) NewListPager(resourceGroup string, options *RegistrationsClientListOptions) *runtime.Pager[RegistrationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RegistrationsClientListResponse]{ + More: func(page RegistrationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RegistrationsClientListResponse) (RegistrationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroup, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return RegistrationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *RegistrationsClient) listCreateRequest(ctx context.Context, resourceGroup string, options *RegistrationsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RegistrationsClient) listHandleResponse(resp *http.Response) (RegistrationsClientListResponse, error) { + result := RegistrationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RegistrationList); err != nil { + return RegistrationsClientListResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Returns a list of all registrations under current subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// options - RegistrationsClientListBySubscriptionOptions contains the optional parameters for the RegistrationsClient.ListBySubscription +// method. +func (client *RegistrationsClient) NewListBySubscriptionPager(options *RegistrationsClientListBySubscriptionOptions) *runtime.Pager[RegistrationsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[RegistrationsClientListBySubscriptionResponse]{ + More: func(page RegistrationsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RegistrationsClientListBySubscriptionResponse) (RegistrationsClientListBySubscriptionResponse, 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 RegistrationsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *RegistrationsClient) listBySubscriptionCreateRequest(ctx context.Context, options *RegistrationsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureStack/registrations" + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *RegistrationsClient) listBySubscriptionHandleResponse(resp *http.Response) (RegistrationsClientListBySubscriptionResponse, error) { + result := RegistrationsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RegistrationList); err != nil { + return RegistrationsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Patch an Azure Stack registration. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-06-01 +// resourceGroup - Name of the resource group. +// registrationName - Name of the Azure Stack registration. +// tokenParam - Registration token +// options - RegistrationsClientUpdateOptions contains the optional parameters for the RegistrationsClient.Update method. +func (client *RegistrationsClient) Update(ctx context.Context, resourceGroup string, registrationName string, tokenParam RegistrationParameter, options *RegistrationsClientUpdateOptions) (RegistrationsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroup, registrationName, tokenParam, options) + if err != nil { + return RegistrationsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return RegistrationsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RegistrationsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *RegistrationsClient) updateCreateRequest(ctx context.Context, resourceGroup string, registrationName string, tokenParam RegistrationParameter, options *RegistrationsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.AzureStack/registrations/{registrationName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroup == "" { + return nil, errors.New("parameter resourceGroup cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroup}", url.PathEscape(resourceGroup)) + if registrationName == "" { + return nil, errors.New("parameter registrationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{registrationName}", url.PathEscape(registrationName)) + 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-06-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, tokenParam) +} + +// updateHandleResponse handles the Update response. +func (client *RegistrationsClient) updateHandleResponse(resp *http.Response) (RegistrationsClientUpdateResponse, error) { + result := RegistrationsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Registration); err != nil { + return RegistrationsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azurestack/armazurestack/response_types.go b/sdk/resourcemanager/azurestack/armazurestack/response_types.go new file mode 100644 index 000000000000..b0a1ad4c6c36 --- /dev/null +++ b/sdk/resourcemanager/azurestack/armazurestack/response_types.go @@ -0,0 +1,125 @@ +//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 armazurestack + +// CloudManifestFileClientGetResponse contains the response from method CloudManifestFileClient.Get. +type CloudManifestFileClientGetResponse struct { + CloudManifestFileResponse +} + +// CloudManifestFileClientListResponse contains the response from method CloudManifestFileClient.List. +type CloudManifestFileClientListResponse struct { + CloudManifestFileResponse +} + +// CustomerSubscriptionsClientCreateResponse contains the response from method CustomerSubscriptionsClient.Create. +type CustomerSubscriptionsClientCreateResponse struct { + CustomerSubscription +} + +// CustomerSubscriptionsClientDeleteResponse contains the response from method CustomerSubscriptionsClient.Delete. +type CustomerSubscriptionsClientDeleteResponse struct { + // placeholder for future response values +} + +// CustomerSubscriptionsClientGetResponse contains the response from method CustomerSubscriptionsClient.Get. +type CustomerSubscriptionsClientGetResponse struct { + CustomerSubscription +} + +// CustomerSubscriptionsClientListResponse contains the response from method CustomerSubscriptionsClient.List. +type CustomerSubscriptionsClientListResponse struct { + CustomerSubscriptionList +} + +// DeploymentLicenseClientCreateResponse contains the response from method DeploymentLicenseClient.Create. +type DeploymentLicenseClientCreateResponse struct { + DeploymentLicenseResponse +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationList +} + +// ProductsClientGetProductResponse contains the response from method ProductsClient.GetProduct. +type ProductsClientGetProductResponse struct { + Product +} + +// ProductsClientGetProductsResponse contains the response from method ProductsClient.GetProducts. +type ProductsClientGetProductsResponse struct { + ProductList +} + +// ProductsClientGetResponse contains the response from method ProductsClient.Get. +type ProductsClientGetResponse struct { + Product +} + +// ProductsClientListDetailsResponse contains the response from method ProductsClient.ListDetails. +type ProductsClientListDetailsResponse struct { + ExtendedProduct +} + +// ProductsClientListProductsResponse contains the response from method ProductsClient.ListProducts. +type ProductsClientListProductsResponse struct { + ProductList +} + +// ProductsClientListResponse contains the response from method ProductsClient.List. +type ProductsClientListResponse struct { + ProductList +} + +// ProductsClientUploadLogResponse contains the response from method ProductsClient.UploadLog. +type ProductsClientUploadLogResponse struct { + ProductLog +} + +// RegistrationsClientCreateOrUpdateResponse contains the response from method RegistrationsClient.CreateOrUpdate. +type RegistrationsClientCreateOrUpdateResponse struct { + Registration +} + +// RegistrationsClientDeleteResponse contains the response from method RegistrationsClient.Delete. +type RegistrationsClientDeleteResponse struct { + // placeholder for future response values +} + +// RegistrationsClientEnableRemoteManagementResponse contains the response from method RegistrationsClient.EnableRemoteManagement. +type RegistrationsClientEnableRemoteManagementResponse struct { + // placeholder for future response values +} + +// RegistrationsClientGetActivationKeyResponse contains the response from method RegistrationsClient.GetActivationKey. +type RegistrationsClientGetActivationKeyResponse struct { + ActivationKeyResult +} + +// RegistrationsClientGetResponse contains the response from method RegistrationsClient.Get. +type RegistrationsClientGetResponse struct { + Registration +} + +// RegistrationsClientListBySubscriptionResponse contains the response from method RegistrationsClient.ListBySubscription. +type RegistrationsClientListBySubscriptionResponse struct { + RegistrationList +} + +// RegistrationsClientListResponse contains the response from method RegistrationsClient.List. +type RegistrationsClientListResponse struct { + RegistrationList +} + +// RegistrationsClientUpdateResponse contains the response from method RegistrationsClient.Update. +type RegistrationsClientUpdateResponse struct { + Registration +}