diff --git a/sdk/resourcemanager/storagemover/armstoragemover/CHANGELOG.md b/sdk/resourcemanager/storagemover/armstoragemover/CHANGELOG.md new file mode 100644 index 000000000000..d8d2638a08aa --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/CHANGELOG.md @@ -0,0 +1,9 @@ +# Release History + +## 0.1.0 (2022-07-21) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagemover/armstoragemover` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 0.1.0, which contains breaking changes. + +To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/azsdk/go/mgmt/migration). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/storagemover/armstoragemover/LICENSE.txt b/sdk/resourcemanager/storagemover/armstoragemover/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/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/storagemover/armstoragemover/README.md b/sdk/resourcemanager/storagemover/armstoragemover/README.md new file mode 100644 index 000000000000..67a196dfbaba --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/README.md @@ -0,0 +1,77 @@ +# Azure Storagemover Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagemover/armstoragemover)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagemover/armstoragemover) + +The `armstoragemover` module provides operations for working with Azure Storagemover. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/storagemover/armstoragemover) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Storagemover module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagemover/armstoragemover +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Storagemover. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Clients + +Azure Storagemover modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armstoragemover.NewEndpointsClient(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions{ + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +client, err := armstoragemover.NewEndpointsClient(, cred, &options) +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Storagemover` 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/storagemover/armstoragemover/agents_client.go b/sdk/resourcemanager/storagemover/armstoragemover/agents_client.go new file mode 100644 index 000000000000..7fc50596f1f1 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/agents_client.go @@ -0,0 +1,377 @@ +//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 armstoragemover + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AgentsClient contains the methods for the Agents group. +// Don't use this type directly, use NewAgentsClient() instead. +type AgentsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewAgentsClient creates a new instance of AgentsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewAgentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AgentsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &AgentsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates an agent resource, which references a hybrid compute machine that can run jobs. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// agentName - The name of the agent resource. +// options - AgentsClientCreateOrUpdateOptions contains the optional parameters for the AgentsClient.CreateOrUpdate method. +func (client *AgentsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, agent Agent, options *AgentsClientCreateOrUpdateOptions) (AgentsClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, storageMoverName, agentName, agent, options) + if err != nil { + return AgentsClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AgentsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AgentsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, agent Agent, options *AgentsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents/{agentName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if agentName == "" { + return nil, errors.New("parameter agentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentName}", url.PathEscape(agentName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, agent) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AgentsClient) createOrUpdateHandleResponse(resp *http.Response) (AgentsClientCreateOrUpdateResponse, error) { + result := AgentsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Agent); err != nil { + return AgentsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes an agent resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// agentName - The name of the agent resource. +// options - AgentsClientBeginDeleteOptions contains the optional parameters for the AgentsClient.BeginDelete method. +func (client *AgentsClient) BeginDelete(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, options *AgentsClientBeginDeleteOptions) (*runtime.Poller[AgentsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storageMoverName, agentName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AgentsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[AgentsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes an agent resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +func (client *AgentsClient) deleteOperation(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, options *AgentsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storageMoverName, agentName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AgentsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, options *AgentsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents/{agentName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if agentName == "" { + return nil, errors.New("parameter agentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentName}", url.PathEscape(agentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets an agent resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// agentName - The name of the agent resource. +// options - AgentsClientGetOptions contains the optional parameters for the AgentsClient.Get method. +func (client *AgentsClient) Get(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, options *AgentsClientGetOptions) (AgentsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, storageMoverName, agentName, options) + if err != nil { + return AgentsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AgentsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AgentsClient) getCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, options *AgentsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents/{agentName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if agentName == "" { + return nil, errors.New("parameter agentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentName}", url.PathEscape(agentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AgentsClient) getHandleResponse(resp *http.Response) (AgentsClientGetResponse, error) { + result := AgentsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Agent); err != nil { + return AgentsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all agents in a Storage Mover. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// options - AgentsClientListOptions contains the optional parameters for the AgentsClient.List method. +func (client *AgentsClient) NewListPager(resourceGroupName string, storageMoverName string, options *AgentsClientListOptions) *runtime.Pager[AgentsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[AgentsClientListResponse]{ + More: func(page AgentsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AgentsClientListResponse) (AgentsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, storageMoverName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AgentsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AgentsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *AgentsClient) listCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, options *AgentsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *AgentsClient) listHandleResponse(resp *http.Response) (AgentsClientListResponse, error) { + result := AgentsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AgentList); err != nil { + return AgentsClientListResponse{}, err + } + return result, nil +} + +// Update - Creates or updates an agent resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// agentName - The name of the agent resource. +// options - AgentsClientUpdateOptions contains the optional parameters for the AgentsClient.Update method. +func (client *AgentsClient) Update(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, agent AgentUpdateParameters, options *AgentsClientUpdateOptions) (AgentsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, storageMoverName, agentName, agent, options) + if err != nil { + return AgentsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AgentsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AgentsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AgentsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, agentName string, agent AgentUpdateParameters, options *AgentsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/agents/{agentName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if agentName == "" { + return nil, errors.New("parameter agentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{agentName}", url.PathEscape(agentName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, agent) +} + +// updateHandleResponse handles the Update response. +func (client *AgentsClient) updateHandleResponse(resp *http.Response) (AgentsClientUpdateResponse, error) { + result := AgentsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Agent); err != nil { + return AgentsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/autorest.md b/sdk/resourcemanager/storagemover/armstoragemover/autorest.md new file mode 100644 index 000000000000..1ea81f8d2e60 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/storagemover/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/storagemover/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/storagemover/armstoragemover/build.go b/sdk/resourcemanager/storagemover/armstoragemover/build.go new file mode 100644 index 000000000000..33eabd9df24e --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/storagemover/armstoragemover + +package armstoragemover diff --git a/sdk/resourcemanager/storagemover/armstoragemover/ci.yml b/sdk/resourcemanager/storagemover/armstoragemover/ci.yml new file mode 100644 index 000000000000..63d7bda48f78 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/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/storagemover/armstoragemover/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/storagemover/armstoragemover/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/storagemover/armstoragemover' diff --git a/sdk/resourcemanager/storagemover/armstoragemover/constants.go b/sdk/resourcemanager/storagemover/armstoragemover/constants.go new file mode 100644 index 000000000000..6f492e3241ba --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/constants.go @@ -0,0 +1,202 @@ +//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 armstoragemover + +const ( + moduleName = "armstoragemover" + 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, + } +} + +// AgentStatus - The agent status. +type AgentStatus string + +const ( + AgentStatusDeprovisioning AgentStatus = "Deprovisioning" + AgentStatusExecuting AgentStatus = "Executing" + AgentStatusOffline AgentStatus = "Offline" + AgentStatusOnline AgentStatus = "Online" + AgentStatusProvisioning AgentStatus = "Provisioning" + AgentStatusRequiresAttention AgentStatus = "RequiresAttention" +) + +// PossibleAgentStatusValues returns the possible values for the AgentStatus const type. +func PossibleAgentStatusValues() []AgentStatus { + return []AgentStatus{ + AgentStatusDeprovisioning, + AgentStatusExecuting, + AgentStatusOffline, + AgentStatusOnline, + AgentStatusProvisioning, + AgentStatusRequiresAttention, + } +} + +// CopyMode - Strategy to use for copy. +type CopyMode string + +const ( + CopyModeAdditive CopyMode = "Additive" + CopyModeMirror CopyMode = "Mirror" +) + +// PossibleCopyModeValues returns the possible values for the CopyMode const type. +func PossibleCopyModeValues() []CopyMode { + return []CopyMode{ + CopyModeAdditive, + CopyModeMirror, + } +} + +// 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, + } +} + +// EndpointType - The endpoint resource type. +type EndpointType string + +const ( + EndpointTypeAzureStorageBlobContainer EndpointType = "AzureStorageBlobContainer" + EndpointTypeNfsMount EndpointType = "NfsMount" +) + +// PossibleEndpointTypeValues returns the possible values for the EndpointType const type. +func PossibleEndpointTypeValues() []EndpointType { + return []EndpointType{ + EndpointTypeAzureStorageBlobContainer, + EndpointTypeNfsMount, + } +} + +// JobRunScanStatus - The status of agent's scanning of source. +type JobRunScanStatus string + +const ( + JobRunScanStatusCompleted JobRunScanStatus = "Completed" + JobRunScanStatusNotStarted JobRunScanStatus = "NotStarted" + JobRunScanStatusScanning JobRunScanStatus = "Scanning" +) + +// PossibleJobRunScanStatusValues returns the possible values for the JobRunScanStatus const type. +func PossibleJobRunScanStatusValues() []JobRunScanStatus { + return []JobRunScanStatus{ + JobRunScanStatusCompleted, + JobRunScanStatusNotStarted, + JobRunScanStatusScanning, + } +} + +// JobRunStatus - The current status of the job run in a non-terminal state, if exists. +type JobRunStatus string + +const ( + JobRunStatusCancelRequested JobRunStatus = "CancelRequested" + JobRunStatusCanceled JobRunStatus = "Canceled" + JobRunStatusCanceling JobRunStatus = "Canceling" + JobRunStatusFailed JobRunStatus = "Failed" + JobRunStatusQueued JobRunStatus = "Queued" + JobRunStatusRunning JobRunStatus = "Running" + JobRunStatusStarted JobRunStatus = "Started" + JobRunStatusSucceeded JobRunStatus = "Succeeded" +) + +// PossibleJobRunStatusValues returns the possible values for the JobRunStatus const type. +func PossibleJobRunStatusValues() []JobRunStatus { + return []JobRunStatus{ + JobRunStatusCancelRequested, + JobRunStatusCanceled, + JobRunStatusCanceling, + JobRunStatusFailed, + JobRunStatusQueued, + JobRunStatusRunning, + JobRunStatusStarted, + JobRunStatusSucceeded, + } +} + +// NfsVersion - The NFS protocol version. +type NfsVersion string + +const ( + NfsVersionNFSauto NfsVersion = "NFSauto" + NfsVersionNFSv3 NfsVersion = "NFSv3" + NfsVersionNFSv4 NfsVersion = "NFSv4" +) + +// PossibleNfsVersionValues returns the possible values for the NfsVersion const type. +func PossibleNfsVersionValues() []NfsVersion { + return []NfsVersion{ + NfsVersionNFSauto, + NfsVersionNFSv3, + NfsVersionNFSv4, + } +} + +// 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 - The provisioning state of this resource. +type ProvisioningState string + +const ( + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateSucceeded, + } +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/endpoints_client.go b/sdk/resourcemanager/storagemover/armstoragemover/endpoints_client.go new file mode 100644 index 000000000000..93dd76fa5e6a --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/endpoints_client.go @@ -0,0 +1,378 @@ +//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 armstoragemover + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// EndpointsClient contains the methods for the Endpoints group. +// Don't use this type directly, use NewEndpointsClient() instead. +type EndpointsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewEndpointsClient creates a new instance of EndpointsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EndpointsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &EndpointsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates an endpoint resource, which represents a data transfer source or destination. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// endpointName - The name of the endpoint resource. +// options - EndpointsClientCreateOrUpdateOptions contains the optional parameters for the EndpointsClient.CreateOrUpdate +// method. +func (client *EndpointsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, endpoint Endpoint, options *EndpointsClientCreateOrUpdateOptions) (EndpointsClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, storageMoverName, endpointName, endpoint, options) + if err != nil { + return EndpointsClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EndpointsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EndpointsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, endpoint Endpoint, options *EndpointsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/endpoints/{endpointName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, endpoint) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EndpointsClient) createOrUpdateHandleResponse(resp *http.Response) (EndpointsClientCreateOrUpdateResponse, error) { + result := EndpointsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Endpoint); err != nil { + return EndpointsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes an endpoint resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// endpointName - The name of the endpoint resource. +// options - EndpointsClientBeginDeleteOptions contains the optional parameters for the EndpointsClient.BeginDelete method. +func (client *EndpointsClient) BeginDelete(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, options *EndpointsClientBeginDeleteOptions) (*runtime.Poller[EndpointsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storageMoverName, endpointName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[EndpointsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[EndpointsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes an endpoint resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +func (client *EndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, options *EndpointsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storageMoverName, endpointName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EndpointsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, options *EndpointsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/endpoints/{endpointName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets an endpoint resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// endpointName - The name of the endpoint resource. +// options - EndpointsClientGetOptions contains the optional parameters for the EndpointsClient.Get method. +func (client *EndpointsClient) Get(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, options *EndpointsClientGetOptions) (EndpointsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, storageMoverName, endpointName, options) + if err != nil { + return EndpointsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EndpointsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *EndpointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, options *EndpointsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/endpoints/{endpointName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EndpointsClient) getHandleResponse(resp *http.Response) (EndpointsClientGetResponse, error) { + result := EndpointsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Endpoint); err != nil { + return EndpointsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all endpoints in a Storage Mover. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// options - EndpointsClientListOptions contains the optional parameters for the EndpointsClient.List method. +func (client *EndpointsClient) NewListPager(resourceGroupName string, storageMoverName string, options *EndpointsClientListOptions) *runtime.Pager[EndpointsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[EndpointsClientListResponse]{ + More: func(page EndpointsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EndpointsClientListResponse) (EndpointsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, storageMoverName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EndpointsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EndpointsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *EndpointsClient) listCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, options *EndpointsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/endpoints" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EndpointsClient) listHandleResponse(resp *http.Response) (EndpointsClientListResponse, error) { + result := EndpointsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EndpointList); err != nil { + return EndpointsClientListResponse{}, err + } + return result, nil +} + +// Update - Updates properties for an endpoint resource. Properties not specified in the request body will be unchanged. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// endpointName - The name of the endpoint resource. +// options - EndpointsClientUpdateOptions contains the optional parameters for the EndpointsClient.Update method. +func (client *EndpointsClient) Update(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, endpoint EndpointBaseUpdateParameters, options *EndpointsClientUpdateOptions) (EndpointsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, storageMoverName, endpointName, endpoint, options) + if err != nil { + return EndpointsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return EndpointsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EndpointsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *EndpointsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, endpointName string, endpoint EndpointBaseUpdateParameters, options *EndpointsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/endpoints/{endpointName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if endpointName == "" { + return nil, errors.New("parameter endpointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{endpointName}", url.PathEscape(endpointName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, endpoint) +} + +// updateHandleResponse handles the Update response. +func (client *EndpointsClient) updateHandleResponse(resp *http.Response) (EndpointsClientUpdateResponse, error) { + result := EndpointsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Endpoint); err != nil { + return EndpointsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/go.mod b/sdk/resourcemanager/storagemover/armstoragemover/go.mod new file mode 100644 index 000000000000..e9f69092b55b --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storagemover/armstoragemover + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/storagemover/armstoragemover/go.sum b/sdk/resourcemanager/storagemover/armstoragemover/go.sum new file mode 100644 index 000000000000..3afb578030a5 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/storagemover/armstoragemover/jobdefinitions_client.go b/sdk/resourcemanager/storagemover/armstoragemover/jobdefinitions_client.go new file mode 100644 index 000000000000..b21a91c3fa0c --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/jobdefinitions_client.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 armstoragemover + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// JobDefinitionsClient contains the methods for the JobDefinitions group. +// Don't use this type directly, use NewJobDefinitionsClient() instead. +type JobDefinitionsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewJobDefinitionsClient creates a new instance of JobDefinitionsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewJobDefinitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*JobDefinitionsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &JobDefinitionsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a job definition resource, which contains configuration for a single unit of managed +// data transfer. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// options - JobDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the JobDefinitionsClient.CreateOrUpdate +// method. +func (client *JobDefinitionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, jobDefinition JobDefinition, options *JobDefinitionsClientCreateOrUpdateOptions) (JobDefinitionsClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, jobDefinition, options) + if err != nil { + return JobDefinitionsClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobDefinitionsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobDefinitionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *JobDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, jobDefinition JobDefinition, options *JobDefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, jobDefinition) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *JobDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (JobDefinitionsClientCreateOrUpdateResponse, error) { + result := JobDefinitionsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobDefinition); err != nil { + return JobDefinitionsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes a job definition resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// options - JobDefinitionsClientBeginDeleteOptions contains the optional parameters for the JobDefinitionsClient.BeginDelete +// method. +func (client *JobDefinitionsClient) BeginDelete(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientBeginDeleteOptions) (*runtime.Poller[JobDefinitionsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[JobDefinitionsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[JobDefinitionsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a job definition resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +func (client *JobDefinitionsClient) deleteOperation(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *JobDefinitionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a job definition resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// options - JobDefinitionsClientGetOptions contains the optional parameters for the JobDefinitionsClient.Get method. +func (client *JobDefinitionsClient) Get(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientGetOptions) (JobDefinitionsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, options) + if err != nil { + return JobDefinitionsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobDefinitionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobDefinitionsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *JobDefinitionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *JobDefinitionsClient) getHandleResponse(resp *http.Response) (JobDefinitionsClientGetResponse, error) { + result := JobDefinitionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobDefinition); err != nil { + return JobDefinitionsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all job definitions in a project. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// options - JobDefinitionsClientListOptions contains the optional parameters for the JobDefinitionsClient.List method. +func (client *JobDefinitionsClient) NewListPager(resourceGroupName string, storageMoverName string, projectName string, options *JobDefinitionsClientListOptions) *runtime.Pager[JobDefinitionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[JobDefinitionsClientListResponse]{ + More: func(page JobDefinitionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *JobDefinitionsClientListResponse) (JobDefinitionsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return JobDefinitionsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobDefinitionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobDefinitionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *JobDefinitionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, options *JobDefinitionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *JobDefinitionsClient) listHandleResponse(resp *http.Response) (JobDefinitionsClientListResponse, error) { + result := JobDefinitionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobDefinitionList); err != nil { + return JobDefinitionsClientListResponse{}, err + } + return result, nil +} + +// StartJob - Requests an agent to start a new instance of this job definition, generating a new job run resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// options - JobDefinitionsClientStartJobOptions contains the optional parameters for the JobDefinitionsClient.StartJob method. +func (client *JobDefinitionsClient) StartJob(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientStartJobOptions) (JobDefinitionsClientStartJobResponse, error) { + req, err := client.startJobCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, options) + if err != nil { + return JobDefinitionsClientStartJobResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobDefinitionsClientStartJobResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobDefinitionsClientStartJobResponse{}, runtime.NewResponseError(resp) + } + return client.startJobHandleResponse(resp) +} + +// startJobCreateRequest creates the StartJob request. +func (client *JobDefinitionsClient) startJobCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientStartJobOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}/startJob" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// startJobHandleResponse handles the StartJob response. +func (client *JobDefinitionsClient) startJobHandleResponse(resp *http.Response) (JobDefinitionsClientStartJobResponse, error) { + result := JobDefinitionsClientStartJobResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobRunResourceID); err != nil { + return JobDefinitionsClientStartJobResponse{}, err + } + return result, nil +} + +// StopJob - Requests the agent of any active instance of this job definition to stop. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// options - JobDefinitionsClientStopJobOptions contains the optional parameters for the JobDefinitionsClient.StopJob method. +func (client *JobDefinitionsClient) StopJob(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientStopJobOptions) (JobDefinitionsClientStopJobResponse, error) { + req, err := client.stopJobCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, options) + if err != nil { + return JobDefinitionsClientStopJobResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobDefinitionsClientStopJobResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobDefinitionsClientStopJobResponse{}, runtime.NewResponseError(resp) + } + return client.stopJobHandleResponse(resp) +} + +// stopJobCreateRequest creates the StopJob request. +func (client *JobDefinitionsClient) stopJobCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobDefinitionsClientStopJobOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}/stopJob" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// stopJobHandleResponse handles the StopJob response. +func (client *JobDefinitionsClient) stopJobHandleResponse(resp *http.Response) (JobDefinitionsClientStopJobResponse, error) { + result := JobDefinitionsClientStopJobResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobRunResourceID); err != nil { + return JobDefinitionsClientStopJobResponse{}, err + } + return result, nil +} + +// Update - Updates properties for a job definition resource. Properties not specified in the request body will be unchanged. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// options - JobDefinitionsClientUpdateOptions contains the optional parameters for the JobDefinitionsClient.Update method. +func (client *JobDefinitionsClient) Update(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, jobDefinition JobDefinitionUpdateParameters, options *JobDefinitionsClientUpdateOptions) (JobDefinitionsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, jobDefinition, options) + if err != nil { + return JobDefinitionsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobDefinitionsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobDefinitionsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *JobDefinitionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, jobDefinition JobDefinitionUpdateParameters, options *JobDefinitionsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, jobDefinition) +} + +// updateHandleResponse handles the Update response. +func (client *JobDefinitionsClient) updateHandleResponse(resp *http.Response) (JobDefinitionsClientUpdateResponse, error) { + result := JobDefinitionsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobDefinition); err != nil { + return JobDefinitionsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/jobruns_client.go b/sdk/resourcemanager/storagemover/armstoragemover/jobruns_client.go new file mode 100644 index 000000000000..c1618fd1029f --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/jobruns_client.go @@ -0,0 +1,206 @@ +//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 armstoragemover + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// JobRunsClient contains the methods for the JobRuns group. +// Don't use this type directly, use NewJobRunsClient() instead. +type JobRunsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewJobRunsClient creates a new instance of JobRunsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewJobRunsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*JobRunsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &JobRunsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// Get - Gets a job run resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// jobRunName - The name of the job run. +// options - JobRunsClientGetOptions contains the optional parameters for the JobRunsClient.Get method. +func (client *JobRunsClient) Get(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, jobRunName string, options *JobRunsClientGetOptions) (JobRunsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, jobRunName, options) + if err != nil { + return JobRunsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobRunsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobRunsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *JobRunsClient) getCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, jobRunName string, options *JobRunsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}/jobRuns/{jobRunName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + if jobRunName == "" { + return nil, errors.New("parameter jobRunName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobRunName}", url.PathEscape(jobRunName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *JobRunsClient) getHandleResponse(resp *http.Response) (JobRunsClientGetResponse, error) { + result := JobRunsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobRun); err != nil { + return JobRunsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all job runs in a job definition. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// jobDefinitionName - The name of the job definition resource. +// options - JobRunsClientListOptions contains the optional parameters for the JobRunsClient.List method. +func (client *JobRunsClient) NewListPager(resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobRunsClientListOptions) *runtime.Pager[JobRunsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[JobRunsClientListResponse]{ + More: func(page JobRunsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *JobRunsClientListResponse) (JobRunsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, jobDefinitionName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return JobRunsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return JobRunsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return JobRunsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *JobRunsClient) listCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, jobDefinitionName string, options *JobRunsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}/jobDefinitions/{jobDefinitionName}/jobRuns" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + if jobDefinitionName == "" { + return nil, errors.New("parameter jobDefinitionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobDefinitionName}", url.PathEscape(jobDefinitionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *JobRunsClient) listHandleResponse(resp *http.Response) (JobRunsClientListResponse, error) { + result := JobRunsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.JobRunList); err != nil { + return JobRunsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/models.go b/sdk/resourcemanager/storagemover/armstoragemover/models.go new file mode 100644 index 000000000000..55f263a4bd4a --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/models.go @@ -0,0 +1,868 @@ +//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 armstoragemover + +import "time" + +// Agent - The agent resource. +type Agent struct { + Properties *AgentProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource system metadata. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// AgentList - List of agents. +type AgentList struct { + // READ-ONLY; Request URL that can be used to query next page of containers. Returned when total number of requested containers + // exceed maximum page size. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY + Value []*Agent `json:"value,omitempty" azure:"ro"` +} + +type AgentProperties struct { + // REQUIRED; The fully qualified resource ID of the hybrid compute resource for the agent. + ArcResourceID *string `json:"arcResourceId,omitempty"` + + // REQUIRED; A GUID for this agent. + ArcVMUUID *string `json:"arcVmUuid,omitempty"` + + // A description for the agent. + Description *string `json:"description,omitempty"` + + // READ-ONLY; The agent status. + AgentStatus *AgentStatus `json:"agentStatus,omitempty" azure:"ro"` + + // READ-ONLY; The agent version. + AgentVersion *string `json:"agentVersion,omitempty" azure:"ro"` + + // READ-ONLY + ErrorDetails *AgentPropertiesErrorDetails `json:"errorDetails,omitempty" azure:"ro"` + + // READ-ONLY; The last updated time of the agent status. + LastStatusUpdate *time.Time `json:"lastStatusUpdate,omitempty" azure:"ro"` + + // READ-ONLY; Local IP address reported by the agent. + LocalIPAddress *string `json:"localIPAddress,omitempty" azure:"ro"` + + // READ-ONLY; Available memory reported by the agent, in MB. + MemoryInMB *int64 `json:"memoryInMB,omitempty" azure:"ro"` + + // READ-ONLY; Available compute cores reported by the agent. + NumberOfCores *int64 `json:"numberOfCores,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +type AgentPropertiesErrorDetails struct { + // Error code reported by Agent + Code *string `json:"code,omitempty"` + + // Expanded description of reported error code + Message *string `json:"message,omitempty"` +} + +// AgentUpdateParameters - The agent resource. +type AgentUpdateParameters struct { + Properties *AgentUpdateProperties `json:"properties,omitempty"` +} + +type AgentUpdateProperties struct { + // A description for the agent. + Description *string `json:"description,omitempty"` +} + +// AgentsClientBeginDeleteOptions contains the optional parameters for the AgentsClient.BeginDelete method. +type AgentsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AgentsClientCreateOrUpdateOptions contains the optional parameters for the AgentsClient.CreateOrUpdate method. +type AgentsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// AgentsClientGetOptions contains the optional parameters for the AgentsClient.Get method. +type AgentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AgentsClientListOptions contains the optional parameters for the AgentsClient.List method. +type AgentsClientListOptions struct { + // placeholder for future optional parameters +} + +// AgentsClientUpdateOptions contains the optional parameters for the AgentsClient.Update method. +type AgentsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +type AzureStorageBlobContainerEndpointProperties struct { + // REQUIRED; The name of the Storage blob container that is the target destination. + BlobContainerName *string `json:"blobContainerName,omitempty"` + + // REQUIRED; The endpoint resource type. + EndpointType *EndpointType `json:"endpointType,omitempty"` + + // REQUIRED; The Azure Resource ID of the storage account that is the target destination. + StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty"` + + // A description for the endpoint. + Description *string `json:"description,omitempty"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GetEndpointBaseProperties implements the EndpointBasePropertiesClassification interface for type AzureStorageBlobContainerEndpointProperties. +func (a *AzureStorageBlobContainerEndpointProperties) GetEndpointBaseProperties() *EndpointBaseProperties { + return &EndpointBaseProperties{ + EndpointType: a.EndpointType, + Description: a.Description, + ProvisioningState: a.ProvisioningState, + } +} + +type AzureStorageBlobContainerEndpointUpdateProperties struct { + // A description for the endpoint. + Description *string `json:"description,omitempty"` +} + +// Endpoint - The endpoint resource, which contains information about file sources and targets. +type Endpoint struct { + // The resource specific properties for the Storage Mover resource. + Properties EndpointBasePropertiesClassification `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource system metadata. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// EndpointBasePropertiesClassification provides polymorphic access to related types. +// Call the interface's GetEndpointBaseProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureStorageBlobContainerEndpointProperties, *EndpointBaseProperties, *NfsMountEndpointProperties +type EndpointBasePropertiesClassification interface { + // GetEndpointBaseProperties returns the EndpointBaseProperties content of the underlying type. + GetEndpointBaseProperties() *EndpointBaseProperties +} + +// EndpointBaseProperties - The resource specific properties for the Storage Mover resource. +type EndpointBaseProperties struct { + // REQUIRED; The endpoint resource type. + EndpointType *EndpointType `json:"endpointType,omitempty"` + + // A description for the endpoint. + Description *string `json:"description,omitempty"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GetEndpointBaseProperties implements the EndpointBasePropertiesClassification interface for type EndpointBaseProperties. +func (e *EndpointBaseProperties) GetEndpointBaseProperties() *EndpointBaseProperties { return e } + +// EndpointBaseUpdateParameters - The endpoint resource. +type EndpointBaseUpdateParameters struct { + // The endpoint resource, which contains information about file sources and targets. + Properties *EndpointBaseUpdateProperties `json:"properties,omitempty"` +} + +// EndpointBaseUpdateProperties - The endpoint resource, which contains information about file sources and targets. +type EndpointBaseUpdateProperties struct { + // A description for the endpoint. + Description *string `json:"description,omitempty"` +} + +// EndpointList - List of endpoints. +type EndpointList struct { + // READ-ONLY; Request URL that can be used to query next page of containers. Returned when total number of requested containers + // exceed maximum page size. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY + Value []*Endpoint `json:"value,omitempty" azure:"ro"` +} + +// EndpointsClientBeginDeleteOptions contains the optional parameters for the EndpointsClient.BeginDelete method. +type EndpointsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// EndpointsClientCreateOrUpdateOptions contains the optional parameters for the EndpointsClient.CreateOrUpdate method. +type EndpointsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// EndpointsClientGetOptions contains the optional parameters for the EndpointsClient.Get method. +type EndpointsClientGetOptions struct { + // placeholder for future optional parameters +} + +// EndpointsClientListOptions contains the optional parameters for the EndpointsClient.List method. +type EndpointsClientListOptions struct { + // placeholder for future optional parameters +} + +// EndpointsClientUpdateOptions contains the optional parameters for the EndpointsClient.Update method. +type EndpointsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// JobDefinition - The job definition resource. +type JobDefinition struct { + // Job definition properties. + Properties *JobDefinitionProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource system metadata. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// JobDefinitionList - List of job definitions. +type JobDefinitionList struct { + // READ-ONLY; Request URL that can be used to query next page of containers. Returned when total number of requested containers + // exceed maximum page size. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY + Value []*JobDefinition `json:"value,omitempty" azure:"ro"` +} + +// JobDefinitionProperties - Job definition properties. +type JobDefinitionProperties struct { + // REQUIRED; The name of the source endpoint. + SourceName *string `json:"sourceName,omitempty"` + + // REQUIRED; The name of the target endpoint. + TargetName *string `json:"targetName,omitempty"` + + // Name of the agent to assign for new job runs of this definition. + AgentName *string `json:"agentName,omitempty"` + + // Strategy to use for copy. + CopyMode *CopyMode `json:"copyMode,omitempty"` + + // A description for the job definition. + Description *string `json:"description,omitempty"` + + // The subpath to use when reading from the source Endpoint. + SourceSubpath *string `json:"sourceSubpath,omitempty"` + + // The subpath to use when writing to the target Endpoint. + TargetSubpath *string `json:"targetSubpath,omitempty"` + + // READ-ONLY; Fully qualified resource id of the agent to assign for new job runs of this definition. + AgentResourceID *string `json:"agentResourceId,omitempty" azure:"ro"` + + // READ-ONLY; The name of the job run in a non-terminal state, if exists. + LatestJobRunName *string `json:"latestJobRunName,omitempty" azure:"ro"` + + // READ-ONLY; The fully qualified resource ID of the job run in a non-terminal state, if exists. + LatestJobRunResourceID *string `json:"latestJobRunResourceId,omitempty" azure:"ro"` + + // READ-ONLY; The current status of the job run in a non-terminal state, if exists. + LatestJobRunStatus *JobRunStatus `json:"latestJobRunStatus,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified resource ID of the source endpoint. + SourceResourceID *string `json:"sourceResourceId,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified resource ID of the target endpoint. + TargetResourceID *string `json:"targetResourceId,omitempty" azure:"ro"` +} + +// JobDefinitionUpdateParameters - The job definition resource. +type JobDefinitionUpdateParameters struct { + // Job definition properties. + Properties *JobDefinitionUpdateProperties `json:"properties,omitempty"` +} + +// JobDefinitionUpdateProperties - Job definition properties. +type JobDefinitionUpdateProperties struct { + // Name of the agent to assign for new job runs of this definition. + AgentName *string `json:"agentName,omitempty"` + + // Strategy to use for copy. + CopyMode *CopyMode `json:"copyMode,omitempty"` + + // A description for the job definition. + Description *string `json:"description,omitempty"` +} + +// JobDefinitionsClientBeginDeleteOptions contains the optional parameters for the JobDefinitionsClient.BeginDelete method. +type JobDefinitionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// JobDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the JobDefinitionsClient.CreateOrUpdate +// method. +type JobDefinitionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// JobDefinitionsClientGetOptions contains the optional parameters for the JobDefinitionsClient.Get method. +type JobDefinitionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// JobDefinitionsClientListOptions contains the optional parameters for the JobDefinitionsClient.List method. +type JobDefinitionsClientListOptions struct { + // placeholder for future optional parameters +} + +// JobDefinitionsClientStartJobOptions contains the optional parameters for the JobDefinitionsClient.StartJob method. +type JobDefinitionsClientStartJobOptions struct { + // placeholder for future optional parameters +} + +// JobDefinitionsClientStopJobOptions contains the optional parameters for the JobDefinitionsClient.StopJob method. +type JobDefinitionsClientStopJobOptions struct { + // placeholder for future optional parameters +} + +// JobDefinitionsClientUpdateOptions contains the optional parameters for the JobDefinitionsClient.Update method. +type JobDefinitionsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// JobRun - The job run resource. +type JobRun struct { + // Job run properties. + Properties *JobRunProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource system metadata. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// JobRunError - Error type +type JobRunError struct { + // Error code of the given entry. + Code *string `json:"code,omitempty"` + + // Error message of the given entry. + Message *string `json:"message,omitempty"` + + // Target of the given error entry. + Target *string `json:"target,omitempty"` +} + +// JobRunList - List of job runs. +type JobRunList struct { + // READ-ONLY; Request URL that can be used to query next page of containers. Returned when total number of requested containers + // exceed maximum page size. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY + Value []*JobRun `json:"value,omitempty" azure:"ro"` +} + +// JobRunProperties - Job run properties. +type JobRunProperties struct { + // READ-ONLY; Name of the agent assigned to this run. + AgentName *string `json:"agentName,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified resource id of the agent assigned to this run. + AgentResourceID *string `json:"agentResourceId,omitempty" azure:"ro"` + + // READ-ONLY; Bytes of data identified for transferring so far in scan. + BytesDesignatedForTransfer *int64 `json:"bytesDesignatedForTransfer,omitempty" azure:"ro"` + + // READ-ONLY; Bytes of data that will not be transferred, as they are excluded by user configuration. + BytesExcluded *int64 `json:"bytesExcluded,omitempty" azure:"ro"` + + // READ-ONLY; Bytes of data that were attempted to transfer and failed. + BytesFailed *int64 `json:"bytesFailed,omitempty" azure:"ro"` + + // READ-ONLY; Bytes of data that will not be transferred, as they are already found on target (e.g. mirror mode). + BytesNoTransferNeeded *int64 `json:"bytesNoTransferNeeded,omitempty" azure:"ro"` + + // READ-ONLY; Bytes of data scanned so far in source. + BytesScanned *int64 `json:"bytesScanned,omitempty" azure:"ro"` + + // READ-ONLY; Bytes of data successfully transferred to target. + BytesTransferred *int64 `json:"bytesTransferred,omitempty" azure:"ro"` + + // READ-ONLY; Bytes of data that will not be transferred, as they are unsupported on target. + BytesUnsupported *int64 `json:"bytesUnsupported,omitempty" azure:"ro"` + + // READ-ONLY; Error details. + Error *JobRunError `json:"error,omitempty" azure:"ro"` + + // READ-ONLY; End time of the run. Null if agent has not reported that the job has ended. + ExecutionEndTime *time.Time `json:"executionEndTime,omitempty" azure:"ro"` + + // READ-ONLY; Start time of the run. Null if no agent reported that the job has started. + ExecutionStartTime *time.Time `json:"executionStartTime,omitempty" azure:"ro"` + + // READ-ONLY; Number of items identified for transferring so far in scan. + ItemsDesignatedForTransfer *int64 `json:"itemsDesignatedForTransfer,omitempty" azure:"ro"` + + // READ-ONLY; Number of items that will not be transferred, as they are excluded by user configuration. + ItemsExcluded *int64 `json:"itemsExcluded,omitempty" azure:"ro"` + + // READ-ONLY; Number of items that were attempted to transfer and failed. + ItemsFailed *int64 `json:"itemsFailed,omitempty" azure:"ro"` + + // READ-ONLY; Number of items that will not be transferred, as they are already found on target (e.g. mirror mode). + ItemsNoTransferNeeded *int64 `json:"itemsNoTransferNeeded,omitempty" azure:"ro"` + + // READ-ONLY; Number of items scanned so far in source. + ItemsScanned *int64 `json:"itemsScanned,omitempty" azure:"ro"` + + // READ-ONLY; Number of items successfully transferred to target. + ItemsTransferred *int64 `json:"itemsTransferred,omitempty" azure:"ro"` + + // READ-ONLY; Number of items that will not be transferred, as they are unsupported on target. + ItemsUnsupported *int64 `json:"itemsUnsupported,omitempty" azure:"ro"` + + // READ-ONLY; Copy of parent Job Definition's properties at time of Job Run creation. + JobDefinitionProperties interface{} `json:"jobDefinitionProperties,omitempty" azure:"ro"` + + // READ-ONLY; Last update time. + LastUpdatedTime *time.Time `json:"lastUpdatedTime,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; The status of agent's scanning of source. + ScanStatus *JobRunScanStatus `json:"scanStatus,omitempty" azure:"ro"` + + // READ-ONLY; Name of source Endpoint resource. This resource may no longer exist. + SourceName *string `json:"sourceName,omitempty" azure:"ro"` + + // READ-ONLY; Copy of source Endpoint resource's properties at time of Job Run creation. + SourceProperties interface{} `json:"sourceProperties,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified resource id of source Endpoint. This id may no longer exist. + SourceResourceID *string `json:"sourceResourceId,omitempty" azure:"ro"` + + // READ-ONLY; The state of the job execution. + Status *JobRunStatus `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; Name of target Endpoint resource. This resource may no longer exist. + TargetName *string `json:"targetName,omitempty" azure:"ro"` + + // READ-ONLY; Copy of Endpoint resource's properties at time of Job Run creation. + TargetProperties interface{} `json:"targetProperties,omitempty" azure:"ro"` + + // READ-ONLY; Fully qualified resource id of of Endpoint. This id may no longer exist. + TargetResourceID *string `json:"targetResourceId,omitempty" azure:"ro"` +} + +// JobRunResourceID - Response that identifies a JobRun. +type JobRunResourceID struct { + // READ-ONLY; Fully qualified resource id of the JobRun. + JobRunResourceID *string `json:"jobRunResourceId,omitempty" azure:"ro"` +} + +// JobRunsClientGetOptions contains the optional parameters for the JobRunsClient.Get method. +type JobRunsClientGetOptions struct { + // placeholder for future optional parameters +} + +// JobRunsClientListOptions contains the optional parameters for the JobRunsClient.List method. +type JobRunsClientListOptions struct { + // placeholder for future optional parameters +} + +// List of Storage Movers. +type List struct { + // READ-ONLY; Request URL that can be used to query next page of containers. Returned when total number of requested containers + // exceed maximum page size. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY + Value []*StorageMover `json:"value,omitempty" azure:"ro"` +} + +type NfsMountEndpointProperties struct { + // REQUIRED; The endpoint resource type. + EndpointType *EndpointType `json:"endpointType,omitempty"` + + // REQUIRED; The host name or IP address of the server exporting the file system. + Host *string `json:"host,omitempty"` + + // REQUIRED; The directory being exported from the server. + RemoteExport *string `json:"remoteExport,omitempty"` + + // A description for the endpoint. + Description *string `json:"description,omitempty"` + + // The NFS protocol version. + NfsVersion *NfsVersion `json:"nfsVersion,omitempty"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// GetEndpointBaseProperties implements the EndpointBasePropertiesClassification interface for type NfsMountEndpointProperties. +func (n *NfsMountEndpointProperties) GetEndpointBaseProperties() *EndpointBaseProperties { + return &EndpointBaseProperties{ + EndpointType: n.EndpointType, + Description: n.Description, + ProvisioningState: n.ProvisioningState, + } +} + +type NfsMountEndpointUpdateProperties struct { + // A description for the endpoint. + Description *string `json:"description,omitempty"` +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay `json:"display,omitempty"` + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin `json:"origin,omitempty" azure:"ro"` +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation `json:"value,omitempty" azure:"ro"` +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// Project - The project resource. +type Project struct { + // Project properties. + Properties *ProjectProperties `json:"properties,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource system metadata. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ProjectList - List of project resources. +type ProjectList struct { + // READ-ONLY; Request URL that can be used to query next page of containers. Returned when total number of requested containers + // exceed maximum page size. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY + Value []*Project `json:"value,omitempty" azure:"ro"` +} + +// ProjectProperties - Project properties. +type ProjectProperties struct { + // A description for the project. + Description *string `json:"description,omitempty"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// ProjectUpdateParameters - The project resource. +type ProjectUpdateParameters struct { + // Project properties. + Properties *ProjectUpdateProperties `json:"properties,omitempty"` +} + +// ProjectUpdateProperties - Project properties. +type ProjectUpdateProperties struct { + // A description for the project. + Description *string `json:"description,omitempty"` +} + +// ProjectsClientBeginDeleteOptions contains the optional parameters for the ProjectsClient.BeginDelete method. +type ProjectsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProjectsClientCreateOrUpdateOptions contains the optional parameters for the ProjectsClient.CreateOrUpdate method. +type ProjectsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. +type ProjectsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProjectsClientListOptions contains the optional parameters for the ProjectsClient.List method. +type ProjectsClientListOptions struct { + // placeholder for future optional parameters +} + +// ProjectsClientUpdateOptions contains the optional parameters for the ProjectsClient.Update method. +type ProjectsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// Properties - The resource specific properties for the Storage Mover resource. +type Properties struct { + // A description for the Storage Mover. + Description *string `json:"description,omitempty"` + + // READ-ONLY; The provisioning state of this resource. + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` +} + +// ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a +// location +type ProxyResource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// StorageMover - The Storage Mover resource, which is a container for a group of Storage Mover agents and projects. +type StorageMover struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // The resource specific properties for the Storage Mover resource. + Properties *Properties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource system metadata. + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// StorageMoversClientBeginDeleteOptions contains the optional parameters for the StorageMoversClient.BeginDelete method. +type StorageMoversClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// StorageMoversClientCreateOrUpdateOptions contains the optional parameters for the StorageMoversClient.CreateOrUpdate method. +type StorageMoversClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// StorageMoversClientGetOptions contains the optional parameters for the StorageMoversClient.Get method. +type StorageMoversClientGetOptions struct { + // placeholder for future optional parameters +} + +// StorageMoversClientListBySubscriptionOptions contains the optional parameters for the StorageMoversClient.ListBySubscription +// method. +type StorageMoversClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// StorageMoversClientListOptions contains the optional parameters for the StorageMoversClient.List method. +type StorageMoversClientListOptions struct { + // placeholder for future optional parameters +} + +// StorageMoversClientUpdateOptions contains the optional parameters for the StorageMoversClient.Update method. +type StorageMoversClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' +type TrackedResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// UpdateParameters - The Storage Mover resource. +type UpdateParameters struct { + // The resource specific properties for the Storage Mover resource. + Properties *UpdateProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` +} + +// UpdateProperties - The resource specific properties for the Storage Mover resource. +type UpdateProperties struct { + // A description for the Storage Mover. + Description *string `json:"description,omitempty"` +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/models_serde.go b/sdk/resourcemanager/storagemover/armstoragemover/models_serde.go new file mode 100644 index 000000000000..298b82edf3ad --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/models_serde.go @@ -0,0 +1,1768 @@ +//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 armstoragemover + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Agent. +func (a Agent) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Agent. +func (a *Agent) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentList. +func (a AgentList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentList. +func (a *AgentList) 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 AgentProperties. +func (a AgentProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentStatus", a.AgentStatus) + populate(objectMap, "agentVersion", a.AgentVersion) + populate(objectMap, "arcResourceId", a.ArcResourceID) + populate(objectMap, "arcVmUuid", a.ArcVMUUID) + populate(objectMap, "description", a.Description) + populate(objectMap, "errorDetails", a.ErrorDetails) + populateTimeRFC3339(objectMap, "lastStatusUpdate", a.LastStatusUpdate) + populate(objectMap, "localIPAddress", a.LocalIPAddress) + populate(objectMap, "memoryInMB", a.MemoryInMB) + populate(objectMap, "numberOfCores", a.NumberOfCores) + populate(objectMap, "provisioningState", a.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentProperties. +func (a *AgentProperties) 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 "agentStatus": + err = unpopulate(val, "AgentStatus", &a.AgentStatus) + delete(rawMsg, key) + case "agentVersion": + err = unpopulate(val, "AgentVersion", &a.AgentVersion) + delete(rawMsg, key) + case "arcResourceId": + err = unpopulate(val, "ArcResourceID", &a.ArcResourceID) + delete(rawMsg, key) + case "arcVmUuid": + err = unpopulate(val, "ArcVMUUID", &a.ArcVMUUID) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "errorDetails": + err = unpopulate(val, "ErrorDetails", &a.ErrorDetails) + delete(rawMsg, key) + case "lastStatusUpdate": + err = unpopulateTimeRFC3339(val, "LastStatusUpdate", &a.LastStatusUpdate) + delete(rawMsg, key) + case "localIPAddress": + err = unpopulate(val, "LocalIPAddress", &a.LocalIPAddress) + delete(rawMsg, key) + case "memoryInMB": + err = unpopulate(val, "MemoryInMB", &a.MemoryInMB) + delete(rawMsg, key) + case "numberOfCores": + err = unpopulate(val, "NumberOfCores", &a.NumberOfCores) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AgentPropertiesErrorDetails. +func (a AgentPropertiesErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", a.Code) + populate(objectMap, "message", a.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentPropertiesErrorDetails. +func (a *AgentPropertiesErrorDetails) 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 "code": + err = unpopulate(val, "Code", &a.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &a.Message) + 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 AgentUpdateParameters. +func (a AgentUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentUpdateParameters. +func (a *AgentUpdateParameters) 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 "properties": + err = unpopulate(val, "Properties", &a.Properties) + 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 AgentUpdateProperties. +func (a AgentUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", a.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AgentUpdateProperties. +func (a *AgentUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &a.Description) + 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 AzureStorageBlobContainerEndpointProperties. +func (a AzureStorageBlobContainerEndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "blobContainerName", a.BlobContainerName) + populate(objectMap, "description", a.Description) + objectMap["endpointType"] = EndpointTypeAzureStorageBlobContainer + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "storageAccountResourceId", a.StorageAccountResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureStorageBlobContainerEndpointProperties. +func (a *AzureStorageBlobContainerEndpointProperties) 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 "blobContainerName": + err = unpopulate(val, "BlobContainerName", &a.BlobContainerName) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "endpointType": + err = unpopulate(val, "EndpointType", &a.EndpointType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "storageAccountResourceId": + err = unpopulate(val, "StorageAccountResourceID", &a.StorageAccountResourceID) + 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 AzureStorageBlobContainerEndpointUpdateProperties. +func (a AzureStorageBlobContainerEndpointUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", a.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzureStorageBlobContainerEndpointUpdateProperties. +func (a *AzureStorageBlobContainerEndpointUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &a.Description) + 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 Endpoint. +func (e Endpoint) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "systemData", e.SystemData) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Endpoint. +func (e *Endpoint) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + e.Properties, err = unmarshalEndpointBasePropertiesClassification(val) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + 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 EndpointBaseProperties. +func (e EndpointBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", e.Description) + objectMap["endpointType"] = e.EndpointType + populate(objectMap, "provisioningState", e.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EndpointBaseProperties. +func (e *EndpointBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "endpointType": + err = unpopulate(val, "EndpointType", &e.EndpointType) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EndpointBaseUpdateParameters. +func (e EndpointBaseUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EndpointBaseUpdateParameters. +func (e *EndpointBaseUpdateParameters) 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 "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EndpointBaseUpdateProperties. +func (e EndpointBaseUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", e.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EndpointBaseUpdateProperties. +func (e *EndpointBaseUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EndpointList. +func (e EndpointList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EndpointList. +func (e *EndpointList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &e.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorAdditionalInfo. +func (e ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(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]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetail. +func (e *ErrorDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "additionalInfo": + err = unpopulate(val, "AdditionalInfo", &e.AdditionalInfo) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &e.Details) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &e.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobDefinition. +func (j JobDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", j.ID) + populate(objectMap, "name", j.Name) + populate(objectMap, "properties", j.Properties) + populate(objectMap, "systemData", j.SystemData) + populate(objectMap, "type", j.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobDefinition. +func (j *JobDefinition) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &j.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &j.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &j.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &j.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &j.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobDefinitionList. +func (j JobDefinitionList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", j.NextLink) + populate(objectMap, "value", j.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobDefinitionList. +func (j *JobDefinitionList) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &j.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &j.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobDefinitionProperties. +func (j JobDefinitionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentName", j.AgentName) + populate(objectMap, "agentResourceId", j.AgentResourceID) + populate(objectMap, "copyMode", j.CopyMode) + populate(objectMap, "description", j.Description) + populate(objectMap, "latestJobRunName", j.LatestJobRunName) + populate(objectMap, "latestJobRunResourceId", j.LatestJobRunResourceID) + populate(objectMap, "latestJobRunStatus", j.LatestJobRunStatus) + populate(objectMap, "provisioningState", j.ProvisioningState) + populate(objectMap, "sourceName", j.SourceName) + populate(objectMap, "sourceResourceId", j.SourceResourceID) + populate(objectMap, "sourceSubpath", j.SourceSubpath) + populate(objectMap, "targetName", j.TargetName) + populate(objectMap, "targetResourceId", j.TargetResourceID) + populate(objectMap, "targetSubpath", j.TargetSubpath) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobDefinitionProperties. +func (j *JobDefinitionProperties) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentName": + err = unpopulate(val, "AgentName", &j.AgentName) + delete(rawMsg, key) + case "agentResourceId": + err = unpopulate(val, "AgentResourceID", &j.AgentResourceID) + delete(rawMsg, key) + case "copyMode": + err = unpopulate(val, "CopyMode", &j.CopyMode) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &j.Description) + delete(rawMsg, key) + case "latestJobRunName": + err = unpopulate(val, "LatestJobRunName", &j.LatestJobRunName) + delete(rawMsg, key) + case "latestJobRunResourceId": + err = unpopulate(val, "LatestJobRunResourceID", &j.LatestJobRunResourceID) + delete(rawMsg, key) + case "latestJobRunStatus": + err = unpopulate(val, "LatestJobRunStatus", &j.LatestJobRunStatus) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &j.ProvisioningState) + delete(rawMsg, key) + case "sourceName": + err = unpopulate(val, "SourceName", &j.SourceName) + delete(rawMsg, key) + case "sourceResourceId": + err = unpopulate(val, "SourceResourceID", &j.SourceResourceID) + delete(rawMsg, key) + case "sourceSubpath": + err = unpopulate(val, "SourceSubpath", &j.SourceSubpath) + delete(rawMsg, key) + case "targetName": + err = unpopulate(val, "TargetName", &j.TargetName) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &j.TargetResourceID) + delete(rawMsg, key) + case "targetSubpath": + err = unpopulate(val, "TargetSubpath", &j.TargetSubpath) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobDefinitionUpdateParameters. +func (j JobDefinitionUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", j.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobDefinitionUpdateParameters. +func (j *JobDefinitionUpdateParameters) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &j.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobDefinitionUpdateProperties. +func (j JobDefinitionUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentName", j.AgentName) + populate(objectMap, "copyMode", j.CopyMode) + populate(objectMap, "description", j.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobDefinitionUpdateProperties. +func (j *JobDefinitionUpdateProperties) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentName": + err = unpopulate(val, "AgentName", &j.AgentName) + delete(rawMsg, key) + case "copyMode": + err = unpopulate(val, "CopyMode", &j.CopyMode) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &j.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobRun. +func (j JobRun) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", j.ID) + populate(objectMap, "name", j.Name) + populate(objectMap, "properties", j.Properties) + populate(objectMap, "systemData", j.SystemData) + populate(objectMap, "type", j.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobRun. +func (j *JobRun) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &j.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &j.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &j.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &j.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &j.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobRunError. +func (j JobRunError) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", j.Code) + populate(objectMap, "message", j.Message) + populate(objectMap, "target", j.Target) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobRunError. +func (j *JobRunError) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &j.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &j.Message) + delete(rawMsg, key) + case "target": + err = unpopulate(val, "Target", &j.Target) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobRunList. +func (j JobRunList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", j.NextLink) + populate(objectMap, "value", j.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobRunList. +func (j *JobRunList) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &j.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &j.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobRunProperties. +func (j JobRunProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "agentName", j.AgentName) + populate(objectMap, "agentResourceId", j.AgentResourceID) + populate(objectMap, "bytesDesignatedForTransfer", j.BytesDesignatedForTransfer) + populate(objectMap, "bytesExcluded", j.BytesExcluded) + populate(objectMap, "bytesFailed", j.BytesFailed) + populate(objectMap, "bytesNoTransferNeeded", j.BytesNoTransferNeeded) + populate(objectMap, "bytesScanned", j.BytesScanned) + populate(objectMap, "bytesTransferred", j.BytesTransferred) + populate(objectMap, "bytesUnsupported", j.BytesUnsupported) + populate(objectMap, "error", j.Error) + populateTimeRFC3339(objectMap, "executionEndTime", j.ExecutionEndTime) + populateTimeRFC3339(objectMap, "executionStartTime", j.ExecutionStartTime) + populate(objectMap, "itemsDesignatedForTransfer", j.ItemsDesignatedForTransfer) + populate(objectMap, "itemsExcluded", j.ItemsExcluded) + populate(objectMap, "itemsFailed", j.ItemsFailed) + populate(objectMap, "itemsNoTransferNeeded", j.ItemsNoTransferNeeded) + populate(objectMap, "itemsScanned", j.ItemsScanned) + populate(objectMap, "itemsTransferred", j.ItemsTransferred) + populate(objectMap, "itemsUnsupported", j.ItemsUnsupported) + populate(objectMap, "jobDefinitionProperties", &j.JobDefinitionProperties) + populateTimeRFC3339(objectMap, "lastUpdatedTime", j.LastUpdatedTime) + populate(objectMap, "provisioningState", j.ProvisioningState) + populate(objectMap, "scanStatus", j.ScanStatus) + populate(objectMap, "sourceName", j.SourceName) + populate(objectMap, "sourceProperties", &j.SourceProperties) + populate(objectMap, "sourceResourceId", j.SourceResourceID) + populate(objectMap, "status", j.Status) + populate(objectMap, "targetName", j.TargetName) + populate(objectMap, "targetProperties", &j.TargetProperties) + populate(objectMap, "targetResourceId", j.TargetResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobRunProperties. +func (j *JobRunProperties) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "agentName": + err = unpopulate(val, "AgentName", &j.AgentName) + delete(rawMsg, key) + case "agentResourceId": + err = unpopulate(val, "AgentResourceID", &j.AgentResourceID) + delete(rawMsg, key) + case "bytesDesignatedForTransfer": + err = unpopulate(val, "BytesDesignatedForTransfer", &j.BytesDesignatedForTransfer) + delete(rawMsg, key) + case "bytesExcluded": + err = unpopulate(val, "BytesExcluded", &j.BytesExcluded) + delete(rawMsg, key) + case "bytesFailed": + err = unpopulate(val, "BytesFailed", &j.BytesFailed) + delete(rawMsg, key) + case "bytesNoTransferNeeded": + err = unpopulate(val, "BytesNoTransferNeeded", &j.BytesNoTransferNeeded) + delete(rawMsg, key) + case "bytesScanned": + err = unpopulate(val, "BytesScanned", &j.BytesScanned) + delete(rawMsg, key) + case "bytesTransferred": + err = unpopulate(val, "BytesTransferred", &j.BytesTransferred) + delete(rawMsg, key) + case "bytesUnsupported": + err = unpopulate(val, "BytesUnsupported", &j.BytesUnsupported) + delete(rawMsg, key) + case "error": + err = unpopulate(val, "Error", &j.Error) + delete(rawMsg, key) + case "executionEndTime": + err = unpopulateTimeRFC3339(val, "ExecutionEndTime", &j.ExecutionEndTime) + delete(rawMsg, key) + case "executionStartTime": + err = unpopulateTimeRFC3339(val, "ExecutionStartTime", &j.ExecutionStartTime) + delete(rawMsg, key) + case "itemsDesignatedForTransfer": + err = unpopulate(val, "ItemsDesignatedForTransfer", &j.ItemsDesignatedForTransfer) + delete(rawMsg, key) + case "itemsExcluded": + err = unpopulate(val, "ItemsExcluded", &j.ItemsExcluded) + delete(rawMsg, key) + case "itemsFailed": + err = unpopulate(val, "ItemsFailed", &j.ItemsFailed) + delete(rawMsg, key) + case "itemsNoTransferNeeded": + err = unpopulate(val, "ItemsNoTransferNeeded", &j.ItemsNoTransferNeeded) + delete(rawMsg, key) + case "itemsScanned": + err = unpopulate(val, "ItemsScanned", &j.ItemsScanned) + delete(rawMsg, key) + case "itemsTransferred": + err = unpopulate(val, "ItemsTransferred", &j.ItemsTransferred) + delete(rawMsg, key) + case "itemsUnsupported": + err = unpopulate(val, "ItemsUnsupported", &j.ItemsUnsupported) + delete(rawMsg, key) + case "jobDefinitionProperties": + err = unpopulate(val, "JobDefinitionProperties", &j.JobDefinitionProperties) + delete(rawMsg, key) + case "lastUpdatedTime": + err = unpopulateTimeRFC3339(val, "LastUpdatedTime", &j.LastUpdatedTime) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &j.ProvisioningState) + delete(rawMsg, key) + case "scanStatus": + err = unpopulate(val, "ScanStatus", &j.ScanStatus) + delete(rawMsg, key) + case "sourceName": + err = unpopulate(val, "SourceName", &j.SourceName) + delete(rawMsg, key) + case "sourceProperties": + err = unpopulate(val, "SourceProperties", &j.SourceProperties) + delete(rawMsg, key) + case "sourceResourceId": + err = unpopulate(val, "SourceResourceID", &j.SourceResourceID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &j.Status) + delete(rawMsg, key) + case "targetName": + err = unpopulate(val, "TargetName", &j.TargetName) + delete(rawMsg, key) + case "targetProperties": + err = unpopulate(val, "TargetProperties", &j.TargetProperties) + delete(rawMsg, key) + case "targetResourceId": + err = unpopulate(val, "TargetResourceID", &j.TargetResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type JobRunResourceID. +func (j JobRunResourceID) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "jobRunResourceId", j.JobRunResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type JobRunResourceID. +func (j *JobRunResourceID) 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", j, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "jobRunResourceId": + err = unpopulate(val, "JobRunResourceID", &j.JobRunResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", j, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type List. +func (l List) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type List. +func (l *List) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &l.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type NfsMountEndpointProperties. +func (n NfsMountEndpointProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", n.Description) + objectMap["endpointType"] = EndpointTypeNfsMount + populate(objectMap, "host", n.Host) + populate(objectMap, "nfsVersion", n.NfsVersion) + populate(objectMap, "provisioningState", n.ProvisioningState) + populate(objectMap, "remoteExport", n.RemoteExport) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NfsMountEndpointProperties. +func (n *NfsMountEndpointProperties) 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 "description": + err = unpopulate(val, "Description", &n.Description) + delete(rawMsg, key) + case "endpointType": + err = unpopulate(val, "EndpointType", &n.EndpointType) + delete(rawMsg, key) + case "host": + err = unpopulate(val, "Host", &n.Host) + delete(rawMsg, key) + case "nfsVersion": + err = unpopulate(val, "NfsVersion", &n.NfsVersion) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &n.ProvisioningState) + delete(rawMsg, key) + case "remoteExport": + err = unpopulate(val, "RemoteExport", &n.RemoteExport) + 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 NfsMountEndpointUpdateProperties. +func (n NfsMountEndpointUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", n.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type NfsMountEndpointUpdateProperties. +func (n *NfsMountEndpointUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &n.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Project. +func (p Project) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Project. +func (p *Project) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectList. +func (p ProjectList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectList. +func (p *ProjectList) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectProperties. +func (p ProjectProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectProperties. +func (p *ProjectProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectUpdateParameters. +func (p ProjectUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectUpdateParameters. +func (p *ProjectUpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProjectUpdateProperties. +func (p ProjectUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProjectUpdateProperties. +func (p *ProjectUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Properties. +func (p Properties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", p.Description) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Properties. +func (p *Properties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &p.Description) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type StorageMover. +func (s StorageMover) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", s.ID) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageMover. +func (s *StorageMover) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackedResource. +func (t *TrackedResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &t.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &t.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UpdateParameters. +func (u UpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", u.Properties) + populate(objectMap, "tags", u.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateParameters. +func (u *UpdateParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &u.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &u.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UpdateProperties. +func (u UpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", u.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateProperties. +func (u *UpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &u.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/operations_client.go b/sdk/resourcemanager/storagemover/armstoragemover/operations_client.go new file mode 100644 index 000000000000..c7558880e3f6 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/operations_client.go @@ -0,0 +1,105 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armstoragemover + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + host string + pl runtime.Pipeline +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// NewListPager - Lists all the supported operations for the Azure Storage Mover REST API. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.StorageMover/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/polymorphic_helpers.go b/sdk/resourcemanager/storagemover/armstoragemover/polymorphic_helpers.go new file mode 100644 index 000000000000..d86e7507f120 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/polymorphic_helpers.go @@ -0,0 +1,32 @@ +//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 armstoragemover + +import "encoding/json" + +func unmarshalEndpointBasePropertiesClassification(rawMsg json.RawMessage) (EndpointBasePropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]interface{} + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b EndpointBasePropertiesClassification + switch m["endpointType"] { + case string(EndpointTypeAzureStorageBlobContainer): + b = &AzureStorageBlobContainerEndpointProperties{} + case string(EndpointTypeNfsMount): + b = &NfsMountEndpointProperties{} + default: + b = &EndpointBaseProperties{} + } + return b, json.Unmarshal(rawMsg, b) +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/projects_client.go b/sdk/resourcemanager/storagemover/armstoragemover/projects_client.go new file mode 100644 index 000000000000..0cbb43b78b06 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/projects_client.go @@ -0,0 +1,377 @@ +//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 armstoragemover + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ProjectsClient contains the methods for the Projects group. +// Don't use this type directly, use NewProjectsClient() instead. +type ProjectsClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewProjectsClient creates a new instance of ProjectsClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewProjectsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProjectsClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &ProjectsClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a project resource, which is a logical grouping of related jobs. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// options - ProjectsClientCreateOrUpdateOptions contains the optional parameters for the ProjectsClient.CreateOrUpdate method. +func (client *ProjectsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, project Project, options *ProjectsClientCreateOrUpdateOptions) (ProjectsClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, project, options) + if err != nil { + return ProjectsClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProjectsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, project Project, options *ProjectsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, project) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProjectsClient) createOrUpdateHandleResponse(resp *http.Response) (ProjectsClientCreateOrUpdateResponse, error) { + result := ProjectsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Project); err != nil { + return ProjectsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes a project resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// options - ProjectsClientBeginDeleteOptions contains the optional parameters for the ProjectsClient.BeginDelete method. +func (client *ProjectsClient) BeginDelete(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, options *ProjectsClientBeginDeleteOptions) (*runtime.Poller[ProjectsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storageMoverName, projectName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ProjectsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[ProjectsClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a project resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +func (client *ProjectsClient) deleteOperation(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, options *ProjectsClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProjectsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, options *ProjectsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a project resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// options - ProjectsClientGetOptions contains the optional parameters for the ProjectsClient.Get method. +func (client *ProjectsClient) Get(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, options *ProjectsClientGetOptions) (ProjectsClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, options) + if err != nil { + return ProjectsClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectsClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectsClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProjectsClient) getCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, options *ProjectsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProjectsClient) getHandleResponse(resp *http.Response) (ProjectsClientGetResponse, error) { + result := ProjectsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Project); err != nil { + return ProjectsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all projects in a Storage Mover. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// options - ProjectsClientListOptions contains the optional parameters for the ProjectsClient.List method. +func (client *ProjectsClient) NewListPager(resourceGroupName string, storageMoverName string, options *ProjectsClientListOptions) *runtime.Pager[ProjectsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ProjectsClientListResponse]{ + More: func(page ProjectsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProjectsClientListResponse) (ProjectsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, storageMoverName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProjectsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ProjectsClient) listCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, options *ProjectsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ProjectsClient) listHandleResponse(resp *http.Response) (ProjectsClientListResponse, error) { + result := ProjectsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProjectList); err != nil { + return ProjectsClientListResponse{}, err + } + return result, nil +} + +// Update - Updates properties for a project resource. Properties not specified in the request body will be unchanged. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// projectName - The name of the project resource. +// options - ProjectsClientUpdateOptions contains the optional parameters for the ProjectsClient.Update method. +func (client *ProjectsClient) Update(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, project ProjectUpdateParameters, options *ProjectsClientUpdateOptions) (ProjectsClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, storageMoverName, projectName, project, options) + if err != nil { + return ProjectsClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ProjectsClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProjectsClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ProjectsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, projectName string, project ProjectUpdateParameters, options *ProjectsClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}/projects/{projectName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + if projectName == "" { + return nil, errors.New("parameter projectName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{projectName}", url.PathEscape(projectName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, project) +} + +// updateHandleResponse handles the Update response. +func (client *ProjectsClient) updateHandleResponse(resp *http.Response) (ProjectsClientUpdateResponse, error) { + result := ProjectsClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Project); err != nil { + return ProjectsClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/response_types.go b/sdk/resourcemanager/storagemover/armstoragemover/response_types.go new file mode 100644 index 000000000000..cf85b3b2e3b7 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/response_types.go @@ -0,0 +1,165 @@ +//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 armstoragemover + +// AgentsClientCreateOrUpdateResponse contains the response from method AgentsClient.CreateOrUpdate. +type AgentsClientCreateOrUpdateResponse struct { + Agent +} + +// AgentsClientDeleteResponse contains the response from method AgentsClient.Delete. +type AgentsClientDeleteResponse struct { + // placeholder for future response values +} + +// AgentsClientGetResponse contains the response from method AgentsClient.Get. +type AgentsClientGetResponse struct { + Agent +} + +// AgentsClientListResponse contains the response from method AgentsClient.List. +type AgentsClientListResponse struct { + AgentList +} + +// AgentsClientUpdateResponse contains the response from method AgentsClient.Update. +type AgentsClientUpdateResponse struct { + Agent +} + +// EndpointsClientCreateOrUpdateResponse contains the response from method EndpointsClient.CreateOrUpdate. +type EndpointsClientCreateOrUpdateResponse struct { + Endpoint +} + +// EndpointsClientDeleteResponse contains the response from method EndpointsClient.Delete. +type EndpointsClientDeleteResponse struct { + // placeholder for future response values +} + +// EndpointsClientGetResponse contains the response from method EndpointsClient.Get. +type EndpointsClientGetResponse struct { + Endpoint +} + +// EndpointsClientListResponse contains the response from method EndpointsClient.List. +type EndpointsClientListResponse struct { + EndpointList +} + +// EndpointsClientUpdateResponse contains the response from method EndpointsClient.Update. +type EndpointsClientUpdateResponse struct { + Endpoint +} + +// JobDefinitionsClientCreateOrUpdateResponse contains the response from method JobDefinitionsClient.CreateOrUpdate. +type JobDefinitionsClientCreateOrUpdateResponse struct { + JobDefinition +} + +// JobDefinitionsClientDeleteResponse contains the response from method JobDefinitionsClient.Delete. +type JobDefinitionsClientDeleteResponse struct { + // placeholder for future response values +} + +// JobDefinitionsClientGetResponse contains the response from method JobDefinitionsClient.Get. +type JobDefinitionsClientGetResponse struct { + JobDefinition +} + +// JobDefinitionsClientListResponse contains the response from method JobDefinitionsClient.List. +type JobDefinitionsClientListResponse struct { + JobDefinitionList +} + +// JobDefinitionsClientStartJobResponse contains the response from method JobDefinitionsClient.StartJob. +type JobDefinitionsClientStartJobResponse struct { + JobRunResourceID +} + +// JobDefinitionsClientStopJobResponse contains the response from method JobDefinitionsClient.StopJob. +type JobDefinitionsClientStopJobResponse struct { + JobRunResourceID +} + +// JobDefinitionsClientUpdateResponse contains the response from method JobDefinitionsClient.Update. +type JobDefinitionsClientUpdateResponse struct { + JobDefinition +} + +// JobRunsClientGetResponse contains the response from method JobRunsClient.Get. +type JobRunsClientGetResponse struct { + JobRun +} + +// JobRunsClientListResponse contains the response from method JobRunsClient.List. +type JobRunsClientListResponse struct { + JobRunList +} + +// OperationsClientListResponse contains the response from method OperationsClient.List. +type OperationsClientListResponse struct { + OperationListResult +} + +// ProjectsClientCreateOrUpdateResponse contains the response from method ProjectsClient.CreateOrUpdate. +type ProjectsClientCreateOrUpdateResponse struct { + Project +} + +// ProjectsClientDeleteResponse contains the response from method ProjectsClient.Delete. +type ProjectsClientDeleteResponse struct { + // placeholder for future response values +} + +// ProjectsClientGetResponse contains the response from method ProjectsClient.Get. +type ProjectsClientGetResponse struct { + Project +} + +// ProjectsClientListResponse contains the response from method ProjectsClient.List. +type ProjectsClientListResponse struct { + ProjectList +} + +// ProjectsClientUpdateResponse contains the response from method ProjectsClient.Update. +type ProjectsClientUpdateResponse struct { + Project +} + +// StorageMoversClientCreateOrUpdateResponse contains the response from method StorageMoversClient.CreateOrUpdate. +type StorageMoversClientCreateOrUpdateResponse struct { + StorageMover +} + +// StorageMoversClientDeleteResponse contains the response from method StorageMoversClient.Delete. +type StorageMoversClientDeleteResponse struct { + // placeholder for future response values +} + +// StorageMoversClientGetResponse contains the response from method StorageMoversClient.Get. +type StorageMoversClientGetResponse struct { + StorageMover +} + +// StorageMoversClientListBySubscriptionResponse contains the response from method StorageMoversClient.ListBySubscription. +type StorageMoversClientListBySubscriptionResponse struct { + List +} + +// StorageMoversClientListResponse contains the response from method StorageMoversClient.List. +type StorageMoversClientListResponse struct { + List +} + +// StorageMoversClientUpdateResponse contains the response from method StorageMoversClient.Update. +type StorageMoversClientUpdateResponse struct { + StorageMover +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/storagemovers_client.go b/sdk/resourcemanager/storagemover/armstoragemover/storagemovers_client.go new file mode 100644 index 000000000000..8f9735cdb411 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/storagemovers_client.go @@ -0,0 +1,414 @@ +//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 armstoragemover + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// StorageMoversClient contains the methods for the StorageMovers group. +// Don't use this type directly, use NewStorageMoversClient() instead. +type StorageMoversClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewStorageMoversClient creates a new instance of StorageMoversClient with the specified values. +// subscriptionID - The ID of the target subscription. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewStorageMoversClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*StorageMoversClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &StorageMoversClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// CreateOrUpdate - Creates or updates a top-level Storage Mover resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// options - StorageMoversClientCreateOrUpdateOptions contains the optional parameters for the StorageMoversClient.CreateOrUpdate +// method. +func (client *StorageMoversClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, storageMoverName string, storageMover StorageMover, options *StorageMoversClientCreateOrUpdateOptions) (StorageMoversClientCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, storageMoverName, storageMover, options) + if err != nil { + return StorageMoversClientCreateOrUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageMoversClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageMoversClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *StorageMoversClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, storageMover StorageMover, options *StorageMoversClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, storageMover) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *StorageMoversClient) createOrUpdateHandleResponse(resp *http.Response) (StorageMoversClientCreateOrUpdateResponse, error) { + result := StorageMoversClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageMover); err != nil { + return StorageMoversClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// BeginDelete - Deletes a Storage Mover resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// options - StorageMoversClientBeginDeleteOptions contains the optional parameters for the StorageMoversClient.BeginDelete +// method. +func (client *StorageMoversClient) BeginDelete(ctx context.Context, resourceGroupName string, storageMoverName string, options *StorageMoversClientBeginDeleteOptions) (*runtime.Poller[StorageMoversClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, storageMoverName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[StorageMoversClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[StorageMoversClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes a Storage Mover resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +func (client *StorageMoversClient) deleteOperation(ctx context.Context, resourceGroupName string, storageMoverName string, options *StorageMoversClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, storageMoverName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *StorageMoversClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, options *StorageMoversClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets a Storage Mover resource. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// options - StorageMoversClientGetOptions contains the optional parameters for the StorageMoversClient.Get method. +func (client *StorageMoversClient) Get(ctx context.Context, resourceGroupName string, storageMoverName string, options *StorageMoversClientGetOptions) (StorageMoversClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, storageMoverName, options) + if err != nil { + return StorageMoversClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageMoversClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageMoversClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *StorageMoversClient) getCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, options *StorageMoversClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *StorageMoversClient) getHandleResponse(resp *http.Response) (StorageMoversClientGetResponse, error) { + result := StorageMoversClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageMover); err != nil { + return StorageMoversClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all Storage Movers in a resource group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - StorageMoversClientListOptions contains the optional parameters for the StorageMoversClient.List method. +func (client *StorageMoversClient) NewListPager(resourceGroupName string, options *StorageMoversClientListOptions) *runtime.Pager[StorageMoversClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[StorageMoversClientListResponse]{ + More: func(page StorageMoversClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StorageMoversClientListResponse) (StorageMoversClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return StorageMoversClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageMoversClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageMoversClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *StorageMoversClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *StorageMoversClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *StorageMoversClient) listHandleResponse(resp *http.Response) (StorageMoversClientListResponse, error) { + result := StorageMoversClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.List); err != nil { + return StorageMoversClientListResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Lists all Storage Movers in a subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// options - StorageMoversClientListBySubscriptionOptions contains the optional parameters for the StorageMoversClient.ListBySubscription +// method. +func (client *StorageMoversClient) NewListBySubscriptionPager(options *StorageMoversClientListBySubscriptionOptions) *runtime.Pager[StorageMoversClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[StorageMoversClientListBySubscriptionResponse]{ + More: func(page StorageMoversClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *StorageMoversClientListBySubscriptionResponse) (StorageMoversClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return StorageMoversClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageMoversClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageMoversClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *StorageMoversClient) listBySubscriptionCreateRequest(ctx context.Context, options *StorageMoversClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.StorageMover/storageMovers" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *StorageMoversClient) listBySubscriptionHandleResponse(resp *http.Response) (StorageMoversClientListBySubscriptionResponse, error) { + result := StorageMoversClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.List); err != nil { + return StorageMoversClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Updates properties for a Storage Mover resource. Properties not specified in the request body will be unchanged. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-07-01-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// storageMoverName - The name of the Storage Mover resource. +// options - StorageMoversClientUpdateOptions contains the optional parameters for the StorageMoversClient.Update method. +func (client *StorageMoversClient) Update(ctx context.Context, resourceGroupName string, storageMoverName string, storageMover UpdateParameters, options *StorageMoversClientUpdateOptions) (StorageMoversClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, storageMoverName, storageMover, options) + if err != nil { + return StorageMoversClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return StorageMoversClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return StorageMoversClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *StorageMoversClient) updateCreateRequest(ctx context.Context, resourceGroupName string, storageMoverName string, storageMover UpdateParameters, options *StorageMoversClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.StorageMover/storageMovers/{storageMoverName}" + 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 storageMoverName == "" { + return nil, errors.New("parameter storageMoverName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{storageMoverName}", url.PathEscape(storageMoverName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, storageMover) +} + +// updateHandleResponse handles the Update response. +func (client *StorageMoversClient) updateHandleResponse(resp *http.Response) (StorageMoversClientUpdateResponse, error) { + result := StorageMoversClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StorageMover); err != nil { + return StorageMoversClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/storagemover/armstoragemover/time_rfc3339.go b/sdk/resourcemanager/storagemover/armstoragemover/time_rfc3339.go new file mode 100644 index 000000000000..c365c3a0c283 --- /dev/null +++ b/sdk/resourcemanager/storagemover/armstoragemover/time_rfc3339.go @@ -0,0 +1,87 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armstoragemover + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}