diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/CHANGELOG.md b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/CHANGELOG.md new file mode 100644 index 000000000000..38c889e9d7a1 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-10-23) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/LICENSE.txt b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/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/recoveryservicesdatareplication/armrecoveryservicesdatareplication/README.md b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/README.md new file mode 100644 index 000000000000..8f3170e9a33a --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/README.md @@ -0,0 +1,85 @@ +# Azure Recoveryservicesdatareplication Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication) + +The `armrecoveryservicesdatareplication` module provides operations for working with Azure Recoveryservicesdatareplication. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Recoveryservicesdatareplication module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Recoveryservicesdatareplication. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Recoveryservicesdatareplication module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armrecoveryservicesdatareplication.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armrecoveryservicesdatareplication.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewFabricClient() +``` + +## 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 `Recoveryservicesdatareplication` 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/recoveryservicesdatareplication/armrecoveryservicesdatareplication/autorest.md b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/autorest.md new file mode 100644 index 000000000000..3325d0975cf3 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/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/recoveryservicesdatareplication/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/recoveryservicesdatareplication/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/recoveryservicesdatareplication/armrecoveryservicesdatareplication/azuresiterecoverymanagementserviceapi_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/azuresiterecoverymanagementserviceapi_client.go new file mode 100644 index 000000000000..73f4629f06d7 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/azuresiterecoverymanagementserviceapi_client.go @@ -0,0 +1,167 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AzureSiteRecoveryManagementServiceAPIClient contains the methods for the AzureSiteRecoveryManagementServiceAPI group. +// Don't use this type directly, use NewAzureSiteRecoveryManagementServiceAPIClient() instead. +type AzureSiteRecoveryManagementServiceAPIClient struct { + internal *arm.Client + subscriptionID string +} + +// NewAzureSiteRecoveryManagementServiceAPIClient creates a new instance of AzureSiteRecoveryManagementServiceAPIClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewAzureSiteRecoveryManagementServiceAPIClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AzureSiteRecoveryManagementServiceAPIClient, error) { + cl, err := arm.NewClient(moduleName+".AzureSiteRecoveryManagementServiceAPIClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &AzureSiteRecoveryManagementServiceAPIClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckNameAvailability - Checks the resource name availability. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - location - The name of the Azure region. +// - options - AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityOptions contains the optional parameters for +// the AzureSiteRecoveryManagementServiceAPIClient.CheckNameAvailability method. +func (client *AzureSiteRecoveryManagementServiceAPIClient) CheckNameAvailability(ctx context.Context, location string, options *AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityOptions) (AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse, error) { + var err error + req, err := client.checkNameAvailabilityCreateRequest(ctx, location, options) + if err != nil { + return AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse{}, err + } + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *AzureSiteRecoveryManagementServiceAPIClient) checkNameAvailabilityCreateRequest(ctx context.Context, location string, options *AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/locations/{location}/checkNameAvailability" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Body != nil { + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil + } + return req, nil +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *AzureSiteRecoveryManagementServiceAPIClient) checkNameAvailabilityHandleResponse(resp *http.Response) (AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse, error) { + result := AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponseModel); err != nil { + return AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// DeploymentPreflight - Performs resource deployment validation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - deploymentID - Deployment Id. +// - options - AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightOptions contains the optional parameters for the +// AzureSiteRecoveryManagementServiceAPIClient.DeploymentPreflight method. +func (client *AzureSiteRecoveryManagementServiceAPIClient) DeploymentPreflight(ctx context.Context, resourceGroupName string, deploymentID string, options *AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightOptions) (AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse, error) { + var err error + req, err := client.deploymentPreflightCreateRequest(ctx, resourceGroupName, deploymentID, options) + if err != nil { + return AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse{}, err + } + resp, err := client.deploymentPreflightHandleResponse(httpResp) + return resp, err +} + +// deploymentPreflightCreateRequest creates the DeploymentPreflight request. +func (client *AzureSiteRecoveryManagementServiceAPIClient) deploymentPreflightCreateRequest(ctx context.Context, resourceGroupName string, deploymentID string, options *AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/deployments/{deploymentId}/preflight" + 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 deploymentID == "" { + return nil, errors.New("parameter deploymentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{deploymentId}", url.PathEscape(deploymentID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Body != nil { + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil + } + return req, nil +} + +// deploymentPreflightHandleResponse handles the DeploymentPreflight response. +func (client *AzureSiteRecoveryManagementServiceAPIClient) deploymentPreflightHandleResponse(resp *http.Response) (AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse, error) { + result := AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DeploymentPreflightModel); err != nil { + return AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/build.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/build.go new file mode 100644 index 000000000000..cd5948344dab --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication + +package armrecoveryservicesdatareplication diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/ci.yml b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/ci.yml new file mode 100644 index 000000000000..6f0ca305777a --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/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/recoveryservicesdatareplication/armrecoveryservicesdatareplication/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication' diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/client_factory.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/client_factory.go new file mode 100644 index 000000000000..11086d73aa53 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/client_factory.go @@ -0,0 +1,133 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewAzureSiteRecoveryManagementServiceAPIClient() *AzureSiteRecoveryManagementServiceAPIClient { + subClient, _ := NewAzureSiteRecoveryManagementServiceAPIClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDraClient() *DraClient { + subClient, _ := NewDraClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewDraOperationStatusClient() *DraOperationStatusClient { + subClient, _ := NewDraOperationStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEmailConfigurationClient() *EmailConfigurationClient { + subClient, _ := NewEmailConfigurationClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewEventClient() *EventClient { + subClient, _ := NewEventClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFabricClient() *FabricClient { + subClient, _ := NewFabricClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFabricOperationsStatusClient() *FabricOperationsStatusClient { + subClient, _ := NewFabricOperationsStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPolicyClient() *PolicyClient { + subClient, _ := NewPolicyClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPolicyOperationStatusClient() *PolicyOperationStatusClient { + subClient, _ := NewPolicyOperationStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewProtectedItemClient() *ProtectedItemClient { + subClient, _ := NewProtectedItemClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewProtectedItemOperationStatusClient() *ProtectedItemOperationStatusClient { + subClient, _ := NewProtectedItemOperationStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewRecoveryPointsClient() *RecoveryPointsClient { + subClient, _ := NewRecoveryPointsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewReplicationExtensionClient() *ReplicationExtensionClient { + subClient, _ := NewReplicationExtensionClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewReplicationExtensionOperationStatusClient() *ReplicationExtensionOperationStatusClient { + subClient, _ := NewReplicationExtensionOperationStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVaultClient() *VaultClient { + subClient, _ := NewVaultClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewVaultOperationStatusClient() *VaultOperationStatusClient { + subClient, _ := NewVaultOperationStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkflowClient() *WorkflowClient { + subClient, _ := NewWorkflowClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewWorkflowOperationStatusClient() *WorkflowOperationStatusClient { + subClient, _ := NewWorkflowOperationStatusClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/constants.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/constants.go new file mode 100644 index 000000000000..cb1640b8e6c0 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/constants.go @@ -0,0 +1,425 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +const ( + moduleName = "armrecoveryservicesdatareplication" + 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, + } +} + +// HealthStatus - Gets or sets the fabric health. +type HealthStatus string + +const ( + HealthStatusCritical HealthStatus = "Critical" + HealthStatusNormal HealthStatus = "Normal" + HealthStatusWarning HealthStatus = "Warning" +) + +// PossibleHealthStatusValues returns the possible values for the HealthStatus const type. +func PossibleHealthStatusValues() []HealthStatus { + return []HealthStatus{ + HealthStatusCritical, + HealthStatusNormal, + HealthStatusWarning, + } +} + +// 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, + } +} + +// ProtectedItemActiveLocation - Gets or sets the location of the protected item. +type ProtectedItemActiveLocation string + +const ( + ProtectedItemActiveLocationPrimary ProtectedItemActiveLocation = "Primary" + ProtectedItemActiveLocationRecovery ProtectedItemActiveLocation = "Recovery" +) + +// PossibleProtectedItemActiveLocationValues returns the possible values for the ProtectedItemActiveLocation const type. +func PossibleProtectedItemActiveLocationValues() []ProtectedItemActiveLocation { + return []ProtectedItemActiveLocation{ + ProtectedItemActiveLocationPrimary, + ProtectedItemActiveLocationRecovery, + } +} + +// ProtectionState - Gets or sets the protection state. +type ProtectionState string + +const ( + ProtectionStateCancelFailoverFailedOnPrimary ProtectionState = "CancelFailoverFailedOnPrimary" + ProtectionStateCancelFailoverFailedOnRecovery ProtectionState = "CancelFailoverFailedOnRecovery" + ProtectionStateCancelFailoverInProgressOnPrimary ProtectionState = "CancelFailoverInProgressOnPrimary" + ProtectionStateCancelFailoverInProgressOnRecovery ProtectionState = "CancelFailoverInProgressOnRecovery" + ProtectionStateCancelFailoverStatesBegin ProtectionState = "CancelFailoverStatesBegin" + ProtectionStateCancelFailoverStatesEnd ProtectionState = "CancelFailoverStatesEnd" + ProtectionStateChangeRecoveryPointCompleted ProtectionState = "ChangeRecoveryPointCompleted" + ProtectionStateChangeRecoveryPointFailed ProtectionState = "ChangeRecoveryPointFailed" + ProtectionStateChangeRecoveryPointInitiated ProtectionState = "ChangeRecoveryPointInitiated" + ProtectionStateChangeRecoveryPointStatesBegin ProtectionState = "ChangeRecoveryPointStatesBegin" + ProtectionStateChangeRecoveryPointStatesEnd ProtectionState = "ChangeRecoveryPointStatesEnd" + ProtectionStateCommitFailoverCompleted ProtectionState = "CommitFailoverCompleted" + ProtectionStateCommitFailoverFailedOnPrimary ProtectionState = "CommitFailoverFailedOnPrimary" + ProtectionStateCommitFailoverFailedOnRecovery ProtectionState = "CommitFailoverFailedOnRecovery" + ProtectionStateCommitFailoverInProgressOnPrimary ProtectionState = "CommitFailoverInProgressOnPrimary" + ProtectionStateCommitFailoverInProgressOnRecovery ProtectionState = "CommitFailoverInProgressOnRecovery" + ProtectionStateCommitFailoverStatesBegin ProtectionState = "CommitFailoverStatesBegin" + ProtectionStateCommitFailoverStatesEnd ProtectionState = "CommitFailoverStatesEnd" + ProtectionStateDisablingFailed ProtectionState = "DisablingFailed" + ProtectionStateDisablingProtection ProtectionState = "DisablingProtection" + ProtectionStateEnablingFailed ProtectionState = "EnablingFailed" + ProtectionStateEnablingProtection ProtectionState = "EnablingProtection" + ProtectionStateInitialReplicationCompletedOnPrimary ProtectionState = "InitialReplicationCompletedOnPrimary" + ProtectionStateInitialReplicationCompletedOnRecovery ProtectionState = "InitialReplicationCompletedOnRecovery" + ProtectionStateInitialReplicationFailed ProtectionState = "InitialReplicationFailed" + ProtectionStateInitialReplicationInProgress ProtectionState = "InitialReplicationInProgress" + ProtectionStateInitialReplicationStatesBegin ProtectionState = "InitialReplicationStatesBegin" + ProtectionStateInitialReplicationStatesEnd ProtectionState = "InitialReplicationStatesEnd" + ProtectionStateMarkedForDeletion ProtectionState = "MarkedForDeletion" + ProtectionStatePlannedFailoverCompleted ProtectionState = "PlannedFailoverCompleted" + ProtectionStatePlannedFailoverCompleting ProtectionState = "PlannedFailoverCompleting" + ProtectionStatePlannedFailoverCompletionFailed ProtectionState = "PlannedFailoverCompletionFailed" + ProtectionStatePlannedFailoverFailed ProtectionState = "PlannedFailoverFailed" + ProtectionStatePlannedFailoverInitiated ProtectionState = "PlannedFailoverInitiated" + ProtectionStatePlannedFailoverTransitionStatesBegin ProtectionState = "PlannedFailoverTransitionStatesBegin" + ProtectionStatePlannedFailoverTransitionStatesEnd ProtectionState = "PlannedFailoverTransitionStatesEnd" + ProtectionStateProtected ProtectionState = "Protected" + ProtectionStateProtectedStatesBegin ProtectionState = "ProtectedStatesBegin" + ProtectionStateProtectedStatesEnd ProtectionState = "ProtectedStatesEnd" + ProtectionStateReprotectFailed ProtectionState = "ReprotectFailed" + ProtectionStateReprotectInitiated ProtectionState = "ReprotectInitiated" + ProtectionStateReprotectStatesBegin ProtectionState = "ReprotectStatesBegin" + ProtectionStateReprotectStatesEnd ProtectionState = "ReprotectStatesEnd" + ProtectionStateUnplannedFailoverCompleted ProtectionState = "UnplannedFailoverCompleted" + ProtectionStateUnplannedFailoverCompleting ProtectionState = "UnplannedFailoverCompleting" + ProtectionStateUnplannedFailoverCompletionFailed ProtectionState = "UnplannedFailoverCompletionFailed" + ProtectionStateUnplannedFailoverFailed ProtectionState = "UnplannedFailoverFailed" + ProtectionStateUnplannedFailoverInitiated ProtectionState = "UnplannedFailoverInitiated" + ProtectionStateUnplannedFailoverTransitionStatesBegin ProtectionState = "UnplannedFailoverTransitionStatesBegin" + ProtectionStateUnplannedFailoverTransitionStatesEnd ProtectionState = "UnplannedFailoverTransitionStatesEnd" + ProtectionStateUnprotectedStatesBegin ProtectionState = "UnprotectedStatesBegin" + ProtectionStateUnprotectedStatesEnd ProtectionState = "UnprotectedStatesEnd" +) + +// PossibleProtectionStateValues returns the possible values for the ProtectionState const type. +func PossibleProtectionStateValues() []ProtectionState { + return []ProtectionState{ + ProtectionStateCancelFailoverFailedOnPrimary, + ProtectionStateCancelFailoverFailedOnRecovery, + ProtectionStateCancelFailoverInProgressOnPrimary, + ProtectionStateCancelFailoverInProgressOnRecovery, + ProtectionStateCancelFailoverStatesBegin, + ProtectionStateCancelFailoverStatesEnd, + ProtectionStateChangeRecoveryPointCompleted, + ProtectionStateChangeRecoveryPointFailed, + ProtectionStateChangeRecoveryPointInitiated, + ProtectionStateChangeRecoveryPointStatesBegin, + ProtectionStateChangeRecoveryPointStatesEnd, + ProtectionStateCommitFailoverCompleted, + ProtectionStateCommitFailoverFailedOnPrimary, + ProtectionStateCommitFailoverFailedOnRecovery, + ProtectionStateCommitFailoverInProgressOnPrimary, + ProtectionStateCommitFailoverInProgressOnRecovery, + ProtectionStateCommitFailoverStatesBegin, + ProtectionStateCommitFailoverStatesEnd, + ProtectionStateDisablingFailed, + ProtectionStateDisablingProtection, + ProtectionStateEnablingFailed, + ProtectionStateEnablingProtection, + ProtectionStateInitialReplicationCompletedOnPrimary, + ProtectionStateInitialReplicationCompletedOnRecovery, + ProtectionStateInitialReplicationFailed, + ProtectionStateInitialReplicationInProgress, + ProtectionStateInitialReplicationStatesBegin, + ProtectionStateInitialReplicationStatesEnd, + ProtectionStateMarkedForDeletion, + ProtectionStatePlannedFailoverCompleted, + ProtectionStatePlannedFailoverCompleting, + ProtectionStatePlannedFailoverCompletionFailed, + ProtectionStatePlannedFailoverFailed, + ProtectionStatePlannedFailoverInitiated, + ProtectionStatePlannedFailoverTransitionStatesBegin, + ProtectionStatePlannedFailoverTransitionStatesEnd, + ProtectionStateProtected, + ProtectionStateProtectedStatesBegin, + ProtectionStateProtectedStatesEnd, + ProtectionStateReprotectFailed, + ProtectionStateReprotectInitiated, + ProtectionStateReprotectStatesBegin, + ProtectionStateReprotectStatesEnd, + ProtectionStateUnplannedFailoverCompleted, + ProtectionStateUnplannedFailoverCompleting, + ProtectionStateUnplannedFailoverCompletionFailed, + ProtectionStateUnplannedFailoverFailed, + ProtectionStateUnplannedFailoverInitiated, + ProtectionStateUnplannedFailoverTransitionStatesBegin, + ProtectionStateUnplannedFailoverTransitionStatesEnd, + ProtectionStateUnprotectedStatesBegin, + ProtectionStateUnprotectedStatesEnd, + } +} + +// ProvisioningState - Gets or sets the provisioning state of the Dra. +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleted ProvisioningState = "Deleted" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleted, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} + +// RecoveryPointType - Gets or sets the recovery point type. +type RecoveryPointType string + +const ( + RecoveryPointTypeApplicationConsistent RecoveryPointType = "ApplicationConsistent" + RecoveryPointTypeCrashConsistent RecoveryPointType = "CrashConsistent" +) + +// PossibleRecoveryPointTypeValues returns the possible values for the RecoveryPointType const type. +func PossibleRecoveryPointTypeValues() []RecoveryPointType { + return []RecoveryPointType{ + RecoveryPointTypeApplicationConsistent, + RecoveryPointTypeCrashConsistent, + } +} + +// ReplicationVaultType - Gets or sets the type of vault. +type ReplicationVaultType string + +const ( + ReplicationVaultTypeDisasterRecovery ReplicationVaultType = "DisasterRecovery" + ReplicationVaultTypeMigrate ReplicationVaultType = "Migrate" +) + +// PossibleReplicationVaultTypeValues returns the possible values for the ReplicationVaultType const type. +func PossibleReplicationVaultTypeValues() []ReplicationVaultType { + return []ReplicationVaultType{ + ReplicationVaultTypeDisasterRecovery, + ReplicationVaultTypeMigrate, + } +} + +// ResynchronizationState - Gets or sets the resynchronization state. +type ResynchronizationState string + +const ( + ResynchronizationStateNone ResynchronizationState = "None" + ResynchronizationStateResynchronizationCompleted ResynchronizationState = "ResynchronizationCompleted" + ResynchronizationStateResynchronizationFailed ResynchronizationState = "ResynchronizationFailed" + ResynchronizationStateResynchronizationInitiated ResynchronizationState = "ResynchronizationInitiated" +) + +// PossibleResynchronizationStateValues returns the possible values for the ResynchronizationState const type. +func PossibleResynchronizationStateValues() []ResynchronizationState { + return []ResynchronizationState{ + ResynchronizationStateNone, + ResynchronizationStateResynchronizationCompleted, + ResynchronizationStateResynchronizationFailed, + ResynchronizationStateResynchronizationInitiated, + } +} + +// TaskState - Gets or sets the task state. +type TaskState string + +const ( + TaskStateCancelled TaskState = "Cancelled" + TaskStateFailed TaskState = "Failed" + TaskStatePending TaskState = "Pending" + TaskStateSkipped TaskState = "Skipped" + TaskStateStarted TaskState = "Started" + TaskStateSucceeded TaskState = "Succeeded" +) + +// PossibleTaskStateValues returns the possible values for the TaskState const type. +func PossibleTaskStateValues() []TaskState { + return []TaskState{ + TaskStateCancelled, + TaskStateFailed, + TaskStatePending, + TaskStateSkipped, + TaskStateStarted, + TaskStateSucceeded, + } +} + +// TestFailoverState - Gets or sets the test failover state. +type TestFailoverState string + +const ( + TestFailoverStateMarkedForDeletion TestFailoverState = "MarkedForDeletion" + TestFailoverStateNone TestFailoverState = "None" + TestFailoverStateTestFailoverCleanupCompleting TestFailoverState = "TestFailoverCleanupCompleting" + TestFailoverStateTestFailoverCleanupInitiated TestFailoverState = "TestFailoverCleanupInitiated" + TestFailoverStateTestFailoverCompleted TestFailoverState = "TestFailoverCompleted" + TestFailoverStateTestFailoverCompleting TestFailoverState = "TestFailoverCompleting" + TestFailoverStateTestFailoverCompletionFailed TestFailoverState = "TestFailoverCompletionFailed" + TestFailoverStateTestFailoverFailed TestFailoverState = "TestFailoverFailed" + TestFailoverStateTestFailoverInitiated TestFailoverState = "TestFailoverInitiated" +) + +// PossibleTestFailoverStateValues returns the possible values for the TestFailoverState const type. +func PossibleTestFailoverStateValues() []TestFailoverState { + return []TestFailoverState{ + TestFailoverStateMarkedForDeletion, + TestFailoverStateNone, + TestFailoverStateTestFailoverCleanupCompleting, + TestFailoverStateTestFailoverCleanupInitiated, + TestFailoverStateTestFailoverCompleted, + TestFailoverStateTestFailoverCompleting, + TestFailoverStateTestFailoverCompletionFailed, + TestFailoverStateTestFailoverFailed, + TestFailoverStateTestFailoverInitiated, + } +} + +// VMNicSelection - Gets or sets the selection type of the NIC. +type VMNicSelection string + +const ( + VMNicSelectionNotSelected VMNicSelection = "NotSelected" + VMNicSelectionSelectedByDefault VMNicSelection = "SelectedByDefault" + VMNicSelectionSelectedByUser VMNicSelection = "SelectedByUser" + VMNicSelectionSelectedByUserOverride VMNicSelection = "SelectedByUserOverride" +) + +// PossibleVMNicSelectionValues returns the possible values for the VMNicSelection const type. +func PossibleVMNicSelectionValues() []VMNicSelection { + return []VMNicSelection{ + VMNicSelectionNotSelected, + VMNicSelectionSelectedByDefault, + VMNicSelectionSelectedByUser, + VMNicSelectionSelectedByUserOverride, + } +} + +// VMwareToAzureMigrateResyncState - Gets or sets the resync state. +type VMwareToAzureMigrateResyncState string + +const ( + VMwareToAzureMigrateResyncStateNone VMwareToAzureMigrateResyncState = "None" + VMwareToAzureMigrateResyncStatePreparedForResynchronization VMwareToAzureMigrateResyncState = "PreparedForResynchronization" + VMwareToAzureMigrateResyncStateStartedResynchronization VMwareToAzureMigrateResyncState = "StartedResynchronization" +) + +// PossibleVMwareToAzureMigrateResyncStateValues returns the possible values for the VMwareToAzureMigrateResyncState const type. +func PossibleVMwareToAzureMigrateResyncStateValues() []VMwareToAzureMigrateResyncState { + return []VMwareToAzureMigrateResyncState{ + VMwareToAzureMigrateResyncStateNone, + VMwareToAzureMigrateResyncStatePreparedForResynchronization, + VMwareToAzureMigrateResyncStateStartedResynchronization, + } +} + +// WorkflowObjectType - Gets or sets the object type. +type WorkflowObjectType string + +const ( + WorkflowObjectTypeAvsDiskPool WorkflowObjectType = "AvsDiskPool" + WorkflowObjectTypeDra WorkflowObjectType = "Dra" + WorkflowObjectTypeFabric WorkflowObjectType = "Fabric" + WorkflowObjectTypePolicy WorkflowObjectType = "Policy" + WorkflowObjectTypeProtectedItem WorkflowObjectType = "ProtectedItem" + WorkflowObjectTypeRecoveryPlan WorkflowObjectType = "RecoveryPlan" + WorkflowObjectTypeReplicationExtension WorkflowObjectType = "ReplicationExtension" + WorkflowObjectTypeVault WorkflowObjectType = "Vault" +) + +// PossibleWorkflowObjectTypeValues returns the possible values for the WorkflowObjectType const type. +func PossibleWorkflowObjectTypeValues() []WorkflowObjectType { + return []WorkflowObjectType{ + WorkflowObjectTypeAvsDiskPool, + WorkflowObjectTypeDra, + WorkflowObjectTypeFabric, + WorkflowObjectTypePolicy, + WorkflowObjectTypeProtectedItem, + WorkflowObjectTypeRecoveryPlan, + WorkflowObjectTypeReplicationExtension, + WorkflowObjectTypeVault, + } +} + +// WorkflowState - Gets or sets the workflow state. +type WorkflowState string + +const ( + WorkflowStateCancelled WorkflowState = "Cancelled" + WorkflowStateCancelling WorkflowState = "Cancelling" + WorkflowStateCompletedWithErrors WorkflowState = "CompletedWithErrors" + WorkflowStateCompletedWithInformation WorkflowState = "CompletedWithInformation" + WorkflowStateCompletedWithWarnings WorkflowState = "CompletedWithWarnings" + WorkflowStateFailed WorkflowState = "Failed" + WorkflowStatePending WorkflowState = "Pending" + WorkflowStateStarted WorkflowState = "Started" + WorkflowStateSucceeded WorkflowState = "Succeeded" +) + +// PossibleWorkflowStateValues returns the possible values for the WorkflowState const type. +func PossibleWorkflowStateValues() []WorkflowState { + return []WorkflowState{ + WorkflowStateCancelled, + WorkflowStateCancelling, + WorkflowStateCompletedWithErrors, + WorkflowStateCompletedWithInformation, + WorkflowStateCompletedWithWarnings, + WorkflowStateFailed, + WorkflowStatePending, + WorkflowStateStarted, + WorkflowStateSucceeded, + } +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/dra_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/dra_client.go new file mode 100644 index 000000000000..a9cec4cb25d2 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/dra_client.go @@ -0,0 +1,318 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DraClient contains the methods for the Dra group. +// Don't use this type directly, use NewDraClient() instead. +type DraClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDraClient creates a new instance of DraClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDraClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DraClient, error) { + cl, err := arm.NewClient(moduleName+".DraClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DraClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates the fabric agent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - fabricAgentName - The fabric agent (Dra) name. +// - body - Dra model. +// - options - DraClientBeginCreateOptions contains the optional parameters for the DraClient.BeginCreate method. +func (client *DraClient) BeginCreate(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, body DraModel, options *DraClientBeginCreateOptions) (*runtime.Poller[DraClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, fabricName, fabricAgentName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DraClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[DraClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Creates the fabric agent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *DraClient) create(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, body DraModel, options *DraClientBeginCreateOptions) (*http.Response, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceGroupName, fabricName, fabricAgentName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *DraClient) createCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, body DraModel, options *DraClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + if fabricAgentName == "" { + return nil, errors.New("parameter fabricAgentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricAgentName}", url.PathEscape(fabricAgentName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes the fabric agent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - fabricAgentName - The fabric agent (Dra) name. +// - options - DraClientBeginDeleteOptions contains the optional parameters for the DraClient.BeginDelete method. +func (client *DraClient) BeginDelete(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, options *DraClientBeginDeleteOptions) (*runtime.Poller[DraClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, fabricName, fabricAgentName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DraClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[DraClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Deletes the fabric agent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *DraClient) deleteOperation(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, options *DraClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, fabricName, fabricAgentName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DraClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, options *DraClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + if fabricAgentName == "" { + return nil, errors.New("parameter fabricAgentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricAgentName}", url.PathEscape(fabricAgentName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the details of the fabric agent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - fabricAgentName - The fabric agent (Dra) name. +// - options - DraClientGetOptions contains the optional parameters for the DraClient.Get method. +func (client *DraClient) Get(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, options *DraClientGetOptions) (DraClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, fabricName, fabricAgentName, options) + if err != nil { + return DraClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DraClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DraClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DraClient) getCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, options *DraClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + if fabricAgentName == "" { + return nil, errors.New("parameter fabricAgentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricAgentName}", url.PathEscape(fabricAgentName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DraClient) getHandleResponse(resp *http.Response) (DraClientGetResponse, error) { + result := DraClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DraModel); err != nil { + return DraClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of fabric agents in the given fabric. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - options - DraClientListOptions contains the optional parameters for the DraClient.NewListPager method. +func (client *DraClient) NewListPager(resourceGroupName string, fabricName string, options *DraClientListOptions) *runtime.Pager[DraClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[DraClientListResponse]{ + More: func(page DraClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DraClientListResponse) (DraClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, fabricName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return DraClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DraClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return DraClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *DraClient) listCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, options *DraClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *DraClient) listHandleResponse(resp *http.Response) (DraClientListResponse, error) { + result := DraClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DraModelCollection); err != nil { + return DraClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/draoperationstatus_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/draoperationstatus_client.go new file mode 100644 index 000000000000..e2cd5afa2780 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/draoperationstatus_client.go @@ -0,0 +1,111 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DraOperationStatusClient contains the methods for the DraOperationStatus group. +// Don't use this type directly, use NewDraOperationStatusClient() instead. +type DraOperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDraOperationStatusClient creates a new instance of DraOperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDraOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DraOperationStatusClient, error) { + cl, err := arm.NewClient(moduleName+".DraOperationStatusClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DraOperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Tracks the results of an asynchronous operation on the fabric agent. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - fabricAgentName - The fabric agent (Dra) name. +// - operationID - The ID of an ongoing async operation. +// - options - DraOperationStatusClientGetOptions contains the optional parameters for the DraOperationStatusClient.Get method. +func (client *DraOperationStatusClient) Get(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, operationID string, options *DraOperationStatusClientGetOptions) (DraOperationStatusClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, fabricName, fabricAgentName, operationID, options) + if err != nil { + return DraOperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DraOperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DraOperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DraOperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, fabricAgentName string, operationID string, options *DraOperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/fabricAgents/{fabricAgentName}/operations/{operationId}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + if fabricAgentName == "" { + return nil, errors.New("parameter fabricAgentName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricAgentName}", url.PathEscape(fabricAgentName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DraOperationStatusClient) getHandleResponse(resp *http.Response) (DraOperationStatusClientGetResponse, error) { + result := DraOperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return DraOperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/emailconfiguration_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/emailconfiguration_client.go new file mode 100644 index 000000000000..0ec57d7504cb --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/emailconfiguration_client.go @@ -0,0 +1,240 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// EmailConfigurationClient contains the methods for the EmailConfiguration group. +// Don't use this type directly, use NewEmailConfigurationClient() instead. +type EmailConfigurationClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEmailConfigurationClient creates a new instance of EmailConfigurationClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewEmailConfigurationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EmailConfigurationClient, error) { + cl, err := arm.NewClient(moduleName+".EmailConfigurationClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EmailConfigurationClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Create - Creates an alert configuration setting for the given vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - emailConfigurationName - The email configuration name. +// - body - EmailConfiguration model. +// - options - EmailConfigurationClientCreateOptions contains the optional parameters for the EmailConfigurationClient.Create +// method. +func (client *EmailConfigurationClient) Create(ctx context.Context, resourceGroupName string, vaultName string, emailConfigurationName string, body EmailConfigurationModel, options *EmailConfigurationClientCreateOptions) (EmailConfigurationClientCreateResponse, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceGroupName, vaultName, emailConfigurationName, body, options) + if err != nil { + return EmailConfigurationClientCreateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EmailConfigurationClientCreateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return EmailConfigurationClientCreateResponse{}, err + } + resp, err := client.createHandleResponse(httpResp) + return resp, err +} + +// createCreateRequest creates the Create request. +func (client *EmailConfigurationClient) createCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, emailConfigurationName string, body EmailConfigurationModel, options *EmailConfigurationClientCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if emailConfigurationName == "" { + return nil, errors.New("parameter emailConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{emailConfigurationName}", url.PathEscape(emailConfigurationName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *EmailConfigurationClient) createHandleResponse(resp *http.Response) (EmailConfigurationClientCreateResponse, error) { + result := EmailConfigurationClientCreateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EmailConfigurationModel); err != nil { + return EmailConfigurationClientCreateResponse{}, err + } + return result, nil +} + +// Get - Gets the details of the alert configuration setting. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - emailConfigurationName - The email configuration name. +// - options - EmailConfigurationClientGetOptions contains the optional parameters for the EmailConfigurationClient.Get method. +func (client *EmailConfigurationClient) Get(ctx context.Context, resourceGroupName string, vaultName string, emailConfigurationName string, options *EmailConfigurationClientGetOptions) (EmailConfigurationClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, emailConfigurationName, options) + if err != nil { + return EmailConfigurationClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EmailConfigurationClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EmailConfigurationClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EmailConfigurationClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, emailConfigurationName string, options *EmailConfigurationClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings/{emailConfigurationName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if emailConfigurationName == "" { + return nil, errors.New("parameter emailConfigurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{emailConfigurationName}", url.PathEscape(emailConfigurationName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EmailConfigurationClient) getHandleResponse(resp *http.Response) (EmailConfigurationClientGetResponse, error) { + result := EmailConfigurationClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EmailConfigurationModel); err != nil { + return EmailConfigurationClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of alert configuration settings for the given vault. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - EmailConfigurationClientListOptions contains the optional parameters for the EmailConfigurationClient.NewListPager +// method. +func (client *EmailConfigurationClient) NewListPager(resourceGroupName string, vaultName string, options *EmailConfigurationClientListOptions) *runtime.Pager[EmailConfigurationClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[EmailConfigurationClientListResponse]{ + More: func(page EmailConfigurationClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EmailConfigurationClientListResponse) (EmailConfigurationClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EmailConfigurationClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EmailConfigurationClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EmailConfigurationClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *EmailConfigurationClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *EmailConfigurationClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/alertSettings" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EmailConfigurationClient) listHandleResponse(resp *http.Response) (EmailConfigurationClientListResponse, error) { + result := EmailConfigurationClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EmailConfigurationModelCollection); err != nil { + return EmailConfigurationClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/event_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/event_client.go new file mode 100644 index 000000000000..6a627f394adc --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/event_client.go @@ -0,0 +1,178 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// EventClient contains the methods for the Event group. +// Don't use this type directly, use NewEventClient() instead. +type EventClient struct { + internal *arm.Client + subscriptionID string +} + +// NewEventClient creates a new instance of EventClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewEventClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*EventClient, error) { + cl, err := arm.NewClient(moduleName+".EventClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &EventClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets the details of the event. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - eventName - The event name. +// - options - EventClientGetOptions contains the optional parameters for the EventClient.Get method. +func (client *EventClient) Get(ctx context.Context, resourceGroupName string, vaultName string, eventName string, options *EventClientGetOptions) (EventClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, eventName, options) + if err != nil { + return EventClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EventClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EventClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *EventClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, eventName string, options *EventClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events/{eventName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if eventName == "" { + return nil, errors.New("parameter eventName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{eventName}", url.PathEscape(eventName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EventClient) getHandleResponse(resp *http.Response) (EventClientGetResponse, error) { + result := EventClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EventModel); err != nil { + return EventClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of events in the given vault. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - EventClientListOptions contains the optional parameters for the EventClient.NewListPager method. +func (client *EventClient) NewListPager(resourceGroupName string, vaultName string, options *EventClientListOptions) *runtime.Pager[EventClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[EventClientListResponse]{ + More: func(page EventClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *EventClientListResponse) (EventClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return EventClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return EventClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return EventClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *EventClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *EventClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/events" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *EventClient) listHandleResponse(resp *http.Response) (EventClientListResponse, error) { + result := EventClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.EventModelCollection); err != nil { + return EventClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/fabric_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/fabric_client.go new file mode 100644 index 000000000000..0d0aa42934e0 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/fabric_client.go @@ -0,0 +1,431 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// FabricClient contains the methods for the Fabric group. +// Don't use this type directly, use NewFabricClient() instead. +type FabricClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFabricClient creates a new instance of FabricClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewFabricClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FabricClient, error) { + cl, err := arm.NewClient(moduleName+".FabricClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FabricClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - body - Fabric properties. +// - options - FabricClientBeginCreateOptions contains the optional parameters for the FabricClient.BeginCreate method. +func (client *FabricClient) BeginCreate(ctx context.Context, resourceGroupName string, fabricName string, body FabricModel, options *FabricClientBeginCreateOptions) (*runtime.Poller[FabricClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, fabricName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FabricClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FabricClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Creates the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *FabricClient) create(ctx context.Context, resourceGroupName string, fabricName string, body FabricModel, options *FabricClientBeginCreateOptions) (*http.Response, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceGroupName, fabricName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *FabricClient) createCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, body FabricModel, options *FabricClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Removes the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - options - FabricClientBeginDeleteOptions contains the optional parameters for the FabricClient.BeginDelete method. +func (client *FabricClient) BeginDelete(ctx context.Context, resourceGroupName string, fabricName string, options *FabricClientBeginDeleteOptions) (*runtime.Poller[FabricClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, fabricName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FabricClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FabricClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Removes the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *FabricClient) deleteOperation(ctx context.Context, resourceGroupName string, fabricName string, options *FabricClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, fabricName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *FabricClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, options *FabricClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the details of the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - options - FabricClientGetOptions contains the optional parameters for the FabricClient.Get method. +func (client *FabricClient) Get(ctx context.Context, resourceGroupName string, fabricName string, options *FabricClientGetOptions) (FabricClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, fabricName, options) + if err != nil { + return FabricClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FabricClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FabricClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *FabricClient) getCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, options *FabricClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FabricClient) getHandleResponse(resp *http.Response) (FabricClientGetResponse, error) { + result := FabricClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FabricModel); err != nil { + return FabricClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of fabrics in the given subscription and resource group. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - FabricClientListOptions contains the optional parameters for the FabricClient.NewListPager method. +func (client *FabricClient) NewListPager(resourceGroupName string, options *FabricClientListOptions) *runtime.Pager[FabricClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[FabricClientListResponse]{ + More: func(page FabricClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FabricClientListResponse) (FabricClientListResponse, 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 FabricClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FabricClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FabricClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *FabricClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *FabricClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *FabricClient) listHandleResponse(resp *http.Response) (FabricClientListResponse, error) { + result := FabricClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FabricModelCollection); err != nil { + return FabricClientListResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets the list of fabrics in the given subscription. +// +// Generated from API version 2021-02-16-preview +// - options - FabricClientListBySubscriptionOptions contains the optional parameters for the FabricClient.NewListBySubscriptionPager +// method. +func (client *FabricClient) NewListBySubscriptionPager(options *FabricClientListBySubscriptionOptions) *runtime.Pager[FabricClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[FabricClientListBySubscriptionResponse]{ + More: func(page FabricClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FabricClientListBySubscriptionResponse) (FabricClientListBySubscriptionResponse, 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 FabricClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FabricClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FabricClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *FabricClient) listBySubscriptionCreateRequest(ctx context.Context, options *FabricClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationFabrics" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *FabricClient) listBySubscriptionHandleResponse(resp *http.Response) (FabricClientListBySubscriptionResponse, error) { + result := FabricClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FabricModelCollection); err != nil { + return FabricClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Performs update on the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - body - Fabric properties. +// - options - FabricClientBeginUpdateOptions contains the optional parameters for the FabricClient.BeginUpdate method. +func (client *FabricClient) BeginUpdate(ctx context.Context, resourceGroupName string, fabricName string, body FabricModelUpdate, options *FabricClientBeginUpdateOptions) (*runtime.Poller[FabricClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, fabricName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FabricClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FabricClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Performs update on the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *FabricClient) update(ctx context.Context, resourceGroupName string, fabricName string, body FabricModelUpdate, options *FabricClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, resourceGroupName, fabricName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *FabricClient) updateCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, body FabricModelUpdate, options *FabricClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/fabricoperationsstatus_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/fabricoperationsstatus_client.go new file mode 100644 index 000000000000..63b6299b16c2 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/fabricoperationsstatus_client.go @@ -0,0 +1,107 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// FabricOperationsStatusClient contains the methods for the FabricOperationsStatus group. +// Don't use this type directly, use NewFabricOperationsStatusClient() instead. +type FabricOperationsStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFabricOperationsStatusClient creates a new instance of FabricOperationsStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewFabricOperationsStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FabricOperationsStatusClient, error) { + cl, err := arm.NewClient(moduleName+".FabricOperationsStatusClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FabricOperationsStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Tracks the results of an asynchronous operation on the fabric. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - fabricName - The fabric name. +// - operationID - The ID of an ongoing async operation. +// - options - FabricOperationsStatusClientGetOptions contains the optional parameters for the FabricOperationsStatusClient.Get +// method. +func (client *FabricOperationsStatusClient) Get(ctx context.Context, resourceGroupName string, fabricName string, operationID string, options *FabricOperationsStatusClientGetOptions) (FabricOperationsStatusClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, fabricName, operationID, options) + if err != nil { + return FabricOperationsStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FabricOperationsStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FabricOperationsStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *FabricOperationsStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, fabricName string, operationID string, options *FabricOperationsStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationFabrics/{fabricName}/operations/{operationId}" + 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 fabricName == "" { + return nil, errors.New("parameter fabricName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{fabricName}", url.PathEscape(fabricName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FabricOperationsStatusClient) getHandleResponse(resp *http.Response) (FabricOperationsStatusClientGetResponse, error) { + result := FabricOperationsStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return FabricOperationsStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/go.mod b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/go.mod new file mode 100644 index 000000000000..1e8ad92da7b3 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/go.sum b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/go.sum new file mode 100644 index 000000000000..5c6bee428364 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/interfaces.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/interfaces.go new file mode 100644 index 000000000000..5cb38b340968 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/interfaces.go @@ -0,0 +1,91 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +// DraModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetDraModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *DraModelCustomProperties, *VMwareDraModelCustomProperties +type DraModelCustomPropertiesClassification interface { + // GetDraModelCustomProperties returns the DraModelCustomProperties content of the underlying type. + GetDraModelCustomProperties() *DraModelCustomProperties +} + +// EventModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetEventModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *EventModelCustomProperties, *HyperVToAzStackHCIEventModelCustomProperties +type EventModelCustomPropertiesClassification interface { + // GetEventModelCustomProperties returns the EventModelCustomProperties content of the underlying type. + GetEventModelCustomProperties() *EventModelCustomProperties +} + +// FabricModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetFabricModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzStackHCIFabricModelCustomProperties, *FabricModelCustomProperties, *HyperVMigrateFabricModelCustomProperties, *VMwareMigrateFabricModelCustomProperties +type FabricModelCustomPropertiesClassification interface { + // GetFabricModelCustomProperties returns the FabricModelCustomProperties content of the underlying type. + GetFabricModelCustomProperties() *FabricModelCustomProperties +} + +// PlannedFailoverModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetPlannedFailoverModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *HyperVToAzStackHCIPlannedFailoverModelCustomProperties, *PlannedFailoverModelCustomProperties, *VMwareToAzStackHCIPlannedFailoverModelCustomProperties +type PlannedFailoverModelCustomPropertiesClassification interface { + // GetPlannedFailoverModelCustomProperties returns the PlannedFailoverModelCustomProperties content of the underlying type. + GetPlannedFailoverModelCustomProperties() *PlannedFailoverModelCustomProperties +} + +// PolicyModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetPolicyModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *HyperVToAzStackHCIPolicyModelCustomProperties, *PolicyModelCustomProperties, *VMwareToAzStackHCIPolicyModelCustomProperties +type PolicyModelCustomPropertiesClassification interface { + // GetPolicyModelCustomProperties returns the PolicyModelCustomProperties content of the underlying type. + GetPolicyModelCustomProperties() *PolicyModelCustomProperties +} + +// ProtectedItemModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetProtectedItemModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *HyperVToAzStackHCIProtectedItemModelCustomProperties, *ProtectedItemModelCustomProperties, *VMwareToAzStackHCIProtectedItemModelCustomProperties +type ProtectedItemModelCustomPropertiesClassification interface { + // GetProtectedItemModelCustomProperties returns the ProtectedItemModelCustomProperties content of the underlying type. + GetProtectedItemModelCustomProperties() *ProtectedItemModelCustomProperties +} + +// RecoveryPointModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetRecoveryPointModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *HyperVToAzStackHCIRecoveryPointModelCustomProperties, *RecoveryPointModelCustomProperties +type RecoveryPointModelCustomPropertiesClassification interface { + // GetRecoveryPointModelCustomProperties returns the RecoveryPointModelCustomProperties content of the underlying type. + GetRecoveryPointModelCustomProperties() *RecoveryPointModelCustomProperties +} + +// ReplicationExtensionModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetReplicationExtensionModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *HyperVToAzStackHCIReplicationExtensionModelCustomProperties, *ReplicationExtensionModelCustomProperties, *VMwareToAzStackHCIReplicationExtensionModelCustomProperties +type ReplicationExtensionModelCustomPropertiesClassification interface { + // GetReplicationExtensionModelCustomProperties returns the ReplicationExtensionModelCustomProperties content of the underlying type. + GetReplicationExtensionModelCustomProperties() *ReplicationExtensionModelCustomProperties +} + +// WorkflowModelCustomPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetWorkflowModelCustomProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *FailoverWorkflowModelCustomProperties, *TestFailoverCleanupWorkflowModelCustomProperties, *TestFailoverWorkflowModelCustomProperties, +// - *WorkflowModelCustomProperties +type WorkflowModelCustomPropertiesClassification interface { + // GetWorkflowModelCustomProperties returns the WorkflowModelCustomProperties content of the underlying type. + GetWorkflowModelCustomProperties() *WorkflowModelCustomProperties +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/models.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/models.go new file mode 100644 index 000000000000..0efe2449ce05 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/models.go @@ -0,0 +1,2290 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import "time" + +// AzStackHCIClusterProperties - AzStackHCI cluster properties. +type AzStackHCIClusterProperties struct { + // REQUIRED; Gets or sets the AzStackHCICluster FQDN name. + ClusterName *string + + // REQUIRED; Gets or sets the AzStackHCICluster resource name. + ResourceName *string + + // REQUIRED; Gets or sets the Storage account name. + StorageAccountName *string + + // REQUIRED; Gets or sets the list of AzStackHCICluster Storage Container. + StorageContainers []*StorageContainerProperties +} + +// AzStackHCIFabricModelCustomProperties - AzStackHCI fabric model custom properties. +type AzStackHCIFabricModelCustomProperties struct { + // REQUIRED; Gets or sets the ARM Id of the AzStackHCI site. + AzStackHciSiteID *string + + // REQUIRED; AzStackHCI cluster properties. + Cluster *AzStackHCIClusterProperties + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the Migration solution ARM Id. + MigrationSolutionID *string + + // READ-ONLY; Gets or sets the Appliance name. + ApplianceName []*string + + // READ-ONLY; Gets or sets the fabric container Id. + FabricContainerID *string + + // READ-ONLY; Gets or sets the fabric resource Id. + FabricResourceID *string + + // READ-ONLY; Gets or sets the migration hub Uri. + MigrationHubURI *string +} + +// GetFabricModelCustomProperties implements the FabricModelCustomPropertiesClassification interface for type AzStackHCIFabricModelCustomProperties. +func (a *AzStackHCIFabricModelCustomProperties) GetFabricModelCustomProperties() *FabricModelCustomProperties { + return &FabricModelCustomProperties{ + InstanceType: a.InstanceType, + } +} + +// CheckNameAvailabilityModel - Check name availability model. +type CheckNameAvailabilityModel struct { + // Gets or sets the resource name. + Name *string + + // Gets or sets the resource type. + Type *string +} + +// CheckNameAvailabilityResponseModel - Check name availability response model. +type CheckNameAvailabilityResponseModel struct { + // Gets or sets the message for resource name unavailability. + Message *string + + // Gets or sets a value indicating whether resource name is available or not. + NameAvailable *bool + + // Gets or sets the reason for resource name unavailability. + Reason *string +} + +// DeploymentPreflightModel - Deployment preflight model. +type DeploymentPreflightModel struct { + // Gets or sets the list of resources. + Resources []*DeploymentPreflightResource +} + +// DeploymentPreflightResource - Deployment preflight resource. +type DeploymentPreflightResource struct { + // Gets or sets the Api version. + APIVersion *string + + // Gets or sets the location of the resource. + Location *string + + // Gets or sets the resource name. + Name *string + + // Gets or sets the resource type. + Type *string +} + +// DraModel - Dra model. +type DraModel struct { + // REQUIRED; Dra model properties. + Properties *DraModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *DraModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// DraModelCollection - Dra model collection. +type DraModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of Dras. + Value []*DraModel +} + +// DraModelCustomProperties - Dra model custom properties. +type DraModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetDraModelCustomProperties implements the DraModelCustomPropertiesClassification interface for type DraModelCustomProperties. +func (d *DraModelCustomProperties) GetDraModelCustomProperties() *DraModelCustomProperties { return d } + +// DraModelProperties - Dra model properties. +type DraModelProperties struct { + // REQUIRED; Identity model. + AuthenticationIdentity *IdentityModel + + // REQUIRED; Dra model custom properties. + CustomProperties DraModelCustomPropertiesClassification + + // REQUIRED; Gets or sets the machine Id where Dra is running. + MachineID *string + + // REQUIRED; Gets or sets the machine name where Dra is running. + MachineName *string + + // REQUIRED; Identity model. + ResourceAccessIdentity *IdentityModel + + // READ-ONLY; Gets or sets the Dra correlation Id. + CorrelationID *string + + // READ-ONLY; Gets or sets the list of health errors. + HealthErrors []*HealthErrorModel + + // READ-ONLY; Gets or sets a value indicating whether Dra is responsive. + IsResponsive *bool + + // READ-ONLY; Gets or sets the time when last heartbeat was sent by the Dra. + LastHeartbeat *time.Time + + // READ-ONLY; Gets or sets the provisioning state of the Dra. + ProvisioningState *ProvisioningState + + // READ-ONLY; Gets or sets the Dra version. + VersionNumber *string +} + +type DraModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// EmailConfigurationModel - Email configuration model. +type EmailConfigurationModel struct { + // REQUIRED; Email configuration model properties. + Properties *EmailConfigurationModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *EmailConfigurationModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// EmailConfigurationModelCollection - Email configuration model collection. +type EmailConfigurationModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of email configurations. + Value []*EmailConfigurationModel +} + +// EmailConfigurationModelProperties - Email configuration model properties. +type EmailConfigurationModelProperties struct { + // REQUIRED; Gets or sets a value indicating whether to send email to subscription administrator. + SendToOwners *bool + + // Gets or sets the custom email address for sending emails. + CustomEmailAddresses []*string + + // Gets or sets the locale for the email notification. + Locale *string +} + +type EmailConfigurationModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// ErrorModel - Error model. +type ErrorModel struct { + // READ-ONLY; Gets or sets the possible causes of error. + Causes *string + + // READ-ONLY; Gets or sets the error code. + Code *string + + // READ-ONLY; Gets or sets the creation time of error. + CreationTime *time.Time + + // READ-ONLY; Gets or sets the error message. + Message *string + + // READ-ONLY; Gets or sets the recommended action to resolve error. + Recommendation *string + + // READ-ONLY; Gets or sets the error severity. + Severity *string + + // READ-ONLY; Gets or sets the error type. + Type *string +} + +// EventModel - Event model. +type EventModel struct { + // REQUIRED; Event model properties. + Properties *EventModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *EventModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// EventModelCollection - Event model collection. +type EventModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of events. + Value []*EventModel +} + +// EventModelCustomProperties - Event model custom properties. +type EventModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetEventModelCustomProperties implements the EventModelCustomPropertiesClassification interface for type EventModelCustomProperties. +func (e *EventModelCustomProperties) GetEventModelCustomProperties() *EventModelCustomProperties { + return e +} + +// EventModelProperties - Event model properties. +type EventModelProperties struct { + // REQUIRED; Event model custom properties. + CustomProperties EventModelCustomPropertiesClassification + + // READ-ONLY; Gets or sets the event correlation Id. + CorrelationID *string + + // READ-ONLY; Gets or sets the event description. + Description *string + + // READ-ONLY; Gets or sets the event name. + EventName *string + + // READ-ONLY; Gets or sets the event type. + EventType *string + + // READ-ONLY; Gets or sets the errors associated with this event. + HealthErrors []*HealthErrorModel + + // READ-ONLY; Gets or sets the resource name. + ResourceName *string + + // READ-ONLY; Gets or sets the resource type. + ResourceType *string + + // READ-ONLY; Gets or sets the event severity. + Severity *string + + // READ-ONLY; Gets or sets the time at which the event occurred at source. + TimeOfOccurrence *time.Time +} + +type EventModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// FabricModel - Fabric model. +type FabricModel struct { + // REQUIRED; Gets or sets the location of the fabric. + Location *string + + // REQUIRED; Fabric model properties. + Properties *FabricModelProperties + + // Gets or sets the resource tags. + Tags map[string]*string + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *FabricModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// FabricModelCollection - Fabric model collection. +type FabricModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of fabrics. + Value []*FabricModel +} + +// FabricModelCustomProperties - Fabric model custom properties. +type FabricModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetFabricModelCustomProperties implements the FabricModelCustomPropertiesClassification interface for type FabricModelCustomProperties. +func (f *FabricModelCustomProperties) GetFabricModelCustomProperties() *FabricModelCustomProperties { + return f +} + +// FabricModelProperties - Fabric model properties. +type FabricModelProperties struct { + // REQUIRED; Fabric model custom properties. + CustomProperties FabricModelCustomPropertiesClassification + + // READ-ONLY; Gets or sets the fabric health. + Health *HealthStatus + + // READ-ONLY; Gets or sets the list of health errors. + HealthErrors []*HealthErrorModel + + // READ-ONLY; Gets or sets the provisioning state of the fabric. + ProvisioningState *ProvisioningState + + // READ-ONLY; Gets or sets the service endpoint. + ServiceEndpoint *string + + // READ-ONLY; Gets or sets the service resource Id. + ServiceResourceID *string +} + +type FabricModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// FabricModelUpdate - Fabric model for update. +type FabricModelUpdate struct { + // Fabric model properties. + Properties *FabricModelProperties + + // Gets or sets the resource tags. + Tags map[string]*string + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *FabricModelUpdateSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +type FabricModelUpdateSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// FailoverProtectedItemProperties - Failover properties of the protected item. +type FailoverProtectedItemProperties struct { + // READ-ONLY; Gets or sets the network name. + NetworkName *string + + // READ-ONLY; Gets or sets the protected item name. + ProtectedItemName *string + + // READ-ONLY; Gets or sets the recovery point Id. + RecoveryPointID *string + + // READ-ONLY; Gets or sets the recovery point time. + RecoveryPointTime *time.Time + + // READ-ONLY; Gets or sets the network subnet. + Subnet *string + + // READ-ONLY; Gets or sets the test VM name. + TestVMName *string + + // READ-ONLY; Gets or sets the VM name. + VMName *string +} + +// FailoverWorkflowModelCustomProperties - Failover workflow model custom properties. +type FailoverWorkflowModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // READ-ONLY; Gets or sets any custom properties of the affected object. + AffectedObjectDetails map[string]*string + + // READ-ONLY; Gets or sets the failed over protected item details. + ProtectedItemDetails []*FailoverProtectedItemProperties +} + +// GetWorkflowModelCustomProperties implements the WorkflowModelCustomPropertiesClassification interface for type FailoverWorkflowModelCustomProperties. +func (f *FailoverWorkflowModelCustomProperties) GetWorkflowModelCustomProperties() *WorkflowModelCustomProperties { + return &WorkflowModelCustomProperties{ + AffectedObjectDetails: f.AffectedObjectDetails, + InstanceType: f.InstanceType, + } +} + +// HealthErrorModel - Health error model. +type HealthErrorModel struct { + // Gets or sets the list of affected resource correlation Ids. This can be used to uniquely identify the count of items affected + // by a specific category and severity as well as count of item affected by + // an specific issue. + AffectedResourceCorrelationIDs []*string + + // Gets or sets the type of affected resource type. + AffectedResourceType *string + + // Gets or sets a list of child health errors associated with this error. + ChildErrors []*InnerHealthErrorModel + + // READ-ONLY; Gets or sets the error category. + Category *string + + // READ-ONLY; Gets or sets possible causes of the error. + Causes *string + + // READ-ONLY; Gets or sets the error code. + Code *string + + // READ-ONLY; Gets or sets the error creation time. + CreationTime *time.Time + + // READ-ONLY; Gets or sets the health category. + HealthCategory *string + + // READ-ONLY; Gets or sets a value indicating whether the error is customer resolvable. + IsCustomerResolvable *bool + + // READ-ONLY; Gets or sets the error message. + Message *string + + // READ-ONLY; Gets or sets recommended action to resolve the error. + Recommendation *string + + // READ-ONLY; Gets or sets the error severity. + Severity *string + + // READ-ONLY; Gets or sets the error source. + Source *string + + // READ-ONLY; Gets or sets the error summary. + Summary *string +} + +// HyperVMigrateFabricModelCustomProperties - HyperV migrate fabric model custom properties. +type HyperVMigrateFabricModelCustomProperties struct { + // REQUIRED; Gets or sets the ARM Id of the HyperV site. + HyperVSiteID *string + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the migration solution ARM Id. + MigrationSolutionID *string + + // READ-ONLY; Gets or sets the fabric container Id. + FabricContainerID *string + + // READ-ONLY; Gets or sets the fabric resource Id. + FabricResourceID *string + + // READ-ONLY; Gets or sets the migration hub Uri. + MigrationHubURI *string +} + +// GetFabricModelCustomProperties implements the FabricModelCustomPropertiesClassification interface for type HyperVMigrateFabricModelCustomProperties. +func (h *HyperVMigrateFabricModelCustomProperties) GetFabricModelCustomProperties() *FabricModelCustomProperties { + return &FabricModelCustomProperties{ + InstanceType: h.InstanceType, + } +} + +// HyperVToAzStackHCIDiskInput - HyperVToAzStack disk input. +type HyperVToAzStackHCIDiskInput struct { + // REQUIRED; Gets or sets the type of the virtual hard disk, vhd or vhdx. + DiskFileFormat *string + + // REQUIRED; Gets or sets the disk Id. + DiskID *string + + // REQUIRED; Gets or sets the disk size in GB. + DiskSizeGB *int64 + + // REQUIRED; Gets or sets a value indicating whether disk is os disk. + IsOsDisk *bool + + // Gets or sets a value indicating whether dynamic sizing is enabled on the virtual hard disk. + IsDynamic *bool + + // Gets or sets the target storage account ARM Id. + StorageContainerID *string +} + +// HyperVToAzStackHCIEventModelCustomProperties - HyperV to AzStackHCI event model custom properties. This class provides +// provider specific details for events of type DataContract.HealthEvents.HealthEventType.ProtectedItemHealth and +// DataContract.HealthEvents.HealthEventType.AgentHealth. +type HyperVToAzStackHCIEventModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // READ-ONLY; Gets or sets the friendly name of the source which has raised this health event. + EventSourceFriendlyName *string + + // READ-ONLY; Gets or sets the protected item friendly name. + ProtectedItemFriendlyName *string + + // READ-ONLY; Gets or sets the server type. + ServerType *string + + // READ-ONLY; Gets or sets the source appliance name. + SourceApplianceName *string + + // READ-ONLY; Gets or sets the source target name. + TargetApplianceName *string +} + +// GetEventModelCustomProperties implements the EventModelCustomPropertiesClassification interface for type HyperVToAzStackHCIEventModelCustomProperties. +func (h *HyperVToAzStackHCIEventModelCustomProperties) GetEventModelCustomProperties() *EventModelCustomProperties { + return &EventModelCustomProperties{ + InstanceType: h.InstanceType, + } +} + +// HyperVToAzStackHCINicInput - HyperVToAzStackHCI NIC properties. +type HyperVToAzStackHCINicInput struct { + // REQUIRED; Gets or sets the NIC Id. + NicID *string + + // REQUIRED; Gets or sets the selection type of the NIC. + SelectionTypeForFailover *VMNicSelection + + // REQUIRED; Gets or sets the target network Id within AzStackHCI Cluster. + TargetNetworkID *string + + // REQUIRED; Gets or sets the target test network Id within AzStackHCI Cluster. + TestNetworkID *string + + // READ-ONLY; Gets or sets the network name. + NetworkName *string +} + +// HyperVToAzStackHCIPlannedFailoverModelCustomProperties - HyperV to AzStackHCI planned failover model custom properties. +type HyperVToAzStackHCIPlannedFailoverModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets a value indicating whether VM needs to be shut down. + ShutdownSourceVM *bool +} + +// GetPlannedFailoverModelCustomProperties implements the PlannedFailoverModelCustomPropertiesClassification interface for +// type HyperVToAzStackHCIPlannedFailoverModelCustomProperties. +func (h *HyperVToAzStackHCIPlannedFailoverModelCustomProperties) GetPlannedFailoverModelCustomProperties() *PlannedFailoverModelCustomProperties { + return &PlannedFailoverModelCustomProperties{ + InstanceType: h.InstanceType, + } +} + +// HyperVToAzStackHCIPolicyModelCustomProperties - HyperV To AzStackHCI Policy model custom properties. +type HyperVToAzStackHCIPolicyModelCustomProperties struct { + // REQUIRED; Gets or sets the app consistent snapshot frequency (in minutes). + AppConsistentFrequencyInMinutes *int32 + + // REQUIRED; Gets or sets the crash consistent snapshot frequency (in minutes). + CrashConsistentFrequencyInMinutes *int32 + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the duration in minutes until which the recovery points need to be stored. + RecoveryPointHistoryInMinutes *int32 +} + +// GetPolicyModelCustomProperties implements the PolicyModelCustomPropertiesClassification interface for type HyperVToAzStackHCIPolicyModelCustomProperties. +func (h *HyperVToAzStackHCIPolicyModelCustomProperties) GetPolicyModelCustomProperties() *PolicyModelCustomProperties { + return &PolicyModelCustomProperties{ + InstanceType: h.InstanceType, + } +} + +// HyperVToAzStackHCIProtectedDiskProperties - HyperVToAzStackHCI protected disk properties. +type HyperVToAzStackHCIProtectedDiskProperties struct { + // READ-ONLY; Gets or sets the disk capacity in bytes. + CapacityInBytes *int64 + + // READ-ONLY; Gets or sets the disk type. + DiskType *string + + // READ-ONLY; Gets or sets a value indicating whether dynamic sizing is enabled on the virtual hard disk. + IsDynamic *bool + + // READ-ONLY; Gets or sets a value indicating whether the disk is the OS disk. + IsOsDisk *bool + + // READ-ONLY; Gets or sets the failover clone disk. + MigrateDiskName *string + + // READ-ONLY; Gets or sets the seed disk name. + SeedDiskName *string + + // READ-ONLY; Gets or sets the source disk Id. + SourceDiskID *string + + // READ-ONLY; Gets or sets the source disk Name. + SourceDiskName *string + + // READ-ONLY; Gets or sets the ARM Id of the storage container. + StorageContainerID *string + + // READ-ONLY; Gets or sets the local path of the storage container. + StorageContainerLocalPath *string + + // READ-ONLY; Gets or sets the test failover clone disk. + TestMigrateDiskName *string +} + +// HyperVToAzStackHCIProtectedItemModelCustomProperties - HyperV to AzStackHCI Protected item model custom properties. +type HyperVToAzStackHCIProtectedItemModelCustomProperties struct { + // REQUIRED; Gets or sets the location of Azure Arc HCI custom location resource. + CustomLocationRegion *string + + // REQUIRED; Gets or sets the list of disks to replicate. + DisksToInclude []*HyperVToAzStackHCIDiskInput + + // REQUIRED; Gets or sets the ARM Id of the discovered machine. + FabricDiscoveryMachineID *string + + // REQUIRED; Gets or sets the hypervisor generation of the virtual machine. + HyperVGeneration *string + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the list of VM NIC to replicate. + NicsToInclude []*HyperVToAzStackHCINicInput + + // REQUIRED; Gets or sets the Run As account Id. + RunAsAccountID *string + + // REQUIRED; Gets or sets the source DRA name. + SourceDraName *string + + // REQUIRED; Gets or sets the target storage container ARM Id. + StorageContainerID *string + + // REQUIRED; Gets or sets the Target Arc Cluster Custom Location ARM Id. + TargetArcClusterCustomLocationID *string + + // REQUIRED; Gets or sets the target DRA name. + TargetDraName *string + + // REQUIRED; Gets or sets the Target HCI Cluster ARM Id. + TargetHciClusterID *string + + // REQUIRED; Gets or sets the target resource group ARM Id. + TargetResourceGroupID *string + + // Protected item dynamic memory config. + DynamicMemoryConfig *ProtectedItemDynamicMemoryConfig + + // Gets or sets a value indicating whether memory is dynamical. + IsDynamicRAM *bool + + // Gets or sets the target CPU cores. + TargetCPUCores *int32 + + // Gets or sets the target memory in mega-bytes. + TargetMemoryInMegaBytes *int32 + + // Gets or sets the target network Id within AzStackHCI Cluster. + TargetNetworkID *string + + // Gets or sets the target VM display name. + TargetVMName *string + + // Gets or sets the target test network Id within AzStackHCI Cluster. + TestNetworkID *string + + // READ-ONLY; Gets or sets the location of the protected item. + ActiveLocation *ProtectedItemActiveLocation + + // READ-ONLY; Gets or sets the recovery point Id to which the VM was failed over. + FailoverRecoveryPointID *string + + // READ-ONLY; Gets or sets the firmware type. + FirmwareType *string + + // READ-ONLY; Gets or sets the initial replication progress percentage. This is calculated based on total bytes processed + // for all disks in the source VM. + InitialReplicationProgressPercentage *int32 + + // READ-ONLY; Gets or sets the last recovery point Id. + LastRecoveryPointID *string + + // READ-ONLY; Gets or sets the last recovery point received time. + LastRecoveryPointReceived *time.Time + + // READ-ONLY; Gets or sets the latest timestamp that replication status is updated. + LastReplicationUpdateTime *time.Time + + // READ-ONLY; Gets or sets the name of the OS. + OSName *string + + // READ-ONLY; Gets or sets the type of the OS. + OSType *string + + // READ-ONLY; Gets or sets the list of protected disks. + ProtectedDisks []*HyperVToAzStackHCIProtectedDiskProperties + + // READ-ONLY; Gets or sets the VM NIC details. + ProtectedNics []*HyperVToAzStackHCIProtectedNicProperties + + // READ-ONLY; Gets or sets the resync progress percentage. This is calculated based on total bytes processed for all disks + // in the source VM. + ResyncProgressPercentage *int32 + + // READ-ONLY; Gets or sets the source appliance name. + SourceApplianceName *string + + // READ-ONLY; Gets or sets the source VM CPU cores. + SourceCPUCores *int32 + + // READ-ONLY; Gets or sets the source VM ram memory size in megabytes. + SourceMemoryInMegaBytes *float64 + + // READ-ONLY; Gets or sets the source VM display name. + SourceVMName *string + + // READ-ONLY; Gets or sets the target appliance name. + TargetApplianceName *string + + // READ-ONLY; Gets or sets the Target AzStackHCI cluster name. + TargetAzStackHciClusterName *string + + // READ-ONLY; Gets or sets the target location. + TargetLocation *string + + // READ-ONLY; Gets or sets the BIOS Id of the target AzStackHCI VM. + TargetVMBiosID *string +} + +// GetProtectedItemModelCustomProperties implements the ProtectedItemModelCustomPropertiesClassification interface for type +// HyperVToAzStackHCIProtectedItemModelCustomProperties. +func (h *HyperVToAzStackHCIProtectedItemModelCustomProperties) GetProtectedItemModelCustomProperties() *ProtectedItemModelCustomProperties { + return &ProtectedItemModelCustomProperties{ + InstanceType: h.InstanceType, + } +} + +// HyperVToAzStackHCIProtectedNicProperties - HyperVToAzStackHCI NIC properties. +type HyperVToAzStackHCIProtectedNicProperties struct { + // READ-ONLY; Gets or sets the NIC mac address. + MacAddress *string + + // READ-ONLY; Gets or sets the network name. + NetworkName *string + + // READ-ONLY; Gets or sets the NIC Id. + NicID *string + + // READ-ONLY; Gets or sets the selection type of the NIC. + SelectionTypeForFailover *VMNicSelection + + // READ-ONLY; Gets or sets the target network Id within AzStackHCI Cluster. + TargetNetworkID *string + + // READ-ONLY; Gets or sets the target test network Id within AzStackHCI Cluster. + TestNetworkID *string +} + +// HyperVToAzStackHCIRecoveryPointModelCustomProperties - HyperV to AzStackHCI recovery point model custom properties. +type HyperVToAzStackHCIRecoveryPointModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // READ-ONLY; Gets or sets the list of the disk Ids. + DiskIDs []*string +} + +// GetRecoveryPointModelCustomProperties implements the RecoveryPointModelCustomPropertiesClassification interface for type +// HyperVToAzStackHCIRecoveryPointModelCustomProperties. +func (h *HyperVToAzStackHCIRecoveryPointModelCustomProperties) GetRecoveryPointModelCustomProperties() *RecoveryPointModelCustomProperties { + return &RecoveryPointModelCustomProperties{ + InstanceType: h.InstanceType, + } +} + +// HyperVToAzStackHCIReplicationExtensionModelCustomProperties - HyperV to AzStackHCI Replication extension model custom properties. +type HyperVToAzStackHCIReplicationExtensionModelCustomProperties struct { + // REQUIRED; Gets or sets the ARM Id of the target AzStackHCI fabric. + AzStackHciFabricArmID *string + + // REQUIRED; Gets or sets the ARM Id of the source HyperV fabric. + HyperVFabricArmID *string + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // Gets or sets the storage account Id. + StorageAccountID *string + + // Gets or sets the Sas Secret of storage account. + StorageAccountSasSecretName *string + + // READ-ONLY; Gets or sets the Uri of ASR. + AsrServiceURI *string + + // READ-ONLY; Gets or sets the ARM Id of the AzStackHCI site. + AzStackHciSiteID *string + + // READ-ONLY; Gets or sets the Uri of Gateway. + GatewayServiceURI *string + + // READ-ONLY; Gets or sets the ARM Id of the HyperV site. + HyperVSiteID *string + + // READ-ONLY; Gets or sets the Uri of Rcm. + RcmServiceURI *string + + // READ-ONLY; Gets or sets the resource group. + ResourceGroup *string + + // READ-ONLY; Gets or sets the resource location. + ResourceLocation *string + + // READ-ONLY; Gets or sets the gateway service Id of source. + SourceGatewayServiceID *string + + // READ-ONLY; Gets or sets the source storage container name. + SourceStorageContainerName *string + + // READ-ONLY; Gets or sets the subscription. + SubscriptionID *string + + // READ-ONLY; Gets or sets the gateway service Id of target. + TargetGatewayServiceID *string + + // READ-ONLY; Gets or sets the target storage container name. + TargetStorageContainerName *string +} + +// GetReplicationExtensionModelCustomProperties implements the ReplicationExtensionModelCustomPropertiesClassification interface +// for type HyperVToAzStackHCIReplicationExtensionModelCustomProperties. +func (h *HyperVToAzStackHCIReplicationExtensionModelCustomProperties) GetReplicationExtensionModelCustomProperties() *ReplicationExtensionModelCustomProperties { + return &ReplicationExtensionModelCustomProperties{ + InstanceType: h.InstanceType, + } +} + +// IdentityModel - Identity model. +type IdentityModel struct { + // REQUIRED; Gets or sets the authority of the SPN with which Dra communicates to service. + AADAuthority *string + + // REQUIRED; Gets or sets the client/application Id of the SPN with which Dra communicates to service. + ApplicationID *string + + // REQUIRED; Gets or sets the audience of the SPN with which Dra communicates to service. + Audience *string + + // REQUIRED; Gets or sets the object Id of the SPN with which Dra communicates to service. + ObjectID *string + + // REQUIRED; Gets or sets the tenant Id of the SPN with which Dra communicates to service. + TenantID *string +} + +// InnerHealthErrorModel - Inner health error model. +type InnerHealthErrorModel struct { + // READ-ONLY; Gets or sets the error category. + Category *string + + // READ-ONLY; Gets or sets possible causes of the error. + Causes *string + + // READ-ONLY; Gets or sets the error code. + Code *string + + // READ-ONLY; Gets or sets the error creation time. + CreationTime *time.Time + + // READ-ONLY; Gets or sets the health category. + HealthCategory *string + + // READ-ONLY; Gets or sets a value indicating whether the error is customer resolvable. + IsCustomerResolvable *bool + + // READ-ONLY; Gets or sets the error message. + Message *string + + // READ-ONLY; Gets or sets recommended action to resolve the error. + Recommendation *string + + // READ-ONLY; Gets or sets the error severity. + Severity *string + + // READ-ONLY; Gets or sets the error source. + Source *string + + // READ-ONLY; Gets or sets the error summary. + Summary *string +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// OperationStatus - Defines the operation status. +type OperationStatus struct { + // Gets or sets the end time. + EndTime *string + + // Gets or sets the Id. + ID *string + + // Gets or sets the operation name. + Name *string + + // Gets or sets the start time. + StartTime *string + + // Gets or sets the status of the operation. ARM expects the terminal status to be one of Succeeded/ Failed/ Canceled. All + // other values imply that the operation is still running. + Status *string +} + +// PlannedFailoverModel - Planned failover model. +type PlannedFailoverModel struct { + // REQUIRED; Planned failover model properties. + Properties *PlannedFailoverModelProperties +} + +// PlannedFailoverModelCustomProperties - Planned failover model custom properties. +type PlannedFailoverModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetPlannedFailoverModelCustomProperties implements the PlannedFailoverModelCustomPropertiesClassification interface for +// type PlannedFailoverModelCustomProperties. +func (p *PlannedFailoverModelCustomProperties) GetPlannedFailoverModelCustomProperties() *PlannedFailoverModelCustomProperties { + return p +} + +// PlannedFailoverModelProperties - Planned failover model properties. +type PlannedFailoverModelProperties struct { + // REQUIRED; Planned failover model custom properties. + CustomProperties PlannedFailoverModelCustomPropertiesClassification +} + +// PolicyModel - Policy model. +type PolicyModel struct { + // REQUIRED; Policy model properties. + Properties *PolicyModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *PolicyModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// PolicyModelCollection - Policy model collection. +type PolicyModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of policies. + Value []*PolicyModel +} + +// PolicyModelCustomProperties - Policy model custom properties. +type PolicyModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetPolicyModelCustomProperties implements the PolicyModelCustomPropertiesClassification interface for type PolicyModelCustomProperties. +func (p *PolicyModelCustomProperties) GetPolicyModelCustomProperties() *PolicyModelCustomProperties { + return p +} + +// PolicyModelProperties - Policy model properties. +type PolicyModelProperties struct { + // REQUIRED; Policy model custom properties. + CustomProperties PolicyModelCustomPropertiesClassification + + // READ-ONLY; Gets or sets the provisioning state of the policy. + ProvisioningState *ProvisioningState +} + +type PolicyModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// ProtectedItemDynamicMemoryConfig - Protected item dynamic memory config. +type ProtectedItemDynamicMemoryConfig struct { + // REQUIRED; Gets or sets maximum memory in MB. + MaximumMemoryInMegaBytes *int64 + + // REQUIRED; Gets or sets minimum memory in MB. + MinimumMemoryInMegaBytes *int64 + + // REQUIRED; Gets or sets target memory buffer in %. + TargetMemoryBufferPercentage *int32 +} + +// ProtectedItemModel - Protected item model. +type ProtectedItemModel struct { + // REQUIRED; Protected item model properties. + Properties *ProtectedItemModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *ProtectedItemModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// ProtectedItemModelCollection - Protected item model collection. +type ProtectedItemModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of protected items. + Value []*ProtectedItemModel +} + +// ProtectedItemModelCustomProperties - Protected item model custom properties. +type ProtectedItemModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetProtectedItemModelCustomProperties implements the ProtectedItemModelCustomPropertiesClassification interface for type +// ProtectedItemModelCustomProperties. +func (p *ProtectedItemModelCustomProperties) GetProtectedItemModelCustomProperties() *ProtectedItemModelCustomProperties { + return p +} + +// ProtectedItemModelProperties - Protected item model properties. +type ProtectedItemModelProperties struct { + // REQUIRED; Protected item model custom properties. + CustomProperties ProtectedItemModelCustomPropertiesClassification + + // REQUIRED; Gets or sets the policy name. + PolicyName *string + + // REQUIRED; Gets or sets the replication extension name. + ReplicationExtensionName *string + + // READ-ONLY; Gets or sets the allowed scenarios on the protected item. + AllowedJobs []*string + + // READ-ONLY; Gets or sets the protected item correlation Id. + CorrelationID *string + + // READ-ONLY + CurrentJob *ProtectedItemModelPropertiesCurrentJob + + // READ-ONLY; Gets or sets the DRA Id. + DraID *string + + // READ-ONLY; Gets or sets the fabric Id. + FabricID *string + + // READ-ONLY; Gets or sets the fabric object Id. + FabricObjectID *string + + // READ-ONLY; Gets or sets the fabric object name. + FabricObjectName *string + + // READ-ONLY; Gets or sets the list of health errors. + HealthErrors []*HealthErrorModel + + // READ-ONLY + LastFailedEnableProtectionJob *ProtectedItemModelPropertiesLastFailedEnableProtectionJob + + // READ-ONLY + LastFailedPlannedFailoverJob *ProtectedItemModelPropertiesLastFailedPlannedFailoverJob + + // READ-ONLY; Gets or sets the Last successful planned failover time. + LastSuccessfulPlannedFailoverTime *time.Time + + // READ-ONLY; Gets or sets the Last successful test failover time. + LastSuccessfulTestFailoverTime *time.Time + + // READ-ONLY; Gets or sets the Last successful unplanned failover time. + LastSuccessfulUnplannedFailoverTime *time.Time + + // READ-ONLY + LastTestFailoverJob *ProtectedItemModelPropertiesLastTestFailoverJob + + // READ-ONLY; Gets or sets the protection state. + ProtectionState *ProtectionState + + // READ-ONLY; Gets or sets the protection state description. + ProtectionStateDescription *string + + // READ-ONLY; Gets or sets the provisioning state of the Dra. + ProvisioningState *ProvisioningState + + // READ-ONLY; Gets or sets protected item replication health. + ReplicationHealth *HealthStatus + + // READ-ONLY; Gets or sets a value indicating whether resynchronization is required or not. + ResyncRequired *bool + + // READ-ONLY; Gets or sets the resynchronization state. + ResynchronizationState *ResynchronizationState + + // READ-ONLY; Gets or sets the source fabric provider Id. + SourceFabricProviderID *string + + // READ-ONLY; Gets or sets the target DRA Id. + TargetDraID *string + + // READ-ONLY; Gets or sets the target fabric Id. + TargetFabricID *string + + // READ-ONLY; Gets or sets the target fabric provider Id. + TargetFabricProviderID *string + + // READ-ONLY; Gets or sets the test failover state. + TestFailoverState *TestFailoverState + + // READ-ONLY; Gets or sets the Test failover state description. + TestFailoverStateDescription *string +} + +type ProtectedItemModelPropertiesCurrentJob struct { + // READ-ONLY; Gets or sets the workflow friendly display name. + DisplayName *string + + // READ-ONLY; Gets or sets end time of the workflow. + EndTime *time.Time + + // READ-ONLY; Gets or sets workflow Id. + ID *string + + // READ-ONLY; Gets or sets workflow name. + Name *string + + // READ-ONLY; Gets or sets protection scenario name. + ScenarioName *string + + // READ-ONLY; Gets or sets start time of the workflow. + StartTime *time.Time + + // READ-ONLY; Gets or sets workflow state. + State *string +} + +type ProtectedItemModelPropertiesLastFailedEnableProtectionJob struct { + // READ-ONLY; Gets or sets the workflow friendly display name. + DisplayName *string + + // READ-ONLY; Gets or sets end time of the workflow. + EndTime *time.Time + + // READ-ONLY; Gets or sets workflow Id. + ID *string + + // READ-ONLY; Gets or sets workflow name. + Name *string + + // READ-ONLY; Gets or sets protection scenario name. + ScenarioName *string + + // READ-ONLY; Gets or sets start time of the workflow. + StartTime *time.Time + + // READ-ONLY; Gets or sets workflow state. + State *string +} + +type ProtectedItemModelPropertiesLastFailedPlannedFailoverJob struct { + // READ-ONLY; Gets or sets the workflow friendly display name. + DisplayName *string + + // READ-ONLY; Gets or sets end time of the workflow. + EndTime *time.Time + + // READ-ONLY; Gets or sets workflow Id. + ID *string + + // READ-ONLY; Gets or sets workflow name. + Name *string + + // READ-ONLY; Gets or sets protection scenario name. + ScenarioName *string + + // READ-ONLY; Gets or sets start time of the workflow. + StartTime *time.Time + + // READ-ONLY; Gets or sets workflow state. + State *string +} + +type ProtectedItemModelPropertiesLastTestFailoverJob struct { + // READ-ONLY; Gets or sets the workflow friendly display name. + DisplayName *string + + // READ-ONLY; Gets or sets end time of the workflow. + EndTime *time.Time + + // READ-ONLY; Gets or sets workflow Id. + ID *string + + // READ-ONLY; Gets or sets workflow name. + Name *string + + // READ-ONLY; Gets or sets protection scenario name. + ScenarioName *string + + // READ-ONLY; Gets or sets start time of the workflow. + StartTime *time.Time + + // READ-ONLY; Gets or sets workflow state. + State *string +} + +type ProtectedItemModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// RecoveryPointModel - Recovery point model. +type RecoveryPointModel struct { + // REQUIRED; Recovery point model properties. + Properties *RecoveryPointModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *RecoveryPointModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// RecoveryPointModelCollection - Recovery point model collection. +type RecoveryPointModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of recovery points. + Value []*RecoveryPointModel +} + +// RecoveryPointModelCustomProperties - Recovery point model custom properties. +type RecoveryPointModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetRecoveryPointModelCustomProperties implements the RecoveryPointModelCustomPropertiesClassification interface for type +// RecoveryPointModelCustomProperties. +func (r *RecoveryPointModelCustomProperties) GetRecoveryPointModelCustomProperties() *RecoveryPointModelCustomProperties { + return r +} + +// RecoveryPointModelProperties - Recovery point model properties. +type RecoveryPointModelProperties struct { + // REQUIRED; Recovery point model custom properties. + CustomProperties RecoveryPointModelCustomPropertiesClassification + + // REQUIRED; Gets or sets the recovery point time. + RecoveryPointTime *time.Time + + // REQUIRED; Gets or sets the recovery point type. + RecoveryPointType *RecoveryPointType +} + +type RecoveryPointModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// ReplicationExtensionModel - Replication extension model. +type ReplicationExtensionModel struct { + // REQUIRED; Replication extension model properties. + Properties *ReplicationExtensionModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *ReplicationExtensionModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// ReplicationExtensionModelCollection - Replication extension model collection. +type ReplicationExtensionModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of replication extensions. + Value []*ReplicationExtensionModel +} + +// ReplicationExtensionModelCustomProperties - Replication extension model custom properties. +type ReplicationExtensionModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// GetReplicationExtensionModelCustomProperties implements the ReplicationExtensionModelCustomPropertiesClassification interface +// for type ReplicationExtensionModelCustomProperties. +func (r *ReplicationExtensionModelCustomProperties) GetReplicationExtensionModelCustomProperties() *ReplicationExtensionModelCustomProperties { + return r +} + +// ReplicationExtensionModelProperties - Replication extension model properties. +type ReplicationExtensionModelProperties struct { + // REQUIRED; Replication extension model custom properties. + CustomProperties ReplicationExtensionModelCustomPropertiesClassification + + // READ-ONLY; Gets or sets the provisioning state of the replication extension. + ProvisioningState *ProvisioningState +} + +type ReplicationExtensionModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// StorageContainerProperties - Storage container properties. +type StorageContainerProperties struct { + // REQUIRED; Gets or sets the ClusterSharedVolumePath. + ClusterSharedVolumePath *string + + // REQUIRED; Gets or sets the Name. + Name *string +} + +// TaskModel - Task model. +type TaskModel struct { + // Gets or sets the list of children workflow models. + ChildrenWorkflows []*WorkflowModel + + // Task model custom properties. + CustomProperties *TaskModelCustomProperties + + // READ-ONLY; Gets or sets the end time. + EndTime *time.Time + + // READ-ONLY; Gets or sets the start time. + StartTime *time.Time + + // READ-ONLY; Gets or sets the task state. + State *TaskState + + // READ-ONLY; Gets or sets the task name. + TaskName *string +} + +// TaskModelCustomProperties - Task model custom properties. +type TaskModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string +} + +// TestFailoverCleanupWorkflowModelCustomProperties - Test failover cleanup workflow model custom properties. +type TestFailoverCleanupWorkflowModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // READ-ONLY; Gets or sets any custom properties of the affected object. + AffectedObjectDetails map[string]*string + + // READ-ONLY; Gets or sets the test failover cleanup comments. + Comments *string +} + +// GetWorkflowModelCustomProperties implements the WorkflowModelCustomPropertiesClassification interface for type TestFailoverCleanupWorkflowModelCustomProperties. +func (t *TestFailoverCleanupWorkflowModelCustomProperties) GetWorkflowModelCustomProperties() *WorkflowModelCustomProperties { + return &WorkflowModelCustomProperties{ + AffectedObjectDetails: t.AffectedObjectDetails, + InstanceType: t.InstanceType, + } +} + +// TestFailoverWorkflowModelCustomProperties - Test failover workflow model custom properties. +type TestFailoverWorkflowModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // READ-ONLY; Gets or sets any custom properties of the affected object. + AffectedObjectDetails map[string]*string + + // READ-ONLY; Gets or sets the test VM details. + ProtectedItemDetails []*FailoverProtectedItemProperties +} + +// GetWorkflowModelCustomProperties implements the WorkflowModelCustomPropertiesClassification interface for type TestFailoverWorkflowModelCustomProperties. +func (t *TestFailoverWorkflowModelCustomProperties) GetWorkflowModelCustomProperties() *WorkflowModelCustomProperties { + return &WorkflowModelCustomProperties{ + AffectedObjectDetails: t.AffectedObjectDetails, + InstanceType: t.InstanceType, + } +} + +// VMwareDraModelCustomProperties - VMware DRA model custom properties. +type VMwareDraModelCustomProperties struct { + // REQUIRED; Gets or sets the BIOS Id of the DRA machine. + BiosID *string + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Identity model. + MarsAuthenticationIdentity *IdentityModel +} + +// GetDraModelCustomProperties implements the DraModelCustomPropertiesClassification interface for type VMwareDraModelCustomProperties. +func (v *VMwareDraModelCustomProperties) GetDraModelCustomProperties() *DraModelCustomProperties { + return &DraModelCustomProperties{ + InstanceType: v.InstanceType, + } +} + +// VMwareMigrateFabricModelCustomProperties - VMware migrate fabric model custom properties. +type VMwareMigrateFabricModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the ARM Id of the migration solution. + MigrationSolutionID *string + + // REQUIRED; Gets or sets the ARM Id of the VMware site. + VmwareSiteID *string +} + +// GetFabricModelCustomProperties implements the FabricModelCustomPropertiesClassification interface for type VMwareMigrateFabricModelCustomProperties. +func (v *VMwareMigrateFabricModelCustomProperties) GetFabricModelCustomProperties() *FabricModelCustomProperties { + return &FabricModelCustomProperties{ + InstanceType: v.InstanceType, + } +} + +// VMwareToAzStackHCIDiskInput - VMwareToAzStack disk input. +type VMwareToAzStackHCIDiskInput struct { + // REQUIRED; Gets or sets the type of the virtual hard disk, vhd or vhdx. + DiskFileFormat *string + + // REQUIRED; Gets or sets the disk Id. + DiskID *string + + // REQUIRED; Gets or sets the disk size in GB. + DiskSizeGB *int64 + + // REQUIRED; Gets or sets a value indicating whether disk is os disk. + IsOsDisk *bool + + // Gets or sets a value indicating whether dynamic sizing is enabled on the virtual hard disk. + IsDynamic *bool + + // Gets or sets the target storage account ARM Id. + StorageContainerID *string +} + +// VMwareToAzStackHCINicInput - VMwareToAzStackHCI NIC properties. +type VMwareToAzStackHCINicInput struct { + // REQUIRED; Gets or sets the NIC label. + Label *string + + // REQUIRED; Gets or sets the NIC Id. + NicID *string + + // REQUIRED; Gets or sets the selection type of the NIC. + SelectionTypeForFailover *VMNicSelection + + // REQUIRED; Gets or sets the target network Id within AzStackHCI Cluster. + TargetNetworkID *string + + // REQUIRED; Gets or sets the target test network Id within AzStackHCI Cluster. + TestNetworkID *string + + // READ-ONLY; Gets or sets the network name. + NetworkName *string +} + +// VMwareToAzStackHCIPlannedFailoverModelCustomProperties - VMware to AzStackHCI planned failover model custom properties. +type VMwareToAzStackHCIPlannedFailoverModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets a value indicating whether VM needs to be shut down. + ShutdownSourceVM *bool +} + +// GetPlannedFailoverModelCustomProperties implements the PlannedFailoverModelCustomPropertiesClassification interface for +// type VMwareToAzStackHCIPlannedFailoverModelCustomProperties. +func (v *VMwareToAzStackHCIPlannedFailoverModelCustomProperties) GetPlannedFailoverModelCustomProperties() *PlannedFailoverModelCustomProperties { + return &PlannedFailoverModelCustomProperties{ + InstanceType: v.InstanceType, + } +} + +// VMwareToAzStackHCIPolicyModelCustomProperties - VMware To AzStackHCI Policy model custom properties. +type VMwareToAzStackHCIPolicyModelCustomProperties struct { + // REQUIRED; Gets or sets the app consistent snapshot frequency (in minutes). + AppConsistentFrequencyInMinutes *int32 + + // REQUIRED; Gets or sets the crash consistent snapshot frequency (in minutes). + CrashConsistentFrequencyInMinutes *int32 + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the duration in minutes until which the recovery points need to be stored. + RecoveryPointHistoryInMinutes *int32 +} + +// GetPolicyModelCustomProperties implements the PolicyModelCustomPropertiesClassification interface for type VMwareToAzStackHCIPolicyModelCustomProperties. +func (v *VMwareToAzStackHCIPolicyModelCustomProperties) GetPolicyModelCustomProperties() *PolicyModelCustomProperties { + return &PolicyModelCustomProperties{ + InstanceType: v.InstanceType, + } +} + +// VMwareToAzStackHCIProtectedDiskProperties - VMwareToAzStackHCI protected disk properties. +type VMwareToAzStackHCIProtectedDiskProperties struct { + // READ-ONLY; Gets or sets the disk capacity in bytes. + CapacityInBytes *int64 + + // READ-ONLY; Gets or sets the disk type. + DiskType *string + + // READ-ONLY; Gets or sets a value indicating whether dynamic sizing is enabled on the virtual hard disk. + IsDynamic *bool + + // READ-ONLY; Gets or sets a value indicating whether the disk is the OS disk. + IsOsDisk *bool + + // READ-ONLY; Gets or sets the failover clone disk. + MigrateDiskName *string + + // READ-ONLY; Gets or sets the seed disk name. + SeedDiskName *string + + // READ-ONLY; Gets or sets the source disk Id. + SourceDiskID *string + + // READ-ONLY; Gets or sets the source disk Name. + SourceDiskName *string + + // READ-ONLY; Gets or sets the ARM Id of the storage container. + StorageContainerID *string + + // READ-ONLY; Gets or sets the local path of the storage container. + StorageContainerLocalPath *string + + // READ-ONLY; Gets or sets the test failover clone disk. + TestMigrateDiskName *string +} + +// VMwareToAzStackHCIProtectedItemModelCustomProperties - VMware to AzStackHCI Protected item model custom properties. +type VMwareToAzStackHCIProtectedItemModelCustomProperties struct { + // REQUIRED; Gets or sets the location of Azure Arc HCI custom location resource. + CustomLocationRegion *string + + // REQUIRED; Gets or sets the list of disks to replicate. + DisksToInclude []*VMwareToAzStackHCIDiskInput + + // REQUIRED; Gets or sets the ARM Id of the discovered machine. + FabricDiscoveryMachineID *string + + // REQUIRED; Gets or sets the hypervisor generation of the virtual machine possible values are 1,2. + HyperVGeneration *string + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the list of VM NIC to replicate. + NicsToInclude []*VMwareToAzStackHCINicInput + + // REQUIRED; Gets or sets the run as account Id. + RunAsAccountID *string + + // REQUIRED; Gets or sets the source DRA name. + SourceDraName *string + + // REQUIRED; Gets or sets the target storage container ARM Id. + StorageContainerID *string + + // REQUIRED; Gets or sets the Target Arc Cluster Custom Location ARM Id. + TargetArcClusterCustomLocationID *string + + // REQUIRED; Gets or sets the target DRA name. + TargetDraName *string + + // REQUIRED; Gets or sets the Target HCI Cluster ARM Id. + TargetHciClusterID *string + + // REQUIRED; Gets or sets the target resource group ARM Id. + TargetResourceGroupID *string + + // Protected item dynamic memory config. + DynamicMemoryConfig *ProtectedItemDynamicMemoryConfig + + // Gets or sets a value indicating whether memory is dynamical. + IsDynamicRAM *bool + + // Gets or sets a value indicating whether auto resync is to be done. + PerformAutoResync *bool + + // Gets or sets the target CPU cores. + TargetCPUCores *int32 + + // Gets or sets the target memory in mega-bytes. + TargetMemoryInMegaBytes *int32 + + // Gets or sets the target network Id within AzStackHCI Cluster. + TargetNetworkID *string + + // Gets or sets the target VM display name. + TargetVMName *string + + // Gets or sets the target test network Id within AzStackHCI Cluster. + TestNetworkID *string + + // READ-ONLY; Gets or sets the location of the protected item. + ActiveLocation *ProtectedItemActiveLocation + + // READ-ONLY; Gets or sets the recovery point Id to which the VM was failed over. + FailoverRecoveryPointID *string + + // READ-ONLY; Gets or sets the firmware type. + FirmwareType *string + + // READ-ONLY; Gets or sets the initial replication progress percentage. This is calculated based on total bytes processed + // for all disks in the source VM. + InitialReplicationProgressPercentage *int32 + + // READ-ONLY; Gets or sets the last recovery point Id. + LastRecoveryPointID *string + + // READ-ONLY; Gets or sets the last recovery point received time. + LastRecoveryPointReceived *time.Time + + // READ-ONLY; Gets or sets the latest timestamp that replication status is updated. + LastReplicationUpdateTime *time.Time + + // READ-ONLY; Gets or sets the migration progress percentage. + MigrationProgressPercentage *int32 + + // READ-ONLY; Gets or sets the name of the OS. + OSName *string + + // READ-ONLY; Gets or sets the type of the OS. + OSType *string + + // READ-ONLY; Gets or sets the list of protected disks. + ProtectedDisks []*VMwareToAzStackHCIProtectedDiskProperties + + // READ-ONLY; Gets or sets the VM NIC details. + ProtectedNics []*VMwareToAzStackHCIProtectedNicProperties + + // READ-ONLY; Gets or sets the resume progress percentage. + ResumeProgressPercentage *int32 + + // READ-ONLY; Gets or sets the resume retry count. + ResumeRetryCount *int64 + + // READ-ONLY; Gets or sets the resync progress percentage. This is calculated based on total bytes processed for all disks + // in the source VM. + ResyncProgressPercentage *int32 + + // READ-ONLY; Gets or sets a value indicating whether resync is required. + ResyncRequired *bool + + // READ-ONLY; Gets or sets the resync retry count. + ResyncRetryCount *int64 + + // READ-ONLY; Gets or sets the resync state. + ResyncState *VMwareToAzureMigrateResyncState + + // READ-ONLY; Gets or sets the source appliance name. + SourceApplianceName *string + + // READ-ONLY; Gets or sets the source VM CPU cores. + SourceCPUCores *int32 + + // READ-ONLY; Gets or sets the source VM ram memory size in megabytes. + SourceMemoryInMegaBytes *float64 + + // READ-ONLY; Gets or sets the source VM display name. + SourceVMName *string + + // READ-ONLY; Gets or sets the target appliance name. + TargetApplianceName *string + + // READ-ONLY; Gets or sets the Target AzStackHCI cluster name. + TargetAzStackHciClusterName *string + + // READ-ONLY; Gets or sets the target location. + TargetLocation *string + + // READ-ONLY; Gets or sets the BIOS Id of the target AzStackHCI VM. + TargetVMBiosID *string +} + +// GetProtectedItemModelCustomProperties implements the ProtectedItemModelCustomPropertiesClassification interface for type +// VMwareToAzStackHCIProtectedItemModelCustomProperties. +func (v *VMwareToAzStackHCIProtectedItemModelCustomProperties) GetProtectedItemModelCustomProperties() *ProtectedItemModelCustomProperties { + return &ProtectedItemModelCustomProperties{ + InstanceType: v.InstanceType, + } +} + +// VMwareToAzStackHCIProtectedNicProperties - VMwareToAzStackHCI NIC properties. +type VMwareToAzStackHCIProtectedNicProperties struct { + // Gets or sets a value indicating whether this is the primary NIC. + IsPrimaryNic *bool + + // READ-ONLY; Gets or sets the NIC label. + Label *string + + // READ-ONLY; Gets or sets the NIC mac address. + MacAddress *string + + // READ-ONLY; Gets or sets the network name. + NetworkName *string + + // READ-ONLY; Gets or sets the NIC Id. + NicID *string + + // READ-ONLY; Gets or sets the selection type of the NIC. + SelectionTypeForFailover *VMNicSelection + + // READ-ONLY; Gets or sets the target network Id within AzStackHCI Cluster. + TargetNetworkID *string + + // READ-ONLY; Gets or sets the target test network Id within AzStackHCI Cluster. + TestNetworkID *string +} + +// VMwareToAzStackHCIReplicationExtensionModelCustomProperties - VMware to AzStackHCI Replication extension model custom properties. +type VMwareToAzStackHCIReplicationExtensionModelCustomProperties struct { + // REQUIRED; Gets or sets the ARM Id of the target AzStackHCI fabric. + AzStackHciFabricArmID *string + + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // REQUIRED; Gets or sets the ARM Id of the source VMware fabric. + VmwareFabricArmID *string + + // Gets or sets the storage account Id. + StorageAccountID *string + + // Gets or sets the Sas Secret of storage account. + StorageAccountSasSecretName *string + + // READ-ONLY; Gets or sets the Uri of ASR. + AsrServiceURI *string + + // READ-ONLY; Gets or sets the ARM Id of the AzStackHCI site. + AzStackHciSiteID *string + + // READ-ONLY; Gets or sets the Uri of Gateway. + GatewayServiceURI *string + + // READ-ONLY; Gets or sets the Uri of Rcm. + RcmServiceURI *string + + // READ-ONLY; Gets or sets the resource group. + ResourceGroup *string + + // READ-ONLY; Gets or sets the resource location. + ResourceLocation *string + + // READ-ONLY; Gets or sets the gateway service Id of source. + SourceGatewayServiceID *string + + // READ-ONLY; Gets or sets the source storage container name. + SourceStorageContainerName *string + + // READ-ONLY; Gets or sets the subscription. + SubscriptionID *string + + // READ-ONLY; Gets or sets the gateway service Id of target. + TargetGatewayServiceID *string + + // READ-ONLY; Gets or sets the target storage container name. + TargetStorageContainerName *string + + // READ-ONLY; Gets or sets the ARM Id of the VMware site. + VmwareSiteID *string +} + +// GetReplicationExtensionModelCustomProperties implements the ReplicationExtensionModelCustomPropertiesClassification interface +// for type VMwareToAzStackHCIReplicationExtensionModelCustomProperties. +func (v *VMwareToAzStackHCIReplicationExtensionModelCustomProperties) GetReplicationExtensionModelCustomProperties() *ReplicationExtensionModelCustomProperties { + return &ReplicationExtensionModelCustomProperties{ + InstanceType: v.InstanceType, + } +} + +// VaultModel - Vault model. +type VaultModel struct { + // REQUIRED; Gets or sets the location of the vault. + Location *string + + // Vault properties. + Properties *VaultModelProperties + + // Gets or sets the resource tags. + Tags map[string]*string + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *VaultModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// VaultModelCollection - Vault model collection. +type VaultModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of vaults. + Value []*VaultModel +} + +// VaultModelProperties - Vault properties. +type VaultModelProperties struct { + // Gets or sets the type of vault. + VaultType *ReplicationVaultType + + // READ-ONLY; Gets or sets the provisioning state of the vault. + ProvisioningState *ProvisioningState + + // READ-ONLY; Gets or sets the service resource Id. + ServiceResourceID *string +} + +type VaultModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// VaultModelUpdate - Vault model for update. +type VaultModelUpdate struct { + // Vault properties. + Properties *VaultModelProperties + + // Gets or sets the resource tags. + Tags map[string]*string + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *VaultModelUpdateSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +type VaultModelUpdateSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} + +// WorkflowModel - Workflow model. +type WorkflowModel struct { + // REQUIRED; Workflow model properties. + Properties *WorkflowModelProperties + + // READ-ONLY; Gets or sets the Id of the resource. + ID *string + + // READ-ONLY; Gets or sets the name of the resource. + Name *string + + // READ-ONLY + SystemData *WorkflowModelSystemData + + // READ-ONLY; Gets or sets the type of the resource. + Type *string +} + +// WorkflowModelCollection - Workflow model collection. +type WorkflowModelCollection struct { + // Gets or sets the value of next link. + NextLink *string + + // Gets or sets the list of workflows. + Value []*WorkflowModel +} + +// WorkflowModelCustomProperties - Workflow model custom properties. +type WorkflowModelCustomProperties struct { + // REQUIRED; Gets or sets the instance type. + InstanceType *string + + // READ-ONLY; Gets or sets any custom properties of the affected object. + AffectedObjectDetails map[string]*string +} + +// GetWorkflowModelCustomProperties implements the WorkflowModelCustomPropertiesClassification interface for type WorkflowModelCustomProperties. +func (w *WorkflowModelCustomProperties) GetWorkflowModelCustomProperties() *WorkflowModelCustomProperties { + return w +} + +// WorkflowModelProperties - Workflow model properties. +type WorkflowModelProperties struct { + // REQUIRED; Workflow model custom properties. + CustomProperties WorkflowModelCustomPropertiesClassification + + // READ-ONLY; Gets or sets the workflow activity id. + ActivityID *string + + // READ-ONLY; Gets or sets the list of allowed actions on the workflow. + AllowedActions []*string + + // READ-ONLY; Gets or sets the friendly display name. + DisplayName *string + + // READ-ONLY; Gets or sets the end time. + EndTime *time.Time + + // READ-ONLY; Gets or sets the list of errors. + Errors []*ErrorModel + + // READ-ONLY; Gets or sets the affected object Id. + ObjectID *string + + // READ-ONLY; Gets or sets the affected object internal Id. + ObjectInternalID *string + + // READ-ONLY; Gets or sets the affected object internal name. + ObjectInternalName *string + + // READ-ONLY; Gets or sets the affected object name. + ObjectName *string + + // READ-ONLY; Gets or sets the object type. + ObjectType *WorkflowObjectType + + // READ-ONLY; Gets or sets the replication provider. + ReplicationProviderID *string + + // READ-ONLY; Gets or sets the source fabric provider. + SourceFabricProviderID *string + + // READ-ONLY; Gets or sets the start time. + StartTime *time.Time + + // READ-ONLY; Gets or sets the workflow state. + State *WorkflowState + + // READ-ONLY; Gets or sets the target fabric provider. + TargetFabricProviderID *string + + // READ-ONLY; Gets or sets the list of tasks. + Tasks []*TaskModel +} + +type WorkflowModelSystemData struct { + // Gets or sets the timestamp of resource creation (UTC). + CreatedAt *time.Time + + // Gets or sets identity that created the resource. + CreatedBy *string + + // Gets or sets the type of identity that created the resource: user, application, managedIdentity. + CreatedByType *string + + // Gets or sets the timestamp of resource last modification (UTC). + LastModifiedAt *time.Time + + // Gets or sets the identity that last modified the resource. + LastModifiedBy *string + + // Gets or sets the type of identity that last modified the resource: user, application, managedIdentity. + LastModifiedByType *string +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/models_serde.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/models_serde.go new file mode 100644 index 000000000000..e4fdc0ea326e --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/models_serde.go @@ -0,0 +1,4778 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AzStackHCIClusterProperties. +func (a AzStackHCIClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterName", a.ClusterName) + populate(objectMap, "resourceName", a.ResourceName) + populate(objectMap, "storageAccountName", a.StorageAccountName) + populate(objectMap, "storageContainers", a.StorageContainers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzStackHCIClusterProperties. +func (a *AzStackHCIClusterProperties) 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 "clusterName": + err = unpopulate(val, "ClusterName", &a.ClusterName) + delete(rawMsg, key) + case "resourceName": + err = unpopulate(val, "ResourceName", &a.ResourceName) + delete(rawMsg, key) + case "storageAccountName": + err = unpopulate(val, "StorageAccountName", &a.StorageAccountName) + delete(rawMsg, key) + case "storageContainers": + err = unpopulate(val, "StorageContainers", &a.StorageContainers) + 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 AzStackHCIFabricModelCustomProperties. +func (a AzStackHCIFabricModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "applianceName", a.ApplianceName) + populate(objectMap, "azStackHciSiteId", a.AzStackHciSiteID) + populate(objectMap, "cluster", a.Cluster) + populate(objectMap, "fabricContainerId", a.FabricContainerID) + populate(objectMap, "fabricResourceId", a.FabricResourceID) + objectMap["instanceType"] = "AzStackHCI" + populate(objectMap, "migrationHubUri", a.MigrationHubURI) + populate(objectMap, "migrationSolutionId", a.MigrationSolutionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AzStackHCIFabricModelCustomProperties. +func (a *AzStackHCIFabricModelCustomProperties) 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 "applianceName": + err = unpopulate(val, "ApplianceName", &a.ApplianceName) + delete(rawMsg, key) + case "azStackHciSiteId": + err = unpopulate(val, "AzStackHciSiteID", &a.AzStackHciSiteID) + delete(rawMsg, key) + case "cluster": + err = unpopulate(val, "Cluster", &a.Cluster) + delete(rawMsg, key) + case "fabricContainerId": + err = unpopulate(val, "FabricContainerID", &a.FabricContainerID) + delete(rawMsg, key) + case "fabricResourceId": + err = unpopulate(val, "FabricResourceID", &a.FabricResourceID) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &a.InstanceType) + delete(rawMsg, key) + case "migrationHubUri": + err = unpopulate(val, "MigrationHubURI", &a.MigrationHubURI) + delete(rawMsg, key) + case "migrationSolutionId": + err = unpopulate(val, "MigrationSolutionID", &a.MigrationSolutionID) + 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 CheckNameAvailabilityModel. +func (c CheckNameAvailabilityModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityModel. +func (c *CheckNameAvailabilityModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponseModel. +func (c CheckNameAvailabilityResponseModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponseModel. +func (c *CheckNameAvailabilityResponseModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentPreflightModel. +func (d DeploymentPreflightModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resources", d.Resources) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentPreflightModel. +func (d *DeploymentPreflightModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resources": + err = unpopulate(val, "Resources", &d.Resources) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DeploymentPreflightResource. +func (d DeploymentPreflightResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "apiVersion", d.APIVersion) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeploymentPreflightResource. +func (d *DeploymentPreflightResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "apiVersion": + err = unpopulate(val, "APIVersion", &d.APIVersion) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DraModel. +func (d DraModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DraModel. +func (d *DraModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DraModelCollection. +func (d DraModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DraModelCollection. +func (d *DraModelCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DraModelCustomProperties. +func (d DraModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = d.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DraModelCustomProperties. +func (d *DraModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceType": + err = unpopulate(val, "InstanceType", &d.InstanceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DraModelProperties. +func (d DraModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "authenticationIdentity", d.AuthenticationIdentity) + populate(objectMap, "correlationId", d.CorrelationID) + populate(objectMap, "customProperties", d.CustomProperties) + populate(objectMap, "healthErrors", d.HealthErrors) + populate(objectMap, "isResponsive", d.IsResponsive) + populateTimeRFC3339(objectMap, "lastHeartbeat", d.LastHeartbeat) + populate(objectMap, "machineId", d.MachineID) + populate(objectMap, "machineName", d.MachineName) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "resourceAccessIdentity", d.ResourceAccessIdentity) + populate(objectMap, "versionNumber", d.VersionNumber) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DraModelProperties. +func (d *DraModelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "authenticationIdentity": + err = unpopulate(val, "AuthenticationIdentity", &d.AuthenticationIdentity) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &d.CorrelationID) + delete(rawMsg, key) + case "customProperties": + d.CustomProperties, err = unmarshalDraModelCustomPropertiesClassification(val) + delete(rawMsg, key) + case "healthErrors": + err = unpopulate(val, "HealthErrors", &d.HealthErrors) + delete(rawMsg, key) + case "isResponsive": + err = unpopulate(val, "IsResponsive", &d.IsResponsive) + delete(rawMsg, key) + case "lastHeartbeat": + err = unpopulateTimeRFC3339(val, "LastHeartbeat", &d.LastHeartbeat) + delete(rawMsg, key) + case "machineId": + err = unpopulate(val, "MachineID", &d.MachineID) + delete(rawMsg, key) + case "machineName": + err = unpopulate(val, "MachineName", &d.MachineName) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "resourceAccessIdentity": + err = unpopulate(val, "ResourceAccessIdentity", &d.ResourceAccessIdentity) + delete(rawMsg, key) + case "versionNumber": + err = unpopulate(val, "VersionNumber", &d.VersionNumber) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DraModelSystemData. +func (d DraModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", d.CreatedAt) + populate(objectMap, "createdBy", d.CreatedBy) + populate(objectMap, "createdByType", d.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", d.LastModifiedAt) + populate(objectMap, "lastModifiedBy", d.LastModifiedBy) + populate(objectMap, "lastModifiedByType", d.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DraModelSystemData. +func (d *DraModelSystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &d.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &d.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &d.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &d.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &d.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &d.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EmailConfigurationModel. +func (e EmailConfigurationModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 EmailConfigurationModel. +func (e *EmailConfigurationModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "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 EmailConfigurationModelCollection. +func (e EmailConfigurationModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmailConfigurationModelCollection. +func (e *EmailConfigurationModelCollection) 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 EmailConfigurationModelProperties. +func (e EmailConfigurationModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customEmailAddresses", e.CustomEmailAddresses) + populate(objectMap, "locale", e.Locale) + populate(objectMap, "sendToOwners", e.SendToOwners) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmailConfigurationModelProperties. +func (e *EmailConfigurationModelProperties) 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 "customEmailAddresses": + err = unpopulate(val, "CustomEmailAddresses", &e.CustomEmailAddresses) + delete(rawMsg, key) + case "locale": + err = unpopulate(val, "Locale", &e.Locale) + delete(rawMsg, key) + case "sendToOwners": + err = unpopulate(val, "SendToOwners", &e.SendToOwners) + 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 EmailConfigurationModelSystemData. +func (e EmailConfigurationModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", e.CreatedAt) + populate(objectMap, "createdBy", e.CreatedBy) + populate(objectMap, "createdByType", e.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", e.LastModifiedAt) + populate(objectMap, "lastModifiedBy", e.LastModifiedBy) + populate(objectMap, "lastModifiedByType", e.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EmailConfigurationModelSystemData. +func (e *EmailConfigurationModelSystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &e.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &e.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &e.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &e.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &e.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &e.LastModifiedByType) + 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 ErrorModel. +func (e ErrorModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "causes", e.Causes) + populate(objectMap, "code", e.Code) + populateTimeRFC3339(objectMap, "creationTime", e.CreationTime) + populate(objectMap, "message", e.Message) + populate(objectMap, "recommendation", e.Recommendation) + populate(objectMap, "severity", e.Severity) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorModel. +func (e *ErrorModel) 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 "causes": + err = unpopulate(val, "Causes", &e.Causes) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &e.CreationTime) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + case "recommendation": + err = unpopulate(val, "Recommendation", &e.Recommendation) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &e.Severity) + 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 EventModel. +func (e EventModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 EventModel. +func (e *EventModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) + case "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 EventModelCollection. +func (e EventModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventModelCollection. +func (e *EventModelCollection) 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 EventModelCustomProperties. +func (e EventModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = e.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventModelCustomProperties. +func (e *EventModelCustomProperties) 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 "instanceType": + err = unpopulate(val, "InstanceType", &e.InstanceType) + 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 EventModelProperties. +func (e EventModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationId", e.CorrelationID) + populate(objectMap, "customProperties", e.CustomProperties) + populate(objectMap, "description", e.Description) + populate(objectMap, "eventName", e.EventName) + populate(objectMap, "eventType", e.EventType) + populate(objectMap, "healthErrors", e.HealthErrors) + populate(objectMap, "resourceName", e.ResourceName) + populate(objectMap, "resourceType", e.ResourceType) + populate(objectMap, "severity", e.Severity) + populateTimeRFC3339(objectMap, "timeOfOccurrence", e.TimeOfOccurrence) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventModelProperties. +func (e *EventModelProperties) 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 "correlationId": + err = unpopulate(val, "CorrelationID", &e.CorrelationID) + delete(rawMsg, key) + case "customProperties": + e.CustomProperties, err = unmarshalEventModelCustomPropertiesClassification(val) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &e.Description) + delete(rawMsg, key) + case "eventName": + err = unpopulate(val, "EventName", &e.EventName) + delete(rawMsg, key) + case "eventType": + err = unpopulate(val, "EventType", &e.EventType) + delete(rawMsg, key) + case "healthErrors": + err = unpopulate(val, "HealthErrors", &e.HealthErrors) + delete(rawMsg, key) + case "resourceName": + err = unpopulate(val, "ResourceName", &e.ResourceName) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &e.ResourceType) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &e.Severity) + delete(rawMsg, key) + case "timeOfOccurrence": + err = unpopulateTimeRFC3339(val, "TimeOfOccurrence", &e.TimeOfOccurrence) + 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 EventModelSystemData. +func (e EventModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", e.CreatedAt) + populate(objectMap, "createdBy", e.CreatedBy) + populate(objectMap, "createdByType", e.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", e.LastModifiedAt) + populate(objectMap, "lastModifiedBy", e.LastModifiedBy) + populate(objectMap, "lastModifiedByType", e.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EventModelSystemData. +func (e *EventModelSystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &e.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &e.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &e.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &e.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &e.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &e.LastModifiedByType) + 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 FabricModel. +func (f FabricModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "location", f.Location) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "tags", f.Tags) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FabricModel. +func (f *FabricModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &f.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FabricModelCollection. +func (f FabricModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FabricModelCollection. +func (f *FabricModelCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FabricModelCustomProperties. +func (f FabricModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = f.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FabricModelCustomProperties. +func (f *FabricModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceType": + err = unpopulate(val, "InstanceType", &f.InstanceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FabricModelProperties. +func (f FabricModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customProperties", f.CustomProperties) + populate(objectMap, "health", f.Health) + populate(objectMap, "healthErrors", f.HealthErrors) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "serviceEndpoint", f.ServiceEndpoint) + populate(objectMap, "serviceResourceId", f.ServiceResourceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FabricModelProperties. +func (f *FabricModelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "customProperties": + f.CustomProperties, err = unmarshalFabricModelCustomPropertiesClassification(val) + delete(rawMsg, key) + case "health": + err = unpopulate(val, "Health", &f.Health) + delete(rawMsg, key) + case "healthErrors": + err = unpopulate(val, "HealthErrors", &f.HealthErrors) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + case "serviceEndpoint": + err = unpopulate(val, "ServiceEndpoint", &f.ServiceEndpoint) + delete(rawMsg, key) + case "serviceResourceId": + err = unpopulate(val, "ServiceResourceID", &f.ServiceResourceID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FabricModelSystemData. +func (f FabricModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", f.CreatedAt) + populate(objectMap, "createdBy", f.CreatedBy) + populate(objectMap, "createdByType", f.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", f.LastModifiedAt) + populate(objectMap, "lastModifiedBy", f.LastModifiedBy) + populate(objectMap, "lastModifiedByType", f.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FabricModelSystemData. +func (f *FabricModelSystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &f.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &f.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &f.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &f.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &f.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &f.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FabricModelUpdate. +func (f FabricModelUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "name", f.Name) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "tags", f.Tags) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FabricModelUpdate. +func (f *FabricModelUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FabricModelUpdateSystemData. +func (f FabricModelUpdateSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", f.CreatedAt) + populate(objectMap, "createdBy", f.CreatedBy) + populate(objectMap, "createdByType", f.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", f.LastModifiedAt) + populate(objectMap, "lastModifiedBy", f.LastModifiedBy) + populate(objectMap, "lastModifiedByType", f.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FabricModelUpdateSystemData. +func (f *FabricModelUpdateSystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &f.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &f.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &f.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &f.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &f.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &f.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FailoverProtectedItemProperties. +func (f FailoverProtectedItemProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "networkName", f.NetworkName) + populate(objectMap, "protectedItemName", f.ProtectedItemName) + populate(objectMap, "recoveryPointId", f.RecoveryPointID) + populateTimeRFC3339(objectMap, "recoveryPointTime", f.RecoveryPointTime) + populate(objectMap, "subnet", f.Subnet) + populate(objectMap, "testVmName", f.TestVMName) + populate(objectMap, "vmName", f.VMName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FailoverProtectedItemProperties. +func (f *FailoverProtectedItemProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "networkName": + err = unpopulate(val, "NetworkName", &f.NetworkName) + delete(rawMsg, key) + case "protectedItemName": + err = unpopulate(val, "ProtectedItemName", &f.ProtectedItemName) + delete(rawMsg, key) + case "recoveryPointId": + err = unpopulate(val, "RecoveryPointID", &f.RecoveryPointID) + delete(rawMsg, key) + case "recoveryPointTime": + err = unpopulateTimeRFC3339(val, "RecoveryPointTime", &f.RecoveryPointTime) + delete(rawMsg, key) + case "subnet": + err = unpopulate(val, "Subnet", &f.Subnet) + delete(rawMsg, key) + case "testVmName": + err = unpopulate(val, "TestVMName", &f.TestVMName) + delete(rawMsg, key) + case "vmName": + err = unpopulate(val, "VMName", &f.VMName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FailoverWorkflowModelCustomProperties. +func (f FailoverWorkflowModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "affectedObjectDetails", f.AffectedObjectDetails) + objectMap["instanceType"] = "FailoverWorkflowDetails" + populate(objectMap, "protectedItemDetails", f.ProtectedItemDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FailoverWorkflowModelCustomProperties. +func (f *FailoverWorkflowModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "affectedObjectDetails": + err = unpopulate(val, "AffectedObjectDetails", &f.AffectedObjectDetails) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &f.InstanceType) + delete(rawMsg, key) + case "protectedItemDetails": + err = unpopulate(val, "ProtectedItemDetails", &f.ProtectedItemDetails) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HealthErrorModel. +func (h HealthErrorModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "affectedResourceCorrelationIds", h.AffectedResourceCorrelationIDs) + populate(objectMap, "affectedResourceType", h.AffectedResourceType) + populate(objectMap, "category", h.Category) + populate(objectMap, "causes", h.Causes) + populate(objectMap, "childErrors", h.ChildErrors) + populate(objectMap, "code", h.Code) + populateTimeRFC3339(objectMap, "creationTime", h.CreationTime) + populate(objectMap, "healthCategory", h.HealthCategory) + populate(objectMap, "isCustomerResolvable", h.IsCustomerResolvable) + populate(objectMap, "message", h.Message) + populate(objectMap, "recommendation", h.Recommendation) + populate(objectMap, "severity", h.Severity) + populate(objectMap, "source", h.Source) + populate(objectMap, "summary", h.Summary) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HealthErrorModel. +func (h *HealthErrorModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "affectedResourceCorrelationIds": + err = unpopulate(val, "AffectedResourceCorrelationIDs", &h.AffectedResourceCorrelationIDs) + delete(rawMsg, key) + case "affectedResourceType": + err = unpopulate(val, "AffectedResourceType", &h.AffectedResourceType) + delete(rawMsg, key) + case "category": + err = unpopulate(val, "Category", &h.Category) + delete(rawMsg, key) + case "causes": + err = unpopulate(val, "Causes", &h.Causes) + delete(rawMsg, key) + case "childErrors": + err = unpopulate(val, "ChildErrors", &h.ChildErrors) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &h.Code) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &h.CreationTime) + delete(rawMsg, key) + case "healthCategory": + err = unpopulate(val, "HealthCategory", &h.HealthCategory) + delete(rawMsg, key) + case "isCustomerResolvable": + err = unpopulate(val, "IsCustomerResolvable", &h.IsCustomerResolvable) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &h.Message) + delete(rawMsg, key) + case "recommendation": + err = unpopulate(val, "Recommendation", &h.Recommendation) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &h.Severity) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &h.Source) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &h.Summary) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVMigrateFabricModelCustomProperties. +func (h HyperVMigrateFabricModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "fabricContainerId", h.FabricContainerID) + populate(objectMap, "fabricResourceId", h.FabricResourceID) + populate(objectMap, "hyperVSiteId", h.HyperVSiteID) + objectMap["instanceType"] = "HyperVMigrate" + populate(objectMap, "migrationHubUri", h.MigrationHubURI) + populate(objectMap, "migrationSolutionId", h.MigrationSolutionID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVMigrateFabricModelCustomProperties. +func (h *HyperVMigrateFabricModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "fabricContainerId": + err = unpopulate(val, "FabricContainerID", &h.FabricContainerID) + delete(rawMsg, key) + case "fabricResourceId": + err = unpopulate(val, "FabricResourceID", &h.FabricResourceID) + delete(rawMsg, key) + case "hyperVSiteId": + err = unpopulate(val, "HyperVSiteID", &h.HyperVSiteID) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &h.InstanceType) + delete(rawMsg, key) + case "migrationHubUri": + err = unpopulate(val, "MigrationHubURI", &h.MigrationHubURI) + delete(rawMsg, key) + case "migrationSolutionId": + err = unpopulate(val, "MigrationSolutionID", &h.MigrationSolutionID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIDiskInput. +func (h HyperVToAzStackHCIDiskInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskFileFormat", h.DiskFileFormat) + populate(objectMap, "diskId", h.DiskID) + populate(objectMap, "diskSizeGB", h.DiskSizeGB) + populate(objectMap, "isDynamic", h.IsDynamic) + populate(objectMap, "isOsDisk", h.IsOsDisk) + populate(objectMap, "storageContainerId", h.StorageContainerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIDiskInput. +func (h *HyperVToAzStackHCIDiskInput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "diskFileFormat": + err = unpopulate(val, "DiskFileFormat", &h.DiskFileFormat) + delete(rawMsg, key) + case "diskId": + err = unpopulate(val, "DiskID", &h.DiskID) + delete(rawMsg, key) + case "diskSizeGB": + err = unpopulate(val, "DiskSizeGB", &h.DiskSizeGB) + delete(rawMsg, key) + case "isDynamic": + err = unpopulate(val, "IsDynamic", &h.IsDynamic) + delete(rawMsg, key) + case "isOsDisk": + err = unpopulate(val, "IsOsDisk", &h.IsOsDisk) + delete(rawMsg, key) + case "storageContainerId": + err = unpopulate(val, "StorageContainerID", &h.StorageContainerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIEventModelCustomProperties. +func (h HyperVToAzStackHCIEventModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eventSourceFriendlyName", h.EventSourceFriendlyName) + objectMap["instanceType"] = "HyperVToAzStackHCI" + populate(objectMap, "protectedItemFriendlyName", h.ProtectedItemFriendlyName) + populate(objectMap, "serverType", h.ServerType) + populate(objectMap, "sourceApplianceName", h.SourceApplianceName) + populate(objectMap, "targetApplianceName", h.TargetApplianceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIEventModelCustomProperties. +func (h *HyperVToAzStackHCIEventModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eventSourceFriendlyName": + err = unpopulate(val, "EventSourceFriendlyName", &h.EventSourceFriendlyName) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &h.InstanceType) + delete(rawMsg, key) + case "protectedItemFriendlyName": + err = unpopulate(val, "ProtectedItemFriendlyName", &h.ProtectedItemFriendlyName) + delete(rawMsg, key) + case "serverType": + err = unpopulate(val, "ServerType", &h.ServerType) + delete(rawMsg, key) + case "sourceApplianceName": + err = unpopulate(val, "SourceApplianceName", &h.SourceApplianceName) + delete(rawMsg, key) + case "targetApplianceName": + err = unpopulate(val, "TargetApplianceName", &h.TargetApplianceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCINicInput. +func (h HyperVToAzStackHCINicInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "networkName", h.NetworkName) + populate(objectMap, "nicId", h.NicID) + populate(objectMap, "selectionTypeForFailover", h.SelectionTypeForFailover) + populate(objectMap, "targetNetworkId", h.TargetNetworkID) + populate(objectMap, "testNetworkId", h.TestNetworkID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCINicInput. +func (h *HyperVToAzStackHCINicInput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "networkName": + err = unpopulate(val, "NetworkName", &h.NetworkName) + delete(rawMsg, key) + case "nicId": + err = unpopulate(val, "NicID", &h.NicID) + delete(rawMsg, key) + case "selectionTypeForFailover": + err = unpopulate(val, "SelectionTypeForFailover", &h.SelectionTypeForFailover) + delete(rawMsg, key) + case "targetNetworkId": + err = unpopulate(val, "TargetNetworkID", &h.TargetNetworkID) + delete(rawMsg, key) + case "testNetworkId": + err = unpopulate(val, "TestNetworkID", &h.TestNetworkID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIPlannedFailoverModelCustomProperties. +func (h HyperVToAzStackHCIPlannedFailoverModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = "HyperVToAzStackHCI" + populate(objectMap, "shutdownSourceVM", h.ShutdownSourceVM) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIPlannedFailoverModelCustomProperties. +func (h *HyperVToAzStackHCIPlannedFailoverModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceType": + err = unpopulate(val, "InstanceType", &h.InstanceType) + delete(rawMsg, key) + case "shutdownSourceVM": + err = unpopulate(val, "ShutdownSourceVM", &h.ShutdownSourceVM) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIPolicyModelCustomProperties. +func (h HyperVToAzStackHCIPolicyModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appConsistentFrequencyInMinutes", h.AppConsistentFrequencyInMinutes) + populate(objectMap, "crashConsistentFrequencyInMinutes", h.CrashConsistentFrequencyInMinutes) + objectMap["instanceType"] = "HyperVToAzStackHCI" + populate(objectMap, "recoveryPointHistoryInMinutes", h.RecoveryPointHistoryInMinutes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIPolicyModelCustomProperties. +func (h *HyperVToAzStackHCIPolicyModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appConsistentFrequencyInMinutes": + err = unpopulate(val, "AppConsistentFrequencyInMinutes", &h.AppConsistentFrequencyInMinutes) + delete(rawMsg, key) + case "crashConsistentFrequencyInMinutes": + err = unpopulate(val, "CrashConsistentFrequencyInMinutes", &h.CrashConsistentFrequencyInMinutes) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &h.InstanceType) + delete(rawMsg, key) + case "recoveryPointHistoryInMinutes": + err = unpopulate(val, "RecoveryPointHistoryInMinutes", &h.RecoveryPointHistoryInMinutes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIProtectedDiskProperties. +func (h HyperVToAzStackHCIProtectedDiskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacityInBytes", h.CapacityInBytes) + populate(objectMap, "diskType", h.DiskType) + populate(objectMap, "isDynamic", h.IsDynamic) + populate(objectMap, "isOsDisk", h.IsOsDisk) + populate(objectMap, "migrateDiskName", h.MigrateDiskName) + populate(objectMap, "seedDiskName", h.SeedDiskName) + populate(objectMap, "sourceDiskId", h.SourceDiskID) + populate(objectMap, "sourceDiskName", h.SourceDiskName) + populate(objectMap, "storageContainerId", h.StorageContainerID) + populate(objectMap, "storageContainerLocalPath", h.StorageContainerLocalPath) + populate(objectMap, "testMigrateDiskName", h.TestMigrateDiskName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIProtectedDiskProperties. +func (h *HyperVToAzStackHCIProtectedDiskProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacityInBytes": + err = unpopulate(val, "CapacityInBytes", &h.CapacityInBytes) + delete(rawMsg, key) + case "diskType": + err = unpopulate(val, "DiskType", &h.DiskType) + delete(rawMsg, key) + case "isDynamic": + err = unpopulate(val, "IsDynamic", &h.IsDynamic) + delete(rawMsg, key) + case "isOsDisk": + err = unpopulate(val, "IsOsDisk", &h.IsOsDisk) + delete(rawMsg, key) + case "migrateDiskName": + err = unpopulate(val, "MigrateDiskName", &h.MigrateDiskName) + delete(rawMsg, key) + case "seedDiskName": + err = unpopulate(val, "SeedDiskName", &h.SeedDiskName) + delete(rawMsg, key) + case "sourceDiskId": + err = unpopulate(val, "SourceDiskID", &h.SourceDiskID) + delete(rawMsg, key) + case "sourceDiskName": + err = unpopulate(val, "SourceDiskName", &h.SourceDiskName) + delete(rawMsg, key) + case "storageContainerId": + err = unpopulate(val, "StorageContainerID", &h.StorageContainerID) + delete(rawMsg, key) + case "storageContainerLocalPath": + err = unpopulate(val, "StorageContainerLocalPath", &h.StorageContainerLocalPath) + delete(rawMsg, key) + case "testMigrateDiskName": + err = unpopulate(val, "TestMigrateDiskName", &h.TestMigrateDiskName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIProtectedItemModelCustomProperties. +func (h HyperVToAzStackHCIProtectedItemModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "activeLocation", h.ActiveLocation) + populate(objectMap, "customLocationRegion", h.CustomLocationRegion) + populate(objectMap, "disksToInclude", h.DisksToInclude) + populate(objectMap, "dynamicMemoryConfig", h.DynamicMemoryConfig) + populate(objectMap, "fabricDiscoveryMachineId", h.FabricDiscoveryMachineID) + populate(objectMap, "failoverRecoveryPointId", h.FailoverRecoveryPointID) + populate(objectMap, "firmwareType", h.FirmwareType) + populate(objectMap, "hyperVGeneration", h.HyperVGeneration) + populate(objectMap, "initialReplicationProgressPercentage", h.InitialReplicationProgressPercentage) + objectMap["instanceType"] = "HyperVToAzStackHCI" + populate(objectMap, "isDynamicRam", h.IsDynamicRAM) + populate(objectMap, "lastRecoveryPointId", h.LastRecoveryPointID) + populateTimeRFC3339(objectMap, "lastRecoveryPointReceived", h.LastRecoveryPointReceived) + populateTimeRFC3339(objectMap, "lastReplicationUpdateTime", h.LastReplicationUpdateTime) + populate(objectMap, "nicsToInclude", h.NicsToInclude) + populate(objectMap, "osName", h.OSName) + populate(objectMap, "osType", h.OSType) + populate(objectMap, "protectedDisks", h.ProtectedDisks) + populate(objectMap, "protectedNics", h.ProtectedNics) + populate(objectMap, "resyncProgressPercentage", h.ResyncProgressPercentage) + populate(objectMap, "runAsAccountId", h.RunAsAccountID) + populate(objectMap, "sourceApplianceName", h.SourceApplianceName) + populate(objectMap, "sourceCpuCores", h.SourceCPUCores) + populate(objectMap, "sourceDraName", h.SourceDraName) + populate(objectMap, "sourceMemoryInMegaBytes", h.SourceMemoryInMegaBytes) + populate(objectMap, "sourceVmName", h.SourceVMName) + populate(objectMap, "storageContainerId", h.StorageContainerID) + populate(objectMap, "targetApplianceName", h.TargetApplianceName) + populate(objectMap, "targetArcClusterCustomLocationId", h.TargetArcClusterCustomLocationID) + populate(objectMap, "targetAzStackHciClusterName", h.TargetAzStackHciClusterName) + populate(objectMap, "targetCpuCores", h.TargetCPUCores) + populate(objectMap, "targetDraName", h.TargetDraName) + populate(objectMap, "targetHciClusterId", h.TargetHciClusterID) + populate(objectMap, "targetLocation", h.TargetLocation) + populate(objectMap, "targetMemoryInMegaBytes", h.TargetMemoryInMegaBytes) + populate(objectMap, "targetNetworkId", h.TargetNetworkID) + populate(objectMap, "targetResourceGroupId", h.TargetResourceGroupID) + populate(objectMap, "targetVmBiosId", h.TargetVMBiosID) + populate(objectMap, "targetVmName", h.TargetVMName) + populate(objectMap, "testNetworkId", h.TestNetworkID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIProtectedItemModelCustomProperties. +func (h *HyperVToAzStackHCIProtectedItemModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "activeLocation": + err = unpopulate(val, "ActiveLocation", &h.ActiveLocation) + delete(rawMsg, key) + case "customLocationRegion": + err = unpopulate(val, "CustomLocationRegion", &h.CustomLocationRegion) + delete(rawMsg, key) + case "disksToInclude": + err = unpopulate(val, "DisksToInclude", &h.DisksToInclude) + delete(rawMsg, key) + case "dynamicMemoryConfig": + err = unpopulate(val, "DynamicMemoryConfig", &h.DynamicMemoryConfig) + delete(rawMsg, key) + case "fabricDiscoveryMachineId": + err = unpopulate(val, "FabricDiscoveryMachineID", &h.FabricDiscoveryMachineID) + delete(rawMsg, key) + case "failoverRecoveryPointId": + err = unpopulate(val, "FailoverRecoveryPointID", &h.FailoverRecoveryPointID) + delete(rawMsg, key) + case "firmwareType": + err = unpopulate(val, "FirmwareType", &h.FirmwareType) + delete(rawMsg, key) + case "hyperVGeneration": + err = unpopulate(val, "HyperVGeneration", &h.HyperVGeneration) + delete(rawMsg, key) + case "initialReplicationProgressPercentage": + err = unpopulate(val, "InitialReplicationProgressPercentage", &h.InitialReplicationProgressPercentage) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &h.InstanceType) + delete(rawMsg, key) + case "isDynamicRam": + err = unpopulate(val, "IsDynamicRAM", &h.IsDynamicRAM) + delete(rawMsg, key) + case "lastRecoveryPointId": + err = unpopulate(val, "LastRecoveryPointID", &h.LastRecoveryPointID) + delete(rawMsg, key) + case "lastRecoveryPointReceived": + err = unpopulateTimeRFC3339(val, "LastRecoveryPointReceived", &h.LastRecoveryPointReceived) + delete(rawMsg, key) + case "lastReplicationUpdateTime": + err = unpopulateTimeRFC3339(val, "LastReplicationUpdateTime", &h.LastReplicationUpdateTime) + delete(rawMsg, key) + case "nicsToInclude": + err = unpopulate(val, "NicsToInclude", &h.NicsToInclude) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, "OSName", &h.OSName) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &h.OSType) + delete(rawMsg, key) + case "protectedDisks": + err = unpopulate(val, "ProtectedDisks", &h.ProtectedDisks) + delete(rawMsg, key) + case "protectedNics": + err = unpopulate(val, "ProtectedNics", &h.ProtectedNics) + delete(rawMsg, key) + case "resyncProgressPercentage": + err = unpopulate(val, "ResyncProgressPercentage", &h.ResyncProgressPercentage) + delete(rawMsg, key) + case "runAsAccountId": + err = unpopulate(val, "RunAsAccountID", &h.RunAsAccountID) + delete(rawMsg, key) + case "sourceApplianceName": + err = unpopulate(val, "SourceApplianceName", &h.SourceApplianceName) + delete(rawMsg, key) + case "sourceCpuCores": + err = unpopulate(val, "SourceCPUCores", &h.SourceCPUCores) + delete(rawMsg, key) + case "sourceDraName": + err = unpopulate(val, "SourceDraName", &h.SourceDraName) + delete(rawMsg, key) + case "sourceMemoryInMegaBytes": + err = unpopulate(val, "SourceMemoryInMegaBytes", &h.SourceMemoryInMegaBytes) + delete(rawMsg, key) + case "sourceVmName": + err = unpopulate(val, "SourceVMName", &h.SourceVMName) + delete(rawMsg, key) + case "storageContainerId": + err = unpopulate(val, "StorageContainerID", &h.StorageContainerID) + delete(rawMsg, key) + case "targetApplianceName": + err = unpopulate(val, "TargetApplianceName", &h.TargetApplianceName) + delete(rawMsg, key) + case "targetArcClusterCustomLocationId": + err = unpopulate(val, "TargetArcClusterCustomLocationID", &h.TargetArcClusterCustomLocationID) + delete(rawMsg, key) + case "targetAzStackHciClusterName": + err = unpopulate(val, "TargetAzStackHciClusterName", &h.TargetAzStackHciClusterName) + delete(rawMsg, key) + case "targetCpuCores": + err = unpopulate(val, "TargetCPUCores", &h.TargetCPUCores) + delete(rawMsg, key) + case "targetDraName": + err = unpopulate(val, "TargetDraName", &h.TargetDraName) + delete(rawMsg, key) + case "targetHciClusterId": + err = unpopulate(val, "TargetHciClusterID", &h.TargetHciClusterID) + delete(rawMsg, key) + case "targetLocation": + err = unpopulate(val, "TargetLocation", &h.TargetLocation) + delete(rawMsg, key) + case "targetMemoryInMegaBytes": + err = unpopulate(val, "TargetMemoryInMegaBytes", &h.TargetMemoryInMegaBytes) + delete(rawMsg, key) + case "targetNetworkId": + err = unpopulate(val, "TargetNetworkID", &h.TargetNetworkID) + delete(rawMsg, key) + case "targetResourceGroupId": + err = unpopulate(val, "TargetResourceGroupID", &h.TargetResourceGroupID) + delete(rawMsg, key) + case "targetVmBiosId": + err = unpopulate(val, "TargetVMBiosID", &h.TargetVMBiosID) + delete(rawMsg, key) + case "targetVmName": + err = unpopulate(val, "TargetVMName", &h.TargetVMName) + delete(rawMsg, key) + case "testNetworkId": + err = unpopulate(val, "TestNetworkID", &h.TestNetworkID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIProtectedNicProperties. +func (h HyperVToAzStackHCIProtectedNicProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "macAddress", h.MacAddress) + populate(objectMap, "networkName", h.NetworkName) + populate(objectMap, "nicId", h.NicID) + populate(objectMap, "selectionTypeForFailover", h.SelectionTypeForFailover) + populate(objectMap, "targetNetworkId", h.TargetNetworkID) + populate(objectMap, "testNetworkId", h.TestNetworkID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIProtectedNicProperties. +func (h *HyperVToAzStackHCIProtectedNicProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "macAddress": + err = unpopulate(val, "MacAddress", &h.MacAddress) + delete(rawMsg, key) + case "networkName": + err = unpopulate(val, "NetworkName", &h.NetworkName) + delete(rawMsg, key) + case "nicId": + err = unpopulate(val, "NicID", &h.NicID) + delete(rawMsg, key) + case "selectionTypeForFailover": + err = unpopulate(val, "SelectionTypeForFailover", &h.SelectionTypeForFailover) + delete(rawMsg, key) + case "targetNetworkId": + err = unpopulate(val, "TargetNetworkID", &h.TargetNetworkID) + delete(rawMsg, key) + case "testNetworkId": + err = unpopulate(val, "TestNetworkID", &h.TestNetworkID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIRecoveryPointModelCustomProperties. +func (h HyperVToAzStackHCIRecoveryPointModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskIds", h.DiskIDs) + objectMap["instanceType"] = "HyperVToAzStackHCI" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIRecoveryPointModelCustomProperties. +func (h *HyperVToAzStackHCIRecoveryPointModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "diskIds": + err = unpopulate(val, "DiskIDs", &h.DiskIDs) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &h.InstanceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type HyperVToAzStackHCIReplicationExtensionModelCustomProperties. +func (h HyperVToAzStackHCIReplicationExtensionModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "asrServiceUri", h.AsrServiceURI) + populate(objectMap, "azStackHciFabricArmId", h.AzStackHciFabricArmID) + populate(objectMap, "azStackHciSiteId", h.AzStackHciSiteID) + populate(objectMap, "gatewayServiceUri", h.GatewayServiceURI) + populate(objectMap, "hyperVFabricArmId", h.HyperVFabricArmID) + populate(objectMap, "hyperVSiteId", h.HyperVSiteID) + objectMap["instanceType"] = "HyperVToAzStackHCI" + populate(objectMap, "rcmServiceUri", h.RcmServiceURI) + populate(objectMap, "resourceGroup", h.ResourceGroup) + populate(objectMap, "resourceLocation", h.ResourceLocation) + populate(objectMap, "sourceGatewayServiceId", h.SourceGatewayServiceID) + populate(objectMap, "sourceStorageContainerName", h.SourceStorageContainerName) + populate(objectMap, "storageAccountId", h.StorageAccountID) + populate(objectMap, "storageAccountSasSecretName", h.StorageAccountSasSecretName) + populate(objectMap, "subscriptionId", h.SubscriptionID) + populate(objectMap, "targetGatewayServiceId", h.TargetGatewayServiceID) + populate(objectMap, "targetStorageContainerName", h.TargetStorageContainerName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type HyperVToAzStackHCIReplicationExtensionModelCustomProperties. +func (h *HyperVToAzStackHCIReplicationExtensionModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "asrServiceUri": + err = unpopulate(val, "AsrServiceURI", &h.AsrServiceURI) + delete(rawMsg, key) + case "azStackHciFabricArmId": + err = unpopulate(val, "AzStackHciFabricArmID", &h.AzStackHciFabricArmID) + delete(rawMsg, key) + case "azStackHciSiteId": + err = unpopulate(val, "AzStackHciSiteID", &h.AzStackHciSiteID) + delete(rawMsg, key) + case "gatewayServiceUri": + err = unpopulate(val, "GatewayServiceURI", &h.GatewayServiceURI) + delete(rawMsg, key) + case "hyperVFabricArmId": + err = unpopulate(val, "HyperVFabricArmID", &h.HyperVFabricArmID) + delete(rawMsg, key) + case "hyperVSiteId": + err = unpopulate(val, "HyperVSiteID", &h.HyperVSiteID) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &h.InstanceType) + delete(rawMsg, key) + case "rcmServiceUri": + err = unpopulate(val, "RcmServiceURI", &h.RcmServiceURI) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &h.ResourceGroup) + delete(rawMsg, key) + case "resourceLocation": + err = unpopulate(val, "ResourceLocation", &h.ResourceLocation) + delete(rawMsg, key) + case "sourceGatewayServiceId": + err = unpopulate(val, "SourceGatewayServiceID", &h.SourceGatewayServiceID) + delete(rawMsg, key) + case "sourceStorageContainerName": + err = unpopulate(val, "SourceStorageContainerName", &h.SourceStorageContainerName) + delete(rawMsg, key) + case "storageAccountId": + err = unpopulate(val, "StorageAccountID", &h.StorageAccountID) + delete(rawMsg, key) + case "storageAccountSasSecretName": + err = unpopulate(val, "StorageAccountSasSecretName", &h.StorageAccountSasSecretName) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &h.SubscriptionID) + delete(rawMsg, key) + case "targetGatewayServiceId": + err = unpopulate(val, "TargetGatewayServiceID", &h.TargetGatewayServiceID) + delete(rawMsg, key) + case "targetStorageContainerName": + err = unpopulate(val, "TargetStorageContainerName", &h.TargetStorageContainerName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", h, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityModel. +func (i IdentityModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "aadAuthority", i.AADAuthority) + populate(objectMap, "applicationId", i.ApplicationID) + populate(objectMap, "audience", i.Audience) + populate(objectMap, "objectId", i.ObjectID) + populate(objectMap, "tenantId", i.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IdentityModel. +func (i *IdentityModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aadAuthority": + err = unpopulate(val, "AADAuthority", &i.AADAuthority) + delete(rawMsg, key) + case "applicationId": + err = unpopulate(val, "ApplicationID", &i.ApplicationID) + delete(rawMsg, key) + case "audience": + err = unpopulate(val, "Audience", &i.Audience) + delete(rawMsg, key) + case "objectId": + err = unpopulate(val, "ObjectID", &i.ObjectID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &i.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InnerHealthErrorModel. +func (i InnerHealthErrorModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "category", i.Category) + populate(objectMap, "causes", i.Causes) + populate(objectMap, "code", i.Code) + populateTimeRFC3339(objectMap, "creationTime", i.CreationTime) + populate(objectMap, "healthCategory", i.HealthCategory) + populate(objectMap, "isCustomerResolvable", i.IsCustomerResolvable) + populate(objectMap, "message", i.Message) + populate(objectMap, "recommendation", i.Recommendation) + populate(objectMap, "severity", i.Severity) + populate(objectMap, "source", i.Source) + populate(objectMap, "summary", i.Summary) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InnerHealthErrorModel. +func (i *InnerHealthErrorModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "category": + err = unpopulate(val, "Category", &i.Category) + delete(rawMsg, key) + case "causes": + err = unpopulate(val, "Causes", &i.Causes) + delete(rawMsg, key) + case "code": + err = unpopulate(val, "Code", &i.Code) + delete(rawMsg, key) + case "creationTime": + err = unpopulateTimeRFC3339(val, "CreationTime", &i.CreationTime) + delete(rawMsg, key) + case "healthCategory": + err = unpopulate(val, "HealthCategory", &i.HealthCategory) + delete(rawMsg, key) + case "isCustomerResolvable": + err = unpopulate(val, "IsCustomerResolvable", &i.IsCustomerResolvable) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &i.Message) + delete(rawMsg, key) + case "recommendation": + err = unpopulate(val, "Recommendation", &i.Recommendation) + delete(rawMsg, key) + case "severity": + err = unpopulate(val, "Severity", &i.Severity) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &i.Source) + delete(rawMsg, key) + case "summary": + err = unpopulate(val, "Summary", &i.Summary) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationStatus. +func (o OperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endTime", o.EndTime) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + populate(objectMap, "startTime", o.StartTime) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatus. +func (o *OperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endTime": + err = unpopulate(val, "EndTime", &o.EndTime) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "startTime": + err = unpopulate(val, "StartTime", &o.StartTime) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PlannedFailoverModel. +func (p PlannedFailoverModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlannedFailoverModel. +func (p *PlannedFailoverModel) 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 PlannedFailoverModelCustomProperties. +func (p PlannedFailoverModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = p.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlannedFailoverModelCustomProperties. +func (p *PlannedFailoverModelCustomProperties) 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 "instanceType": + err = unpopulate(val, "InstanceType", &p.InstanceType) + 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 PlannedFailoverModelProperties. +func (p PlannedFailoverModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customProperties", p.CustomProperties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PlannedFailoverModelProperties. +func (p *PlannedFailoverModelProperties) 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 "customProperties": + p.CustomProperties, err = unmarshalPlannedFailoverModelCustomPropertiesClassification(val) + 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 PolicyModel. +func (p PolicyModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 PolicyModel. +func (p *PolicyModel) 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 PolicyModelCollection. +func (p PolicyModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyModelCollection. +func (p *PolicyModelCollection) 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 PolicyModelCustomProperties. +func (p PolicyModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = p.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyModelCustomProperties. +func (p *PolicyModelCustomProperties) 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 "instanceType": + err = unpopulate(val, "InstanceType", &p.InstanceType) + 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 PolicyModelProperties. +func (p PolicyModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customProperties", p.CustomProperties) + populate(objectMap, "provisioningState", p.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyModelProperties. +func (p *PolicyModelProperties) 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 "customProperties": + p.CustomProperties, err = unmarshalPolicyModelCustomPropertiesClassification(val) + 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 PolicyModelSystemData. +func (p PolicyModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", p.CreatedAt) + populate(objectMap, "createdBy", p.CreatedBy) + populate(objectMap, "createdByType", p.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", p.LastModifiedAt) + populate(objectMap, "lastModifiedBy", p.LastModifiedBy) + populate(objectMap, "lastModifiedByType", p.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PolicyModelSystemData. +func (p *PolicyModelSystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &p.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &p.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &p.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &p.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &p.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &p.LastModifiedByType) + 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 ProtectedItemDynamicMemoryConfig. +func (p ProtectedItemDynamicMemoryConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "maximumMemoryInMegaBytes", p.MaximumMemoryInMegaBytes) + populate(objectMap, "minimumMemoryInMegaBytes", p.MinimumMemoryInMegaBytes) + populate(objectMap, "targetMemoryBufferPercentage", p.TargetMemoryBufferPercentage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemDynamicMemoryConfig. +func (p *ProtectedItemDynamicMemoryConfig) 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 "maximumMemoryInMegaBytes": + err = unpopulate(val, "MaximumMemoryInMegaBytes", &p.MaximumMemoryInMegaBytes) + delete(rawMsg, key) + case "minimumMemoryInMegaBytes": + err = unpopulate(val, "MinimumMemoryInMegaBytes", &p.MinimumMemoryInMegaBytes) + delete(rawMsg, key) + case "targetMemoryBufferPercentage": + err = unpopulate(val, "TargetMemoryBufferPercentage", &p.TargetMemoryBufferPercentage) + 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 ProtectedItemModel. +func (p ProtectedItemModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 ProtectedItemModel. +func (p *ProtectedItemModel) 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 ProtectedItemModelCollection. +func (p ProtectedItemModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelCollection. +func (p *ProtectedItemModelCollection) 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 ProtectedItemModelCustomProperties. +func (p ProtectedItemModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = p.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelCustomProperties. +func (p *ProtectedItemModelCustomProperties) 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 "instanceType": + err = unpopulate(val, "InstanceType", &p.InstanceType) + 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 ProtectedItemModelProperties. +func (p ProtectedItemModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedJobs", p.AllowedJobs) + populate(objectMap, "correlationId", p.CorrelationID) + populate(objectMap, "currentJob", p.CurrentJob) + populate(objectMap, "customProperties", p.CustomProperties) + populate(objectMap, "draId", p.DraID) + populate(objectMap, "fabricId", p.FabricID) + populate(objectMap, "fabricObjectId", p.FabricObjectID) + populate(objectMap, "fabricObjectName", p.FabricObjectName) + populate(objectMap, "healthErrors", p.HealthErrors) + populate(objectMap, "lastFailedEnableProtectionJob", p.LastFailedEnableProtectionJob) + populate(objectMap, "lastFailedPlannedFailoverJob", p.LastFailedPlannedFailoverJob) + populateTimeRFC3339(objectMap, "lastSuccessfulPlannedFailoverTime", p.LastSuccessfulPlannedFailoverTime) + populateTimeRFC3339(objectMap, "lastSuccessfulTestFailoverTime", p.LastSuccessfulTestFailoverTime) + populateTimeRFC3339(objectMap, "lastSuccessfulUnplannedFailoverTime", p.LastSuccessfulUnplannedFailoverTime) + populate(objectMap, "lastTestFailoverJob", p.LastTestFailoverJob) + populate(objectMap, "policyName", p.PolicyName) + populate(objectMap, "protectionState", p.ProtectionState) + populate(objectMap, "protectionStateDescription", p.ProtectionStateDescription) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "replicationExtensionName", p.ReplicationExtensionName) + populate(objectMap, "replicationHealth", p.ReplicationHealth) + populate(objectMap, "resyncRequired", p.ResyncRequired) + populate(objectMap, "resynchronizationState", p.ResynchronizationState) + populate(objectMap, "sourceFabricProviderId", p.SourceFabricProviderID) + populate(objectMap, "targetDraId", p.TargetDraID) + populate(objectMap, "targetFabricId", p.TargetFabricID) + populate(objectMap, "targetFabricProviderId", p.TargetFabricProviderID) + populate(objectMap, "testFailoverState", p.TestFailoverState) + populate(objectMap, "testFailoverStateDescription", p.TestFailoverStateDescription) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelProperties. +func (p *ProtectedItemModelProperties) 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 "allowedJobs": + err = unpopulate(val, "AllowedJobs", &p.AllowedJobs) + delete(rawMsg, key) + case "correlationId": + err = unpopulate(val, "CorrelationID", &p.CorrelationID) + delete(rawMsg, key) + case "currentJob": + err = unpopulate(val, "CurrentJob", &p.CurrentJob) + delete(rawMsg, key) + case "customProperties": + p.CustomProperties, err = unmarshalProtectedItemModelCustomPropertiesClassification(val) + delete(rawMsg, key) + case "draId": + err = unpopulate(val, "DraID", &p.DraID) + delete(rawMsg, key) + case "fabricId": + err = unpopulate(val, "FabricID", &p.FabricID) + delete(rawMsg, key) + case "fabricObjectId": + err = unpopulate(val, "FabricObjectID", &p.FabricObjectID) + delete(rawMsg, key) + case "fabricObjectName": + err = unpopulate(val, "FabricObjectName", &p.FabricObjectName) + delete(rawMsg, key) + case "healthErrors": + err = unpopulate(val, "HealthErrors", &p.HealthErrors) + delete(rawMsg, key) + case "lastFailedEnableProtectionJob": + err = unpopulate(val, "LastFailedEnableProtectionJob", &p.LastFailedEnableProtectionJob) + delete(rawMsg, key) + case "lastFailedPlannedFailoverJob": + err = unpopulate(val, "LastFailedPlannedFailoverJob", &p.LastFailedPlannedFailoverJob) + delete(rawMsg, key) + case "lastSuccessfulPlannedFailoverTime": + err = unpopulateTimeRFC3339(val, "LastSuccessfulPlannedFailoverTime", &p.LastSuccessfulPlannedFailoverTime) + delete(rawMsg, key) + case "lastSuccessfulTestFailoverTime": + err = unpopulateTimeRFC3339(val, "LastSuccessfulTestFailoverTime", &p.LastSuccessfulTestFailoverTime) + delete(rawMsg, key) + case "lastSuccessfulUnplannedFailoverTime": + err = unpopulateTimeRFC3339(val, "LastSuccessfulUnplannedFailoverTime", &p.LastSuccessfulUnplannedFailoverTime) + delete(rawMsg, key) + case "lastTestFailoverJob": + err = unpopulate(val, "LastTestFailoverJob", &p.LastTestFailoverJob) + delete(rawMsg, key) + case "policyName": + err = unpopulate(val, "PolicyName", &p.PolicyName) + delete(rawMsg, key) + case "protectionState": + err = unpopulate(val, "ProtectionState", &p.ProtectionState) + delete(rawMsg, key) + case "protectionStateDescription": + err = unpopulate(val, "ProtectionStateDescription", &p.ProtectionStateDescription) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "replicationExtensionName": + err = unpopulate(val, "ReplicationExtensionName", &p.ReplicationExtensionName) + delete(rawMsg, key) + case "replicationHealth": + err = unpopulate(val, "ReplicationHealth", &p.ReplicationHealth) + delete(rawMsg, key) + case "resyncRequired": + err = unpopulate(val, "ResyncRequired", &p.ResyncRequired) + delete(rawMsg, key) + case "resynchronizationState": + err = unpopulate(val, "ResynchronizationState", &p.ResynchronizationState) + delete(rawMsg, key) + case "sourceFabricProviderId": + err = unpopulate(val, "SourceFabricProviderID", &p.SourceFabricProviderID) + delete(rawMsg, key) + case "targetDraId": + err = unpopulate(val, "TargetDraID", &p.TargetDraID) + delete(rawMsg, key) + case "targetFabricId": + err = unpopulate(val, "TargetFabricID", &p.TargetFabricID) + delete(rawMsg, key) + case "targetFabricProviderId": + err = unpopulate(val, "TargetFabricProviderID", &p.TargetFabricProviderID) + delete(rawMsg, key) + case "testFailoverState": + err = unpopulate(val, "TestFailoverState", &p.TestFailoverState) + delete(rawMsg, key) + case "testFailoverStateDescription": + err = unpopulate(val, "TestFailoverStateDescription", &p.TestFailoverStateDescription) + 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 ProtectedItemModelPropertiesCurrentJob. +func (p ProtectedItemModelPropertiesCurrentJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", p.DisplayName) + populateTimeRFC3339(objectMap, "endTime", p.EndTime) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "scenarioName", p.ScenarioName) + populateTimeRFC3339(objectMap, "startTime", p.StartTime) + populate(objectMap, "state", p.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelPropertiesCurrentJob. +func (p *ProtectedItemModelPropertiesCurrentJob) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &p.EndTime) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "scenarioName": + err = unpopulate(val, "ScenarioName", &p.ScenarioName) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &p.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &p.State) + 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 ProtectedItemModelPropertiesLastFailedEnableProtectionJob. +func (p ProtectedItemModelPropertiesLastFailedEnableProtectionJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", p.DisplayName) + populateTimeRFC3339(objectMap, "endTime", p.EndTime) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "scenarioName", p.ScenarioName) + populateTimeRFC3339(objectMap, "startTime", p.StartTime) + populate(objectMap, "state", p.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelPropertiesLastFailedEnableProtectionJob. +func (p *ProtectedItemModelPropertiesLastFailedEnableProtectionJob) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &p.EndTime) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "scenarioName": + err = unpopulate(val, "ScenarioName", &p.ScenarioName) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &p.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &p.State) + 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 ProtectedItemModelPropertiesLastFailedPlannedFailoverJob. +func (p ProtectedItemModelPropertiesLastFailedPlannedFailoverJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", p.DisplayName) + populateTimeRFC3339(objectMap, "endTime", p.EndTime) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "scenarioName", p.ScenarioName) + populateTimeRFC3339(objectMap, "startTime", p.StartTime) + populate(objectMap, "state", p.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelPropertiesLastFailedPlannedFailoverJob. +func (p *ProtectedItemModelPropertiesLastFailedPlannedFailoverJob) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &p.EndTime) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "scenarioName": + err = unpopulate(val, "ScenarioName", &p.ScenarioName) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &p.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &p.State) + 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 ProtectedItemModelPropertiesLastTestFailoverJob. +func (p ProtectedItemModelPropertiesLastTestFailoverJob) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "displayName", p.DisplayName) + populateTimeRFC3339(objectMap, "endTime", p.EndTime) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "scenarioName", p.ScenarioName) + populateTimeRFC3339(objectMap, "startTime", p.StartTime) + populate(objectMap, "state", p.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelPropertiesLastTestFailoverJob. +func (p *ProtectedItemModelPropertiesLastTestFailoverJob) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &p.EndTime) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "scenarioName": + err = unpopulate(val, "ScenarioName", &p.ScenarioName) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &p.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &p.State) + 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 ProtectedItemModelSystemData. +func (p ProtectedItemModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", p.CreatedAt) + populate(objectMap, "createdBy", p.CreatedBy) + populate(objectMap, "createdByType", p.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", p.LastModifiedAt) + populate(objectMap, "lastModifiedBy", p.LastModifiedBy) + populate(objectMap, "lastModifiedByType", p.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProtectedItemModelSystemData. +func (p *ProtectedItemModelSystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &p.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &p.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &p.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &p.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &p.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &p.LastModifiedByType) + 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 RecoveryPointModel. +func (r RecoveryPointModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecoveryPointModel. +func (r *RecoveryPointModel) 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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecoveryPointModelCollection. +func (r RecoveryPointModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecoveryPointModelCollection. +func (r *RecoveryPointModelCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RecoveryPointModelCustomProperties. +func (r RecoveryPointModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = r.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecoveryPointModelCustomProperties. +func (r *RecoveryPointModelCustomProperties) 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 "instanceType": + err = unpopulate(val, "InstanceType", &r.InstanceType) + 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 RecoveryPointModelProperties. +func (r RecoveryPointModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customProperties", r.CustomProperties) + populateTimeRFC3339(objectMap, "recoveryPointTime", r.RecoveryPointTime) + populate(objectMap, "recoveryPointType", r.RecoveryPointType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecoveryPointModelProperties. +func (r *RecoveryPointModelProperties) 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 "customProperties": + r.CustomProperties, err = unmarshalRecoveryPointModelCustomPropertiesClassification(val) + delete(rawMsg, key) + case "recoveryPointTime": + err = unpopulateTimeRFC3339(val, "RecoveryPointTime", &r.RecoveryPointTime) + delete(rawMsg, key) + case "recoveryPointType": + err = unpopulate(val, "RecoveryPointType", &r.RecoveryPointType) + 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 RecoveryPointModelSystemData. +func (r RecoveryPointModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", r.CreatedAt) + populate(objectMap, "createdBy", r.CreatedBy) + populate(objectMap, "createdByType", r.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", r.LastModifiedAt) + populate(objectMap, "lastModifiedBy", r.LastModifiedBy) + populate(objectMap, "lastModifiedByType", r.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RecoveryPointModelSystemData. +func (r *RecoveryPointModelSystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &r.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &r.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &r.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &r.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &r.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &r.LastModifiedByType) + 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 ReplicationExtensionModel. +func (r ReplicationExtensionModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "properties", r.Properties) + populate(objectMap, "systemData", r.SystemData) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicationExtensionModel. +func (r *ReplicationExtensionModel) 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 "properties": + err = unpopulate(val, "Properties", &r.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &r.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReplicationExtensionModelCollection. +func (r ReplicationExtensionModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicationExtensionModelCollection. +func (r *ReplicationExtensionModelCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &r.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &r.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReplicationExtensionModelCustomProperties. +func (r ReplicationExtensionModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = r.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicationExtensionModelCustomProperties. +func (r *ReplicationExtensionModelCustomProperties) 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 "instanceType": + err = unpopulate(val, "InstanceType", &r.InstanceType) + 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 ReplicationExtensionModelProperties. +func (r ReplicationExtensionModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "customProperties", r.CustomProperties) + populate(objectMap, "provisioningState", r.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicationExtensionModelProperties. +func (r *ReplicationExtensionModelProperties) 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 "customProperties": + r.CustomProperties, err = unmarshalReplicationExtensionModelCustomPropertiesClassification(val) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &r.ProvisioningState) + 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 ReplicationExtensionModelSystemData. +func (r ReplicationExtensionModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", r.CreatedAt) + populate(objectMap, "createdBy", r.CreatedBy) + populate(objectMap, "createdByType", r.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", r.LastModifiedAt) + populate(objectMap, "lastModifiedBy", r.LastModifiedBy) + populate(objectMap, "lastModifiedByType", r.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReplicationExtensionModelSystemData. +func (r *ReplicationExtensionModelSystemData) 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 "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &r.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &r.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &r.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &r.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &r.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &r.LastModifiedByType) + 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 StorageContainerProperties. +func (s StorageContainerProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clusterSharedVolumePath", s.ClusterSharedVolumePath) + populate(objectMap, "name", s.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageContainerProperties. +func (s *StorageContainerProperties) 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 "clusterSharedVolumePath": + err = unpopulate(val, "ClusterSharedVolumePath", &s.ClusterSharedVolumePath) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + 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 TaskModel. +func (t TaskModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "childrenWorkflows", t.ChildrenWorkflows) + populate(objectMap, "customProperties", t.CustomProperties) + populateTimeRFC3339(objectMap, "endTime", t.EndTime) + populateTimeRFC3339(objectMap, "startTime", t.StartTime) + populate(objectMap, "state", t.State) + populate(objectMap, "taskName", t.TaskName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskModel. +func (t *TaskModel) 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 "childrenWorkflows": + err = unpopulate(val, "ChildrenWorkflows", &t.ChildrenWorkflows) + delete(rawMsg, key) + case "customProperties": + err = unpopulate(val, "CustomProperties", &t.CustomProperties) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &t.EndTime) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &t.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &t.State) + delete(rawMsg, key) + case "taskName": + err = unpopulate(val, "TaskName", &t.TaskName) + 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 TaskModelCustomProperties. +func (t TaskModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "instanceType", t.InstanceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TaskModelCustomProperties. +func (t *TaskModelCustomProperties) 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 "instanceType": + err = unpopulate(val, "InstanceType", &t.InstanceType) + 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 TestFailoverCleanupWorkflowModelCustomProperties. +func (t TestFailoverCleanupWorkflowModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "affectedObjectDetails", t.AffectedObjectDetails) + populate(objectMap, "comments", t.Comments) + objectMap["instanceType"] = "TestFailoverCleanupWorkflowDetails" + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestFailoverCleanupWorkflowModelCustomProperties. +func (t *TestFailoverCleanupWorkflowModelCustomProperties) 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 "affectedObjectDetails": + err = unpopulate(val, "AffectedObjectDetails", &t.AffectedObjectDetails) + delete(rawMsg, key) + case "comments": + err = unpopulate(val, "Comments", &t.Comments) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &t.InstanceType) + 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 TestFailoverWorkflowModelCustomProperties. +func (t TestFailoverWorkflowModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "affectedObjectDetails", t.AffectedObjectDetails) + objectMap["instanceType"] = "TestFailoverWorkflowDetails" + populate(objectMap, "protectedItemDetails", t.ProtectedItemDetails) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TestFailoverWorkflowModelCustomProperties. +func (t *TestFailoverWorkflowModelCustomProperties) 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 "affectedObjectDetails": + err = unpopulate(val, "AffectedObjectDetails", &t.AffectedObjectDetails) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &t.InstanceType) + delete(rawMsg, key) + case "protectedItemDetails": + err = unpopulate(val, "ProtectedItemDetails", &t.ProtectedItemDetails) + 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 VMwareDraModelCustomProperties. +func (v VMwareDraModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "biosId", v.BiosID) + objectMap["instanceType"] = "VMware" + populate(objectMap, "marsAuthenticationIdentity", v.MarsAuthenticationIdentity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareDraModelCustomProperties. +func (v *VMwareDraModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "biosId": + err = unpopulate(val, "BiosID", &v.BiosID) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &v.InstanceType) + delete(rawMsg, key) + case "marsAuthenticationIdentity": + err = unpopulate(val, "MarsAuthenticationIdentity", &v.MarsAuthenticationIdentity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareMigrateFabricModelCustomProperties. +func (v VMwareMigrateFabricModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = "VMwareMigrate" + populate(objectMap, "migrationSolutionId", v.MigrationSolutionID) + populate(objectMap, "vmwareSiteId", v.VmwareSiteID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareMigrateFabricModelCustomProperties. +func (v *VMwareMigrateFabricModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceType": + err = unpopulate(val, "InstanceType", &v.InstanceType) + delete(rawMsg, key) + case "migrationSolutionId": + err = unpopulate(val, "MigrationSolutionID", &v.MigrationSolutionID) + delete(rawMsg, key) + case "vmwareSiteId": + err = unpopulate(val, "VmwareSiteID", &v.VmwareSiteID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCIDiskInput. +func (v VMwareToAzStackHCIDiskInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "diskFileFormat", v.DiskFileFormat) + populate(objectMap, "diskId", v.DiskID) + populate(objectMap, "diskSizeGB", v.DiskSizeGB) + populate(objectMap, "isDynamic", v.IsDynamic) + populate(objectMap, "isOsDisk", v.IsOsDisk) + populate(objectMap, "storageContainerId", v.StorageContainerID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCIDiskInput. +func (v *VMwareToAzStackHCIDiskInput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "diskFileFormat": + err = unpopulate(val, "DiskFileFormat", &v.DiskFileFormat) + delete(rawMsg, key) + case "diskId": + err = unpopulate(val, "DiskID", &v.DiskID) + delete(rawMsg, key) + case "diskSizeGB": + err = unpopulate(val, "DiskSizeGB", &v.DiskSizeGB) + delete(rawMsg, key) + case "isDynamic": + err = unpopulate(val, "IsDynamic", &v.IsDynamic) + delete(rawMsg, key) + case "isOsDisk": + err = unpopulate(val, "IsOsDisk", &v.IsOsDisk) + delete(rawMsg, key) + case "storageContainerId": + err = unpopulate(val, "StorageContainerID", &v.StorageContainerID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCINicInput. +func (v VMwareToAzStackHCINicInput) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "label", v.Label) + populate(objectMap, "networkName", v.NetworkName) + populate(objectMap, "nicId", v.NicID) + populate(objectMap, "selectionTypeForFailover", v.SelectionTypeForFailover) + populate(objectMap, "targetNetworkId", v.TargetNetworkID) + populate(objectMap, "testNetworkId", v.TestNetworkID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCINicInput. +func (v *VMwareToAzStackHCINicInput) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "label": + err = unpopulate(val, "Label", &v.Label) + delete(rawMsg, key) + case "networkName": + err = unpopulate(val, "NetworkName", &v.NetworkName) + delete(rawMsg, key) + case "nicId": + err = unpopulate(val, "NicID", &v.NicID) + delete(rawMsg, key) + case "selectionTypeForFailover": + err = unpopulate(val, "SelectionTypeForFailover", &v.SelectionTypeForFailover) + delete(rawMsg, key) + case "targetNetworkId": + err = unpopulate(val, "TargetNetworkID", &v.TargetNetworkID) + delete(rawMsg, key) + case "testNetworkId": + err = unpopulate(val, "TestNetworkID", &v.TestNetworkID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCIPlannedFailoverModelCustomProperties. +func (v VMwareToAzStackHCIPlannedFailoverModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["instanceType"] = "VMwareToAzStackHCI" + populate(objectMap, "shutdownSourceVM", v.ShutdownSourceVM) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCIPlannedFailoverModelCustomProperties. +func (v *VMwareToAzStackHCIPlannedFailoverModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "instanceType": + err = unpopulate(val, "InstanceType", &v.InstanceType) + delete(rawMsg, key) + case "shutdownSourceVM": + err = unpopulate(val, "ShutdownSourceVM", &v.ShutdownSourceVM) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCIPolicyModelCustomProperties. +func (v VMwareToAzStackHCIPolicyModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "appConsistentFrequencyInMinutes", v.AppConsistentFrequencyInMinutes) + populate(objectMap, "crashConsistentFrequencyInMinutes", v.CrashConsistentFrequencyInMinutes) + objectMap["instanceType"] = "VMwareToAzStackHCI" + populate(objectMap, "recoveryPointHistoryInMinutes", v.RecoveryPointHistoryInMinutes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCIPolicyModelCustomProperties. +func (v *VMwareToAzStackHCIPolicyModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appConsistentFrequencyInMinutes": + err = unpopulate(val, "AppConsistentFrequencyInMinutes", &v.AppConsistentFrequencyInMinutes) + delete(rawMsg, key) + case "crashConsistentFrequencyInMinutes": + err = unpopulate(val, "CrashConsistentFrequencyInMinutes", &v.CrashConsistentFrequencyInMinutes) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &v.InstanceType) + delete(rawMsg, key) + case "recoveryPointHistoryInMinutes": + err = unpopulate(val, "RecoveryPointHistoryInMinutes", &v.RecoveryPointHistoryInMinutes) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCIProtectedDiskProperties. +func (v VMwareToAzStackHCIProtectedDiskProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "capacityInBytes", v.CapacityInBytes) + populate(objectMap, "diskType", v.DiskType) + populate(objectMap, "isDynamic", v.IsDynamic) + populate(objectMap, "isOsDisk", v.IsOsDisk) + populate(objectMap, "migrateDiskName", v.MigrateDiskName) + populate(objectMap, "seedDiskName", v.SeedDiskName) + populate(objectMap, "sourceDiskId", v.SourceDiskID) + populate(objectMap, "sourceDiskName", v.SourceDiskName) + populate(objectMap, "storageContainerId", v.StorageContainerID) + populate(objectMap, "storageContainerLocalPath", v.StorageContainerLocalPath) + populate(objectMap, "testMigrateDiskName", v.TestMigrateDiskName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCIProtectedDiskProperties. +func (v *VMwareToAzStackHCIProtectedDiskProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "capacityInBytes": + err = unpopulate(val, "CapacityInBytes", &v.CapacityInBytes) + delete(rawMsg, key) + case "diskType": + err = unpopulate(val, "DiskType", &v.DiskType) + delete(rawMsg, key) + case "isDynamic": + err = unpopulate(val, "IsDynamic", &v.IsDynamic) + delete(rawMsg, key) + case "isOsDisk": + err = unpopulate(val, "IsOsDisk", &v.IsOsDisk) + delete(rawMsg, key) + case "migrateDiskName": + err = unpopulate(val, "MigrateDiskName", &v.MigrateDiskName) + delete(rawMsg, key) + case "seedDiskName": + err = unpopulate(val, "SeedDiskName", &v.SeedDiskName) + delete(rawMsg, key) + case "sourceDiskId": + err = unpopulate(val, "SourceDiskID", &v.SourceDiskID) + delete(rawMsg, key) + case "sourceDiskName": + err = unpopulate(val, "SourceDiskName", &v.SourceDiskName) + delete(rawMsg, key) + case "storageContainerId": + err = unpopulate(val, "StorageContainerID", &v.StorageContainerID) + delete(rawMsg, key) + case "storageContainerLocalPath": + err = unpopulate(val, "StorageContainerLocalPath", &v.StorageContainerLocalPath) + delete(rawMsg, key) + case "testMigrateDiskName": + err = unpopulate(val, "TestMigrateDiskName", &v.TestMigrateDiskName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCIProtectedItemModelCustomProperties. +func (v VMwareToAzStackHCIProtectedItemModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "activeLocation", v.ActiveLocation) + populate(objectMap, "customLocationRegion", v.CustomLocationRegion) + populate(objectMap, "disksToInclude", v.DisksToInclude) + populate(objectMap, "dynamicMemoryConfig", v.DynamicMemoryConfig) + populate(objectMap, "fabricDiscoveryMachineId", v.FabricDiscoveryMachineID) + populate(objectMap, "failoverRecoveryPointId", v.FailoverRecoveryPointID) + populate(objectMap, "firmwareType", v.FirmwareType) + populate(objectMap, "hyperVGeneration", v.HyperVGeneration) + populate(objectMap, "initialReplicationProgressPercentage", v.InitialReplicationProgressPercentage) + objectMap["instanceType"] = "VMwareToAzStackHCI" + populate(objectMap, "isDynamicRam", v.IsDynamicRAM) + populate(objectMap, "lastRecoveryPointId", v.LastRecoveryPointID) + populateTimeRFC3339(objectMap, "lastRecoveryPointReceived", v.LastRecoveryPointReceived) + populateTimeRFC3339(objectMap, "lastReplicationUpdateTime", v.LastReplicationUpdateTime) + populate(objectMap, "migrationProgressPercentage", v.MigrationProgressPercentage) + populate(objectMap, "nicsToInclude", v.NicsToInclude) + populate(objectMap, "osName", v.OSName) + populate(objectMap, "osType", v.OSType) + populate(objectMap, "performAutoResync", v.PerformAutoResync) + populate(objectMap, "protectedDisks", v.ProtectedDisks) + populate(objectMap, "protectedNics", v.ProtectedNics) + populate(objectMap, "resumeProgressPercentage", v.ResumeProgressPercentage) + populate(objectMap, "resumeRetryCount", v.ResumeRetryCount) + populate(objectMap, "resyncProgressPercentage", v.ResyncProgressPercentage) + populate(objectMap, "resyncRequired", v.ResyncRequired) + populate(objectMap, "resyncRetryCount", v.ResyncRetryCount) + populate(objectMap, "resyncState", v.ResyncState) + populate(objectMap, "runAsAccountId", v.RunAsAccountID) + populate(objectMap, "sourceApplianceName", v.SourceApplianceName) + populate(objectMap, "sourceCpuCores", v.SourceCPUCores) + populate(objectMap, "sourceDraName", v.SourceDraName) + populate(objectMap, "sourceMemoryInMegaBytes", v.SourceMemoryInMegaBytes) + populate(objectMap, "sourceVmName", v.SourceVMName) + populate(objectMap, "storageContainerId", v.StorageContainerID) + populate(objectMap, "targetApplianceName", v.TargetApplianceName) + populate(objectMap, "targetArcClusterCustomLocationId", v.TargetArcClusterCustomLocationID) + populate(objectMap, "targetAzStackHciClusterName", v.TargetAzStackHciClusterName) + populate(objectMap, "targetCpuCores", v.TargetCPUCores) + populate(objectMap, "targetDraName", v.TargetDraName) + populate(objectMap, "targetHciClusterId", v.TargetHciClusterID) + populate(objectMap, "targetLocation", v.TargetLocation) + populate(objectMap, "targetMemoryInMegaBytes", v.TargetMemoryInMegaBytes) + populate(objectMap, "targetNetworkId", v.TargetNetworkID) + populate(objectMap, "targetResourceGroupId", v.TargetResourceGroupID) + populate(objectMap, "targetVmBiosId", v.TargetVMBiosID) + populate(objectMap, "targetVmName", v.TargetVMName) + populate(objectMap, "testNetworkId", v.TestNetworkID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCIProtectedItemModelCustomProperties. +func (v *VMwareToAzStackHCIProtectedItemModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "activeLocation": + err = unpopulate(val, "ActiveLocation", &v.ActiveLocation) + delete(rawMsg, key) + case "customLocationRegion": + err = unpopulate(val, "CustomLocationRegion", &v.CustomLocationRegion) + delete(rawMsg, key) + case "disksToInclude": + err = unpopulate(val, "DisksToInclude", &v.DisksToInclude) + delete(rawMsg, key) + case "dynamicMemoryConfig": + err = unpopulate(val, "DynamicMemoryConfig", &v.DynamicMemoryConfig) + delete(rawMsg, key) + case "fabricDiscoveryMachineId": + err = unpopulate(val, "FabricDiscoveryMachineID", &v.FabricDiscoveryMachineID) + delete(rawMsg, key) + case "failoverRecoveryPointId": + err = unpopulate(val, "FailoverRecoveryPointID", &v.FailoverRecoveryPointID) + delete(rawMsg, key) + case "firmwareType": + err = unpopulate(val, "FirmwareType", &v.FirmwareType) + delete(rawMsg, key) + case "hyperVGeneration": + err = unpopulate(val, "HyperVGeneration", &v.HyperVGeneration) + delete(rawMsg, key) + case "initialReplicationProgressPercentage": + err = unpopulate(val, "InitialReplicationProgressPercentage", &v.InitialReplicationProgressPercentage) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &v.InstanceType) + delete(rawMsg, key) + case "isDynamicRam": + err = unpopulate(val, "IsDynamicRAM", &v.IsDynamicRAM) + delete(rawMsg, key) + case "lastRecoveryPointId": + err = unpopulate(val, "LastRecoveryPointID", &v.LastRecoveryPointID) + delete(rawMsg, key) + case "lastRecoveryPointReceived": + err = unpopulateTimeRFC3339(val, "LastRecoveryPointReceived", &v.LastRecoveryPointReceived) + delete(rawMsg, key) + case "lastReplicationUpdateTime": + err = unpopulateTimeRFC3339(val, "LastReplicationUpdateTime", &v.LastReplicationUpdateTime) + delete(rawMsg, key) + case "migrationProgressPercentage": + err = unpopulate(val, "MigrationProgressPercentage", &v.MigrationProgressPercentage) + delete(rawMsg, key) + case "nicsToInclude": + err = unpopulate(val, "NicsToInclude", &v.NicsToInclude) + delete(rawMsg, key) + case "osName": + err = unpopulate(val, "OSName", &v.OSName) + delete(rawMsg, key) + case "osType": + err = unpopulate(val, "OSType", &v.OSType) + delete(rawMsg, key) + case "performAutoResync": + err = unpopulate(val, "PerformAutoResync", &v.PerformAutoResync) + delete(rawMsg, key) + case "protectedDisks": + err = unpopulate(val, "ProtectedDisks", &v.ProtectedDisks) + delete(rawMsg, key) + case "protectedNics": + err = unpopulate(val, "ProtectedNics", &v.ProtectedNics) + delete(rawMsg, key) + case "resumeProgressPercentage": + err = unpopulate(val, "ResumeProgressPercentage", &v.ResumeProgressPercentage) + delete(rawMsg, key) + case "resumeRetryCount": + err = unpopulate(val, "ResumeRetryCount", &v.ResumeRetryCount) + delete(rawMsg, key) + case "resyncProgressPercentage": + err = unpopulate(val, "ResyncProgressPercentage", &v.ResyncProgressPercentage) + delete(rawMsg, key) + case "resyncRequired": + err = unpopulate(val, "ResyncRequired", &v.ResyncRequired) + delete(rawMsg, key) + case "resyncRetryCount": + err = unpopulate(val, "ResyncRetryCount", &v.ResyncRetryCount) + delete(rawMsg, key) + case "resyncState": + err = unpopulate(val, "ResyncState", &v.ResyncState) + delete(rawMsg, key) + case "runAsAccountId": + err = unpopulate(val, "RunAsAccountID", &v.RunAsAccountID) + delete(rawMsg, key) + case "sourceApplianceName": + err = unpopulate(val, "SourceApplianceName", &v.SourceApplianceName) + delete(rawMsg, key) + case "sourceCpuCores": + err = unpopulate(val, "SourceCPUCores", &v.SourceCPUCores) + delete(rawMsg, key) + case "sourceDraName": + err = unpopulate(val, "SourceDraName", &v.SourceDraName) + delete(rawMsg, key) + case "sourceMemoryInMegaBytes": + err = unpopulate(val, "SourceMemoryInMegaBytes", &v.SourceMemoryInMegaBytes) + delete(rawMsg, key) + case "sourceVmName": + err = unpopulate(val, "SourceVMName", &v.SourceVMName) + delete(rawMsg, key) + case "storageContainerId": + err = unpopulate(val, "StorageContainerID", &v.StorageContainerID) + delete(rawMsg, key) + case "targetApplianceName": + err = unpopulate(val, "TargetApplianceName", &v.TargetApplianceName) + delete(rawMsg, key) + case "targetArcClusterCustomLocationId": + err = unpopulate(val, "TargetArcClusterCustomLocationID", &v.TargetArcClusterCustomLocationID) + delete(rawMsg, key) + case "targetAzStackHciClusterName": + err = unpopulate(val, "TargetAzStackHciClusterName", &v.TargetAzStackHciClusterName) + delete(rawMsg, key) + case "targetCpuCores": + err = unpopulate(val, "TargetCPUCores", &v.TargetCPUCores) + delete(rawMsg, key) + case "targetDraName": + err = unpopulate(val, "TargetDraName", &v.TargetDraName) + delete(rawMsg, key) + case "targetHciClusterId": + err = unpopulate(val, "TargetHciClusterID", &v.TargetHciClusterID) + delete(rawMsg, key) + case "targetLocation": + err = unpopulate(val, "TargetLocation", &v.TargetLocation) + delete(rawMsg, key) + case "targetMemoryInMegaBytes": + err = unpopulate(val, "TargetMemoryInMegaBytes", &v.TargetMemoryInMegaBytes) + delete(rawMsg, key) + case "targetNetworkId": + err = unpopulate(val, "TargetNetworkID", &v.TargetNetworkID) + delete(rawMsg, key) + case "targetResourceGroupId": + err = unpopulate(val, "TargetResourceGroupID", &v.TargetResourceGroupID) + delete(rawMsg, key) + case "targetVmBiosId": + err = unpopulate(val, "TargetVMBiosID", &v.TargetVMBiosID) + delete(rawMsg, key) + case "targetVmName": + err = unpopulate(val, "TargetVMName", &v.TargetVMName) + delete(rawMsg, key) + case "testNetworkId": + err = unpopulate(val, "TestNetworkID", &v.TestNetworkID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCIProtectedNicProperties. +func (v VMwareToAzStackHCIProtectedNicProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "isPrimaryNic", v.IsPrimaryNic) + populate(objectMap, "label", v.Label) + populate(objectMap, "macAddress", v.MacAddress) + populate(objectMap, "networkName", v.NetworkName) + populate(objectMap, "nicId", v.NicID) + populate(objectMap, "selectionTypeForFailover", v.SelectionTypeForFailover) + populate(objectMap, "targetNetworkId", v.TargetNetworkID) + populate(objectMap, "testNetworkId", v.TestNetworkID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCIProtectedNicProperties. +func (v *VMwareToAzStackHCIProtectedNicProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "isPrimaryNic": + err = unpopulate(val, "IsPrimaryNic", &v.IsPrimaryNic) + delete(rawMsg, key) + case "label": + err = unpopulate(val, "Label", &v.Label) + delete(rawMsg, key) + case "macAddress": + err = unpopulate(val, "MacAddress", &v.MacAddress) + delete(rawMsg, key) + case "networkName": + err = unpopulate(val, "NetworkName", &v.NetworkName) + delete(rawMsg, key) + case "nicId": + err = unpopulate(val, "NicID", &v.NicID) + delete(rawMsg, key) + case "selectionTypeForFailover": + err = unpopulate(val, "SelectionTypeForFailover", &v.SelectionTypeForFailover) + delete(rawMsg, key) + case "targetNetworkId": + err = unpopulate(val, "TargetNetworkID", &v.TargetNetworkID) + delete(rawMsg, key) + case "testNetworkId": + err = unpopulate(val, "TestNetworkID", &v.TestNetworkID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VMwareToAzStackHCIReplicationExtensionModelCustomProperties. +func (v VMwareToAzStackHCIReplicationExtensionModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "asrServiceUri", v.AsrServiceURI) + populate(objectMap, "azStackHciFabricArmId", v.AzStackHciFabricArmID) + populate(objectMap, "azStackHciSiteId", v.AzStackHciSiteID) + populate(objectMap, "gatewayServiceUri", v.GatewayServiceURI) + objectMap["instanceType"] = "VMwareToAzStackHCI" + populate(objectMap, "rcmServiceUri", v.RcmServiceURI) + populate(objectMap, "resourceGroup", v.ResourceGroup) + populate(objectMap, "resourceLocation", v.ResourceLocation) + populate(objectMap, "sourceGatewayServiceId", v.SourceGatewayServiceID) + populate(objectMap, "sourceStorageContainerName", v.SourceStorageContainerName) + populate(objectMap, "storageAccountId", v.StorageAccountID) + populate(objectMap, "storageAccountSasSecretName", v.StorageAccountSasSecretName) + populate(objectMap, "subscriptionId", v.SubscriptionID) + populate(objectMap, "targetGatewayServiceId", v.TargetGatewayServiceID) + populate(objectMap, "targetStorageContainerName", v.TargetStorageContainerName) + populate(objectMap, "vmwareFabricArmId", v.VmwareFabricArmID) + populate(objectMap, "vmwareSiteId", v.VmwareSiteID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VMwareToAzStackHCIReplicationExtensionModelCustomProperties. +func (v *VMwareToAzStackHCIReplicationExtensionModelCustomProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "asrServiceUri": + err = unpopulate(val, "AsrServiceURI", &v.AsrServiceURI) + delete(rawMsg, key) + case "azStackHciFabricArmId": + err = unpopulate(val, "AzStackHciFabricArmID", &v.AzStackHciFabricArmID) + delete(rawMsg, key) + case "azStackHciSiteId": + err = unpopulate(val, "AzStackHciSiteID", &v.AzStackHciSiteID) + delete(rawMsg, key) + case "gatewayServiceUri": + err = unpopulate(val, "GatewayServiceURI", &v.GatewayServiceURI) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &v.InstanceType) + delete(rawMsg, key) + case "rcmServiceUri": + err = unpopulate(val, "RcmServiceURI", &v.RcmServiceURI) + delete(rawMsg, key) + case "resourceGroup": + err = unpopulate(val, "ResourceGroup", &v.ResourceGroup) + delete(rawMsg, key) + case "resourceLocation": + err = unpopulate(val, "ResourceLocation", &v.ResourceLocation) + delete(rawMsg, key) + case "sourceGatewayServiceId": + err = unpopulate(val, "SourceGatewayServiceID", &v.SourceGatewayServiceID) + delete(rawMsg, key) + case "sourceStorageContainerName": + err = unpopulate(val, "SourceStorageContainerName", &v.SourceStorageContainerName) + delete(rawMsg, key) + case "storageAccountId": + err = unpopulate(val, "StorageAccountID", &v.StorageAccountID) + delete(rawMsg, key) + case "storageAccountSasSecretName": + err = unpopulate(val, "StorageAccountSasSecretName", &v.StorageAccountSasSecretName) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &v.SubscriptionID) + delete(rawMsg, key) + case "targetGatewayServiceId": + err = unpopulate(val, "TargetGatewayServiceID", &v.TargetGatewayServiceID) + delete(rawMsg, key) + case "targetStorageContainerName": + err = unpopulate(val, "TargetStorageContainerName", &v.TargetStorageContainerName) + delete(rawMsg, key) + case "vmwareFabricArmId": + err = unpopulate(val, "VmwareFabricArmID", &v.VmwareFabricArmID) + delete(rawMsg, key) + case "vmwareSiteId": + err = unpopulate(val, "VmwareSiteID", &v.VmwareSiteID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VaultModel. +func (v VaultModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "location", v.Location) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VaultModel. +func (v *VaultModel) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &v.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &v.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VaultModelCollection. +func (v VaultModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VaultModelCollection. +func (v *VaultModelCollection) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VaultModelProperties. +func (v VaultModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", v.ProvisioningState) + populate(objectMap, "serviceResourceId", v.ServiceResourceID) + populate(objectMap, "vaultType", v.VaultType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VaultModelProperties. +func (v *VaultModelProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &v.ProvisioningState) + delete(rawMsg, key) + case "serviceResourceId": + err = unpopulate(val, "ServiceResourceID", &v.ServiceResourceID) + delete(rawMsg, key) + case "vaultType": + err = unpopulate(val, "VaultType", &v.VaultType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VaultModelSystemData. +func (v VaultModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", v.CreatedAt) + populate(objectMap, "createdBy", v.CreatedBy) + populate(objectMap, "createdByType", v.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", v.LastModifiedAt) + populate(objectMap, "lastModifiedBy", v.LastModifiedBy) + populate(objectMap, "lastModifiedByType", v.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VaultModelSystemData. +func (v *VaultModelSystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &v.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &v.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &v.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &v.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &v.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &v.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VaultModelUpdate. +func (v VaultModelUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) + populate(objectMap, "tags", v.Tags) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VaultModelUpdate. +func (v *VaultModelUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &v.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VaultModelUpdateSystemData. +func (v VaultModelUpdateSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", v.CreatedAt) + populate(objectMap, "createdBy", v.CreatedBy) + populate(objectMap, "createdByType", v.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", v.LastModifiedAt) + populate(objectMap, "lastModifiedBy", v.LastModifiedBy) + populate(objectMap, "lastModifiedByType", v.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VaultModelUpdateSystemData. +func (v *VaultModelUpdateSystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &v.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &v.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &v.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &v.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &v.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &v.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowModel. +func (w WorkflowModel) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowModel. +func (w *WorkflowModel) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &w.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowModelCollection. +func (w WorkflowModelCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowModelCollection. +func (w *WorkflowModelCollection) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowModelCustomProperties. +func (w WorkflowModelCustomProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "affectedObjectDetails", w.AffectedObjectDetails) + objectMap["instanceType"] = w.InstanceType + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowModelCustomProperties. +func (w *WorkflowModelCustomProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "affectedObjectDetails": + err = unpopulate(val, "AffectedObjectDetails", &w.AffectedObjectDetails) + delete(rawMsg, key) + case "instanceType": + err = unpopulate(val, "InstanceType", &w.InstanceType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowModelProperties. +func (w WorkflowModelProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "activityId", w.ActivityID) + populate(objectMap, "allowedActions", w.AllowedActions) + populate(objectMap, "customProperties", w.CustomProperties) + populate(objectMap, "displayName", w.DisplayName) + populateTimeRFC3339(objectMap, "endTime", w.EndTime) + populate(objectMap, "errors", w.Errors) + populate(objectMap, "objectId", w.ObjectID) + populate(objectMap, "objectInternalId", w.ObjectInternalID) + populate(objectMap, "objectInternalName", w.ObjectInternalName) + populate(objectMap, "objectName", w.ObjectName) + populate(objectMap, "objectType", w.ObjectType) + populate(objectMap, "replicationProviderId", w.ReplicationProviderID) + populate(objectMap, "sourceFabricProviderId", w.SourceFabricProviderID) + populateTimeRFC3339(objectMap, "startTime", w.StartTime) + populate(objectMap, "state", w.State) + populate(objectMap, "targetFabricProviderId", w.TargetFabricProviderID) + populate(objectMap, "tasks", w.Tasks) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowModelProperties. +func (w *WorkflowModelProperties) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "activityId": + err = unpopulate(val, "ActivityID", &w.ActivityID) + delete(rawMsg, key) + case "allowedActions": + err = unpopulate(val, "AllowedActions", &w.AllowedActions) + delete(rawMsg, key) + case "customProperties": + w.CustomProperties, err = unmarshalWorkflowModelCustomPropertiesClassification(val) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &w.DisplayName) + delete(rawMsg, key) + case "endTime": + err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) + delete(rawMsg, key) + case "errors": + err = unpopulate(val, "Errors", &w.Errors) + delete(rawMsg, key) + case "objectId": + err = unpopulate(val, "ObjectID", &w.ObjectID) + delete(rawMsg, key) + case "objectInternalId": + err = unpopulate(val, "ObjectInternalID", &w.ObjectInternalID) + delete(rawMsg, key) + case "objectInternalName": + err = unpopulate(val, "ObjectInternalName", &w.ObjectInternalName) + delete(rawMsg, key) + case "objectName": + err = unpopulate(val, "ObjectName", &w.ObjectName) + delete(rawMsg, key) + case "objectType": + err = unpopulate(val, "ObjectType", &w.ObjectType) + delete(rawMsg, key) + case "replicationProviderId": + err = unpopulate(val, "ReplicationProviderID", &w.ReplicationProviderID) + delete(rawMsg, key) + case "sourceFabricProviderId": + err = unpopulate(val, "SourceFabricProviderID", &w.SourceFabricProviderID) + delete(rawMsg, key) + case "startTime": + err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &w.State) + delete(rawMsg, key) + case "targetFabricProviderId": + err = unpopulate(val, "TargetFabricProviderID", &w.TargetFabricProviderID) + delete(rawMsg, key) + case "tasks": + err = unpopulate(val, "Tasks", &w.Tasks) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkflowModelSystemData. +func (w WorkflowModelSystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "createdAt", w.CreatedAt) + populate(objectMap, "createdBy", w.CreatedBy) + populate(objectMap, "createdByType", w.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", w.LastModifiedAt) + populate(objectMap, "lastModifiedBy", w.LastModifiedBy) + populate(objectMap, "lastModifiedByType", w.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkflowModelSystemData. +func (w *WorkflowModelSystemData) 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", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &w.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &w.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &w.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &w.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &w.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &w.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/operations_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/operations_client.go new file mode 100644 index 000000000000..a16dbf9e512f --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/operations_client.go @@ -0,0 +1,93 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - Gets the operations. +// +// Generated from API version 2021-02-16-preview +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + 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.internal.Pipeline().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.DataReplication/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-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/recoveryservicesdatareplication/armrecoveryservicesdatareplication/options.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/options.go new file mode 100644 index 000000000000..a802a5622ecd --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/options.go @@ -0,0 +1,293 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +// AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityOptions contains the optional parameters for the AzureSiteRecoveryManagementServiceAPIClient.CheckNameAvailability +// method. +type AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityOptions struct { + // Resource details. + Body *CheckNameAvailabilityModel +} + +// AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightOptions contains the optional parameters for the AzureSiteRecoveryManagementServiceAPIClient.DeploymentPreflight +// method. +type AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightOptions struct { + // Deployment preflight model. + Body *DeploymentPreflightModel +} + +// DraClientBeginCreateOptions contains the optional parameters for the DraClient.BeginCreate method. +type DraClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DraClientBeginDeleteOptions contains the optional parameters for the DraClient.BeginDelete method. +type DraClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DraClientGetOptions contains the optional parameters for the DraClient.Get method. +type DraClientGetOptions struct { + // placeholder for future optional parameters +} + +// DraClientListOptions contains the optional parameters for the DraClient.NewListPager method. +type DraClientListOptions struct { + // placeholder for future optional parameters +} + +// DraOperationStatusClientGetOptions contains the optional parameters for the DraOperationStatusClient.Get method. +type DraOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// EmailConfigurationClientCreateOptions contains the optional parameters for the EmailConfigurationClient.Create method. +type EmailConfigurationClientCreateOptions struct { + // placeholder for future optional parameters +} + +// EmailConfigurationClientGetOptions contains the optional parameters for the EmailConfigurationClient.Get method. +type EmailConfigurationClientGetOptions struct { + // placeholder for future optional parameters +} + +// EmailConfigurationClientListOptions contains the optional parameters for the EmailConfigurationClient.NewListPager method. +type EmailConfigurationClientListOptions struct { + // placeholder for future optional parameters +} + +// EventClientGetOptions contains the optional parameters for the EventClient.Get method. +type EventClientGetOptions struct { + // placeholder for future optional parameters +} + +// EventClientListOptions contains the optional parameters for the EventClient.NewListPager method. +type EventClientListOptions struct { + // Continuation token. + ContinuationToken *string + + // Filter string. + Filter *string +} + +// FabricClientBeginCreateOptions contains the optional parameters for the FabricClient.BeginCreate method. +type FabricClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FabricClientBeginDeleteOptions contains the optional parameters for the FabricClient.BeginDelete method. +type FabricClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FabricClientBeginUpdateOptions contains the optional parameters for the FabricClient.BeginUpdate method. +type FabricClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FabricClientGetOptions contains the optional parameters for the FabricClient.Get method. +type FabricClientGetOptions struct { + // placeholder for future optional parameters +} + +// FabricClientListBySubscriptionOptions contains the optional parameters for the FabricClient.NewListBySubscriptionPager +// method. +type FabricClientListBySubscriptionOptions struct { + // Continuation token from the previous call. + ContinuationToken *string +} + +// FabricClientListOptions contains the optional parameters for the FabricClient.NewListPager method. +type FabricClientListOptions struct { + // Continuation token from the previous call. + ContinuationToken *string +} + +// FabricOperationsStatusClientGetOptions contains the optional parameters for the FabricOperationsStatusClient.Get method. +type FabricOperationsStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PolicyClientBeginCreateOptions contains the optional parameters for the PolicyClient.BeginCreate method. +type PolicyClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PolicyClientBeginDeleteOptions contains the optional parameters for the PolicyClient.BeginDelete method. +type PolicyClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PolicyClientGetOptions contains the optional parameters for the PolicyClient.Get method. +type PolicyClientGetOptions struct { + // placeholder for future optional parameters +} + +// PolicyClientListOptions contains the optional parameters for the PolicyClient.NewListPager method. +type PolicyClientListOptions struct { + // placeholder for future optional parameters +} + +// PolicyOperationStatusClientGetOptions contains the optional parameters for the PolicyOperationStatusClient.Get method. +type PolicyOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProtectedItemClientBeginCreateOptions contains the optional parameters for the ProtectedItemClient.BeginCreate method. +type ProtectedItemClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProtectedItemClientBeginDeleteOptions contains the optional parameters for the ProtectedItemClient.BeginDelete method. +type ProtectedItemClientBeginDeleteOptions struct { + // A flag indicating whether to do force delete or not. + ForceDelete *bool + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProtectedItemClientBeginPlannedFailoverOptions contains the optional parameters for the ProtectedItemClient.BeginPlannedFailover +// method. +type ProtectedItemClientBeginPlannedFailoverOptions struct { + // Planned failover model. + Body *PlannedFailoverModel + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ProtectedItemClientGetOptions contains the optional parameters for the ProtectedItemClient.Get method. +type ProtectedItemClientGetOptions struct { + // placeholder for future optional parameters +} + +// ProtectedItemClientListOptions contains the optional parameters for the ProtectedItemClient.NewListPager method. +type ProtectedItemClientListOptions struct { + // placeholder for future optional parameters +} + +// ProtectedItemOperationStatusClientGetOptions contains the optional parameters for the ProtectedItemOperationStatusClient.Get +// method. +type ProtectedItemOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// RecoveryPointsClientGetOptions contains the optional parameters for the RecoveryPointsClient.Get method. +type RecoveryPointsClientGetOptions struct { + // placeholder for future optional parameters +} + +// RecoveryPointsClientListOptions contains the optional parameters for the RecoveryPointsClient.NewListPager method. +type RecoveryPointsClientListOptions struct { + // placeholder for future optional parameters +} + +// ReplicationExtensionClientBeginCreateOptions contains the optional parameters for the ReplicationExtensionClient.BeginCreate +// method. +type ReplicationExtensionClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReplicationExtensionClientBeginDeleteOptions contains the optional parameters for the ReplicationExtensionClient.BeginDelete +// method. +type ReplicationExtensionClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReplicationExtensionClientGetOptions contains the optional parameters for the ReplicationExtensionClient.Get method. +type ReplicationExtensionClientGetOptions struct { + // placeholder for future optional parameters +} + +// ReplicationExtensionClientListOptions contains the optional parameters for the ReplicationExtensionClient.NewListPager +// method. +type ReplicationExtensionClientListOptions struct { + // placeholder for future optional parameters +} + +// ReplicationExtensionOperationStatusClientGetOptions contains the optional parameters for the ReplicationExtensionOperationStatusClient.Get +// method. +type ReplicationExtensionOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// VaultClientBeginCreateOptions contains the optional parameters for the VaultClient.BeginCreate method. +type VaultClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VaultClientBeginDeleteOptions contains the optional parameters for the VaultClient.BeginDelete method. +type VaultClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VaultClientBeginUpdateOptions contains the optional parameters for the VaultClient.BeginUpdate method. +type VaultClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VaultClientGetOptions contains the optional parameters for the VaultClient.Get method. +type VaultClientGetOptions struct { + // placeholder for future optional parameters +} + +// VaultClientListBySubscriptionOptions contains the optional parameters for the VaultClient.NewListBySubscriptionPager method. +type VaultClientListBySubscriptionOptions struct { + // Continuation token from the previous call. + ContinuationToken *string +} + +// VaultClientListOptions contains the optional parameters for the VaultClient.NewListPager method. +type VaultClientListOptions struct { + // Continuation token from the previous call. + ContinuationToken *string +} + +// VaultOperationStatusClientGetOptions contains the optional parameters for the VaultOperationStatusClient.Get method. +type VaultOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowClientGetOptions contains the optional parameters for the WorkflowClient.Get method. +type WorkflowClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowClientListOptions contains the optional parameters for the WorkflowClient.NewListPager method. +type WorkflowClientListOptions struct { + // Continuation token. + ContinuationToken *string + + // Filter string. + Filter *string +} + +// WorkflowOperationStatusClientGetOptions contains the optional parameters for the WorkflowOperationStatusClient.Get method. +type WorkflowOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/policy_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/policy_client.go new file mode 100644 index 000000000000..ff8d772b3886 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/policy_client.go @@ -0,0 +1,318 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PolicyClient contains the methods for the Policy group. +// Don't use this type directly, use NewPolicyClient() instead. +type PolicyClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPolicyClient creates a new instance of PolicyClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPolicyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyClient, error) { + cl, err := arm.NewClient(moduleName+".PolicyClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PolicyClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates the policy. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - policyName - The policy name. +// - body - Policy model. +// - options - PolicyClientBeginCreateOptions contains the optional parameters for the PolicyClient.BeginCreate method. +func (client *PolicyClient) BeginCreate(ctx context.Context, resourceGroupName string, vaultName string, policyName string, body PolicyModel, options *PolicyClientBeginCreateOptions) (*runtime.Poller[PolicyClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, vaultName, policyName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PolicyClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PolicyClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Creates the policy. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *PolicyClient) create(ctx context.Context, resourceGroupName string, vaultName string, policyName string, body PolicyModel, options *PolicyClientBeginCreateOptions) (*http.Response, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceGroupName, vaultName, policyName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *PolicyClient) createCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, policyName string, body PolicyModel, options *PolicyClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if policyName == "" { + return nil, errors.New("parameter policyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyName}", url.PathEscape(policyName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Removes the policy. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - policyName - The policy name. +// - options - PolicyClientBeginDeleteOptions contains the optional parameters for the PolicyClient.BeginDelete method. +func (client *PolicyClient) BeginDelete(ctx context.Context, resourceGroupName string, vaultName string, policyName string, options *PolicyClientBeginDeleteOptions) (*runtime.Poller[PolicyClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, vaultName, policyName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PolicyClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PolicyClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Removes the policy. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *PolicyClient) deleteOperation(ctx context.Context, resourceGroupName string, vaultName string, policyName string, options *PolicyClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, policyName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, policyName string, options *PolicyClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if policyName == "" { + return nil, errors.New("parameter policyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyName}", url.PathEscape(policyName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the details of the policy. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - policyName - The policy name. +// - options - PolicyClientGetOptions contains the optional parameters for the PolicyClient.Get method. +func (client *PolicyClient) Get(ctx context.Context, resourceGroupName string, vaultName string, policyName string, options *PolicyClientGetOptions) (PolicyClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, policyName, options) + if err != nil { + return PolicyClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PolicyClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, policyName string, options *PolicyClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if policyName == "" { + return nil, errors.New("parameter policyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyName}", url.PathEscape(policyName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PolicyClient) getHandleResponse(resp *http.Response) (PolicyClientGetResponse, error) { + result := PolicyClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyModel); err != nil { + return PolicyClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of policies in the given vault. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - PolicyClientListOptions contains the optional parameters for the PolicyClient.NewListPager method. +func (client *PolicyClient) NewListPager(resourceGroupName string, vaultName string, options *PolicyClientListOptions) *runtime.Pager[PolicyClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[PolicyClientListResponse]{ + More: func(page PolicyClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PolicyClientListResponse) (PolicyClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return PolicyClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PolicyClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *PolicyClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *PolicyClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *PolicyClient) listHandleResponse(resp *http.Response) (PolicyClientListResponse, error) { + result := PolicyClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PolicyModelCollection); err != nil { + return PolicyClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/policyoperationstatus_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/policyoperationstatus_client.go new file mode 100644 index 000000000000..2d1789c49c3e --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/policyoperationstatus_client.go @@ -0,0 +1,112 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// PolicyOperationStatusClient contains the methods for the PolicyOperationStatus group. +// Don't use this type directly, use NewPolicyOperationStatusClient() instead. +type PolicyOperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPolicyOperationStatusClient creates a new instance of PolicyOperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPolicyOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PolicyOperationStatusClient, error) { + cl, err := arm.NewClient(moduleName+".PolicyOperationStatusClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PolicyOperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Tracks the results of an asynchronous operation on the policy. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - policyName - The policy name. +// - operationID - The ID of an ongoing async operation. +// - options - PolicyOperationStatusClientGetOptions contains the optional parameters for the PolicyOperationStatusClient.Get +// method. +func (client *PolicyOperationStatusClient) Get(ctx context.Context, resourceGroupName string, vaultName string, policyName string, operationID string, options *PolicyOperationStatusClientGetOptions) (PolicyOperationStatusClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, policyName, operationID, options) + if err != nil { + return PolicyOperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PolicyOperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PolicyOperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PolicyOperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, policyName string, operationID string, options *PolicyOperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationPolicies/{policyName}/operations/{operationId}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if policyName == "" { + return nil, errors.New("parameter policyName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyName}", url.PathEscape(policyName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PolicyOperationStatusClient) getHandleResponse(resp *http.Response) (PolicyOperationStatusClientGetResponse, error) { + result := PolicyOperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return PolicyOperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/polymorphic_helpers.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/polymorphic_helpers.go new file mode 100644 index 000000000000..286a31af02aa --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/polymorphic_helpers.go @@ -0,0 +1,216 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import "encoding/json" + +func unmarshalDraModelCustomPropertiesClassification(rawMsg json.RawMessage) (DraModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b DraModelCustomPropertiesClassification + switch m["instanceType"] { + case "VMware": + b = &VMwareDraModelCustomProperties{} + default: + b = &DraModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalEventModelCustomPropertiesClassification(rawMsg json.RawMessage) (EventModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b EventModelCustomPropertiesClassification + switch m["instanceType"] { + case "HyperVToAzStackHCI": + b = &HyperVToAzStackHCIEventModelCustomProperties{} + default: + b = &EventModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalFabricModelCustomPropertiesClassification(rawMsg json.RawMessage) (FabricModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b FabricModelCustomPropertiesClassification + switch m["instanceType"] { + case "AzStackHCI": + b = &AzStackHCIFabricModelCustomProperties{} + case "HyperVMigrate": + b = &HyperVMigrateFabricModelCustomProperties{} + case "VMwareMigrate": + b = &VMwareMigrateFabricModelCustomProperties{} + default: + b = &FabricModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalPlannedFailoverModelCustomPropertiesClassification(rawMsg json.RawMessage) (PlannedFailoverModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b PlannedFailoverModelCustomPropertiesClassification + switch m["instanceType"] { + case "HyperVToAzStackHCI": + b = &HyperVToAzStackHCIPlannedFailoverModelCustomProperties{} + case "VMwareToAzStackHCI": + b = &VMwareToAzStackHCIPlannedFailoverModelCustomProperties{} + default: + b = &PlannedFailoverModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalPolicyModelCustomPropertiesClassification(rawMsg json.RawMessage) (PolicyModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b PolicyModelCustomPropertiesClassification + switch m["instanceType"] { + case "HyperVToAzStackHCI": + b = &HyperVToAzStackHCIPolicyModelCustomProperties{} + case "VMwareToAzStackHCI": + b = &VMwareToAzStackHCIPolicyModelCustomProperties{} + default: + b = &PolicyModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalProtectedItemModelCustomPropertiesClassification(rawMsg json.RawMessage) (ProtectedItemModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b ProtectedItemModelCustomPropertiesClassification + switch m["instanceType"] { + case "HyperVToAzStackHCI": + b = &HyperVToAzStackHCIProtectedItemModelCustomProperties{} + case "VMwareToAzStackHCI": + b = &VMwareToAzStackHCIProtectedItemModelCustomProperties{} + default: + b = &ProtectedItemModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalRecoveryPointModelCustomPropertiesClassification(rawMsg json.RawMessage) (RecoveryPointModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b RecoveryPointModelCustomPropertiesClassification + switch m["instanceType"] { + case "HyperVToAzStackHCI": + b = &HyperVToAzStackHCIRecoveryPointModelCustomProperties{} + default: + b = &RecoveryPointModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalReplicationExtensionModelCustomPropertiesClassification(rawMsg json.RawMessage) (ReplicationExtensionModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b ReplicationExtensionModelCustomPropertiesClassification + switch m["instanceType"] { + case "HyperVToAzStackHCI": + b = &HyperVToAzStackHCIReplicationExtensionModelCustomProperties{} + case "VMwareToAzStackHCI": + b = &VMwareToAzStackHCIReplicationExtensionModelCustomProperties{} + default: + b = &ReplicationExtensionModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalWorkflowModelCustomPropertiesClassification(rawMsg json.RawMessage) (WorkflowModelCustomPropertiesClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b WorkflowModelCustomPropertiesClassification + switch m["instanceType"] { + case "FailoverWorkflowDetails": + b = &FailoverWorkflowModelCustomProperties{} + case "TestFailoverCleanupWorkflowDetails": + b = &TestFailoverCleanupWorkflowModelCustomProperties{} + case "TestFailoverWorkflowDetails": + b = &TestFailoverWorkflowModelCustomProperties{} + default: + b = &WorkflowModelCustomProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/protecteditem_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/protecteditem_client.go new file mode 100644 index 000000000000..36adb0dc3cb1 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/protecteditem_client.go @@ -0,0 +1,402 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ProtectedItemClient contains the methods for the ProtectedItem group. +// Don't use this type directly, use NewProtectedItemClient() instead. +type ProtectedItemClient struct { + internal *arm.Client + subscriptionID string +} + +// NewProtectedItemClient creates a new instance of ProtectedItemClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewProtectedItemClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProtectedItemClient, error) { + cl, err := arm.NewClient(moduleName+".ProtectedItemClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ProtectedItemClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - protectedItemName - The protected item name. +// - body - Protected item model. +// - options - ProtectedItemClientBeginCreateOptions contains the optional parameters for the ProtectedItemClient.BeginCreate +// method. +func (client *ProtectedItemClient) BeginCreate(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, body ProtectedItemModel, options *ProtectedItemClientBeginCreateOptions) (*runtime.Poller[ProtectedItemClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, vaultName, protectedItemName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProtectedItemClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ProtectedItemClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Creates the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *ProtectedItemClient) create(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, body ProtectedItemModel, options *ProtectedItemClientBeginCreateOptions) (*http.Response, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceGroupName, vaultName, protectedItemName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *ProtectedItemClient) createCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, body ProtectedItemModel, options *ProtectedItemClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if protectedItemName == "" { + return nil, errors.New("parameter protectedItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{protectedItemName}", url.PathEscape(protectedItemName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Removes the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - protectedItemName - The protected item name. +// - options - ProtectedItemClientBeginDeleteOptions contains the optional parameters for the ProtectedItemClient.BeginDelete +// method. +func (client *ProtectedItemClient) BeginDelete(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientBeginDeleteOptions) (*runtime.Poller[ProtectedItemClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, vaultName, protectedItemName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProtectedItemClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ProtectedItemClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Removes the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *ProtectedItemClient) deleteOperation(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, protectedItemName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProtectedItemClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if protectedItemName == "" { + return nil, errors.New("parameter protectedItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{protectedItemName}", url.PathEscape(protectedItemName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.ForceDelete != nil { + reqQP.Set("forceDelete", strconv.FormatBool(*options.ForceDelete)) + } + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the details of the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - protectedItemName - The protected item name. +// - options - ProtectedItemClientGetOptions contains the optional parameters for the ProtectedItemClient.Get method. +func (client *ProtectedItemClient) Get(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientGetOptions) (ProtectedItemClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, protectedItemName, options) + if err != nil { + return ProtectedItemClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProtectedItemClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProtectedItemClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ProtectedItemClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if protectedItemName == "" { + return nil, errors.New("parameter protectedItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{protectedItemName}", url.PathEscape(protectedItemName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProtectedItemClient) getHandleResponse(resp *http.Response) (ProtectedItemClientGetResponse, error) { + result := ProtectedItemClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProtectedItemModel); err != nil { + return ProtectedItemClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of protected items in the given vault. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - ProtectedItemClientListOptions contains the optional parameters for the ProtectedItemClient.NewListPager method. +func (client *ProtectedItemClient) NewListPager(resourceGroupName string, vaultName string, options *ProtectedItemClientListOptions) *runtime.Pager[ProtectedItemClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ProtectedItemClientListResponse]{ + More: func(page ProtectedItemClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ProtectedItemClientListResponse) (ProtectedItemClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ProtectedItemClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProtectedItemClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ProtectedItemClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ProtectedItemClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *ProtectedItemClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ProtectedItemClient) listHandleResponse(resp *http.Response) (ProtectedItemClientListResponse, error) { + result := ProtectedItemClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ProtectedItemModelCollection); err != nil { + return ProtectedItemClientListResponse{}, err + } + return result, nil +} + +// BeginPlannedFailover - Performs the planned failover on the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - protectedItemName - The protected item name. +// - options - ProtectedItemClientBeginPlannedFailoverOptions contains the optional parameters for the ProtectedItemClient.BeginPlannedFailover +// method. +func (client *ProtectedItemClient) BeginPlannedFailover(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientBeginPlannedFailoverOptions) (*runtime.Poller[ProtectedItemClientPlannedFailoverResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.plannedFailover(ctx, resourceGroupName, vaultName, protectedItemName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ProtectedItemClientPlannedFailoverResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ProtectedItemClientPlannedFailoverResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// PlannedFailover - Performs the planned failover on the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *ProtectedItemClient) plannedFailover(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientBeginPlannedFailoverOptions) (*http.Response, error) { + var err error + req, err := client.plannedFailoverCreateRequest(ctx, resourceGroupName, vaultName, protectedItemName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// plannedFailoverCreateRequest creates the PlannedFailover request. +func (client *ProtectedItemClient) plannedFailoverCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *ProtectedItemClientBeginPlannedFailoverOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/plannedFailover" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if protectedItemName == "" { + return nil, errors.New("parameter protectedItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{protectedItemName}", url.PathEscape(protectedItemName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Body != nil { + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil + } + return req, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/protecteditemoperationstatus_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/protecteditemoperationstatus_client.go new file mode 100644 index 000000000000..1c22f1c419a7 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/protecteditemoperationstatus_client.go @@ -0,0 +1,112 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ProtectedItemOperationStatusClient contains the methods for the ProtectedItemOperationStatus group. +// Don't use this type directly, use NewProtectedItemOperationStatusClient() instead. +type ProtectedItemOperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewProtectedItemOperationStatusClient creates a new instance of ProtectedItemOperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewProtectedItemOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ProtectedItemOperationStatusClient, error) { + cl, err := arm.NewClient(moduleName+".ProtectedItemOperationStatusClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ProtectedItemOperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Tracks the results of an asynchronous operation on the protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - protectedItemName - The protected item name. +// - operationID - The ID of an ongoing async operation. +// - options - ProtectedItemOperationStatusClientGetOptions contains the optional parameters for the ProtectedItemOperationStatusClient.Get +// method. +func (client *ProtectedItemOperationStatusClient) Get(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, operationID string, options *ProtectedItemOperationStatusClientGetOptions) (ProtectedItemOperationStatusClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, protectedItemName, operationID, options) + if err != nil { + return ProtectedItemOperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ProtectedItemOperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ProtectedItemOperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ProtectedItemOperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, operationID string, options *ProtectedItemOperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/operations/{operationId}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if protectedItemName == "" { + return nil, errors.New("parameter protectedItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{protectedItemName}", url.PathEscape(protectedItemName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProtectedItemOperationStatusClient) getHandleResponse(resp *http.Response) (ProtectedItemOperationStatusClientGetResponse, error) { + result := ProtectedItemOperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return ProtectedItemOperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/recoverypoints_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/recoverypoints_client.go new file mode 100644 index 000000000000..df7254d8e4bf --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/recoverypoints_client.go @@ -0,0 +1,182 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// RecoveryPointsClient contains the methods for the RecoveryPoints group. +// Don't use this type directly, use NewRecoveryPointsClient() instead. +type RecoveryPointsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewRecoveryPointsClient creates a new instance of RecoveryPointsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewRecoveryPointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RecoveryPointsClient, error) { + cl, err := arm.NewClient(moduleName+".RecoveryPointsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &RecoveryPointsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets the details of the recovery point of a protected item. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - protectedItemName - The protected item name. +// - recoveryPointName - The recovery point name. +// - options - RecoveryPointsClientGetOptions contains the optional parameters for the RecoveryPointsClient.Get method. +func (client *RecoveryPointsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, recoveryPointName string, options *RecoveryPointsClientGetOptions) (RecoveryPointsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, protectedItemName, recoveryPointName, options) + if err != nil { + return RecoveryPointsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecoveryPointsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecoveryPointsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *RecoveryPointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, recoveryPointName string, options *RecoveryPointsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints/{recoveryPointName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if protectedItemName == "" { + return nil, errors.New("parameter protectedItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{protectedItemName}", url.PathEscape(protectedItemName)) + if recoveryPointName == "" { + return nil, errors.New("parameter recoveryPointName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{recoveryPointName}", url.PathEscape(recoveryPointName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *RecoveryPointsClient) getHandleResponse(resp *http.Response) (RecoveryPointsClientGetResponse, error) { + result := RecoveryPointsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecoveryPointModel); err != nil { + return RecoveryPointsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of recovery points of the given protected item. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - protectedItemName - The protected item name. +// - options - RecoveryPointsClientListOptions contains the optional parameters for the RecoveryPointsClient.NewListPager method. +func (client *RecoveryPointsClient) NewListPager(resourceGroupName string, vaultName string, protectedItemName string, options *RecoveryPointsClientListOptions) *runtime.Pager[RecoveryPointsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[RecoveryPointsClientListResponse]{ + More: func(page RecoveryPointsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *RecoveryPointsClientListResponse) (RecoveryPointsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, protectedItemName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return RecoveryPointsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return RecoveryPointsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return RecoveryPointsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *RecoveryPointsClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, protectedItemName string, options *RecoveryPointsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/protectedItems/{protectedItemName}/recoveryPoints" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if protectedItemName == "" { + return nil, errors.New("parameter protectedItemName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{protectedItemName}", url.PathEscape(protectedItemName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *RecoveryPointsClient) listHandleResponse(resp *http.Response) (RecoveryPointsClientListResponse, error) { + result := RecoveryPointsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RecoveryPointModelCollection); err != nil { + return RecoveryPointsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/replicationextension_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/replicationextension_client.go new file mode 100644 index 000000000000..8c9b0951e71d --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/replicationextension_client.go @@ -0,0 +1,322 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ReplicationExtensionClient contains the methods for the ReplicationExtension group. +// Don't use this type directly, use NewReplicationExtensionClient() instead. +type ReplicationExtensionClient struct { + internal *arm.Client + subscriptionID string +} + +// NewReplicationExtensionClient creates a new instance of ReplicationExtensionClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewReplicationExtensionClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReplicationExtensionClient, error) { + cl, err := arm.NewClient(moduleName+".ReplicationExtensionClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ReplicationExtensionClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates the replication extension in the given vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - replicationExtensionName - The replication extension name. +// - body - Replication extension model. +// - options - ReplicationExtensionClientBeginCreateOptions contains the optional parameters for the ReplicationExtensionClient.BeginCreate +// method. +func (client *ReplicationExtensionClient) BeginCreate(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, body ReplicationExtensionModel, options *ReplicationExtensionClientBeginCreateOptions) (*runtime.Poller[ReplicationExtensionClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, vaultName, replicationExtensionName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationExtensionClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ReplicationExtensionClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Creates the replication extension in the given vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *ReplicationExtensionClient) create(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, body ReplicationExtensionModel, options *ReplicationExtensionClientBeginCreateOptions) (*http.Response, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceGroupName, vaultName, replicationExtensionName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *ReplicationExtensionClient) createCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, body ReplicationExtensionModel, options *ReplicationExtensionClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if replicationExtensionName == "" { + return nil, errors.New("parameter replicationExtensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationExtensionName}", url.PathEscape(replicationExtensionName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes the replication extension in the given vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - replicationExtensionName - The replication extension name. +// - options - ReplicationExtensionClientBeginDeleteOptions contains the optional parameters for the ReplicationExtensionClient.BeginDelete +// method. +func (client *ReplicationExtensionClient) BeginDelete(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, options *ReplicationExtensionClientBeginDeleteOptions) (*runtime.Poller[ReplicationExtensionClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, vaultName, replicationExtensionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReplicationExtensionClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ReplicationExtensionClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Deletes the replication extension in the given vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *ReplicationExtensionClient) deleteOperation(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, options *ReplicationExtensionClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, replicationExtensionName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ReplicationExtensionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, options *ReplicationExtensionClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if replicationExtensionName == "" { + return nil, errors.New("parameter replicationExtensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationExtensionName}", url.PathEscape(replicationExtensionName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the details of the replication extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - replicationExtensionName - The replication extension name. +// - options - ReplicationExtensionClientGetOptions contains the optional parameters for the ReplicationExtensionClient.Get +// method. +func (client *ReplicationExtensionClient) Get(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, options *ReplicationExtensionClientGetOptions) (ReplicationExtensionClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, replicationExtensionName, options) + if err != nil { + return ReplicationExtensionClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReplicationExtensionClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReplicationExtensionClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ReplicationExtensionClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, options *ReplicationExtensionClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if replicationExtensionName == "" { + return nil, errors.New("parameter replicationExtensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationExtensionName}", url.PathEscape(replicationExtensionName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ReplicationExtensionClient) getHandleResponse(resp *http.Response) (ReplicationExtensionClientGetResponse, error) { + result := ReplicationExtensionClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReplicationExtensionModel); err != nil { + return ReplicationExtensionClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of replication extensions in the given vault. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - ReplicationExtensionClientListOptions contains the optional parameters for the ReplicationExtensionClient.NewListPager +// method. +func (client *ReplicationExtensionClient) NewListPager(resourceGroupName string, vaultName string, options *ReplicationExtensionClientListOptions) *runtime.Pager[ReplicationExtensionClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ReplicationExtensionClientListResponse]{ + More: func(page ReplicationExtensionClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ReplicationExtensionClientListResponse) (ReplicationExtensionClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ReplicationExtensionClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReplicationExtensionClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ReplicationExtensionClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ReplicationExtensionClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *ReplicationExtensionClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ReplicationExtensionClient) listHandleResponse(resp *http.Response) (ReplicationExtensionClientListResponse, error) { + result := ReplicationExtensionClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ReplicationExtensionModelCollection); err != nil { + return ReplicationExtensionClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/replicationextensionoperationstatus_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/replicationextensionoperationstatus_client.go new file mode 100644 index 000000000000..0ff29676002c --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/replicationextensionoperationstatus_client.go @@ -0,0 +1,112 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// ReplicationExtensionOperationStatusClient contains the methods for the ReplicationExtensionOperationStatus group. +// Don't use this type directly, use NewReplicationExtensionOperationStatusClient() instead. +type ReplicationExtensionOperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewReplicationExtensionOperationStatusClient creates a new instance of ReplicationExtensionOperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewReplicationExtensionOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ReplicationExtensionOperationStatusClient, error) { + cl, err := arm.NewClient(moduleName+".ReplicationExtensionOperationStatusClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ReplicationExtensionOperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Tracks the results of an asynchronous operation on the replication extension. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - replicationExtensionName - The replication extension name. +// - operationID - The ID of an ongoing async operation. +// - options - ReplicationExtensionOperationStatusClientGetOptions contains the optional parameters for the ReplicationExtensionOperationStatusClient.Get +// method. +func (client *ReplicationExtensionOperationStatusClient) Get(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, operationID string, options *ReplicationExtensionOperationStatusClientGetOptions) (ReplicationExtensionOperationStatusClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, replicationExtensionName, operationID, options) + if err != nil { + return ReplicationExtensionOperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ReplicationExtensionOperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReplicationExtensionOperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ReplicationExtensionOperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, replicationExtensionName string, operationID string, options *ReplicationExtensionOperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/replicationExtensions/{replicationExtensionName}/operations/{operationId}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if replicationExtensionName == "" { + return nil, errors.New("parameter replicationExtensionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{replicationExtensionName}", url.PathEscape(replicationExtensionName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ReplicationExtensionOperationStatusClient) getHandleResponse(resp *http.Response) (ReplicationExtensionOperationStatusClientGetResponse, error) { + result := ReplicationExtensionOperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return ReplicationExtensionOperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/response_types.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/response_types.go new file mode 100644 index 000000000000..8d3e756a0220 --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/response_types.go @@ -0,0 +1,291 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +// AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse contains the response from method AzureSiteRecoveryManagementServiceAPIClient.CheckNameAvailability. +type AzureSiteRecoveryManagementServiceAPIClientCheckNameAvailabilityResponse struct { + // Check name availability response model. + CheckNameAvailabilityResponseModel +} + +// AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse contains the response from method AzureSiteRecoveryManagementServiceAPIClient.DeploymentPreflight. +type AzureSiteRecoveryManagementServiceAPIClientDeploymentPreflightResponse struct { + // Deployment preflight model. + DeploymentPreflightModel +} + +// DraClientCreateResponse contains the response from method DraClient.BeginCreate. +type DraClientCreateResponse struct { + // Dra model. + DraModel +} + +// DraClientDeleteResponse contains the response from method DraClient.BeginDelete. +type DraClientDeleteResponse struct { + // placeholder for future response values +} + +// DraClientGetResponse contains the response from method DraClient.Get. +type DraClientGetResponse struct { + // Dra model. + DraModel +} + +// DraClientListResponse contains the response from method DraClient.NewListPager. +type DraClientListResponse struct { + // Dra model collection. + DraModelCollection +} + +// DraOperationStatusClientGetResponse contains the response from method DraOperationStatusClient.Get. +type DraOperationStatusClientGetResponse struct { + // Defines the operation status. + OperationStatus +} + +// EmailConfigurationClientCreateResponse contains the response from method EmailConfigurationClient.Create. +type EmailConfigurationClientCreateResponse struct { + // Email configuration model. + EmailConfigurationModel +} + +// EmailConfigurationClientGetResponse contains the response from method EmailConfigurationClient.Get. +type EmailConfigurationClientGetResponse struct { + // Email configuration model. + EmailConfigurationModel +} + +// EmailConfigurationClientListResponse contains the response from method EmailConfigurationClient.NewListPager. +type EmailConfigurationClientListResponse struct { + // Email configuration model collection. + EmailConfigurationModelCollection +} + +// EventClientGetResponse contains the response from method EventClient.Get. +type EventClientGetResponse struct { + // Event model. + EventModel +} + +// EventClientListResponse contains the response from method EventClient.NewListPager. +type EventClientListResponse struct { + // Event model collection. + EventModelCollection +} + +// FabricClientCreateResponse contains the response from method FabricClient.BeginCreate. +type FabricClientCreateResponse struct { + // Fabric model. + FabricModel +} + +// FabricClientDeleteResponse contains the response from method FabricClient.BeginDelete. +type FabricClientDeleteResponse struct { + // placeholder for future response values +} + +// FabricClientGetResponse contains the response from method FabricClient.Get. +type FabricClientGetResponse struct { + // Fabric model. + FabricModel +} + +// FabricClientListBySubscriptionResponse contains the response from method FabricClient.NewListBySubscriptionPager. +type FabricClientListBySubscriptionResponse struct { + // Fabric model collection. + FabricModelCollection +} + +// FabricClientListResponse contains the response from method FabricClient.NewListPager. +type FabricClientListResponse struct { + // Fabric model collection. + FabricModelCollection +} + +// FabricClientUpdateResponse contains the response from method FabricClient.BeginUpdate. +type FabricClientUpdateResponse struct { + // Fabric model. + FabricModel +} + +// FabricOperationsStatusClientGetResponse contains the response from method FabricOperationsStatusClient.Get. +type FabricOperationsStatusClientGetResponse struct { + // Defines the operation status. + OperationStatus +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// PolicyClientCreateResponse contains the response from method PolicyClient.BeginCreate. +type PolicyClientCreateResponse struct { + // Policy model. + PolicyModel +} + +// PolicyClientDeleteResponse contains the response from method PolicyClient.BeginDelete. +type PolicyClientDeleteResponse struct { + // placeholder for future response values +} + +// PolicyClientGetResponse contains the response from method PolicyClient.Get. +type PolicyClientGetResponse struct { + // Policy model. + PolicyModel +} + +// PolicyClientListResponse contains the response from method PolicyClient.NewListPager. +type PolicyClientListResponse struct { + // Policy model collection. + PolicyModelCollection +} + +// PolicyOperationStatusClientGetResponse contains the response from method PolicyOperationStatusClient.Get. +type PolicyOperationStatusClientGetResponse struct { + // Defines the operation status. + OperationStatus +} + +// ProtectedItemClientCreateResponse contains the response from method ProtectedItemClient.BeginCreate. +type ProtectedItemClientCreateResponse struct { + // Protected item model. + ProtectedItemModel +} + +// ProtectedItemClientDeleteResponse contains the response from method ProtectedItemClient.BeginDelete. +type ProtectedItemClientDeleteResponse struct { + // placeholder for future response values +} + +// ProtectedItemClientGetResponse contains the response from method ProtectedItemClient.Get. +type ProtectedItemClientGetResponse struct { + // Protected item model. + ProtectedItemModel +} + +// ProtectedItemClientListResponse contains the response from method ProtectedItemClient.NewListPager. +type ProtectedItemClientListResponse struct { + // Protected item model collection. + ProtectedItemModelCollection +} + +// ProtectedItemClientPlannedFailoverResponse contains the response from method ProtectedItemClient.BeginPlannedFailover. +type ProtectedItemClientPlannedFailoverResponse struct { + // Planned failover model. + PlannedFailoverModel +} + +// ProtectedItemOperationStatusClientGetResponse contains the response from method ProtectedItemOperationStatusClient.Get. +type ProtectedItemOperationStatusClientGetResponse struct { + // Defines the operation status. + OperationStatus +} + +// RecoveryPointsClientGetResponse contains the response from method RecoveryPointsClient.Get. +type RecoveryPointsClientGetResponse struct { + // Recovery point model. + RecoveryPointModel +} + +// RecoveryPointsClientListResponse contains the response from method RecoveryPointsClient.NewListPager. +type RecoveryPointsClientListResponse struct { + // Recovery point model collection. + RecoveryPointModelCollection +} + +// ReplicationExtensionClientCreateResponse contains the response from method ReplicationExtensionClient.BeginCreate. +type ReplicationExtensionClientCreateResponse struct { + // Replication extension model. + ReplicationExtensionModel +} + +// ReplicationExtensionClientDeleteResponse contains the response from method ReplicationExtensionClient.BeginDelete. +type ReplicationExtensionClientDeleteResponse struct { + // placeholder for future response values +} + +// ReplicationExtensionClientGetResponse contains the response from method ReplicationExtensionClient.Get. +type ReplicationExtensionClientGetResponse struct { + // Replication extension model. + ReplicationExtensionModel +} + +// ReplicationExtensionClientListResponse contains the response from method ReplicationExtensionClient.NewListPager. +type ReplicationExtensionClientListResponse struct { + // Replication extension model collection. + ReplicationExtensionModelCollection +} + +// ReplicationExtensionOperationStatusClientGetResponse contains the response from method ReplicationExtensionOperationStatusClient.Get. +type ReplicationExtensionOperationStatusClientGetResponse struct { + // Defines the operation status. + OperationStatus +} + +// VaultClientCreateResponse contains the response from method VaultClient.BeginCreate. +type VaultClientCreateResponse struct { + // Vault model. + VaultModel +} + +// VaultClientDeleteResponse contains the response from method VaultClient.BeginDelete. +type VaultClientDeleteResponse struct { + // placeholder for future response values +} + +// VaultClientGetResponse contains the response from method VaultClient.Get. +type VaultClientGetResponse struct { + // Vault model. + VaultModel +} + +// VaultClientListBySubscriptionResponse contains the response from method VaultClient.NewListBySubscriptionPager. +type VaultClientListBySubscriptionResponse struct { + // Vault model collection. + VaultModelCollection +} + +// VaultClientListResponse contains the response from method VaultClient.NewListPager. +type VaultClientListResponse struct { + // Vault model collection. + VaultModelCollection +} + +// VaultClientUpdateResponse contains the response from method VaultClient.BeginUpdate. +type VaultClientUpdateResponse struct { + // Vault model. + VaultModel +} + +// VaultOperationStatusClientGetResponse contains the response from method VaultOperationStatusClient.Get. +type VaultOperationStatusClientGetResponse struct { + // Defines the operation status. + OperationStatus +} + +// WorkflowClientGetResponse contains the response from method WorkflowClient.Get. +type WorkflowClientGetResponse struct { + // Workflow model. + WorkflowModel +} + +// WorkflowClientListResponse contains the response from method WorkflowClient.NewListPager. +type WorkflowClientListResponse struct { + // Workflow model collection. + WorkflowModelCollection +} + +// WorkflowOperationStatusClientGetResponse contains the response from method WorkflowOperationStatusClient.Get. +type WorkflowOperationStatusClientGetResponse struct { + // Defines the operation status. + OperationStatus +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/time_rfc3339.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/time_rfc3339.go new file mode 100644 index 000000000000..fefab5b144bd --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/time_rfc3339.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/vault_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/vault_client.go new file mode 100644 index 000000000000..f162b104743a --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/vault_client.go @@ -0,0 +1,431 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// VaultClient contains the methods for the Vault group. +// Don't use this type directly, use NewVaultClient() instead. +type VaultClient struct { + internal *arm.Client + subscriptionID string +} + +// NewVaultClient creates a new instance of VaultClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewVaultClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VaultClient, error) { + cl, err := arm.NewClient(moduleName+".VaultClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VaultClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Creates the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - body - Vault properties. +// - options - VaultClientBeginCreateOptions contains the optional parameters for the VaultClient.BeginCreate method. +func (client *VaultClient) BeginCreate(ctx context.Context, resourceGroupName string, vaultName string, body VaultModel, options *VaultClientBeginCreateOptions) (*runtime.Poller[VaultClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, vaultName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VaultClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VaultClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Create - Creates the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *VaultClient) create(ctx context.Context, resourceGroupName string, vaultName string, body VaultModel, options *VaultClientBeginCreateOptions) (*http.Response, error) { + var err error + req, err := client.createCreateRequest(ctx, resourceGroupName, vaultName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *VaultClient) createCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, body VaultModel, options *VaultClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Removes the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - VaultClientBeginDeleteOptions contains the optional parameters for the VaultClient.BeginDelete method. +func (client *VaultClient) BeginDelete(ctx context.Context, resourceGroupName string, vaultName string, options *VaultClientBeginDeleteOptions) (*runtime.Poller[VaultClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, vaultName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VaultClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VaultClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Removes the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *VaultClient) deleteOperation(ctx context.Context, resourceGroupName string, vaultName string, options *VaultClientBeginDeleteOptions) (*http.Response, error) { + var err error + req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *VaultClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *VaultClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the details of the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - VaultClientGetOptions contains the optional parameters for the VaultClient.Get method. +func (client *VaultClient) Get(ctx context.Context, resourceGroupName string, vaultName string, options *VaultClientGetOptions) (VaultClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, options) + if err != nil { + return VaultClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VaultClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VaultClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VaultClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *VaultClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VaultClient) getHandleResponse(resp *http.Response) (VaultClientGetResponse, error) { + result := VaultClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VaultModel); err != nil { + return VaultClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of vaults in the given subscription and resource group. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - VaultClientListOptions contains the optional parameters for the VaultClient.NewListPager method. +func (client *VaultClient) NewListPager(resourceGroupName string, options *VaultClientListOptions) *runtime.Pager[VaultClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[VaultClientListResponse]{ + More: func(page VaultClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VaultClientListResponse) (VaultClientListResponse, 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 VaultClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VaultClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VaultClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *VaultClient) listCreateRequest(ctx context.Context, resourceGroupName string, options *VaultClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *VaultClient) listHandleResponse(resp *http.Response) (VaultClientListResponse, error) { + result := VaultClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VaultModelCollection); err != nil { + return VaultClientListResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets the list of vaults in the given subscription. +// +// Generated from API version 2021-02-16-preview +// - options - VaultClientListBySubscriptionOptions contains the optional parameters for the VaultClient.NewListBySubscriptionPager +// method. +func (client *VaultClient) NewListBySubscriptionPager(options *VaultClientListBySubscriptionOptions) *runtime.Pager[VaultClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[VaultClientListBySubscriptionResponse]{ + More: func(page VaultClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *VaultClientListBySubscriptionResponse) (VaultClientListBySubscriptionResponse, 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 VaultClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VaultClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return VaultClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *VaultClient) listBySubscriptionCreateRequest(ctx context.Context, options *VaultClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataReplication/replicationVaults" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *VaultClient) listBySubscriptionHandleResponse(resp *http.Response) (VaultClientListBySubscriptionResponse, error) { + result := VaultClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.VaultModelCollection); err != nil { + return VaultClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Performs update on the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - body - Vault properties. +// - options - VaultClientBeginUpdateOptions contains the optional parameters for the VaultClient.BeginUpdate method. +func (client *VaultClient) BeginUpdate(ctx context.Context, resourceGroupName string, vaultName string, body VaultModelUpdate, options *VaultClientBeginUpdateOptions) (*runtime.Poller[VaultClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, vaultName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VaultClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[VaultClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Performs update on the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +func (client *VaultClient) update(ctx context.Context, resourceGroupName string, vaultName string, body VaultModelUpdate, options *VaultClientBeginUpdateOptions) (*http.Response, error) { + var err error + req, err := client.updateCreateRequest(ctx, resourceGroupName, vaultName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *VaultClient) updateCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, body VaultModelUpdate, options *VaultClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/vaultoperationstatus_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/vaultoperationstatus_client.go new file mode 100644 index 000000000000..c0092c75ff7a --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/vaultoperationstatus_client.go @@ -0,0 +1,107 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// VaultOperationStatusClient contains the methods for the VaultOperationStatus group. +// Don't use this type directly, use NewVaultOperationStatusClient() instead. +type VaultOperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewVaultOperationStatusClient creates a new instance of VaultOperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewVaultOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VaultOperationStatusClient, error) { + cl, err := arm.NewClient(moduleName+".VaultOperationStatusClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &VaultOperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Tracks the results of an asynchronous operation on the vault. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - operationID - The ID of an ongoing async operation. +// - options - VaultOperationStatusClientGetOptions contains the optional parameters for the VaultOperationStatusClient.Get +// method. +func (client *VaultOperationStatusClient) Get(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *VaultOperationStatusClientGetOptions) (VaultOperationStatusClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, operationID, options) + if err != nil { + return VaultOperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return VaultOperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VaultOperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *VaultOperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *VaultOperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/operations/{operationId}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *VaultOperationStatusClient) getHandleResponse(resp *http.Response) (VaultOperationStatusClientGetResponse, error) { + result := VaultOperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return VaultOperationStatusClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/workflow_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/workflow_client.go new file mode 100644 index 000000000000..09686fb2ff2e --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/workflow_client.go @@ -0,0 +1,178 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// WorkflowClient contains the methods for the Workflow group. +// Don't use this type directly, use NewWorkflowClient() instead. +type WorkflowClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkflowClient creates a new instance of WorkflowClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkflowClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowClient, error) { + cl, err := arm.NewClient(moduleName+".WorkflowClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkflowClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Gets the details of the job. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - jobName - The job (workflow) name. +// - options - WorkflowClientGetOptions contains the optional parameters for the WorkflowClient.Get method. +func (client *WorkflowClient) Get(ctx context.Context, resourceGroupName string, vaultName string, jobName string, options *WorkflowClientGetOptions) (WorkflowClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, jobName, options) + if err != nil { + return WorkflowClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkflowClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkflowClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, jobName string, options *WorkflowClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkflowClient) getHandleResponse(resp *http.Response) (WorkflowClientGetResponse, error) { + result := WorkflowClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkflowModel); err != nil { + return WorkflowClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Gets the list of jobs in the given vault. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - options - WorkflowClientListOptions contains the optional parameters for the WorkflowClient.NewListPager method. +func (client *WorkflowClient) NewListPager(resourceGroupName string, vaultName string, options *WorkflowClientListOptions) *runtime.Pager[WorkflowClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkflowClientListResponse]{ + More: func(page WorkflowClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkflowClientListResponse) (WorkflowClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return WorkflowClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkflowClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return WorkflowClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *WorkflowClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *WorkflowClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.ContinuationToken != nil { + reqQP.Set("continuationToken", *options.ContinuationToken) + } + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *WorkflowClient) listHandleResponse(resp *http.Response) (WorkflowClientListResponse, error) { + result := WorkflowClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkflowModelCollection); err != nil { + return WorkflowClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/workflowoperationstatus_client.go b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/workflowoperationstatus_client.go new file mode 100644 index 000000000000..e7ad3d24c1be --- /dev/null +++ b/sdk/resourcemanager/recoveryservicesdatareplication/armrecoveryservicesdatareplication/workflowoperationstatus_client.go @@ -0,0 +1,112 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armrecoveryservicesdatareplication + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// WorkflowOperationStatusClient contains the methods for the WorkflowOperationStatus group. +// Don't use this type directly, use NewWorkflowOperationStatusClient() instead. +type WorkflowOperationStatusClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkflowOperationStatusClient creates a new instance of WorkflowOperationStatusClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkflowOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowOperationStatusClient, error) { + cl, err := arm.NewClient(moduleName+".WorkflowOperationStatusClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkflowOperationStatusClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Tracks the results of an asynchronous operation on the job. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2021-02-16-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - vaultName - The vault name. +// - jobName - The job (workflow) name. +// - operationID - The ID of an ongoing async operation. +// - options - WorkflowOperationStatusClientGetOptions contains the optional parameters for the WorkflowOperationStatusClient.Get +// method. +func (client *WorkflowOperationStatusClient) Get(ctx context.Context, resourceGroupName string, vaultName string, jobName string, operationID string, options *WorkflowOperationStatusClientGetOptions) (WorkflowOperationStatusClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, jobName, operationID, options) + if err != nil { + return WorkflowOperationStatusClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkflowOperationStatusClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowOperationStatusClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkflowOperationStatusClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, jobName string, operationID string, options *WorkflowOperationStatusClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataReplication/replicationVaults/{vaultName}/jobs/{jobName}/operations/{operationId}" + 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 vaultName == "" { + return nil, errors.New("parameter vaultName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{vaultName}", url.PathEscape(vaultName)) + if jobName == "" { + return nil, errors.New("parameter jobName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{jobName}", url.PathEscape(jobName)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-02-16-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkflowOperationStatusClient) getHandleResponse(resp *http.Response) (WorkflowOperationStatusClientGetResponse, error) { + result := WorkflowOperationStatusClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationStatus); err != nil { + return WorkflowOperationStatusClientGetResponse{}, err + } + return result, nil +}