From 53efd90ec90fb1a14a1513c596eba6616b03c0a7 Mon Sep 17 00:00:00 2001 From: Alancere <804873052@qq.com> Date: Wed, 21 Feb 2024 17:05:13 +0800 Subject: [PATCH] [Release] sdk/resourcemanager/largeinstance/armlargeinstance/0.1.0 generation from spec commit: 6051d2b126f5b1e4b623cde8edfa3e25cf730685 --- .../armlargeinstance/CHANGELOG.md | 7 + .../armlargeinstance/LICENSE.txt | 21 + .../largeinstance/armlargeinstance/README.md | 92 ++ .../armlargeinstance/autorest.md | 13 + .../azurelargeinstance_client.go | 532 ++++++++++ .../azurelargeinstance_client_example_test.go | 537 ++++++++++ .../azurelargestorageinstance_client.go | 296 ++++++ ...argestorageinstance_client_example_test.go | 357 +++++++ .../largeinstance/armlargeinstance/build.go | 7 + .../largeinstance/armlargeinstance/ci.yml | 28 + .../armlargeinstance/client_factory.go | 60 ++ .../armlargeinstance/constants.go | 396 ++++++++ .../fake/azurelargeinstance_server.go | 399 ++++++++ .../fake/azurelargestorageinstance_server.go | 232 +++++ .../armlargeinstance/fake/internal.go | 64 ++ .../fake/operations_server.go | 96 ++ .../armlargeinstance/fake/server_factory.go | 89 ++ .../armlargeinstance/fake/time_rfc3339.go | 110 ++ .../largeinstance/armlargeinstance/go.mod | 21 + .../largeinstance/armlargeinstance/go.sum | 31 + .../largeinstance/armlargeinstance/models.go | 359 +++++++ .../armlargeinstance/models_serde.go | 954 ++++++++++++++++++ .../armlargeinstance/operations_client.go | 88 ++ .../operations_client_example_test.go | 66 ++ .../largeinstance/armlargeinstance/options.go | 85 ++ .../armlargeinstance/responses.go | 85 ++ .../armlargeinstance/time_rfc3339.go | 110 ++ 27 files changed, 5135 insertions(+) create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/CHANGELOG.md create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/LICENSE.txt create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/README.md create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/autorest.md create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client_example_test.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client_example_test.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/build.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/ci.yml create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/client_factory.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/constants.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargeinstance_server.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargestorageinstance_server.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/fake/internal.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/fake/operations_server.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/fake/server_factory.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/go.mod create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/go.sum create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/models.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/models_serde.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/operations_client.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/operations_client_example_test.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/options.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/responses.go create mode 100644 sdk/resourcemanager/largeinstance/armlargeinstance/time_rfc3339.go diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/CHANGELOG.md b/sdk/resourcemanager/largeinstance/armlargeinstance/CHANGELOG.md new file mode 100644 index 000000000000..6ae3f0cc31bd --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2024-02-23) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/LICENSE.txt b/sdk/resourcemanager/largeinstance/armlargeinstance/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/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/largeinstance/armlargeinstance/README.md b/sdk/resourcemanager/largeinstance/armlargeinstance/README.md new file mode 100644 index 000000000000..d560af007015 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/README.md @@ -0,0 +1,92 @@ +# Azure Largeinstance Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance) + +The `armlargeinstance` module provides operations for working with Azure Largeinstance. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/largeinstance/armlargeinstance) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Largeinstance module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Largeinstance. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Largeinstance module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armlargeinstance.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armlargeinstance.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewAzureLargeInstanceClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## 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 `Largeinstance` 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/largeinstance/armlargeinstance/autorest.md b/sdk/resourcemanager/largeinstance/armlargeinstance/autorest.md new file mode 100644 index 000000000000..1621b2cee069 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +tag: package-2023-07-20-preview +``` \ No newline at end of file diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client.go b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client.go new file mode 100644 index 000000000000..eefafee2eeb9 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client.go @@ -0,0 +1,532 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AzureLargeInstanceClient contains the methods for the AzureLargeInstance group. +// Don't use this type directly, use NewAzureLargeInstanceClient() instead. +type AzureLargeInstanceClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAzureLargeInstanceClient creates a new instance of AzureLargeInstanceClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAzureLargeInstanceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureLargeInstanceClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AzureLargeInstanceClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets an Azure Large Instance for the specified subscription, resource group, and instance name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - azureLargeInstanceName - Name of the AzureLargeInstance. +// - options - AzureLargeInstanceClientGetOptions contains the optional parameters for the AzureLargeInstanceClient.Get method. +func (client *AzureLargeInstanceClient) Get(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientGetOptions) (AzureLargeInstanceClientGetResponse, error) { + var err error + const operationName = "AzureLargeInstanceClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, azureLargeInstanceName, options) + if err != nil { + return AzureLargeInstanceClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureLargeInstanceClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureLargeInstanceClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AzureLargeInstanceClient) getCreateRequest(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if azureLargeInstanceName == "" { + return nil, errors.New("parameter azureLargeInstanceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{azureLargeInstanceName}", url.PathEscape(azureLargeInstanceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AzureLargeInstanceClient) getHandleResponse(resp *http.Response) (AzureLargeInstanceClientGetResponse, error) { + result := AzureLargeInstanceClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeInstance); err != nil { + return AzureLargeInstanceClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of Azure Large Instances in the specified subscription and resource group. The +// operations returns various properties of each Azure Large Instance. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - AzureLargeInstanceClientListByResourceGroupOptions contains the optional parameters for the AzureLargeInstanceClient.NewListByResourceGroupPager +// method. +func (client *AzureLargeInstanceClient) NewListByResourceGroupPager(resourceGroupName string, options *AzureLargeInstanceClientListByResourceGroupOptions) *runtime.Pager[AzureLargeInstanceClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[AzureLargeInstanceClientListByResourceGroupResponse]{ + More: func(page AzureLargeInstanceClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AzureLargeInstanceClientListByResourceGroupResponse) (AzureLargeInstanceClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AzureLargeInstanceClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return AzureLargeInstanceClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AzureLargeInstanceClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AzureLargeInstanceClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AzureLargeInstanceClient) listByResourceGroupHandleResponse(resp *http.Response) (AzureLargeInstanceClientListByResourceGroupResponse, error) { + result := AzureLargeInstanceClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeInstanceListResult); err != nil { + return AzureLargeInstanceClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets a list of Azure Large Instances in the specified subscription. The operations returns +// various properties of each Azure Large Instance. +// +// Generated from API version 2023-07-20-preview +// - options - AzureLargeInstanceClientListBySubscriptionOptions contains the optional parameters for the AzureLargeInstanceClient.NewListBySubscriptionPager +// method. +func (client *AzureLargeInstanceClient) NewListBySubscriptionPager(options *AzureLargeInstanceClientListBySubscriptionOptions) *runtime.Pager[AzureLargeInstanceClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[AzureLargeInstanceClientListBySubscriptionResponse]{ + More: func(page AzureLargeInstanceClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AzureLargeInstanceClientListBySubscriptionResponse) (AzureLargeInstanceClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AzureLargeInstanceClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return AzureLargeInstanceClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *AzureLargeInstanceClient) listBySubscriptionCreateRequest(ctx context.Context, options *AzureLargeInstanceClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureLargeInstance/azureLargeInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *AzureLargeInstanceClient) listBySubscriptionHandleResponse(resp *http.Response) (AzureLargeInstanceClientListBySubscriptionResponse, error) { + result := AzureLargeInstanceClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeInstanceListResult); err != nil { + return AzureLargeInstanceClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginRestart - The operation to restart an Azure Large Instance (only for compute instances) +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - azureLargeInstanceName - Name of the AzureLargeInstance. +// - options - AzureLargeInstanceClientBeginRestartOptions contains the optional parameters for the AzureLargeInstanceClient.BeginRestart +// method. +func (client *AzureLargeInstanceClient) BeginRestart(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginRestartOptions) (*runtime.Poller[AzureLargeInstanceClientRestartResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.restart(ctx, resourceGroupName, azureLargeInstanceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureLargeInstanceClientRestartResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AzureLargeInstanceClientRestartResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Restart - The operation to restart an Azure Large Instance (only for compute instances) +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +func (client *AzureLargeInstanceClient) restart(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginRestartOptions) (*http.Response, error) { + var err error + const operationName = "AzureLargeInstanceClient.BeginRestart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.restartCreateRequest(ctx, resourceGroupName, azureLargeInstanceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// restartCreateRequest creates the Restart request. +func (client *AzureLargeInstanceClient) restartCreateRequest(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginRestartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}/restart" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if azureLargeInstanceName == "" { + return nil, errors.New("parameter azureLargeInstanceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{azureLargeInstanceName}", url.PathEscape(azureLargeInstanceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.ForceParameter != nil { + if err := runtime.MarshalAsJSON(req, *options.ForceParameter); err != nil { + return nil, err + } + return req, nil + } + return req, nil +} + +// BeginShutdown - The operation to shutdown an Azure Large Instance (only for compute instances) +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - azureLargeInstanceName - Name of the AzureLargeInstance. +// - options - AzureLargeInstanceClientBeginShutdownOptions contains the optional parameters for the AzureLargeInstanceClient.BeginShutdown +// method. +func (client *AzureLargeInstanceClient) BeginShutdown(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginShutdownOptions) (*runtime.Poller[AzureLargeInstanceClientShutdownResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.shutdown(ctx, resourceGroupName, azureLargeInstanceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureLargeInstanceClientShutdownResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AzureLargeInstanceClientShutdownResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Shutdown - The operation to shutdown an Azure Large Instance (only for compute instances) +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +func (client *AzureLargeInstanceClient) shutdown(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginShutdownOptions) (*http.Response, error) { + var err error + const operationName = "AzureLargeInstanceClient.BeginShutdown" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.shutdownCreateRequest(ctx, resourceGroupName, azureLargeInstanceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// shutdownCreateRequest creates the Shutdown request. +func (client *AzureLargeInstanceClient) shutdownCreateRequest(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginShutdownOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}/shutdown" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if azureLargeInstanceName == "" { + return nil, errors.New("parameter azureLargeInstanceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{azureLargeInstanceName}", url.PathEscape(azureLargeInstanceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginStart - The operation to start an Azure Large Instance (only for compute instances) +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - azureLargeInstanceName - Name of the AzureLargeInstance. +// - options - AzureLargeInstanceClientBeginStartOptions contains the optional parameters for the AzureLargeInstanceClient.BeginStart +// method. +func (client *AzureLargeInstanceClient) BeginStart(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginStartOptions) (*runtime.Poller[AzureLargeInstanceClientStartResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.start(ctx, resourceGroupName, azureLargeInstanceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AzureLargeInstanceClientStartResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AzureLargeInstanceClientStartResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Start - The operation to start an Azure Large Instance (only for compute instances) +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +func (client *AzureLargeInstanceClient) start(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginStartOptions) (*http.Response, error) { + var err error + const operationName = "AzureLargeInstanceClient.BeginStart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.startCreateRequest(ctx, resourceGroupName, azureLargeInstanceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// startCreateRequest creates the Start request. +func (client *AzureLargeInstanceClient) startCreateRequest(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *AzureLargeInstanceClientBeginStartOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}/start" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if azureLargeInstanceName == "" { + return nil, errors.New("parameter azureLargeInstanceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{azureLargeInstanceName}", url.PathEscape(azureLargeInstanceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Update - Patches the Tags field of an Azure Large Instance for the specified subscription, resource group, and instance +// name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - azureLargeInstanceName - Name of the AzureLargeInstance. +// - properties - The resource properties to be updated. +// - options - AzureLargeInstanceClientUpdateOptions contains the optional parameters for the AzureLargeInstanceClient.Update +// method. +func (client *AzureLargeInstanceClient) Update(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, properties AzureLargeInstanceTagsUpdate, options *AzureLargeInstanceClientUpdateOptions) (AzureLargeInstanceClientUpdateResponse, error) { + var err error + const operationName = "AzureLargeInstanceClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, azureLargeInstanceName, properties, options) + if err != nil { + return AzureLargeInstanceClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureLargeInstanceClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureLargeInstanceClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *AzureLargeInstanceClient) updateCreateRequest(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, properties AzureLargeInstanceTagsUpdate, options *AzureLargeInstanceClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if azureLargeInstanceName == "" { + return nil, errors.New("parameter azureLargeInstanceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{azureLargeInstanceName}", url.PathEscape(azureLargeInstanceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *AzureLargeInstanceClient) updateHandleResponse(resp *http.Response) (AzureLargeInstanceClientUpdateResponse, error) { + result := AzureLargeInstanceClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeInstance); err != nil { + return AzureLargeInstanceClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client_example_test.go b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client_example_test.go new file mode 100644 index 000000000000..556b44f1c8ff --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargeinstance_client_example_test.go @@ -0,0 +1,537 @@ +//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 armlargeinstance_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListBySubscription.json +func ExampleAzureLargeInstanceClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAzureLargeInstanceClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AzureLargeInstanceListResult = armlargeinstance.AzureLargeInstanceListResult{ + // Value: []*armlargeinstance.AzureLargeInstance{ + // { + // Name: to.Ptr("myAzureLargeInstance1"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeInstances"), + // ID: to.Ptr("/subscriptions/57d3422f-467a-448e-b798-ebf490849542/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myAzureLargeInstance1"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-13T08:01:22.123Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeInstanceProperties{ + // AzureLargeInstanceID: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e1"), + // HardwareProfile: &armlargeinstance.HardwareProfile{ + // AzureLargeInstanceSize: to.Ptr(armlargeinstance.AzureLargeInstanceSizeNamesEnumS72), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS), + // }, + // HwRevision: to.Ptr("Rev 4.2"), + // NetworkProfile: &armlargeinstance.NetworkProfile{ + // CircuitID: to.Ptr("/subscriptions/57d3422f-467a-448e-b798-ebf490849542/resourceGroups/myResourceGroup/providers/Microsoft.Network/expressRouteCircuits/myCircuitId"), + // NetworkInterfaces: []*armlargeinstance.IPAddress{ + // { + // IPAddress: to.Ptr("123.123.123.123"), + // }}, + // }, + // OSProfile: &armlargeinstance.OsProfile{ + // ComputerName: to.Ptr("myComputerName"), + // OSType: to.Ptr("SLES 12 SP2"), + // Version: to.Ptr("12 SP2"), + // }, + // PowerState: to.Ptr(armlargeinstance.AzureLargeInstancePowerStateEnumRestarting), + // ProvisioningState: to.Ptr(armlargeinstance.AzureLargeInstanceProvisioningStatesEnumSucceeded), + // StorageProfile: &armlargeinstance.StorageProfile{ + // NfsIPAddress: to.Ptr("123.123.119.123"), + // }, + // }, + // }, + // { + // Name: to.Ptr("myAzureLargeInstance2"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myAzureLargeInstance2"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-13T08:01:22.123Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeInstanceProperties{ + // AzureLargeInstanceID: to.Ptr("589bce49-9fe6-4dc8-82df-cf6ae25e0cb9"), + // HardwareProfile: &armlargeinstance.HardwareProfile{ + // AzureLargeInstanceSize: to.Ptr(armlargeinstance.AzureLargeInstanceSizeNamesEnumS72), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS), + // }, + // HwRevision: to.Ptr("Rev 4.2"), + // NetworkProfile: &armlargeinstance.NetworkProfile{ + // CircuitID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Network/expressRouteCircuits/myCircuitId"), + // NetworkInterfaces: []*armlargeinstance.IPAddress{ + // { + // IPAddress: to.Ptr("123.123.123.123"), + // }}, + // }, + // OSProfile: &armlargeinstance.OsProfile{ + // ComputerName: to.Ptr("myComputerName2"), + // OSType: to.Ptr("SLES 12 SP2"), + // Version: to.Ptr("12 SP2"), + // }, + // PowerState: to.Ptr(armlargeinstance.AzureLargeInstancePowerStateEnumRestarting), + // ProvisioningState: to.Ptr(armlargeinstance.AzureLargeInstanceProvisioningStatesEnumSucceeded), + // StorageProfile: &armlargeinstance.StorageProfile{ + // NfsIPAddress: to.Ptr("123.123.119.123"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListByResourceGroup.json +func ExampleAzureLargeInstanceClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAzureLargeInstanceClient().NewListByResourceGroupPager("myResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AzureLargeInstanceListResult = armlargeinstance.AzureLargeInstanceListResult{ + // Value: []*armlargeinstance.AzureLargeInstance{ + // { + // Name: to.Ptr("myAzureLargeMetalInstance1"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myAzureLargeMetalInstance1"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeInstanceProperties{ + // AzureLargeInstanceID: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e1"), + // HardwareProfile: &armlargeinstance.HardwareProfile{ + // AzureLargeInstanceSize: to.Ptr(armlargeinstance.AzureLargeInstanceSizeNamesEnumS72), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS), + // }, + // HwRevision: to.Ptr("Rev 3"), + // NetworkProfile: &armlargeinstance.NetworkProfile{ + // CircuitID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Network/expressRouteCircuit"), + // NetworkInterfaces: []*armlargeinstance.IPAddress{ + // { + // IPAddress: to.Ptr("100.100.100.100"), + // }}, + // }, + // OSProfile: &armlargeinstance.OsProfile{ + // ComputerName: to.Ptr("myComputerName1"), + // OSType: to.Ptr("SUSE"), + // SSHPublicKey: to.Ptr("{ssh-rsa public key}"), + // Version: to.Ptr("12 SP1"), + // }, + // PowerState: to.Ptr(armlargeinstance.AzureLargeInstancePowerStateEnumStarted), + // ProvisioningState: to.Ptr(armlargeinstance.AzureLargeInstanceProvisioningStatesEnumSucceeded), + // ProximityPlacementGroup: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myplacementgroup"), + // StorageProfile: &armlargeinstance.StorageProfile{ + // NfsIPAddress: to.Ptr("200.200.200.200"), + // }, + // }, + // }, + // { + // Name: to.Ptr("myABMInstance2"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myABMInstance2"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-13T08:01:22.123Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeInstanceProperties{ + // AzureLargeInstanceID: to.Ptr("589bce49-9fe6-4dc8-82df-cf6ae25e0cb9"), + // HardwareProfile: &armlargeinstance.HardwareProfile{ + // AzureLargeInstanceSize: to.Ptr(armlargeinstance.AzureLargeInstanceSizeNamesEnumS384), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnumHPE), + // }, + // HwRevision: to.Ptr("Rev 3"), + // NetworkProfile: &armlargeinstance.NetworkProfile{ + // CircuitID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Network/expressRouteCircuit"), + // NetworkInterfaces: []*armlargeinstance.IPAddress{ + // { + // IPAddress: to.Ptr("100.100.100.101"), + // }}, + // }, + // OSProfile: &armlargeinstance.OsProfile{ + // ComputerName: to.Ptr("myComputerName2"), + // OSType: to.Ptr("SUSE"), + // SSHPublicKey: to.Ptr("{ssh-rsa public key}"), + // Version: to.Ptr("12 SP1"), + // }, + // PartnerNodeID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myAzureLargeMetalInstance1"), + // PowerState: to.Ptr(armlargeinstance.AzureLargeInstancePowerStateEnumStarted), + // ProvisioningState: to.Ptr(armlargeinstance.AzureLargeInstanceProvisioningStatesEnumSucceeded), + // ProximityPlacementGroup: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myplacementgroup"), + // StorageProfile: &armlargeinstance.StorageProfile{ + // NfsIPAddress: to.Ptr("200.200.200.201"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Get.json +func ExampleAzureLargeInstanceClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAzureLargeInstanceClient().Get(ctx, "myResourceGroup", "myAzureLargeInstance", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureLargeInstance = armlargeinstance.AzureLargeInstance{ + // Name: to.Ptr("myAzureLargeInstance"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myAzureLargeInstance"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeInstanceProperties{ + // AzureLargeInstanceID: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e1"), + // HardwareProfile: &armlargeinstance.HardwareProfile{ + // AzureLargeInstanceSize: to.Ptr(armlargeinstance.AzureLargeInstanceSizeNamesEnumS72), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS), + // }, + // HwRevision: to.Ptr("Rev 4.2"), + // NetworkProfile: &armlargeinstance.NetworkProfile{ + // CircuitID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Network/expressRouteCircuits/myCircuitId"), + // NetworkInterfaces: []*armlargeinstance.IPAddress{ + // { + // IPAddress: to.Ptr("123.123.123.123"), + // }}, + // }, + // OSProfile: &armlargeinstance.OsProfile{ + // ComputerName: to.Ptr("myComputerName"), + // OSType: to.Ptr("SLES 12 SP2"), + // Version: to.Ptr("12 SP2"), + // }, + // PowerState: to.Ptr(armlargeinstance.AzureLargeInstancePowerStateEnumRestarting), + // ProvisioningState: to.Ptr(armlargeinstance.AzureLargeInstanceProvisioningStatesEnumSucceeded), + // StorageProfile: &armlargeinstance.StorageProfile{ + // NfsIPAddress: to.Ptr("123.123.119.123"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_PatchTags_Delete.json +func ExampleAzureLargeInstanceClient_Update_azureLargeInstanceDeleteTag() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAzureLargeInstanceClient().Update(ctx, "myResourceGroup", "myALInstance", armlargeinstance.AzureLargeInstanceTagsUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureLargeInstance = armlargeinstance.AzureLargeInstance{ + // Name: to.Ptr("myALInstance"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myALInstance"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // }, + // Properties: &armlargeinstance.AzureLargeInstanceProperties{ + // AzureLargeInstanceID: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e1"), + // HardwareProfile: &armlargeinstance.HardwareProfile{ + // AzureLargeInstanceSize: to.Ptr(armlargeinstance.AzureLargeInstanceSizeNamesEnumS72), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS), + // }, + // HwRevision: to.Ptr("Rev 3"), + // NetworkProfile: &armlargeinstance.NetworkProfile{ + // CircuitID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Network/expressRouteCircuit"), + // NetworkInterfaces: []*armlargeinstance.IPAddress{ + // { + // IPAddress: to.Ptr("100.100.100.100"), + // }}, + // }, + // OSProfile: &armlargeinstance.OsProfile{ + // ComputerName: to.Ptr("myComputerName"), + // OSType: to.Ptr("SUSE"), + // SSHPublicKey: to.Ptr("{ssh-rsa public key}"), + // Version: to.Ptr("12 SP1"), + // }, + // PartnerNodeID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myALInstance2"), + // PowerState: to.Ptr(armlargeinstance.AzureLargeInstancePowerStateEnumStarted), + // ProvisioningState: to.Ptr(armlargeinstance.AzureLargeInstanceProvisioningStatesEnumSucceeded), + // ProximityPlacementGroup: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myplacementgroup"), + // StorageProfile: &armlargeinstance.StorageProfile{ + // NfsIPAddress: to.Ptr("200.200.200.200"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_PatchTags.json +func ExampleAzureLargeInstanceClient_Update_azureLargeInstanceUpdateTag() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAzureLargeInstanceClient().Update(ctx, "myResourceGroup", "myALInstance", armlargeinstance.AzureLargeInstanceTagsUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureLargeInstance = armlargeinstance.AzureLargeInstance{ + // Name: to.Ptr("myALInstance"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myALInstance"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus"), + // Tags: map[string]*string{ + // "testkey": to.Ptr("testvalue"), + // }, + // Properties: &armlargeinstance.AzureLargeInstanceProperties{ + // AzureLargeInstanceID: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e1"), + // HardwareProfile: &armlargeinstance.HardwareProfile{ + // AzureLargeInstanceSize: to.Ptr(armlargeinstance.AzureLargeInstanceSizeNamesEnumS72), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS), + // }, + // HwRevision: to.Ptr("Rev 3"), + // NetworkProfile: &armlargeinstance.NetworkProfile{ + // CircuitID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Network/expressRouteCircuit"), + // NetworkInterfaces: []*armlargeinstance.IPAddress{ + // { + // IPAddress: to.Ptr("100.100.100.100"), + // }}, + // }, + // OSProfile: &armlargeinstance.OsProfile{ + // ComputerName: to.Ptr("myComputerName"), + // OSType: to.Ptr("SUSE"), + // SSHPublicKey: to.Ptr("{ssh-rsa public key}"), + // Version: to.Ptr("12 SP1"), + // }, + // PartnerNodeID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeInstances/myALInstance2"), + // PowerState: to.Ptr(armlargeinstance.AzureLargeInstancePowerStateEnumStarted), + // ProvisioningState: to.Ptr(armlargeinstance.AzureLargeInstanceProvisioningStatesEnumSucceeded), + // ProximityPlacementGroup: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.Compute/proximityPlacementGroups/myplacementgroup"), + // StorageProfile: &armlargeinstance.StorageProfile{ + // NfsIPAddress: to.Ptr("200.200.200.200"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Restart.json +func ExampleAzureLargeInstanceClient_BeginRestart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAzureLargeInstanceClient().BeginRestart(ctx, "myResourceGroup", "myALInstance", &armlargeinstance.AzureLargeInstanceClientBeginRestartOptions{ForceParameter: nil}) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationStatusResult = armlargeinstance.OperationStatusResult{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000001"), + // Error: &armlargeinstance.ErrorDetail{ + // Code: to.Ptr(""), + // Message: to.Ptr(""), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-04T21:17:24.905Z"); return t}()), + // Status: to.Ptr("InProgress"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Shutdown.json +func ExampleAzureLargeInstanceClient_BeginShutdown() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAzureLargeInstanceClient().BeginShutdown(ctx, "myResourceGroup", "myALInstance", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationStatusResult = armlargeinstance.OperationStatusResult{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000001"), + // Error: &armlargeinstance.ErrorDetail{ + // Code: to.Ptr(""), + // Message: to.Ptr(""), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-04T21:17:24.905Z"); return t}()), + // Status: to.Ptr("InProgress"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Start.json +func ExampleAzureLargeInstanceClient_BeginStart() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewAzureLargeInstanceClient().BeginStart(ctx, "myResourceGroup", "myALInstance", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.OperationStatusResult = armlargeinstance.OperationStatusResult{ + // Name: to.Ptr("00000000-0000-0000-0000-000000000001"), + // Error: &armlargeinstance.ErrorDetail{ + // Code: to.Ptr(""), + // Message: to.Ptr(""), + // }, + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-04T21:17:24.905Z"); return t}()), + // Status: to.Ptr("InProgress"), + // } +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client.go b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client.go new file mode 100644 index 000000000000..bbb04de98dfd --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client.go @@ -0,0 +1,296 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AzureLargeStorageInstanceClient contains the methods for the AzureLargeStorageInstance group. +// Don't use this type directly, use NewAzureLargeStorageInstanceClient() instead. +type AzureLargeStorageInstanceClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAzureLargeStorageInstanceClient creates a new instance of AzureLargeStorageInstanceClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAzureLargeStorageInstanceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureLargeStorageInstanceClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AzureLargeStorageInstanceClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets an Azure Large Storage instance for the specified subscription, resource group, and instance name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - azureLargeStorageInstanceName - Name of the AzureLargeStorageInstance. +// - options - AzureLargeStorageInstanceClientGetOptions contains the optional parameters for the AzureLargeStorageInstanceClient.Get +// method. +func (client *AzureLargeStorageInstanceClient) Get(ctx context.Context, resourceGroupName string, azureLargeStorageInstanceName string, options *AzureLargeStorageInstanceClientGetOptions) (AzureLargeStorageInstanceClientGetResponse, error) { + var err error + const operationName = "AzureLargeStorageInstanceClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, azureLargeStorageInstanceName, options) + if err != nil { + return AzureLargeStorageInstanceClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureLargeStorageInstanceClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureLargeStorageInstanceClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *AzureLargeStorageInstanceClient) getCreateRequest(ctx context.Context, resourceGroupName string, azureLargeStorageInstanceName string, options *AzureLargeStorageInstanceClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeStorageInstances/{azureLargeStorageInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if azureLargeStorageInstanceName == "" { + return nil, errors.New("parameter azureLargeStorageInstanceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{azureLargeStorageInstanceName}", url.PathEscape(azureLargeStorageInstanceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AzureLargeStorageInstanceClient) getHandleResponse(resp *http.Response) (AzureLargeStorageInstanceClientGetResponse, error) { + result := AzureLargeStorageInstanceClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeStorageInstance); err != nil { + return AzureLargeStorageInstanceClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of AzureLargeStorageInstances in the specified subscription and resource group. +// The operations returns various properties of each Azure LargeStorage instance. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - AzureLargeStorageInstanceClientListByResourceGroupOptions contains the optional parameters for the AzureLargeStorageInstanceClient.NewListByResourceGroupPager +// method. +func (client *AzureLargeStorageInstanceClient) NewListByResourceGroupPager(resourceGroupName string, options *AzureLargeStorageInstanceClientListByResourceGroupOptions) *runtime.Pager[AzureLargeStorageInstanceClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[AzureLargeStorageInstanceClientListByResourceGroupResponse]{ + More: func(page AzureLargeStorageInstanceClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AzureLargeStorageInstanceClientListByResourceGroupResponse) (AzureLargeStorageInstanceClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AzureLargeStorageInstanceClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return AzureLargeStorageInstanceClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AzureLargeStorageInstanceClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AzureLargeStorageInstanceClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeStorageInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AzureLargeStorageInstanceClient) listByResourceGroupHandleResponse(resp *http.Response) (AzureLargeStorageInstanceClientListByResourceGroupResponse, error) { + result := AzureLargeStorageInstanceClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeStorageInstanceListResult); err != nil { + return AzureLargeStorageInstanceClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets a list of AzureLargeStorageInstances in the specified subscription. The operations returns +// various properties of each Azure LargeStorage instance. +// +// Generated from API version 2023-07-20-preview +// - options - AzureLargeStorageInstanceClientListBySubscriptionOptions contains the optional parameters for the AzureLargeStorageInstanceClient.NewListBySubscriptionPager +// method. +func (client *AzureLargeStorageInstanceClient) NewListBySubscriptionPager(options *AzureLargeStorageInstanceClientListBySubscriptionOptions) *runtime.Pager[AzureLargeStorageInstanceClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[AzureLargeStorageInstanceClientListBySubscriptionResponse]{ + More: func(page AzureLargeStorageInstanceClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AzureLargeStorageInstanceClientListBySubscriptionResponse) (AzureLargeStorageInstanceClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AzureLargeStorageInstanceClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return AzureLargeStorageInstanceClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *AzureLargeStorageInstanceClient) listBySubscriptionCreateRequest(ctx context.Context, options *AzureLargeStorageInstanceClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureLargeInstance/azureLargeStorageInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *AzureLargeStorageInstanceClient) listBySubscriptionHandleResponse(resp *http.Response) (AzureLargeStorageInstanceClientListBySubscriptionResponse, error) { + result := AzureLargeStorageInstanceClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeStorageInstanceListResult); err != nil { + return AzureLargeStorageInstanceClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Patches the Tags field of a Azure Large Storage Instance for the specified subscription, resource group, and instance +// name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-07-20-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - azureLargeStorageInstanceName - Name of the AzureLargeStorageInstance. +// - properties - The resource properties to be updated. +// - options - AzureLargeStorageInstanceClientUpdateOptions contains the optional parameters for the AzureLargeStorageInstanceClient.Update +// method. +func (client *AzureLargeStorageInstanceClient) Update(ctx context.Context, resourceGroupName string, azureLargeStorageInstanceName string, properties AzureLargeStorageInstanceTagsUpdate, options *AzureLargeStorageInstanceClientUpdateOptions) (AzureLargeStorageInstanceClientUpdateResponse, error) { + var err error + const operationName = "AzureLargeStorageInstanceClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, azureLargeStorageInstanceName, properties, options) + if err != nil { + return AzureLargeStorageInstanceClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureLargeStorageInstanceClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureLargeStorageInstanceClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *AzureLargeStorageInstanceClient) updateCreateRequest(ctx context.Context, resourceGroupName string, azureLargeStorageInstanceName string, properties AzureLargeStorageInstanceTagsUpdate, options *AzureLargeStorageInstanceClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeStorageInstances/{azureLargeStorageInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if azureLargeStorageInstanceName == "" { + return nil, errors.New("parameter azureLargeStorageInstanceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{azureLargeStorageInstanceName}", url.PathEscape(azureLargeStorageInstanceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *AzureLargeStorageInstanceClient) updateHandleResponse(resp *http.Response) (AzureLargeStorageInstanceClientUpdateResponse, error) { + result := AzureLargeStorageInstanceClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureLargeStorageInstance); err != nil { + return AzureLargeStorageInstanceClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client_example_test.go b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client_example_test.go new file mode 100644 index 000000000000..3948f1478309 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/azurelargestorageinstance_client_example_test.go @@ -0,0 +1,357 @@ +//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 armlargeinstance_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListBySubscription.json +func ExampleAzureLargeStorageInstanceClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAzureLargeStorageInstanceClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AzureLargeStorageInstanceListResult = armlargeinstance.AzureLargeStorageInstanceListResult{ + // Value: []*armlargeinstance.AzureLargeStorageInstance{ + // { + // Name: to.Ptr("myAzureLargeInstance1"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeStorageInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeStorageInstances/myAzureLargeInstance1"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeStorageInstanceProperties{ + // AzureLargeStorageInstanceUniqueIdentifier: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e9"), + // StorageProperties: &armlargeinstance.StorageProperties{ + // Generation: to.Ptr("Gen4"), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnum("NetApp")), + // OfferingType: to.Ptr("EPIC"), + // ProvisioningState: to.Ptr(armlargeinstance.ProvisioningStateSucceeded), + // StorageBillingProperties: &armlargeinstance.StorageBillingProperties{ + // BillingMode: to.Ptr("PAYG"), + // SKU: to.Ptr(""), + // }, + // StorageType: to.Ptr("FC"), + // WorkloadType: to.Ptr("ODB"), + // }, + // }, + // }, + // { + // Name: to.Ptr("myAzureLargeInstance2"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeStorageInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeStorageInstances/myAzureLargeInstance2"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-13T08:01:22.123Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeStorageInstanceProperties{ + // AzureLargeStorageInstanceUniqueIdentifier: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24f7"), + // StorageProperties: &armlargeinstance.StorageProperties{ + // Generation: to.Ptr("Gen4"), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnum("NetApp")), + // OfferingType: to.Ptr("EPIC"), + // ProvisioningState: to.Ptr(armlargeinstance.ProvisioningStateSucceeded), + // StorageBillingProperties: &armlargeinstance.StorageBillingProperties{ + // BillingMode: to.Ptr("RI"), + // SKU: to.Ptr(""), + // }, + // StorageType: to.Ptr("NFS"), + // WorkloadType: to.Ptr("Cogito"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListByResourceGroup.json +func ExampleAzureLargeStorageInstanceClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewAzureLargeStorageInstanceClient().NewListByResourceGroupPager("myResourceGroup", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.AzureLargeStorageInstanceListResult = armlargeinstance.AzureLargeStorageInstanceListResult{ + // Value: []*armlargeinstance.AzureLargeStorageInstance{ + // { + // Name: to.Ptr("myAzureLargeStorageInstance1"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeStorageInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeStorageInstances/myAzureLargeStorageInstance1"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeStorageInstanceProperties{ + // AzureLargeStorageInstanceUniqueIdentifier: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e9"), + // StorageProperties: &armlargeinstance.StorageProperties{ + // Generation: to.Ptr("Gen4"), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnum("NetApp")), + // OfferingType: to.Ptr("EPIC"), + // ProvisioningState: to.Ptr(armlargeinstance.ProvisioningStateSucceeded), + // StorageBillingProperties: &armlargeinstance.StorageBillingProperties{ + // BillingMode: to.Ptr("PAYG"), + // SKU: to.Ptr(""), + // }, + // StorageType: to.Ptr("FC"), + // WorkloadType: to.Ptr("ODB"), + // }, + // }, + // }, + // { + // Name: to.Ptr("myAzureLargeStorageInstance2"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeStorageInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeStorageInstances/myAzureLargeStorageInstance2"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-08-13T08:01:22.123Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeStorageInstanceProperties{ + // AzureLargeStorageInstanceUniqueIdentifier: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24f7"), + // StorageProperties: &armlargeinstance.StorageProperties{ + // Generation: to.Ptr("Gen4"), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnum("NetApp")), + // OfferingType: to.Ptr("EPIC"), + // ProvisioningState: to.Ptr(armlargeinstance.ProvisioningStateSucceeded), + // StorageBillingProperties: &armlargeinstance.StorageBillingProperties{ + // BillingMode: to.Ptr("RI"), + // SKU: to.Ptr(""), + // }, + // StorageType: to.Ptr("NFS"), + // WorkloadType: to.Ptr("Cogito"), + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_Get.json +func ExampleAzureLargeStorageInstanceClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAzureLargeStorageInstanceClient().Get(ctx, "myResourceGroup", "myAzureLargeStorageInstance", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureLargeStorageInstance = armlargeinstance.AzureLargeStorageInstance{ + // Name: to.Ptr("myAzureLargeStorageInstance"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeStorageInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeStorageInstances/myAzureLargeStorageInstance"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "key": to.Ptr("value"), + // }, + // Properties: &armlargeinstance.AzureLargeStorageInstanceProperties{ + // AzureLargeStorageInstanceUniqueIdentifier: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e9"), + // StorageProperties: &armlargeinstance.StorageProperties{ + // Generation: to.Ptr("Gen4"), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnum("NetApp")), + // OfferingType: to.Ptr("EPIC"), + // ProvisioningState: to.Ptr(armlargeinstance.ProvisioningStateSucceeded), + // StorageBillingProperties: &armlargeinstance.StorageBillingProperties{ + // BillingMode: to.Ptr("PAYG"), + // SKU: to.Ptr(""), + // }, + // StorageType: to.Ptr("FC"), + // WorkloadType: to.Ptr("ODB"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_PatchTags_Delete.json +func ExampleAzureLargeStorageInstanceClient_Update_azureLargeStorageInstanceDeleteTag() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAzureLargeStorageInstanceClient().Update(ctx, "myResourceGroup", "myALSInstance", armlargeinstance.AzureLargeStorageInstanceTagsUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureLargeStorageInstance = armlargeinstance.AzureLargeStorageInstance{ + // Name: to.Ptr("myAzureLargeStorageInstance"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeStorageInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeStorageInstances/myAzureLargeStorageInstance"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // }, + // Properties: &armlargeinstance.AzureLargeStorageInstanceProperties{ + // AzureLargeStorageInstanceUniqueIdentifier: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e9"), + // StorageProperties: &armlargeinstance.StorageProperties{ + // Generation: to.Ptr("Gen4"), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnum("NetApp")), + // OfferingType: to.Ptr("EPIC"), + // ProvisioningState: to.Ptr(armlargeinstance.ProvisioningStateSucceeded), + // StorageBillingProperties: &armlargeinstance.StorageBillingProperties{ + // BillingMode: to.Ptr("PAYG"), + // SKU: to.Ptr(""), + // }, + // StorageType: to.Ptr("FC"), + // WorkloadType: to.Ptr("ODB"), + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_PatchTags.json +func ExampleAzureLargeStorageInstanceClient_Update_azureLargeStorageInstanceUpdateTag() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewAzureLargeStorageInstanceClient().Update(ctx, "myResourceGroup", "myALSInstance", armlargeinstance.AzureLargeStorageInstanceTagsUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AzureLargeStorageInstance = armlargeinstance.AzureLargeStorageInstance{ + // Name: to.Ptr("myAzureLargeStorageInstance"), + // Type: to.Ptr("Microsoft.AzureLargeInstance/AzureLargeStorageInstances"), + // ID: to.Ptr("/subscriptions/f0f4887f-d13c-4943-a8ba-d7da28d2a3fd/resourceGroups/myResourceGroup/providers/Microsoft.AzureLargeInstance/AzureLargeStorageInstances/myAzureLargeStorageInstance"), + // SystemData: &armlargeinstance.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-20T23:10:22.682Z"); return t}()), + // CreatedBy: to.Ptr("user@microsoft.com"), + // CreatedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-21T08:01:22.000Z"); return t}()), + // LastModifiedBy: to.Ptr("user@microsoft.com"), + // LastModifiedByType: to.Ptr(armlargeinstance.CreatedByTypeUser), + // }, + // Location: to.Ptr("westus2"), + // Tags: map[string]*string{ + // "testkey": to.Ptr("testvalue"), + // }, + // Properties: &armlargeinstance.AzureLargeStorageInstanceProperties{ + // AzureLargeStorageInstanceUniqueIdentifier: to.Ptr("23415635-4d7e-41dc-9598-8194f22c24e9"), + // StorageProperties: &armlargeinstance.StorageProperties{ + // Generation: to.Ptr("Gen4"), + // HardwareType: to.Ptr(armlargeinstance.AzureLargeInstanceHardwareTypeNamesEnum("NetApp")), + // OfferingType: to.Ptr("EPIC"), + // ProvisioningState: to.Ptr(armlargeinstance.ProvisioningStateSucceeded), + // StorageBillingProperties: &armlargeinstance.StorageBillingProperties{ + // BillingMode: to.Ptr("PAYG"), + // SKU: to.Ptr(""), + // }, + // StorageType: to.Ptr("FC"), + // WorkloadType: to.Ptr("ODB"), + // }, + // }, + // } +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/build.go b/sdk/resourcemanager/largeinstance/armlargeinstance/build.go new file mode 100644 index 000000000000..893f0e79b071 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/largeinstance/armlargeinstance + +package armlargeinstance diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/ci.yml b/sdk/resourcemanager/largeinstance/armlargeinstance/ci.yml new file mode 100644 index 000000000000..b7bbd4453b61 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/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/largeinstance/armlargeinstance/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/largeinstance/armlargeinstance/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/largeinstance/armlargeinstance' diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/client_factory.go b/sdk/resourcemanager/largeinstance/armlargeinstance/client_factory.go new file mode 100644 index 000000000000..c4a463facd17 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/client_factory.go @@ -0,0 +1,60 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewAzureLargeInstanceClient creates a new instance of AzureLargeInstanceClient. +func (c *ClientFactory) NewAzureLargeInstanceClient() *AzureLargeInstanceClient { + return &AzureLargeInstanceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewAzureLargeStorageInstanceClient creates a new instance of AzureLargeStorageInstanceClient. +func (c *ClientFactory) NewAzureLargeStorageInstanceClient() *AzureLargeStorageInstanceClient { + return &AzureLargeStorageInstanceClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/constants.go b/sdk/resourcemanager/largeinstance/armlargeinstance/constants.go new file mode 100644 index 000000000000..5454bc356d7b --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/constants.go @@ -0,0 +1,396 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// AzureLargeInstanceForcePowerState - Enum of two possible values to determine if the ALI instance restart operation should +// forcefully terminate and halt any existing processes that may be running on the server or not. +type AzureLargeInstanceForcePowerState string + +const ( + // AzureLargeInstanceForcePowerStateActive - Active means that the restart operation will terminate and halt existing processes + // that may be running on the server + AzureLargeInstanceForcePowerStateActive AzureLargeInstanceForcePowerState = "active" + // AzureLargeInstanceForcePowerStateInactive - Inactive means that the restart operation will not terminate and halt existing + // processes that may be running on the server + AzureLargeInstanceForcePowerStateInactive AzureLargeInstanceForcePowerState = "inactive" +) + +// PossibleAzureLargeInstanceForcePowerStateValues returns the possible values for the AzureLargeInstanceForcePowerState const type. +func PossibleAzureLargeInstanceForcePowerStateValues() []AzureLargeInstanceForcePowerState { + return []AzureLargeInstanceForcePowerState{ + AzureLargeInstanceForcePowerStateActive, + AzureLargeInstanceForcePowerStateInactive, + } +} + +// AzureLargeInstanceHardwareTypeNamesEnum - Enum of the hardware options (vendor and/or their product name) for an Azure +// Large Instance +type AzureLargeInstanceHardwareTypeNamesEnum string + +const ( + // AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS - Hardware type of UCS from vendor Cisco + AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS AzureLargeInstanceHardwareTypeNamesEnum = "Cisco_UCS" + // AzureLargeInstanceHardwareTypeNamesEnumHPE - Hardware type of HPE from vendor Hewlett Packard Enterprise + AzureLargeInstanceHardwareTypeNamesEnumHPE AzureLargeInstanceHardwareTypeNamesEnum = "HPE" + // AzureLargeInstanceHardwareTypeNamesEnumSDFLEX - Hardware type of SDFLEX + AzureLargeInstanceHardwareTypeNamesEnumSDFLEX AzureLargeInstanceHardwareTypeNamesEnum = "SDFLEX" +) + +// PossibleAzureLargeInstanceHardwareTypeNamesEnumValues returns the possible values for the AzureLargeInstanceHardwareTypeNamesEnum const type. +func PossibleAzureLargeInstanceHardwareTypeNamesEnumValues() []AzureLargeInstanceHardwareTypeNamesEnum { + return []AzureLargeInstanceHardwareTypeNamesEnum{ + AzureLargeInstanceHardwareTypeNamesEnumCiscoUCS, + AzureLargeInstanceHardwareTypeNamesEnumHPE, + AzureLargeInstanceHardwareTypeNamesEnumSDFLEX, + } +} + +// AzureLargeInstancePowerStateEnum - Power states that an Azure Large Instance can be in +type AzureLargeInstancePowerStateEnum string + +const ( + // AzureLargeInstancePowerStateEnumRestarting - Restarting means that the Azure Large Instance resource is restarting. + AzureLargeInstancePowerStateEnumRestarting AzureLargeInstancePowerStateEnum = "restarting" + // AzureLargeInstancePowerStateEnumStarted - Started means that the Azure Large Instance resource has been powered on. + AzureLargeInstancePowerStateEnumStarted AzureLargeInstancePowerStateEnum = "started" + // AzureLargeInstancePowerStateEnumStarting - Starting means that the Azure Large Instance resource is turning on. + AzureLargeInstancePowerStateEnumStarting AzureLargeInstancePowerStateEnum = "starting" + // AzureLargeInstancePowerStateEnumStopped - Stopped means that the Azure Large Instance resource has shut down. + AzureLargeInstancePowerStateEnumStopped AzureLargeInstancePowerStateEnum = "stopped" + // AzureLargeInstancePowerStateEnumStopping - Stopping means that the Azure Large Instance resource is shutting down. + AzureLargeInstancePowerStateEnumStopping AzureLargeInstancePowerStateEnum = "stopping" + // AzureLargeInstancePowerStateEnumUnknown - Unknown means that the state of the Azure Large Instance is unknown. + AzureLargeInstancePowerStateEnumUnknown AzureLargeInstancePowerStateEnum = "unknown" +) + +// PossibleAzureLargeInstancePowerStateEnumValues returns the possible values for the AzureLargeInstancePowerStateEnum const type. +func PossibleAzureLargeInstancePowerStateEnumValues() []AzureLargeInstancePowerStateEnum { + return []AzureLargeInstancePowerStateEnum{ + AzureLargeInstancePowerStateEnumRestarting, + AzureLargeInstancePowerStateEnumStarted, + AzureLargeInstancePowerStateEnumStarting, + AzureLargeInstancePowerStateEnumStopped, + AzureLargeInstancePowerStateEnumStopping, + AzureLargeInstancePowerStateEnumUnknown, + } +} + +// AzureLargeInstanceProvisioningStatesEnum - Provisioning states that an Azure Large Instance can be in +type AzureLargeInstanceProvisioningStatesEnum string + +const ( + // AzureLargeInstanceProvisioningStatesEnumAccepted - Accepted means Azure Large Instance resource provisioning has been accepted. + AzureLargeInstanceProvisioningStatesEnumAccepted AzureLargeInstanceProvisioningStatesEnum = "Accepted" + // AzureLargeInstanceProvisioningStatesEnumCanceled - Cancelled Azure Large Instance resource operation has been cancelled + AzureLargeInstanceProvisioningStatesEnumCanceled AzureLargeInstanceProvisioningStatesEnum = "Canceled" + // AzureLargeInstanceProvisioningStatesEnumCreating - Creating means Azure Large Instance resource is being created. + AzureLargeInstanceProvisioningStatesEnumCreating AzureLargeInstanceProvisioningStatesEnum = "Creating" + // AzureLargeInstanceProvisioningStatesEnumDeleting - Deleting means Azure Large Instance resource is in the process of being + // deleted + AzureLargeInstanceProvisioningStatesEnumDeleting AzureLargeInstanceProvisioningStatesEnum = "Deleting" + // AzureLargeInstanceProvisioningStatesEnumFailed - Failed means Azure Large Instance resource is in failed state + AzureLargeInstanceProvisioningStatesEnumFailed AzureLargeInstanceProvisioningStatesEnum = "Failed" + // AzureLargeInstanceProvisioningStatesEnumMigrating - Migrating means Azure Large Instance resource is being migrated from + // one subscription or resource group to another + AzureLargeInstanceProvisioningStatesEnumMigrating AzureLargeInstanceProvisioningStatesEnum = "Migrating" + // AzureLargeInstanceProvisioningStatesEnumSucceeded - Succeeded means Azure Large Instance resource creation succeeded during + // last create/update + AzureLargeInstanceProvisioningStatesEnumSucceeded AzureLargeInstanceProvisioningStatesEnum = "Succeeded" + // AzureLargeInstanceProvisioningStatesEnumUpdating - Updating means an existing Azure Large Instance resource is being updated + AzureLargeInstanceProvisioningStatesEnumUpdating AzureLargeInstanceProvisioningStatesEnum = "Updating" +) + +// PossibleAzureLargeInstanceProvisioningStatesEnumValues returns the possible values for the AzureLargeInstanceProvisioningStatesEnum const type. +func PossibleAzureLargeInstanceProvisioningStatesEnumValues() []AzureLargeInstanceProvisioningStatesEnum { + return []AzureLargeInstanceProvisioningStatesEnum{ + AzureLargeInstanceProvisioningStatesEnumAccepted, + AzureLargeInstanceProvisioningStatesEnumCanceled, + AzureLargeInstanceProvisioningStatesEnumCreating, + AzureLargeInstanceProvisioningStatesEnumDeleting, + AzureLargeInstanceProvisioningStatesEnumFailed, + AzureLargeInstanceProvisioningStatesEnumMigrating, + AzureLargeInstanceProvisioningStatesEnumSucceeded, + AzureLargeInstanceProvisioningStatesEnumUpdating, + } +} + +// AzureLargeInstanceSizeNamesEnum - Enum of available model types (each of which have their own storage / memory sizes) for +// an Azure Large Instance type. See https://docs.microsoft.com/azure/sap/large-instances/hana-available-skus +type AzureLargeInstanceSizeNamesEnum string + +const ( + // AzureLargeInstanceSizeNamesEnumS112 - No longer offered or used. + AzureLargeInstanceSizeNamesEnumS112 AzureLargeInstanceSizeNamesEnum = "S112" + // AzureLargeInstanceSizeNamesEnumS144 - Type I class SKU that can't be purchased anymore + AzureLargeInstanceSizeNamesEnumS144 AzureLargeInstanceSizeNamesEnum = "S144" + // AzureLargeInstanceSizeNamesEnumS144M - Type I class SKU that can't be purchased anymore + AzureLargeInstanceSizeNamesEnumS144M AzureLargeInstanceSizeNamesEnum = "S144m" + // AzureLargeInstanceSizeNamesEnumS192 - Type I class SKU that can't be purchased anymore + AzureLargeInstanceSizeNamesEnumS192 AzureLargeInstanceSizeNamesEnum = "S192" + // AzureLargeInstanceSizeNamesEnumS192M - Type I class SKU that can't be purchased anymore + AzureLargeInstanceSizeNamesEnumS192M AzureLargeInstanceSizeNamesEnum = "S192m" + // AzureLargeInstanceSizeNamesEnumS192Xm - Type I class SKU that can't be purchased anymore + AzureLargeInstanceSizeNamesEnumS192Xm AzureLargeInstanceSizeNamesEnum = "S192xm" + // AzureLargeInstanceSizeNamesEnumS224 - 4 sockets, 224 CPU threads, 112 CPU cores, 3 TB total memory, 3 TB DRAM, 6.3 TB storage, + // Cisco_UCS hardware type + AzureLargeInstanceSizeNamesEnumS224 AzureLargeInstanceSizeNamesEnum = "S224" + // AzureLargeInstanceSizeNamesEnumS224M - 4 sockets, 224 CPU threads, 112 CPU cores, 6 TB total memory, 6 TB DRAM, 10.5 TB + // storage, Cisco_UCS hardware type + AzureLargeInstanceSizeNamesEnumS224M AzureLargeInstanceSizeNamesEnum = "S224m" + // AzureLargeInstanceSizeNamesEnumS224Om - 4 sockets, 224 CPU threads, 112 CPU cores, 6 TB total memory, 3 TB DRAM, 3 TB memory + // optane, 10.5 TB storage, Cisco_UCS hardware type + AzureLargeInstanceSizeNamesEnumS224Om AzureLargeInstanceSizeNamesEnum = "S224om" + // AzureLargeInstanceSizeNamesEnumS224Oo - 4 sockets, 224 CPU threads, 112 CPU cores, 4.5 TB total memory, 1.5 TB DRAM, 3 + // TB memory optane, 8.4 TB storage, Cisco_UCS hardware type + AzureLargeInstanceSizeNamesEnumS224Oo AzureLargeInstanceSizeNamesEnum = "S224oo" + // AzureLargeInstanceSizeNamesEnumS224Oom - 4 sockets, 224 CPU threads, 112 CPU cores, 9 TB total memory, 3 TB DRAM, 6 TB + // memory optane, 14.8 TB storage, Cisco_UCS hardware type + AzureLargeInstanceSizeNamesEnumS224Oom AzureLargeInstanceSizeNamesEnum = "S224oom" + // AzureLargeInstanceSizeNamesEnumS224Ooo - 4 sockets, 224 CPU threads, 112 CPU cores, 7.5TB total memory, 1.5 TB DRAM, 6 + // TB memory optane, 12.7 TB storage, Cisco_UCS hardware type + AzureLargeInstanceSizeNamesEnumS224Ooo AzureLargeInstanceSizeNamesEnum = "S224ooo" + // AzureLargeInstanceSizeNamesEnumS224Se - 4 sockets, 448 CPU threads, 6 TB total memory, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS224Se AzureLargeInstanceSizeNamesEnum = "S224se" + // AzureLargeInstanceSizeNamesEnumS384 - 8 sockets, 384 CPU threads, 192 CPU cores, 4 TB total memory, 4 TB DRAM, 16 TB storage, + // HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS384 AzureLargeInstanceSizeNamesEnum = "S384" + // AzureLargeInstanceSizeNamesEnumS384M - 8 sockets, 384 CPU threads, 192 CPU cores, 6 TB total memory, 6 TB DRAM, 18 TB storage, + // HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS384M AzureLargeInstanceSizeNamesEnum = "S384m" + // AzureLargeInstanceSizeNamesEnumS384Xm - 8 sockets, 384 CPU threads, 192 CPU cores, 8 TB total memory, 8 TB DRAM, 22 TB + // storage, HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS384Xm AzureLargeInstanceSizeNamesEnum = "S384xm" + // AzureLargeInstanceSizeNamesEnumS384Xxm - 8 sockets, 384 CPU threads, 12 TB total memory, HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS384Xxm AzureLargeInstanceSizeNamesEnum = "S384xxm" + // AzureLargeInstanceSizeNamesEnumS448 - 8 sockets, 448 CPU threads, 224 CPU cores, 6 TB total memory, 6 TB DRAM, 10.5 TB + // storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS448 AzureLargeInstanceSizeNamesEnum = "S448" + // AzureLargeInstanceSizeNamesEnumS448M - 8 sockets, 448 CPU threads, 224 CPU cores, 12 TB total memory, 12 TB DRAM, 18.9 + // TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS448M AzureLargeInstanceSizeNamesEnum = "S448m" + // AzureLargeInstanceSizeNamesEnumS448Om - 8 sockets, 448 CPU threads, 224 CPU cores, 12 TB total memory, 6 TB DRAM, 6 TB + // memory optane, 18.9 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS448Om AzureLargeInstanceSizeNamesEnum = "S448om" + // AzureLargeInstanceSizeNamesEnumS448Oo - 8 sockets, 448 CPU threads, 224 CPU cores, 9 TB total memory, 3 TB DRAM, 6 TB memory + // optane, 14.8 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS448Oo AzureLargeInstanceSizeNamesEnum = "S448oo" + // AzureLargeInstanceSizeNamesEnumS448Oom - 8 sockets, 448 CPU threads, 224 CPU cores, 18 TB total memory, 6 TB DRAM, 12 memory + // optane, 27.4 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS448Oom AzureLargeInstanceSizeNamesEnum = "S448oom" + // AzureLargeInstanceSizeNamesEnumS448Ooo - 8 sockets, 448 CPU threads, 224 CPU cores, 15 TB total memory, 3 TB DRAM, 12 memory + // optane, 23.2 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS448Ooo AzureLargeInstanceSizeNamesEnum = "S448ooo" + // AzureLargeInstanceSizeNamesEnumS448Se - 8 sockets, 448 CPU threads, 12 TB total memory, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS448Se AzureLargeInstanceSizeNamesEnum = "S448se" + // AzureLargeInstanceSizeNamesEnumS576M - 12 sockets, 576 CPU threads, 288 CPU cores, 12 TB total memory, 12 TB DRAM, 28 TB + // storage, HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS576M AzureLargeInstanceSizeNamesEnum = "S576m" + // AzureLargeInstanceSizeNamesEnumS576Xm - 12 sockets, 576 CPU threads, 288 CPU cores, 18 TB total memory, HPEMc990x hardware + // type + AzureLargeInstanceSizeNamesEnumS576Xm AzureLargeInstanceSizeNamesEnum = "S576xm" + // AzureLargeInstanceSizeNamesEnumS672 - 12 sockets, 672 CPU threads, 336 CPU cores, 9 TB total memory, 9 TB DRAM, 14.7 TB + // storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS672 AzureLargeInstanceSizeNamesEnum = "S672" + // AzureLargeInstanceSizeNamesEnumS672M - 12 sockets, 672 CPU threads, 336 CPU cores, 18 TB total memory, 18 TB DRAM, 27.4 + // TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS672M AzureLargeInstanceSizeNamesEnum = "S672m" + // AzureLargeInstanceSizeNamesEnumS672Om - 12 sockets, 672 CPU threads, 336 CPU cores, 18 TB total memory, 9 TB DRAM, 9 TB + // memory optane, 27.4 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS672Om AzureLargeInstanceSizeNamesEnum = "S672om" + // AzureLargeInstanceSizeNamesEnumS672Oo - 12 sockets, 672 CPU threads, 336 CPU cores, 13.5 TB total memory, 4.5 TB DRAM, + // 9 TB memory optane, 21.1 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS672Oo AzureLargeInstanceSizeNamesEnum = "S672oo" + // AzureLargeInstanceSizeNamesEnumS672Oom - 12 sockets, 672 CPU threads, 336 CPU cores, 27 TB total memory, 9 TB DRAM, 18 + // TB memory optane, 40 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS672Oom AzureLargeInstanceSizeNamesEnum = "S672oom" + // AzureLargeInstanceSizeNamesEnumS672Ooo - 12 sockets, 672 CPU threads, 336 CPU cores, 22.5 TB total memory, 4.5 TB DRAM, + // 18 TB memory optane, 33.7 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS672Ooo AzureLargeInstanceSizeNamesEnum = "S672ooo" + // AzureLargeInstanceSizeNamesEnumS72 - Type I class SKU that can't be purchased anymore + AzureLargeInstanceSizeNamesEnumS72 AzureLargeInstanceSizeNamesEnum = "S72" + // AzureLargeInstanceSizeNamesEnumS72M - Type I class SKU that can't be purchased anymore + AzureLargeInstanceSizeNamesEnumS72M AzureLargeInstanceSizeNamesEnum = "S72m" + // AzureLargeInstanceSizeNamesEnumS768 - No longer offered or used. + AzureLargeInstanceSizeNamesEnumS768 AzureLargeInstanceSizeNamesEnum = "S768" + // AzureLargeInstanceSizeNamesEnumS768M - 16 sockets, 768 CPU threads, 384 CPU cores, 16 TB total memory, 16 TB DRAM, 36 TB + // storage, HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS768M AzureLargeInstanceSizeNamesEnum = "S768m" + // AzureLargeInstanceSizeNamesEnumS768Xm - 16 sockets, 768 CPU threads, 384 CPU cores, 24 TB total memory, 24 TB DRAM, 56 + // TB storage, HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS768Xm AzureLargeInstanceSizeNamesEnum = "S768xm" + // AzureLargeInstanceSizeNamesEnumS896 - 16 sockets, 896 CPU threads, 448 CPU cores, 12 TB total memory, 12 TB DRAM, 18.9 + // TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS896 AzureLargeInstanceSizeNamesEnum = "S896" + // AzureLargeInstanceSizeNamesEnumS896M - 16 sockets, 896 CPU threads, 448 CPU cores, 24 TB total memory, 24 TB DRAM, 35.8 + // TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS896M AzureLargeInstanceSizeNamesEnum = "S896m" + // AzureLargeInstanceSizeNamesEnumS896Om - 16 sockets, 896 CPU threads, 448 CPU cores, 24 TB total memory, 12 TB DRAM, 12 + // TB memory optane, 35.8 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS896Om AzureLargeInstanceSizeNamesEnum = "S896om" + // AzureLargeInstanceSizeNamesEnumS896Oo - 16 sockets, 896 CPU threads, 448 CPU cores, 18 TB total memory, 6 TB DRAM, 12 TB + // memory optane, 27.4 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS896Oo AzureLargeInstanceSizeNamesEnum = "S896oo" + // AzureLargeInstanceSizeNamesEnumS896Oom - 16 sockets, 896 CPU threads, 448 CPU cores, 36 TB total memory, 12 TB DRAM, 24 + // TB memory optane, 52.7 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS896Oom AzureLargeInstanceSizeNamesEnum = "S896oom" + // AzureLargeInstanceSizeNamesEnumS896Ooo - 16 sockets, 896 CPU threads, 448 CPU cores, 30 TB total memory, 6 TB DRAM, 24 + // TB memory optane, 44.3 TB storage, SDFLEX hardware type + AzureLargeInstanceSizeNamesEnumS896Ooo AzureLargeInstanceSizeNamesEnum = "S896ooo" + // AzureLargeInstanceSizeNamesEnumS96 - 2 sockets, 96 CPU threads, 48 CPU cores, 768 GB total memory, 768 GB DRAM, 3.0 TB + // storage, Cisco_UCS hardware type + AzureLargeInstanceSizeNamesEnumS96 AzureLargeInstanceSizeNamesEnum = "S96" + // AzureLargeInstanceSizeNamesEnumS960M - 20 sockets, 960 CPU threads, 480 CPU cores, 20 TB total memory, 20 TB DRAM, 46 TB + // storage, HPEMc990x hardware type + AzureLargeInstanceSizeNamesEnumS960M AzureLargeInstanceSizeNamesEnum = "S960m" +) + +// PossibleAzureLargeInstanceSizeNamesEnumValues returns the possible values for the AzureLargeInstanceSizeNamesEnum const type. +func PossibleAzureLargeInstanceSizeNamesEnumValues() []AzureLargeInstanceSizeNamesEnum { + return []AzureLargeInstanceSizeNamesEnum{ + AzureLargeInstanceSizeNamesEnumS112, + AzureLargeInstanceSizeNamesEnumS144, + AzureLargeInstanceSizeNamesEnumS144M, + AzureLargeInstanceSizeNamesEnumS192, + AzureLargeInstanceSizeNamesEnumS192M, + AzureLargeInstanceSizeNamesEnumS192Xm, + AzureLargeInstanceSizeNamesEnumS224, + AzureLargeInstanceSizeNamesEnumS224M, + AzureLargeInstanceSizeNamesEnumS224Om, + AzureLargeInstanceSizeNamesEnumS224Oo, + AzureLargeInstanceSizeNamesEnumS224Oom, + AzureLargeInstanceSizeNamesEnumS224Ooo, + AzureLargeInstanceSizeNamesEnumS224Se, + AzureLargeInstanceSizeNamesEnumS384, + AzureLargeInstanceSizeNamesEnumS384M, + AzureLargeInstanceSizeNamesEnumS384Xm, + AzureLargeInstanceSizeNamesEnumS384Xxm, + AzureLargeInstanceSizeNamesEnumS448, + AzureLargeInstanceSizeNamesEnumS448M, + AzureLargeInstanceSizeNamesEnumS448Om, + AzureLargeInstanceSizeNamesEnumS448Oo, + AzureLargeInstanceSizeNamesEnumS448Oom, + AzureLargeInstanceSizeNamesEnumS448Ooo, + AzureLargeInstanceSizeNamesEnumS448Se, + AzureLargeInstanceSizeNamesEnumS576M, + AzureLargeInstanceSizeNamesEnumS576Xm, + AzureLargeInstanceSizeNamesEnumS672, + AzureLargeInstanceSizeNamesEnumS672M, + AzureLargeInstanceSizeNamesEnumS672Om, + AzureLargeInstanceSizeNamesEnumS672Oo, + AzureLargeInstanceSizeNamesEnumS672Oom, + AzureLargeInstanceSizeNamesEnumS672Ooo, + AzureLargeInstanceSizeNamesEnumS72, + AzureLargeInstanceSizeNamesEnumS72M, + AzureLargeInstanceSizeNamesEnumS768, + AzureLargeInstanceSizeNamesEnumS768M, + AzureLargeInstanceSizeNamesEnumS768Xm, + AzureLargeInstanceSizeNamesEnumS896, + AzureLargeInstanceSizeNamesEnumS896M, + AzureLargeInstanceSizeNamesEnumS896Om, + AzureLargeInstanceSizeNamesEnumS896Oo, + AzureLargeInstanceSizeNamesEnumS896Oom, + AzureLargeInstanceSizeNamesEnumS896Ooo, + AzureLargeInstanceSizeNamesEnumS96, + AzureLargeInstanceSizeNamesEnumS960M, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - An enum of possible operation states for an AzureLargeStorageInstances +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Accepted means ARM resource has been accepted. + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Cancelled means resource operation has been cancelled + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating - Creating means ARM resource is being created. + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting - Deleting means resource is in the process of being deleted + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Failed means resource is in failed state + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateMigrating - Migrating means resource is being migrated from one subscription or resource group to another + ProvisioningStateMigrating ProvisioningState = "Migrating" + // ProvisioningStateSucceeded - Succeeded means resource creation succeeded during last create/update + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Updating means an existing ARM resource is being updated + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateMigrating, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargeinstance_server.go b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargeinstance_server.go new file mode 100644 index 000000000000..6737c7cedc54 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargeinstance_server.go @@ -0,0 +1,399 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// AzureLargeInstanceServer is a fake server for instances of the armlargeinstance.AzureLargeInstanceClient type. +type AzureLargeInstanceServer struct { + // Get is the fake for method AzureLargeInstanceClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *armlargeinstance.AzureLargeInstanceClientGetOptions) (resp azfake.Responder[armlargeinstance.AzureLargeInstanceClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method AzureLargeInstanceClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armlargeinstance.AzureLargeInstanceClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlargeinstance.AzureLargeInstanceClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method AzureLargeInstanceClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlargeinstance.AzureLargeInstanceClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlargeinstance.AzureLargeInstanceClientListBySubscriptionResponse]) + + // BeginRestart is the fake for method AzureLargeInstanceClient.BeginRestart + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginRestart func(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *armlargeinstance.AzureLargeInstanceClientBeginRestartOptions) (resp azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientRestartResponse], errResp azfake.ErrorResponder) + + // BeginShutdown is the fake for method AzureLargeInstanceClient.BeginShutdown + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginShutdown func(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *armlargeinstance.AzureLargeInstanceClientBeginShutdownOptions) (resp azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientShutdownResponse], errResp azfake.ErrorResponder) + + // BeginStart is the fake for method AzureLargeInstanceClient.BeginStart + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginStart func(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, options *armlargeinstance.AzureLargeInstanceClientBeginStartOptions) (resp azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientStartResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method AzureLargeInstanceClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, azureLargeInstanceName string, properties armlargeinstance.AzureLargeInstanceTagsUpdate, options *armlargeinstance.AzureLargeInstanceClientUpdateOptions) (resp azfake.Responder[armlargeinstance.AzureLargeInstanceClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAzureLargeInstanceServerTransport creates a new instance of AzureLargeInstanceServerTransport with the provided implementation. +// The returned AzureLargeInstanceServerTransport instance is connected to an instance of armlargeinstance.AzureLargeInstanceClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAzureLargeInstanceServerTransport(srv *AzureLargeInstanceServer) *AzureLargeInstanceServerTransport { + return &AzureLargeInstanceServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlargeinstance.AzureLargeInstanceClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlargeinstance.AzureLargeInstanceClientListBySubscriptionResponse]](), + beginRestart: newTracker[azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientRestartResponse]](), + beginShutdown: newTracker[azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientShutdownResponse]](), + beginStart: newTracker[azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientStartResponse]](), + } +} + +// AzureLargeInstanceServerTransport connects instances of armlargeinstance.AzureLargeInstanceClient to instances of AzureLargeInstanceServer. +// Don't use this type directly, use NewAzureLargeInstanceServerTransport instead. +type AzureLargeInstanceServerTransport struct { + srv *AzureLargeInstanceServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlargeinstance.AzureLargeInstanceClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlargeinstance.AzureLargeInstanceClientListBySubscriptionResponse]] + beginRestart *tracker[azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientRestartResponse]] + beginShutdown *tracker[azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientShutdownResponse]] + beginStart *tracker[azfake.PollerResponder[armlargeinstance.AzureLargeInstanceClientStartResponse]] +} + +// Do implements the policy.Transporter interface for AzureLargeInstanceServerTransport. +func (a *AzureLargeInstanceServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "AzureLargeInstanceClient.Get": + resp, err = a.dispatchGet(req) + case "AzureLargeInstanceClient.NewListByResourceGroupPager": + resp, err = a.dispatchNewListByResourceGroupPager(req) + case "AzureLargeInstanceClient.NewListBySubscriptionPager": + resp, err = a.dispatchNewListBySubscriptionPager(req) + case "AzureLargeInstanceClient.BeginRestart": + resp, err = a.dispatchBeginRestart(req) + case "AzureLargeInstanceClient.BeginShutdown": + resp, err = a.dispatchBeginShutdown(req) + case "AzureLargeInstanceClient.BeginStart": + resp, err = a.dispatchBeginStart(req) + case "AzureLargeInstanceClient.Update": + resp, err = a.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AzureLargeInstanceServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + azureLargeInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("azureLargeInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, azureLargeInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureLargeInstance, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AzureLargeInstanceServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := a.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeInstances` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + a.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armlargeinstance.AzureLargeInstanceClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + a.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (a *AzureLargeInstanceServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := a.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeInstances` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := a.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + a.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlargeinstance.AzureLargeInstanceClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + a.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (a *AzureLargeInstanceServerTransport) dispatchBeginRestart(req *http.Request) (*http.Response, error) { + if a.srv.BeginRestart == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRestart not implemented")} + } + beginRestart := a.beginRestart.get(req) + if beginRestart == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/restart` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlargeinstance.ForceState](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + azureLargeInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("azureLargeInstanceName")]) + if err != nil { + return nil, err + } + var options *armlargeinstance.AzureLargeInstanceClientBeginRestartOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlargeinstance.AzureLargeInstanceClientBeginRestartOptions{ + ForceParameter: &body, + } + } + respr, errRespr := a.srv.BeginRestart(req.Context(), resourceGroupNameParam, azureLargeInstanceNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRestart = &respr + a.beginRestart.add(req, beginRestart) + } + + resp, err := server.PollerResponderNext(beginRestart, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginRestart.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRestart) { + a.beginRestart.remove(req) + } + + return resp, nil +} + +func (a *AzureLargeInstanceServerTransport) dispatchBeginShutdown(req *http.Request) (*http.Response, error) { + if a.srv.BeginShutdown == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginShutdown not implemented")} + } + beginShutdown := a.beginShutdown.get(req) + if beginShutdown == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/shutdown` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + azureLargeInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("azureLargeInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginShutdown(req.Context(), resourceGroupNameParam, azureLargeInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginShutdown = &respr + a.beginShutdown.add(req, beginShutdown) + } + + resp, err := server.PollerResponderNext(beginShutdown, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginShutdown.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginShutdown) { + a.beginShutdown.remove(req) + } + + return resp, nil +} + +func (a *AzureLargeInstanceServerTransport) dispatchBeginStart(req *http.Request) (*http.Response, error) { + if a.srv.BeginStart == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStart not implemented")} + } + beginStart := a.beginStart.get(req) + if beginStart == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/start` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + azureLargeInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("azureLargeInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginStart(req.Context(), resourceGroupNameParam, azureLargeInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStart = &respr + a.beginStart.add(req, beginStart) + } + + resp, err := server.PollerResponderNext(beginStart, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + a.beginStart.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStart) { + a.beginStart.remove(req) + } + + return resp, nil +} + +func (a *AzureLargeInstanceServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if a.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlargeinstance.AzureLargeInstanceTagsUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + azureLargeInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("azureLargeInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Update(req.Context(), resourceGroupNameParam, azureLargeInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureLargeInstance, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargestorageinstance_server.go b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargestorageinstance_server.go new file mode 100644 index 000000000000..ea64f5ca1cd0 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/azurelargestorageinstance_server.go @@ -0,0 +1,232 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance" + "net/http" + "net/url" + "regexp" +) + +// AzureLargeStorageInstanceServer is a fake server for instances of the armlargeinstance.AzureLargeStorageInstanceClient type. +type AzureLargeStorageInstanceServer struct { + // Get is the fake for method AzureLargeStorageInstanceClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, azureLargeStorageInstanceName string, options *armlargeinstance.AzureLargeStorageInstanceClientGetOptions) (resp azfake.Responder[armlargeinstance.AzureLargeStorageInstanceClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method AzureLargeStorageInstanceClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armlargeinstance.AzureLargeStorageInstanceClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlargeinstance.AzureLargeStorageInstanceClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method AzureLargeStorageInstanceClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlargeinstance.AzureLargeStorageInstanceClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlargeinstance.AzureLargeStorageInstanceClientListBySubscriptionResponse]) + + // Update is the fake for method AzureLargeStorageInstanceClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, azureLargeStorageInstanceName string, properties armlargeinstance.AzureLargeStorageInstanceTagsUpdate, options *armlargeinstance.AzureLargeStorageInstanceClientUpdateOptions) (resp azfake.Responder[armlargeinstance.AzureLargeStorageInstanceClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAzureLargeStorageInstanceServerTransport creates a new instance of AzureLargeStorageInstanceServerTransport with the provided implementation. +// The returned AzureLargeStorageInstanceServerTransport instance is connected to an instance of armlargeinstance.AzureLargeStorageInstanceClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAzureLargeStorageInstanceServerTransport(srv *AzureLargeStorageInstanceServer) *AzureLargeStorageInstanceServerTransport { + return &AzureLargeStorageInstanceServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlargeinstance.AzureLargeStorageInstanceClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlargeinstance.AzureLargeStorageInstanceClientListBySubscriptionResponse]](), + } +} + +// AzureLargeStorageInstanceServerTransport connects instances of armlargeinstance.AzureLargeStorageInstanceClient to instances of AzureLargeStorageInstanceServer. +// Don't use this type directly, use NewAzureLargeStorageInstanceServerTransport instead. +type AzureLargeStorageInstanceServerTransport struct { + srv *AzureLargeStorageInstanceServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlargeinstance.AzureLargeStorageInstanceClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlargeinstance.AzureLargeStorageInstanceClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for AzureLargeStorageInstanceServerTransport. +func (a *AzureLargeStorageInstanceServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "AzureLargeStorageInstanceClient.Get": + resp, err = a.dispatchGet(req) + case "AzureLargeStorageInstanceClient.NewListByResourceGroupPager": + resp, err = a.dispatchNewListByResourceGroupPager(req) + case "AzureLargeStorageInstanceClient.NewListBySubscriptionPager": + resp, err = a.dispatchNewListBySubscriptionPager(req) + case "AzureLargeStorageInstanceClient.Update": + resp, err = a.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AzureLargeStorageInstanceServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeStorageInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + azureLargeStorageInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("azureLargeStorageInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, azureLargeStorageInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureLargeStorageInstance, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AzureLargeStorageInstanceServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := a.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeStorageInstances` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + a.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armlargeinstance.AzureLargeStorageInstanceClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + a.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (a *AzureLargeStorageInstanceServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := a.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeStorageInstances` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := a.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + a.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlargeinstance.AzureLargeStorageInstanceClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + a.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (a *AzureLargeStorageInstanceServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if a.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureLargeInstance/azureLargeStorageInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlargeinstance.AzureLargeStorageInstanceTagsUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + azureLargeStorageInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("azureLargeStorageInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Update(req.Context(), resourceGroupNameParam, azureLargeStorageInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureLargeStorageInstance, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/fake/internal.go b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/internal.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/fake/operations_server.go b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/operations_server.go new file mode 100644 index 000000000000..e42aeda2c9c1 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance" + "net/http" +) + +// OperationsServer is a fake server for instances of the armlargeinstance.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armlargeinstance.OperationsClientListOptions) (resp azfake.PagerResponder[armlargeinstance.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armlargeinstance.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlargeinstance.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armlargeinstance.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armlargeinstance.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlargeinstance.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/fake/server_factory.go b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/server_factory.go new file mode 100644 index 000000000000..b8b3c80b471f --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/server_factory.go @@ -0,0 +1,89 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armlargeinstance.ClientFactory type. +type ServerFactory struct { + AzureLargeInstanceServer AzureLargeInstanceServer + AzureLargeStorageInstanceServer AzureLargeStorageInstanceServer + OperationsServer OperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armlargeinstance.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armlargeinstance.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trAzureLargeInstanceServer *AzureLargeInstanceServerTransport + trAzureLargeStorageInstanceServer *AzureLargeStorageInstanceServerTransport + trOperationsServer *OperationsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "AzureLargeInstanceClient": + initServer(s, &s.trAzureLargeInstanceServer, func() *AzureLargeInstanceServerTransport { + return NewAzureLargeInstanceServerTransport(&s.srv.AzureLargeInstanceServer) + }) + resp, err = s.trAzureLargeInstanceServer.Do(req) + case "AzureLargeStorageInstanceClient": + initServer(s, &s.trAzureLargeStorageInstanceServer, func() *AzureLargeStorageInstanceServerTransport { + return NewAzureLargeStorageInstanceServerTransport(&s.srv.AzureLargeStorageInstanceServer) + }) + resp, err = s.trAzureLargeStorageInstanceServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/fake/time_rfc3339.go b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/time_rfc3339.go new file mode 100644 index 000000000000..81f308b0d343 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/fake/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/go.mod b/sdk/resourcemanager/largeinstance/armlargeinstance/go.mod new file mode 100644 index 000000000000..f1c416e11bad --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect + github.com/golang-jwt/jwt/v5 v5.2.0 // indirect + github.com/google/uuid v1.5.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/go.sum b/sdk/resourcemanager/largeinstance/armlargeinstance/go.sum new file mode 100644 index 000000000000..fa6f57056f38 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/go.sum @@ -0,0 +1,31 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2 h1:c4k2FIYIh4xtwqrQwV0Ct1v5+ehlNXj5NI/MWVsiTkQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.2/go.mod h1:5FDJtLEO/GxwNgUxbwrY3LP0pEoThTQJtk2oysdXHxM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 h1:sO0/P7g68FrryJzljemN+6GTssUXdANk6aJ7T1ZxnsQ= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMivxiS2iYFZsgDbU9OnnJ163x5UGVKYo= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2 h1:LqbJ/WzJUwBf8UiaSzgX7aMclParm9/5Vgp+TY51uBQ= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.2/go.mod h1:yInRyqWXAuaPrgI7p70+lDDgh3mlBohis29jGMISnmc= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/models.go b/sdk/resourcemanager/largeinstance/armlargeinstance/models.go new file mode 100644 index 000000000000..fc4be44270af --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/models.go @@ -0,0 +1,359 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +import "time" + +// AzureLargeInstance - Azure Large Instance info on Azure (ARM properties and AzureLargeInstance properties) +type AzureLargeInstance struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *AzureLargeInstanceProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// AzureLargeInstanceListResult - The response of a AzureLargeInstance list operation. +type AzureLargeInstanceListResult struct { + // REQUIRED; The AzureLargeInstance items on this page + Value []*AzureLargeInstance + + // The link to the next page of items + NextLink *string +} + +// AzureLargeInstanceProperties - Describes the properties of an Azure Large Instance. +type AzureLargeInstanceProperties struct { + // Specifies the hardware settings for the Azure Large Instance. + HardwareProfile *HardwareProfile + + // Specifies the network settings for the Azure Large Instance. + NetworkProfile *NetworkProfile + + // Specifies the operating system settings for the Azure Large Instance. + OSProfile *OsProfile + + // ARM ID of another AzureLargeInstance that will share a network with this AzureLargeInstance + PartnerNodeID *string + + // Specifies the storage settings for the Azure Large Instance disks. + StorageProfile *StorageProfile + + // READ-ONLY; Specifies the Azure Large Instance unique ID. + AzureLargeInstanceID *string + + // READ-ONLY; Hardware revision of an Azure Large Instance + HwRevision *string + + // READ-ONLY; Resource power state + PowerState *AzureLargeInstancePowerStateEnum + + // READ-ONLY; State of provisioning of the AzureLargeInstance + ProvisioningState *AzureLargeInstanceProvisioningStatesEnum + + // READ-ONLY; Resource proximity placement group + ProximityPlacementGroup *string +} + +// AzureLargeInstanceTagsUpdate - The type used for updating tags in AzureLargeInstance resources. +type AzureLargeInstanceTagsUpdate struct { + // Resource tags. + Tags map[string]*string +} + +// AzureLargeStorageInstance info on Azure (ARM properties and AzureLargeStorageInstance properties) +type AzureLargeStorageInstance struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *AzureLargeStorageInstanceProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// AzureLargeStorageInstanceListResult - The response of a AzureLargeStorageInstance list operation. +type AzureLargeStorageInstanceListResult struct { + // REQUIRED; The AzureLargeStorageInstance items on this page + Value []*AzureLargeStorageInstance + + // The link to the next page of items + NextLink *string +} + +// AzureLargeStorageInstanceProperties - Describes the properties of an AzureLargeStorageInstance. +type AzureLargeStorageInstanceProperties struct { + // Specifies the AzureLargeStorageInstance unique ID. + AzureLargeStorageInstanceUniqueIdentifier *string + + // Specifies the storage properties for the AzureLargeStorage instance. + StorageProperties *StorageProperties +} + +// AzureLargeStorageInstanceTagsUpdate - The type used for updating tags in AzureLargeStorageInstance resources. +type AzureLargeStorageInstanceTagsUpdate struct { + // Resource tags. + Tags map[string]*string +} + +// Disk - Specifies the disk information fo the Azure Large Instance +type Disk struct { + // Specifies the size of an empty data disk in gigabytes. + DiskSizeGB *int32 + + // The disk name. + Name *string + + // READ-ONLY; Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM + // and therefore must be unique for each data disk attached to a VM. + Lun *int32 +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info any + + // READ-ONLY; The additional info type. + Type *string +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo + + // READ-ONLY; The error code. + Code *string + + // READ-ONLY; The error details. + Details []*ErrorDetail + + // READ-ONLY; The error message. + Message *string + + // READ-ONLY; The error target. + Target *string +} + +// ForceState - The active state empowers the server with the ability to forcefully terminate and halt any existing processes +// that may be running on the server +type ForceState struct { + // Whether to force restart by shutting all processes. + ForceState *AzureLargeInstanceForcePowerState +} + +// HardwareProfile - Specifies the hardware settings for the Azure Large Instance. +type HardwareProfile struct { + // READ-ONLY; Specifies the Azure Large Instance SKU. + AzureLargeInstanceSize *AzureLargeInstanceSizeNamesEnum + + // READ-ONLY; Name of the hardware type (vendor and/or their product name) + HardwareType *AzureLargeInstanceHardwareTypeNamesEnum +} + +// IPAddress - Specifies the IP address of the network interface. +type IPAddress struct { + // Specifies the IP address of the network interface. + IPAddress *string +} + +// NetworkProfile - Specifies the network settings for the Azure Large Instance disks. +type NetworkProfile struct { + // Specifies the network interfaces for the Azure Large Instance. + NetworkInterfaces []*IPAddress + + // READ-ONLY; Specifies the circuit id for connecting to express route. + CircuitID *string +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// OperationStatusResult - The current status of an async operation. +type OperationStatusResult struct { + // REQUIRED; Operation status. + Status *string + + // The end time of the operation. + EndTime *time.Time + + // If present, details of the operation error. + Error *ErrorDetail + + // Fully qualified ID for the async operation. + ID *string + + // Name of the async operation. + Name *string + + // The operations list. + Operations []*OperationStatusResult + + // Percent of the operation that is complete. + PercentComplete *float32 + + // The start time of the operation. + StartTime *time.Time + + // READ-ONLY; Fully qualified ID of the resource against which the original async operation was started. + ResourceID *string +} + +// OsProfile - Specifies the operating system settings for the Azure Large Instance. +type OsProfile struct { + // Specifies the host OS name of the Azure Large Instance. + ComputerName *string + + // Specifies the SSH public key used to access the operating system. + SSHPublicKey *string + + // READ-ONLY; This property allows you to specify the type of the OS. + OSType *string + + // READ-ONLY; Specifies version of operating system. + Version *string +} + +// StorageBillingProperties - Describes the billing related details of the AzureLargeStorageInstance. +type StorageBillingProperties struct { + // the billing mode for the storage instance + BillingMode *string + + // the SKU type that is provisioned + SKU *string +} + +// StorageProfile - Specifies the storage settings for the Azure Large Instance disks. +type StorageProfile struct { + // Specifies information about the operating system disk used by Azure Large Instance. + OSDisks []*Disk + + // READ-ONLY; IP Address to connect to storage. + NfsIPAddress *string +} + +// StorageProperties - described the storage properties of the azure large storage instance +type StorageProperties struct { + // the kind of storage instance + Generation *string + + // the hardware type of the storage instance + HardwareType *AzureLargeInstanceHardwareTypeNamesEnum + + // the offering type for which the resource is getting provisioned + OfferingType *string + + // the billing related information for the resource + StorageBillingProperties *StorageBillingProperties + + // the storage protocol for which the resource is getting provisioned + StorageType *string + + // the workload for which the resource is getting provisioned + WorkloadType *string + + // READ-ONLY; State of provisioning of the AzureLargeStorageInstance + ProvisioningState *ProvisioningState +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/models_serde.go b/sdk/resourcemanager/largeinstance/armlargeinstance/models_serde.go new file mode 100644 index 000000000000..4ddbdf65e7a8 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/models_serde.go @@ -0,0 +1,954 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AzureLargeInstance. +func (a AzureLargeInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeInstance. +func (a *AzureLargeInstance) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureLargeInstanceListResult. +func (a AzureLargeInstanceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeInstanceListResult. +func (a *AzureLargeInstanceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureLargeInstanceProperties. +func (a AzureLargeInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureLargeInstanceId", a.AzureLargeInstanceID) + populate(objectMap, "hardwareProfile", a.HardwareProfile) + populate(objectMap, "hwRevision", a.HwRevision) + populate(objectMap, "networkProfile", a.NetworkProfile) + populate(objectMap, "osProfile", a.OSProfile) + populate(objectMap, "partnerNodeId", a.PartnerNodeID) + populate(objectMap, "powerState", a.PowerState) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "proximityPlacementGroup", a.ProximityPlacementGroup) + populate(objectMap, "storageProfile", a.StorageProfile) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeInstanceProperties. +func (a *AzureLargeInstanceProperties) 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 "azureLargeInstanceId": + err = unpopulate(val, "AzureLargeInstanceID", &a.AzureLargeInstanceID) + delete(rawMsg, key) + case "hardwareProfile": + err = unpopulate(val, "HardwareProfile", &a.HardwareProfile) + delete(rawMsg, key) + case "hwRevision": + err = unpopulate(val, "HwRevision", &a.HwRevision) + delete(rawMsg, key) + case "networkProfile": + err = unpopulate(val, "NetworkProfile", &a.NetworkProfile) + delete(rawMsg, key) + case "osProfile": + err = unpopulate(val, "OSProfile", &a.OSProfile) + delete(rawMsg, key) + case "partnerNodeId": + err = unpopulate(val, "PartnerNodeID", &a.PartnerNodeID) + delete(rawMsg, key) + case "powerState": + err = unpopulate(val, "PowerState", &a.PowerState) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "proximityPlacementGroup": + err = unpopulate(val, "ProximityPlacementGroup", &a.ProximityPlacementGroup) + delete(rawMsg, key) + case "storageProfile": + err = unpopulate(val, "StorageProfile", &a.StorageProfile) + 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 AzureLargeInstanceTagsUpdate. +func (a AzureLargeInstanceTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeInstanceTagsUpdate. +func (a *AzureLargeInstanceTagsUpdate) 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 "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 AzureLargeStorageInstance. +func (a AzureLargeStorageInstance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeStorageInstance. +func (a *AzureLargeStorageInstance) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureLargeStorageInstanceListResult. +func (a AzureLargeStorageInstanceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeStorageInstanceListResult. +func (a *AzureLargeStorageInstanceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AzureLargeStorageInstanceProperties. +func (a AzureLargeStorageInstanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureLargeStorageInstanceUniqueIdentifier", a.AzureLargeStorageInstanceUniqueIdentifier) + populate(objectMap, "storageProperties", a.StorageProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeStorageInstanceProperties. +func (a *AzureLargeStorageInstanceProperties) 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 "azureLargeStorageInstanceUniqueIdentifier": + err = unpopulate(val, "AzureLargeStorageInstanceUniqueIdentifier", &a.AzureLargeStorageInstanceUniqueIdentifier) + delete(rawMsg, key) + case "storageProperties": + err = unpopulate(val, "StorageProperties", &a.StorageProperties) + 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 AzureLargeStorageInstanceTagsUpdate. +func (a AzureLargeStorageInstanceTagsUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureLargeStorageInstanceTagsUpdate. +func (a *AzureLargeStorageInstanceTagsUpdate) 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 "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 Disk. +func (d Disk) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskSizeGB", d.DiskSizeGB) + populate(objectMap, "lun", d.Lun) + populate(objectMap, "name", d.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Disk. +func (d *Disk) 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 "diskSizeGB": + err = unpopulate(val, "DiskSizeGB", &d.DiskSizeGB) + delete(rawMsg, key) + case "lun": + err = unpopulate(val, "Lun", &d.Lun) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateAny(objectMap, "info", e.Info) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorAdditionalInfo. +func (e *ErrorAdditionalInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "info": + err = unpopulate(val, "Info", &e.Info) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ForceState. +func (f ForceState) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "forceState", f.ForceState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ForceState. +func (f *ForceState) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "forceState": + err = unpopulate(val, "ForceState", &f.ForceState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HardwareProfile. +func (h HardwareProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "azureLargeInstanceSize", h.AzureLargeInstanceSize) + populate(objectMap, "hardwareType", h.HardwareType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HardwareProfile. +func (h *HardwareProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "azureLargeInstanceSize": + err = unpopulate(val, "AzureLargeInstanceSize", &h.AzureLargeInstanceSize) + delete(rawMsg, key) + case "hardwareType": + err = unpopulate(val, "HardwareType", &h.HardwareType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IPAddress. +func (i IPAddress) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ipAddress", i.IPAddress) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IPAddress. +func (i *IPAddress) 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 "ipAddress": + err = unpopulate(val, "IPAddress", &i.IPAddress) + 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 NetworkProfile. +func (n NetworkProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "circuitId", n.CircuitID) + populate(objectMap, "networkInterfaces", n.NetworkInterfaces) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NetworkProfile. +func (n *NetworkProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "circuitId": + err = unpopulate(val, "CircuitID", &n.CircuitID) + delete(rawMsg, key) + case "networkInterfaces": + err = unpopulate(val, "NetworkInterfaces", &n.NetworkInterfaces) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationStatusResult. +func (o OperationStatusResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "endTime", o.EndTime) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "operations", o.Operations) + populate(objectMap, "percentComplete", o.PercentComplete) + populate(objectMap, "resourceId", o.ResourceID) + populateDateTimeRFC3339(objectMap, "startTime", o.StartTime) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatusResult. +func (o *OperationStatusResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulateDateTimeRFC3339(val, "EndTime", &o.EndTime) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "operations": + err = unpopulate(val, "Operations", &o.Operations) + delete(rawMsg, key) + case "percentComplete": + err = unpopulate(val, "PercentComplete", &o.PercentComplete) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &o.ResourceID) + delete(rawMsg, key) + case "startTime": + err = unpopulateDateTimeRFC3339(val, "StartTime", &o.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OsProfile. +func (o OsProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "computerName", o.ComputerName) + populate(objectMap, "osType", o.OSType) + populate(objectMap, "sshPublicKey", o.SSHPublicKey) + populate(objectMap, "version", o.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OsProfile. +func (o *OsProfile) 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 "computerName": + err = unpopulate(val, "ComputerName", &o.ComputerName) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &o.OSType) + delete(rawMsg, key) + case "sshPublicKey": + err = unpopulate(val, "SSHPublicKey", &o.SSHPublicKey) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &o.Version) + 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 StorageBillingProperties. +func (s StorageBillingProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingMode", s.BillingMode) + populate(objectMap, "sku", s.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageBillingProperties. +func (s *StorageBillingProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingMode": + err = unpopulate(val, "BillingMode", &s.BillingMode) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageProfile. +func (s StorageProfile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nfsIpAddress", s.NfsIPAddress) + populate(objectMap, "osDisks", s.OSDisks) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageProfile. +func (s *StorageProfile) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nfsIpAddress": + err = unpopulate(val, "NfsIPAddress", &s.NfsIPAddress) + delete(rawMsg, key) + case "osDisks": + err = unpopulate(val, "OSDisks", &s.OSDisks) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageProperties. +func (s StorageProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "generation", s.Generation) + populate(objectMap, "hardwareType", s.HardwareType) + populate(objectMap, "offeringType", s.OfferingType) + populate(objectMap, "provisioningState", s.ProvisioningState) + populate(objectMap, "storageBillingProperties", s.StorageBillingProperties) + populate(objectMap, "storageType", s.StorageType) + populate(objectMap, "workloadType", s.WorkloadType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageProperties. +func (s *StorageProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "generation": + err = unpopulate(val, "Generation", &s.Generation) + delete(rawMsg, key) + case "hardwareType": + err = unpopulate(val, "HardwareType", &s.HardwareType) + delete(rawMsg, key) + case "offeringType": + err = unpopulate(val, "OfferingType", &s.OfferingType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + delete(rawMsg, key) + case "storageBillingProperties": + err = unpopulate(val, "StorageBillingProperties", &s.StorageBillingProperties) + delete(rawMsg, key) + case "storageType": + err = unpopulate(val, "StorageType", &s.StorageType) + delete(rawMsg, key) + case "workloadType": + err = unpopulate(val, "WorkloadType", &s.WorkloadType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func populateAny(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil || string(data) == "null" { + 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/largeinstance/armlargeinstance/operations_client.go b/sdk/resourcemanager/largeinstance/armlargeinstance/operations_client.go new file mode 100644 index 000000000000..1d6f3626df08 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// 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) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2023-07-20-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager 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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureLargeInstance/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-07-20-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/operations_client_example_test.go b/sdk/resourcemanager/largeinstance/armlargeinstance/operations_client_example_test.go new file mode 100644 index 000000000000..2db610fcb800 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/operations_client_example_test.go @@ -0,0 +1,66 @@ +//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 armlargeinstance_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/largeinstance/armlargeinstance" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/6051d2b126f5b1e4b623cde8edfa3e25cf730685/specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstanceOperations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armlargeinstance.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armlargeinstance.OperationListResult{ + // Value: []*armlargeinstance.Operation{ + // { + // Name: to.Ptr("Microsoft.AzureLargeInstance/read"), + // Display: &armlargeinstance.OperationDisplay{ + // Description: to.Ptr("Read any AzureLargeInstance"), + // Operation: to.Ptr("Read AzureLargeInstance"), + // Provider: to.Ptr("Microsoft Azure Large Instance"), + // Resource: to.Ptr("AzureLargeInstance"), + // }, + // IsDataAction: to.Ptr(false), + // }, + // { + // Name: to.Ptr("Microsoft.AzureLargeInstance"), + // Display: &armlargeinstance.OperationDisplay{ + // Description: to.Ptr("Start any AzureLargeInstance"), + // Operation: to.Ptr("Start AzureLargeInstance"), + // Provider: to.Ptr("Microsoft Azure Large Instance"), + // Resource: to.Ptr("AzureLargeInstance"), + // }, + // IsDataAction: to.Ptr(true), + // }}, + // } + } +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/options.go b/sdk/resourcemanager/largeinstance/armlargeinstance/options.go new file mode 100644 index 000000000000..94e3f208d459 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/options.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +// AzureLargeInstanceClientBeginRestartOptions contains the optional parameters for the AzureLargeInstanceClient.BeginRestart +// method. +type AzureLargeInstanceClientBeginRestartOptions struct { + // When set to 'active', this parameter empowers the server with the ability to forcefully terminate and halt any existing + // processes that may be running on the server + ForceParameter *ForceState + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AzureLargeInstanceClientBeginShutdownOptions contains the optional parameters for the AzureLargeInstanceClient.BeginShutdown +// method. +type AzureLargeInstanceClientBeginShutdownOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AzureLargeInstanceClientBeginStartOptions contains the optional parameters for the AzureLargeInstanceClient.BeginStart +// method. +type AzureLargeInstanceClientBeginStartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AzureLargeInstanceClientGetOptions contains the optional parameters for the AzureLargeInstanceClient.Get method. +type AzureLargeInstanceClientGetOptions struct { + // placeholder for future optional parameters +} + +// AzureLargeInstanceClientListByResourceGroupOptions contains the optional parameters for the AzureLargeInstanceClient.NewListByResourceGroupPager +// method. +type AzureLargeInstanceClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AzureLargeInstanceClientListBySubscriptionOptions contains the optional parameters for the AzureLargeInstanceClient.NewListBySubscriptionPager +// method. +type AzureLargeInstanceClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// AzureLargeInstanceClientUpdateOptions contains the optional parameters for the AzureLargeInstanceClient.Update method. +type AzureLargeInstanceClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// AzureLargeStorageInstanceClientGetOptions contains the optional parameters for the AzureLargeStorageInstanceClient.Get +// method. +type AzureLargeStorageInstanceClientGetOptions struct { + // placeholder for future optional parameters +} + +// AzureLargeStorageInstanceClientListByResourceGroupOptions contains the optional parameters for the AzureLargeStorageInstanceClient.NewListByResourceGroupPager +// method. +type AzureLargeStorageInstanceClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AzureLargeStorageInstanceClientListBySubscriptionOptions contains the optional parameters for the AzureLargeStorageInstanceClient.NewListBySubscriptionPager +// method. +type AzureLargeStorageInstanceClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// AzureLargeStorageInstanceClientUpdateOptions contains the optional parameters for the AzureLargeStorageInstanceClient.Update +// method. +type AzureLargeStorageInstanceClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/responses.go b/sdk/resourcemanager/largeinstance/armlargeinstance/responses.go new file mode 100644 index 000000000000..508404f98f58 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/responses.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +// AzureLargeInstanceClientGetResponse contains the response from method AzureLargeInstanceClient.Get. +type AzureLargeInstanceClientGetResponse struct { + // Azure Large Instance info on Azure (ARM properties and AzureLargeInstance + // properties) + AzureLargeInstance +} + +// AzureLargeInstanceClientListByResourceGroupResponse contains the response from method AzureLargeInstanceClient.NewListByResourceGroupPager. +type AzureLargeInstanceClientListByResourceGroupResponse struct { + // The response of a AzureLargeInstance list operation. + AzureLargeInstanceListResult +} + +// AzureLargeInstanceClientListBySubscriptionResponse contains the response from method AzureLargeInstanceClient.NewListBySubscriptionPager. +type AzureLargeInstanceClientListBySubscriptionResponse struct { + // The response of a AzureLargeInstance list operation. + AzureLargeInstanceListResult +} + +// AzureLargeInstanceClientRestartResponse contains the response from method AzureLargeInstanceClient.BeginRestart. +type AzureLargeInstanceClientRestartResponse struct { + // The current status of an async operation. + OperationStatusResult +} + +// AzureLargeInstanceClientShutdownResponse contains the response from method AzureLargeInstanceClient.BeginShutdown. +type AzureLargeInstanceClientShutdownResponse struct { + // The current status of an async operation. + OperationStatusResult +} + +// AzureLargeInstanceClientStartResponse contains the response from method AzureLargeInstanceClient.BeginStart. +type AzureLargeInstanceClientStartResponse struct { + // The current status of an async operation. + OperationStatusResult +} + +// AzureLargeInstanceClientUpdateResponse contains the response from method AzureLargeInstanceClient.Update. +type AzureLargeInstanceClientUpdateResponse struct { + // Azure Large Instance info on Azure (ARM properties and AzureLargeInstance + // properties) + AzureLargeInstance +} + +// AzureLargeStorageInstanceClientGetResponse contains the response from method AzureLargeStorageInstanceClient.Get. +type AzureLargeStorageInstanceClientGetResponse struct { + // AzureLargeStorageInstance info on Azure (ARM properties and + // AzureLargeStorageInstance properties) + AzureLargeStorageInstance +} + +// AzureLargeStorageInstanceClientListByResourceGroupResponse contains the response from method AzureLargeStorageInstanceClient.NewListByResourceGroupPager. +type AzureLargeStorageInstanceClientListByResourceGroupResponse struct { + // The response of a AzureLargeStorageInstance list operation. + AzureLargeStorageInstanceListResult +} + +// AzureLargeStorageInstanceClientListBySubscriptionResponse contains the response from method AzureLargeStorageInstanceClient.NewListBySubscriptionPager. +type AzureLargeStorageInstanceClientListBySubscriptionResponse struct { + // The response of a AzureLargeStorageInstance list operation. + AzureLargeStorageInstanceListResult +} + +// AzureLargeStorageInstanceClientUpdateResponse contains the response from method AzureLargeStorageInstanceClient.Update. +type AzureLargeStorageInstanceClientUpdateResponse struct { + // AzureLargeStorageInstance info on Azure (ARM properties and + // AzureLargeStorageInstance properties) + AzureLargeStorageInstance +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} diff --git a/sdk/resourcemanager/largeinstance/armlargeinstance/time_rfc3339.go b/sdk/resourcemanager/largeinstance/armlargeinstance/time_rfc3339.go new file mode 100644 index 000000000000..80a6171f9be1 --- /dev/null +++ b/sdk/resourcemanager/largeinstance/armlargeinstance/time_rfc3339.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armlargeinstance + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}