diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/CHANGELOG.md b/sdk/resourcemanager/dataprotection/armdataprotection/CHANGELOG.md index 2ef316a274c9..add273ddbe93 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/CHANGELOG.md +++ b/sdk/resourcemanager/dataprotection/armdataprotection/CHANGELOG.md @@ -1,5 +1,47 @@ # Release History +## 3.0.0 (2023-11-10) +### Breaking Changes + +- Type of `BaseResourceProperties.ObjectType` has been changed from `*string` to `*ResourcePropertiesObjectType` +- Function `timeRFC3339.MarshalText` has been removed +- Function `*timeRFC3339.Parse` has been removed +- Function `*timeRFC3339.UnmarshalText` has been removed + +### Features Added + +- New enum type `RecoveryPointCompletionState` with values `RecoveryPointCompletionStateCompleted`, `RecoveryPointCompletionStatePartial` +- New enum type `ResourcePropertiesObjectType` with values `ResourcePropertiesObjectTypeDefaultResourceProperties` +- New function `*BackupInstancesClient.BeginTriggerCrossRegionRestore(context.Context, string, string, CrossRegionRestoreRequestObject, *BackupInstancesClientBeginTriggerCrossRegionRestoreOptions) (*runtime.Poller[BackupInstancesClientTriggerCrossRegionRestoreResponse], error)` +- New function `*BackupInstancesClient.BeginValidateCrossRegionRestore(context.Context, string, string, ValidateCrossRegionRestoreRequestObject, *BackupInstancesClientBeginValidateCrossRegionRestoreOptions) (*runtime.Poller[BackupInstancesClientValidateCrossRegionRestoreResponse], error)` +- New function `*ClientFactory.NewCrossRegionRestoreJobClient() *CrossRegionRestoreJobClient` +- New function `*ClientFactory.NewCrossRegionRestoreJobsClient() *CrossRegionRestoreJobsClient` +- New function `*ClientFactory.NewSecondaryRPsClient() *SecondaryRPsClient` +- New function `NewCrossRegionRestoreJobClient(string, azcore.TokenCredential, *arm.ClientOptions) (*CrossRegionRestoreJobClient, error)` +- New function `*CrossRegionRestoreJobClient.Get(context.Context, string, string, CrossRegionRestoreJobRequest, *CrossRegionRestoreJobClientGetOptions) (CrossRegionRestoreJobClientGetResponse, error)` +- New function `NewCrossRegionRestoreJobsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*CrossRegionRestoreJobsClient, error)` +- New function `*CrossRegionRestoreJobsClient.NewListPager(string, string, CrossRegionRestoreJobsRequest, *CrossRegionRestoreJobsClientListOptions) *runtime.Pager[CrossRegionRestoreJobsClientListResponse]` +- New function `*DefaultResourceProperties.GetBaseResourceProperties() *BaseResourceProperties` +- New function `*KubernetesClusterVaultTierRestoreCriteria.GetItemLevelRestoreCriteria() *ItemLevelRestoreCriteria` +- New function `NewSecondaryRPsClient(string, azcore.TokenCredential, *arm.ClientOptions) (*SecondaryRPsClient, error)` +- New function `*SecondaryRPsClient.NewFetchPager(string, string, FetchSecondaryRPsRequestParameters, *SecondaryRPsClientFetchOptions) *runtime.Pager[SecondaryRPsClientFetchResponse]` +- New function `dateTimeRFC3339.MarshalText() ([]byte, error)` +- New function `*dateTimeRFC3339.Parse(string) error` +- New function `*dateTimeRFC3339.UnmarshalText([]byte) error` +- New struct `CrossRegionRestoreDetails` +- New struct `CrossRegionRestoreJobRequest` +- New struct `CrossRegionRestoreJobsRequest` +- New struct `CrossRegionRestoreRequestObject` +- New struct `DefaultResourceProperties` +- New struct `FetchSecondaryRPsRequestParameters` +- New struct `KubernetesClusterVaultTierRestoreCriteria` +- New struct `UserFacingWarningDetail` +- New struct `ValidateCrossRegionRestoreRequestObject` +- New field `RecoveryPointState` in struct `AzureBackupDiscreteRecoveryPoint` +- New field `ReplicatedRegions` in struct `BackupVault` +- New field `WarningDetails` in struct `JobExtendedInfo` + + ## 2.3.0 (2023-07-28) ### Features Added diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/autorest.md b/sdk/resourcemanager/dataprotection/armdataprotection/autorest.md index 2a5c79ee2a3f..7bf0ba8ecf01 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/autorest.md +++ b/sdk/resourcemanager/dataprotection/armdataprotection/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dataprotection/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/dataprotection/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.3.0 -tag: package-2023-05 +module-version: 3.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backupinstances_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/backupinstances_client.go index 00b774b16713..f5e5764ec1c3 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backupinstances_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/backupinstances_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type BackupInstancesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewBackupInstancesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackupInstancesClient, error) { - cl, err := arm.NewClient(moduleName+".BackupInstancesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,7 +46,7 @@ func NewBackupInstancesClient(subscriptionID string, credential azcore.TokenCred // BeginAdhocBackup - Trigger adhoc backup // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -60,34 +59,49 @@ func (client *BackupInstancesClient) BeginAdhocBackup(ctx context.Context, resou if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientAdhocBackupResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientAdhocBackupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientAdhocBackupResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientAdhocBackupResponse]{ + Tracer: client.internal.Tracer(), + }) } } // AdhocBackup - Trigger adhoc backup // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) adhocBackup(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters TriggerBackupRequest, options *BackupInstancesClientBeginAdhocBackupOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginAdhocBackup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.adhocBackupCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // adhocBackupCreateRequest creates the AdhocBackup request. func (client *BackupInstancesClient) adhocBackupCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters TriggerBackupRequest, options *BackupInstancesClientBeginAdhocBackupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/backup" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -106,16 +120,19 @@ func (client *BackupInstancesClient) adhocBackupCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginCreateOrUpdate - Create or update a backup instance in a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -128,34 +145,48 @@ func (client *BackupInstancesClient) BeginCreateOrUpdate(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // CreateOrUpdate - Create or update a backup instance in a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) createOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters BackupInstanceResource, options *BackupInstancesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *BackupInstancesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters BackupInstanceResource, options *BackupInstancesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -174,16 +205,19 @@ func (client *BackupInstancesClient) createOrUpdateCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Delete a backup instance in a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -195,34 +229,48 @@ func (client *BackupInstancesClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Delete - Delete a backup instance in a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) deleteOperation(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. func (client *BackupInstancesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -241,7 +289,7 @@ func (client *BackupInstancesClient) deleteCreateRequest(ctx context.Context, re return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -250,29 +298,39 @@ func (client *BackupInstancesClient) deleteCreateRequest(ctx context.Context, re // Get - Gets a backup instance with name in a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. // - options - BackupInstancesClientGetOptions contains the optional parameters for the BackupInstancesClient.Get method. func (client *BackupInstancesClient) Get(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientGetOptions) (BackupInstancesClientGetResponse, error) { + var err error + const operationName = "BackupInstancesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return BackupInstancesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupInstancesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupInstancesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BackupInstancesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *BackupInstancesClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -291,7 +349,7 @@ func (client *BackupInstancesClient) getCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -309,30 +367,40 @@ func (client *BackupInstancesClient) getHandleResponse(resp *http.Response) (Bac // GetBackupInstanceOperationResult - Get result of backup instance creation operation // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. // - options - BackupInstancesClientGetBackupInstanceOperationResultOptions contains the optional parameters for the BackupInstancesClient.GetBackupInstanceOperationResult // method. func (client *BackupInstancesClient) GetBackupInstanceOperationResult(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, operationID string, options *BackupInstancesClientGetBackupInstanceOperationResultOptions) (BackupInstancesClientGetBackupInstanceOperationResultResponse, error) { + var err error + const operationName = "BackupInstancesClient.GetBackupInstanceOperationResult" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getBackupInstanceOperationResultCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, operationID, options) if err != nil { return BackupInstancesClientGetBackupInstanceOperationResultResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupInstancesClientGetBackupInstanceOperationResultResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return BackupInstancesClientGetBackupInstanceOperationResultResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return BackupInstancesClientGetBackupInstanceOperationResultResponse{}, err } - return client.getBackupInstanceOperationResultHandleResponse(resp) + resp, err := client.getBackupInstanceOperationResultHandleResponse(httpResp) + return resp, err } // getBackupInstanceOperationResultCreateRequest creates the GetBackupInstanceOperationResult request. func (client *BackupInstancesClient) getBackupInstanceOperationResultCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, operationID string, options *BackupInstancesClientGetBackupInstanceOperationResultOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/operationResults/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -355,7 +423,7 @@ func (client *BackupInstancesClient) getBackupInstanceOperationResultCreateReque return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -372,7 +440,7 @@ func (client *BackupInstancesClient) getBackupInstanceOperationResultHandleRespo // NewListPager - Gets a backup instances belonging to a backup vault // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - BackupInstancesClientListOptions contains the optional parameters for the BackupInstancesClient.NewListPager @@ -383,31 +451,29 @@ func (client *BackupInstancesClient) NewListPager(resourceGroupName string, vaul return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *BackupInstancesClientListResponse) (BackupInstancesClientListResponse, 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 BackupInstancesClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BackupInstancesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + }, nil) if err != nil { return BackupInstancesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupInstancesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. func (client *BackupInstancesClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *BackupInstancesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -422,7 +488,7 @@ func (client *BackupInstancesClient) listCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -440,7 +506,7 @@ func (client *BackupInstancesClient) listHandleResponse(resp *http.Response) (Ba // BeginResumeBackups - This operation will resume backups for backup instance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -452,34 +518,48 @@ func (client *BackupInstancesClient) BeginResumeBackups(ctx context.Context, res if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientResumeBackupsResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientResumeBackupsResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientResumeBackupsResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientResumeBackupsResponse]{ + Tracer: client.internal.Tracer(), + }) } } // ResumeBackups - This operation will resume backups for backup instance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) resumeBackups(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginResumeBackupsOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginResumeBackups" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.resumeBackupsCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // resumeBackupsCreateRequest creates the ResumeBackups request. func (client *BackupInstancesClient) resumeBackupsCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginResumeBackupsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeBackups" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -498,7 +578,7 @@ func (client *BackupInstancesClient) resumeBackupsCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -507,7 +587,7 @@ func (client *BackupInstancesClient) resumeBackupsCreateRequest(ctx context.Cont // BeginResumeProtection - This operation will resume protection for a stopped backup instance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -519,34 +599,48 @@ func (client *BackupInstancesClient) BeginResumeProtection(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientResumeProtectionResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientResumeProtectionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientResumeProtectionResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientResumeProtectionResponse]{ + Tracer: client.internal.Tracer(), + }) } } // ResumeProtection - This operation will resume protection for a stopped backup instance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) resumeProtection(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginResumeProtectionOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginResumeProtection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.resumeProtectionCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // resumeProtectionCreateRequest creates the ResumeProtection request. func (client *BackupInstancesClient) resumeProtectionCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginResumeProtectionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/resumeProtection" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -565,7 +659,7 @@ func (client *BackupInstancesClient) resumeProtectionCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -574,7 +668,7 @@ func (client *BackupInstancesClient) resumeProtectionCreateRequest(ctx context.C // BeginStopProtection - This operation will stop protection of a backup instance and data will be held forever // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -586,34 +680,48 @@ func (client *BackupInstancesClient) BeginStopProtection(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientStopProtectionResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientStopProtectionResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientStopProtectionResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientStopProtectionResponse]{ + Tracer: client.internal.Tracer(), + }) } } // StopProtection - This operation will stop protection of a backup instance and data will be held forever // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) stopProtection(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginStopProtectionOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginStopProtection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.stopProtectionCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // stopProtectionCreateRequest creates the StopProtection request. func (client *BackupInstancesClient) stopProtectionCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginStopProtectionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/stopProtection" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -632,7 +740,7 @@ func (client *BackupInstancesClient) stopProtectionCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -642,7 +750,7 @@ func (client *BackupInstancesClient) stopProtectionCreateRequest(ctx context.Con // (except latest Recovery point, which will be retained forever) // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -654,9 +762,14 @@ func (client *BackupInstancesClient) BeginSuspendBackups(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientSuspendBackupsResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientSuspendBackupsResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientSuspendBackupsResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientSuspendBackupsResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -664,25 +777,34 @@ func (client *BackupInstancesClient) BeginSuspendBackups(ctx context.Context, re // latest Recovery point, which will be retained forever) // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) suspendBackups(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginSuspendBackupsOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginSuspendBackups" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.suspendBackupsCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // suspendBackupsCreateRequest creates the SuspendBackups request. func (client *BackupInstancesClient) suspendBackupsCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *BackupInstancesClientBeginSuspendBackupsOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/suspendBackups" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -701,7 +823,7 @@ func (client *BackupInstancesClient) suspendBackupsCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -711,7 +833,7 @@ func (client *BackupInstancesClient) suspendBackupsCreateRequest(ctx context.Con // will bring backup instance to valid state // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -724,9 +846,14 @@ func (client *BackupInstancesClient) BeginSyncBackupInstance(ctx context.Context if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientSyncBackupInstanceResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientSyncBackupInstanceResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientSyncBackupInstanceResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientSyncBackupInstanceResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -734,25 +861,34 @@ func (client *BackupInstancesClient) BeginSyncBackupInstance(ctx context.Context // bring backup instance to valid state // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) syncBackupInstance(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters SyncBackupInstanceRequest, options *BackupInstancesClientBeginSyncBackupInstanceOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginSyncBackupInstance" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.syncBackupInstanceCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // syncBackupInstanceCreateRequest creates the SyncBackupInstance request. func (client *BackupInstancesClient) syncBackupInstanceCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters SyncBackupInstanceRequest, options *BackupInstancesClientBeginSyncBackupInstanceOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/sync" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -771,16 +907,99 @@ func (client *BackupInstancesClient) syncBackupInstanceCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginTriggerCrossRegionRestore - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - parameters - Request body for trigger CRR operation +// - options - BackupInstancesClientBeginTriggerCrossRegionRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginTriggerCrossRegionRestore +// method. +func (client *BackupInstancesClient) BeginTriggerCrossRegionRestore(ctx context.Context, resourceGroupName string, location string, parameters CrossRegionRestoreRequestObject, options *BackupInstancesClientBeginTriggerCrossRegionRestoreOptions) (*runtime.Poller[BackupInstancesClientTriggerCrossRegionRestoreResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.triggerCrossRegionRestore(ctx, resourceGroupName, location, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientTriggerCrossRegionRestoreResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientTriggerCrossRegionRestoreResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// TriggerCrossRegionRestore - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *BackupInstancesClient) triggerCrossRegionRestore(ctx context.Context, resourceGroupName string, location string, parameters CrossRegionRestoreRequestObject, options *BackupInstancesClientBeginTriggerCrossRegionRestoreOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginTriggerCrossRegionRestore" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.triggerCrossRegionRestoreCreateRequest(ctx, resourceGroupName, location, parameters, 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 +} + +// triggerCrossRegionRestoreCreateRequest creates the TriggerCrossRegionRestore request. +func (client *BackupInstancesClient) triggerCrossRegionRestoreCreateRequest(ctx context.Context, resourceGroupName string, location string, parameters CrossRegionRestoreRequestObject, options *BackupInstancesClientBeginTriggerCrossRegionRestoreOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/crossRegionRestore" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginTriggerRehydrate - rehydrate recovery point for restore for a BackupInstance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -793,29 +1012,40 @@ func (client *BackupInstancesClient) BeginTriggerRehydrate(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientTriggerRehydrateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientTriggerRehydrateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientTriggerRehydrateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientTriggerRehydrateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // TriggerRehydrate - rehydrate recovery point for restore for a BackupInstance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) triggerRehydrate(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters AzureBackupRehydrationRequest, options *BackupInstancesClientBeginTriggerRehydrateOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginTriggerRehydrate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.triggerRehydrateCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // triggerRehydrateCreateRequest creates the TriggerRehydrate request. @@ -825,6 +1055,9 @@ func (client *BackupInstancesClient) triggerRehydrateCreateRequest(ctx context.C return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if vaultName == "" { return nil, errors.New("parameter vaultName cannot be empty") @@ -839,16 +1072,19 @@ func (client *BackupInstancesClient) triggerRehydrateCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginTriggerRestore - Triggers restore for a BackupInstance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -861,34 +1097,49 @@ func (client *BackupInstancesClient) BeginTriggerRestore(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientTriggerRestoreResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientTriggerRestoreResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientTriggerRestoreResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientTriggerRestoreResponse]{ + Tracer: client.internal.Tracer(), + }) } } // TriggerRestore - Triggers restore for a BackupInstance // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) triggerRestore(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters AzureBackupRestoreRequestClassification, options *BackupInstancesClientBeginTriggerRestoreOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginTriggerRestore" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.triggerRestoreCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // triggerRestoreCreateRequest creates the TriggerRestore request. func (client *BackupInstancesClient) triggerRestoreCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters AzureBackupRestoreRequestClassification, options *BackupInstancesClientBeginTriggerRestoreOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/restore" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -907,16 +1158,99 @@ func (client *BackupInstancesClient) triggerRestoreCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// BeginValidateCrossRegionRestore - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - parameters - Request body for operation +// - options - BackupInstancesClientBeginValidateCrossRegionRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginValidateCrossRegionRestore +// method. +func (client *BackupInstancesClient) BeginValidateCrossRegionRestore(ctx context.Context, resourceGroupName string, location string, parameters ValidateCrossRegionRestoreRequestObject, options *BackupInstancesClientBeginValidateCrossRegionRestoreOptions) (*runtime.Poller[BackupInstancesClientValidateCrossRegionRestoreResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.validateCrossRegionRestore(ctx, resourceGroupName, location, parameters, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientValidateCrossRegionRestoreResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientValidateCrossRegionRestoreResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ValidateCrossRegionRestore - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *BackupInstancesClient) validateCrossRegionRestore(ctx context.Context, resourceGroupName string, location string, parameters ValidateCrossRegionRestoreRequestObject, options *BackupInstancesClientBeginValidateCrossRegionRestoreOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginValidateCrossRegionRestore" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateCrossRegionRestoreCreateRequest(ctx, resourceGroupName, location, parameters, 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 +} + +// validateCrossRegionRestoreCreateRequest creates the ValidateCrossRegionRestore request. +func (client *BackupInstancesClient) validateCrossRegionRestoreCreateRequest(ctx context.Context, resourceGroupName string, location string, parameters ValidateCrossRegionRestoreRequestObject, options *BackupInstancesClientBeginValidateCrossRegionRestoreOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/validateCrossRegionRestore" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if 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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginValidateForBackup - Validate whether adhoc backup will be successful or not // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - parameters - Request body for operation @@ -928,34 +1262,49 @@ func (client *BackupInstancesClient) BeginValidateForBackup(ctx context.Context, if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientValidateForBackupResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientValidateForBackupResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientValidateForBackupResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientValidateForBackupResponse]{ + Tracer: client.internal.Tracer(), + }) } } // ValidateForBackup - Validate whether adhoc backup will be successful or not // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) validateForBackup(ctx context.Context, resourceGroupName string, vaultName string, parameters ValidateForBackupRequest, options *BackupInstancesClientBeginValidateForBackupOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginValidateForBackup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.validateForBackupCreateRequest(ctx, resourceGroupName, vaultName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // validateForBackupCreateRequest creates the ValidateForBackup request. func (client *BackupInstancesClient) validateForBackupCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, parameters ValidateForBackupRequest, options *BackupInstancesClientBeginValidateForBackupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/validateForBackup" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -970,16 +1319,19 @@ func (client *BackupInstancesClient) validateForBackupCreateRequest(ctx context. return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginValidateForRestore - Validates if Restore can be triggered for a DataSource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -992,34 +1344,49 @@ func (client *BackupInstancesClient) BeginValidateForRestore(ctx context.Context if err != nil { return nil, err } - return runtime.NewPoller[BackupInstancesClientValidateForRestoreResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupInstancesClientValidateForRestoreResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupInstancesClientValidateForRestoreResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupInstancesClientValidateForRestoreResponse]{ + Tracer: client.internal.Tracer(), + }) } } // ValidateForRestore - Validates if Restore can be triggered for a DataSource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupInstancesClient) validateForRestore(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters ValidateRestoreRequestObject, options *BackupInstancesClientBeginValidateForRestoreOptions) (*http.Response, error) { + var err error + const operationName = "BackupInstancesClient.BeginValidateForRestore" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.validateForRestoreCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // validateForRestoreCreateRequest creates the ValidateForRestore request. func (client *BackupInstancesClient) validateForRestoreCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters ValidateRestoreRequestObject, options *BackupInstancesClientBeginValidateForRestoreOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/validateRestore" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -1038,8 +1405,11 @@ func (client *BackupInstancesClient) validateForRestoreCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backupinstances_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/backupinstances_client_example_test.go deleted file mode 100644 index 90073849c4d8..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backupinstances_client_example_test.go +++ /dev/null @@ -1,791 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/ListBackupInstances.json -func ExampleBackupInstancesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBackupInstancesClient().NewListPager("000pikumar", "PratikPrivatePreviewVault1", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BackupInstanceResourceList = armdataprotection.BackupInstanceResourceList{ - // Value: []*armdataprotection.BackupInstanceResource{ - // { - // Name: to.Ptr("harshitbi2"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupInstances/harshitbi2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Properties: &armdataprotection.BackupInstance{ - // DataSourceInfo: &armdataprotection.Datasource{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("Datasource"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("testdb"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // DataSourceSetInfo: &armdataprotection.DatasourceSet{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("DatasourceSet"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("viveksipgtest"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // FriendlyName: to.Ptr("harshitbi2"), - // ObjectType: to.Ptr("BackupInstance"), - // PolicyInfo: &armdataprotection.PolicyInfo{ - // PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1"), - // PolicyVersion: to.Ptr("3.2"), - // }, - // ProtectionStatus: &armdataprotection.ProtectionStatusDetails{ - // Status: to.Ptr(armdataprotection.Status("NotProtected")), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/GetBackupInstance.json -func ExampleBackupInstancesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupInstancesClient().Get(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupInstanceResource = armdataprotection.BackupInstanceResource{ - // Name: to.Ptr("harshitbi2"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupInstances/harshitbi2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Properties: &armdataprotection.BackupInstance{ - // DataSourceInfo: &armdataprotection.Datasource{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("Datasource"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("testdb"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // DataSourceSetInfo: &armdataprotection.DatasourceSet{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("DatasourceSet"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("viveksipgtest"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // FriendlyName: to.Ptr("harshitbi2"), - // ObjectType: to.Ptr("BackupInstance"), - // PolicyInfo: &armdataprotection.PolicyInfo{ - // PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1"), - // PolicyVersion: to.Ptr("3.2"), - // }, - // ProtectionStatus: &armdataprotection.ProtectionStatusDetails{ - // Status: to.Ptr(armdataprotection.Status("NotProtected")), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/PutBackupInstance.json -func ExampleBackupInstancesClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginCreateOrUpdate(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", armdataprotection.BackupInstanceResource{ - Tags: map[string]*string{ - "key1": to.Ptr("val1"), - }, - Properties: &armdataprotection.BackupInstance{ - DataSourceInfo: &armdataprotection.Datasource{ - DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ObjectType: to.Ptr("Datasource"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("testdb"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ResourceURI: to.Ptr(""), - }, - DataSourceSetInfo: &armdataprotection.DatasourceSet{ - DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ObjectType: to.Ptr("DatasourceSet"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("viveksipgtest"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"), - ResourceURI: to.Ptr(""), - }, - DatasourceAuthCredentials: &armdataprotection.SecretStoreBasedAuthCredentials{ - ObjectType: to.Ptr("SecretStoreBasedAuthCredentials"), - SecretStoreResource: &armdataprotection.SecretStoreResource{ - SecretStoreType: to.Ptr(armdataprotection.SecretStoreTypeAzureKeyVault), - URI: to.Ptr("https://samplevault.vault.azure.net/secrets/credentials"), - }, - }, - FriendlyName: to.Ptr("harshitbi2"), - ObjectType: to.Ptr("BackupInstance"), - PolicyInfo: &armdataprotection.PolicyInfo{ - PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/Backupvaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1"), - PolicyParameters: &armdataprotection.PolicyParameters{ - DataStoreParametersList: []armdataprotection.DataStoreParametersClassification{ - &armdataprotection.AzureOperationalStoreParameters{ - DataStoreType: to.Ptr(armdataprotection.DataStoreTypesOperationalStore), - ObjectType: to.Ptr("AzureOperationalStoreParameters"), - ResourceGroupID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest"), - }}, - }, - }, - ValidationType: to.Ptr(armdataprotection.ValidationTypeShallowValidation), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupInstanceResource = armdataprotection.BackupInstanceResource{ - // Name: to.Ptr("harshitbi2"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupInstances/harshitbi2"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Properties: &armdataprotection.BackupInstance{ - // DataSourceInfo: &armdataprotection.Datasource{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("Datasource"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("testdb"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // DataSourceSetInfo: &armdataprotection.DatasourceSet{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("DatasourceSet"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("viveksipgtest"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // FriendlyName: to.Ptr("harshitbi2"), - // ObjectType: to.Ptr("BackupInstance"), - // PolicyInfo: &armdataprotection.PolicyInfo{ - // PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1"), - // PolicyParameters: &armdataprotection.PolicyParameters{ - // DataStoreParametersList: []armdataprotection.DataStoreParametersClassification{ - // &armdataprotection.AzureOperationalStoreParameters{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesOperationalStore), - // ObjectType: to.Ptr("AzureOperationalStoreParameters"), - // ResourceGroupID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest"), - // }}, - // }, - // PolicyVersion: to.Ptr("3.2"), - // }, - // ProtectionStatus: &armdataprotection.ProtectionStatusDetails{ - // Status: to.Ptr(armdataprotection.Status("NotProtected")), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/DeleteBackupInstance.json -func ExampleBackupInstancesClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginDelete(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/TriggerBackup.json -func ExampleBackupInstancesClient_BeginAdhocBackup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginAdhocBackup(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", armdataprotection.TriggerBackupRequest{ - BackupRuleOptions: &armdataprotection.AdHocBackupRuleOptions{ - RuleName: to.Ptr("BackupWeekly"), - TriggerOption: &armdataprotection.AdhocBackupTriggerOption{ - RetentionTagOverride: to.Ptr("yearly"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationJobExtendedInfo = armdataprotection.OperationJobExtendedInfo{ - // ObjectType: to.Ptr("OperationJobExtendedInfo"), - // JobID: to.Ptr("c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/ValidateForBackup.json -func ExampleBackupInstancesClient_BeginValidateForBackup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginValidateForBackup(ctx, "000pikumar", "PratikPrivatePreviewVault1", armdataprotection.ValidateForBackupRequest{ - BackupInstance: &armdataprotection.BackupInstance{ - DataSourceInfo: &armdataprotection.Datasource{ - DatasourceType: to.Ptr("OssDB"), - ObjectType: to.Ptr("Datasource"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("testdb"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ResourceURI: to.Ptr(""), - }, - DataSourceSetInfo: &armdataprotection.DatasourceSet{ - DatasourceType: to.Ptr("OssDB"), - ObjectType: to.Ptr("DatasourceSet"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("viveksipgtest"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"), - ResourceURI: to.Ptr(""), - }, - DatasourceAuthCredentials: &armdataprotection.SecretStoreBasedAuthCredentials{ - ObjectType: to.Ptr("SecretStoreBasedAuthCredentials"), - SecretStoreResource: &armdataprotection.SecretStoreResource{ - SecretStoreType: to.Ptr(armdataprotection.SecretStoreTypeAzureKeyVault), - URI: to.Ptr("https://samplevault.vault.azure.net/secrets/credentials"), - }, - }, - FriendlyName: to.Ptr("harshitbi2"), - ObjectType: to.Ptr("BackupInstance"), - PolicyInfo: &armdataprotection.PolicyInfo{ - PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/Backupvaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationJobExtendedInfo = armdataprotection.OperationJobExtendedInfo{ - // ObjectType: to.Ptr("OperationJobExtendedInfo"), - // JobID: to.Ptr("c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/GetBackupInstanceOperationResult.json -func ExampleBackupInstancesClient_GetBackupInstanceOperationResult() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupInstancesClient().GetBackupInstanceOperationResult(ctx, "SampleResourceGroup", "swaggerExample", "testInstance1", "YWUzNDFkMzQtZmM5OS00MmUyLWEzNDMtZGJkMDIxZjlmZjgzOzdmYzBiMzhmLTc2NmItNDM5NS05OWQ1LTVmOGEzNzg4MWQzNA==", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupInstanceResource = armdataprotection.BackupInstanceResource{ - // Name: to.Ptr("testInstance1"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/swaggerExample/backupInstances/testInstance1"), - // Properties: &armdataprotection.BackupInstance{ - // DataSourceInfo: &armdataprotection.Datasource{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("Datasource"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("testdb"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // DataSourceSetInfo: &armdataprotection.DatasourceSet{ - // DatasourceType: to.Ptr("OssDB"), - // ObjectType: to.Ptr("DatasourceSet"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("viveksipgtest"), - // ResourceType: to.Ptr("OssDB"), - // ResourceURI: to.Ptr(""), - // }, - // FriendlyName: to.Ptr("testInstance1"), - // ObjectType: to.Ptr("BackupInstance"), - // PolicyInfo: &armdataprotection.PolicyInfo{ - // PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/swaggerExample/backupPolicies/PratikPolicy1"), - // PolicyVersion: to.Ptr("3.2"), - // }, - // ProtectionStatus: &armdataprotection.ProtectionStatusDetails{ - // Status: to.Ptr(armdataprotection.StatusConfiguringProtection), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/TriggerRehydrate.json -func ExampleBackupInstancesClient_BeginTriggerRehydrate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginTriggerRehydrate(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", armdataprotection.AzureBackupRehydrationRequest{ - RecoveryPointID: to.Ptr("hardcodedRP"), - RehydrationPriority: to.Ptr(armdataprotection.RehydrationPriorityHigh), - RehydrationRetentionDuration: to.Ptr("7D"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/TriggerRestore.json -func ExampleBackupInstancesClient_BeginTriggerRestore_triggerRestore() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginTriggerRestore(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", &armdataprotection.AzureBackupRecoveryPointBasedRestoreRequest{ - ObjectType: to.Ptr("AzureBackupRecoveryPointBasedRestoreRequest"), - RestoreTargetInfo: &armdataprotection.RestoreTargetInfo{ - ObjectType: to.Ptr("RestoreTargetInfo"), - RecoveryOption: to.Ptr(armdataprotection.RecoveryOptionFailIfExists), - RestoreLocation: to.Ptr("southeastasia"), - DatasourceAuthCredentials: &armdataprotection.SecretStoreBasedAuthCredentials{ - ObjectType: to.Ptr("SecretStoreBasedAuthCredentials"), - SecretStoreResource: &armdataprotection.SecretStoreResource{ - SecretStoreType: to.Ptr(armdataprotection.SecretStoreTypeAzureKeyVault), - URI: to.Ptr("https://samplevault.vault.azure.net/secrets/credentials"), - }, - }, - DatasourceInfo: &armdataprotection.Datasource{ - DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ObjectType: to.Ptr("Datasource"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/targetdb"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("targetdb"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ResourceURI: to.Ptr(""), - }, - DatasourceSetInfo: &armdataprotection.DatasourceSet{ - DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ObjectType: to.Ptr("DatasourceSet"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("viveksipgtest"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"), - ResourceURI: to.Ptr(""), - }, - }, - SourceDataStoreType: to.Ptr(armdataprotection.SourceDataStoreTypeVaultStore), - SourceResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - RecoveryPointID: to.Ptr("hardcodedRP"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationJobExtendedInfo = armdataprotection.OperationJobExtendedInfo{ - // ObjectType: to.Ptr("OperationJobExtendedInfo"), - // JobID: to.Ptr("c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/TriggerRestoreAsFiles.json -func ExampleBackupInstancesClient_BeginTriggerRestore_triggerRestoreAsFiles() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginTriggerRestore(ctx, "000pikumar", "PrivatePreviewVault1", "testInstance1", &armdataprotection.AzureBackupRecoveryPointBasedRestoreRequest{ - ObjectType: to.Ptr("AzureBackupRecoveryPointBasedRestoreRequest"), - RestoreTargetInfo: &armdataprotection.RestoreFilesTargetInfo{ - ObjectType: to.Ptr("RestoreFilesTargetInfo"), - RecoveryOption: to.Ptr(armdataprotection.RecoveryOptionFailIfExists), - RestoreLocation: to.Ptr("southeastasia"), - TargetDetails: &armdataprotection.TargetDetails{ - FilePrefix: to.Ptr("restoredblob"), - RestoreTargetLocationType: to.Ptr(armdataprotection.RestoreTargetLocationTypeAzureBlobs), - URL: to.Ptr("https://teststorage.blob.core.windows.net/restoretest"), - }, - }, - SourceDataStoreType: to.Ptr(armdataprotection.SourceDataStoreTypeVaultStore), - SourceResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - RecoveryPointID: to.Ptr("hardcodedRP"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationJobExtendedInfo = armdataprotection.OperationJobExtendedInfo{ - // ObjectType: to.Ptr("OperationJobExtendedInfo"), - // JobID: to.Ptr("c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/TriggerRestoreWithRehydration.json -func ExampleBackupInstancesClient_BeginTriggerRestore_triggerRestoreWithRehydration() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginTriggerRestore(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", &armdataprotection.AzureBackupRestoreWithRehydrationRequest{ - ObjectType: to.Ptr("AzureBackupRestoreWithRehydrationRequest"), - RestoreTargetInfo: &armdataprotection.RestoreTargetInfo{ - ObjectType: to.Ptr("RestoreTargetInfo"), - RecoveryOption: to.Ptr(armdataprotection.RecoveryOptionFailIfExists), - RestoreLocation: to.Ptr("southeastasia"), - DatasourceInfo: &armdataprotection.Datasource{ - DatasourceType: to.Ptr("OssDB"), - ObjectType: to.Ptr("Datasource"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("testdb"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ResourceURI: to.Ptr(""), - }, - DatasourceSetInfo: &armdataprotection.DatasourceSet{ - DatasourceType: to.Ptr("OssDB"), - ObjectType: to.Ptr("DatasourceSet"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("viveksipgtest"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"), - ResourceURI: to.Ptr(""), - }, - }, - SourceDataStoreType: to.Ptr(armdataprotection.SourceDataStoreTypeVaultStore), - SourceResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - RecoveryPointID: to.Ptr("hardcodedRP"), - RehydrationPriority: to.Ptr(armdataprotection.RehydrationPriorityHigh), - RehydrationRetentionDuration: to.Ptr("7D"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationJobExtendedInfo = armdataprotection.OperationJobExtendedInfo{ - // ObjectType: to.Ptr("OperationJobExtendedInfo"), - // JobID: to.Ptr("c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/ResumeBackups.json -func ExampleBackupInstancesClient_BeginResumeBackups() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginResumeBackups(ctx, "testrg", "testvault", "testbi", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/ResumeProtection.json -func ExampleBackupInstancesClient_BeginResumeProtection() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginResumeProtection(ctx, "testrg", "testvault", "testbi", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/StopProtection.json -func ExampleBackupInstancesClient_BeginStopProtection() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginStopProtection(ctx, "testrg", "testvault", "testbi", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/SuspendBackups.json -func ExampleBackupInstancesClient_BeginSuspendBackups() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginSuspendBackups(ctx, "testrg", "testvault", "testbi", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/SyncBackupInstance.json -func ExampleBackupInstancesClient_BeginSyncBackupInstance() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginSyncBackupInstance(ctx, "testrg", "testvault", "testbi", armdataprotection.SyncBackupInstanceRequest{ - SyncType: to.Ptr(armdataprotection.SyncTypeDefault), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/ValidateRestore.json -func ExampleBackupInstancesClient_BeginValidateForRestore() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupInstancesClient().BeginValidateForRestore(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", armdataprotection.ValidateRestoreRequestObject{ - RestoreRequestObject: &armdataprotection.AzureBackupRecoveryPointBasedRestoreRequest{ - ObjectType: to.Ptr("AzureBackupRecoveryPointBasedRestoreRequest"), - RestoreTargetInfo: &armdataprotection.RestoreTargetInfo{ - ObjectType: to.Ptr("RestoreTargetInfo"), - RecoveryOption: to.Ptr(armdataprotection.RecoveryOptionFailIfExists), - RestoreLocation: to.Ptr("southeastasia"), - DatasourceAuthCredentials: &armdataprotection.SecretStoreBasedAuthCredentials{ - ObjectType: to.Ptr("SecretStoreBasedAuthCredentials"), - SecretStoreResource: &armdataprotection.SecretStoreResource{ - SecretStoreType: to.Ptr(armdataprotection.SecretStoreTypeAzureKeyVault), - URI: to.Ptr("https://samplevault.vault.azure.net/secrets/credentials"), - }, - }, - DatasourceInfo: &armdataprotection.Datasource{ - DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ObjectType: to.Ptr("Datasource"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/targetdb"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("targetdb"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ResourceURI: to.Ptr(""), - }, - DatasourceSetInfo: &armdataprotection.DatasourceSet{ - DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - ObjectType: to.Ptr("DatasourceSet"), - ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - ResourceLocation: to.Ptr(""), - ResourceName: to.Ptr("viveksipgtest"), - ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"), - ResourceURI: to.Ptr(""), - }, - }, - SourceDataStoreType: to.Ptr(armdataprotection.SourceDataStoreTypeVaultStore), - SourceResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - RecoveryPointID: to.Ptr("hardcodedRP"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationJobExtendedInfo = armdataprotection.OperationJobExtendedInfo{ - // ObjectType: to.Ptr("OperationJobExtendedInfo"), - // JobID: to.Ptr("c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backuppolicies_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/backuppolicies_client.go index 5321bf7d1ee7..17c4033addc3 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backuppolicies_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/backuppolicies_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type BackupPoliciesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewBackupPoliciesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackupPoliciesClient, error) { - cl, err := arm.NewClient(moduleName+".BackupPoliciesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,7 +46,7 @@ func NewBackupPoliciesClient(subscriptionID string, credential azcore.TokenCrede // CreateOrUpdate - Creates or Updates a backup policy belonging to a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupPolicyName - Name of the policy @@ -55,23 +54,33 @@ func NewBackupPoliciesClient(subscriptionID string, credential azcore.TokenCrede // - options - BackupPoliciesClientCreateOrUpdateOptions contains the optional parameters for the BackupPoliciesClient.CreateOrUpdate // method. func (client *BackupPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, parameters BaseBackupPolicyResource, options *BackupPoliciesClientCreateOrUpdateOptions) (BackupPoliciesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "BackupPoliciesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vaultName, backupPolicyName, parameters, options) if err != nil { return BackupPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupPoliciesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupPoliciesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BackupPoliciesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *BackupPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, parameters BaseBackupPolicyResource, options *BackupPoliciesClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -90,10 +99,13 @@ func (client *BackupPoliciesClient) createOrUpdateCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -108,21 +120,27 @@ func (client *BackupPoliciesClient) createOrUpdateHandleResponse(resp *http.Resp // Delete - Deletes a backup policy belonging to a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - BackupPoliciesClientDeleteOptions contains the optional parameters for the BackupPoliciesClient.Delete method. func (client *BackupPoliciesClient) Delete(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, options *BackupPoliciesClientDeleteOptions) (BackupPoliciesClientDeleteResponse, error) { + var err error + const operationName = "BackupPoliciesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, backupPolicyName, options) if err != nil { return BackupPoliciesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupPoliciesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return BackupPoliciesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return BackupPoliciesClientDeleteResponse{}, err } return BackupPoliciesClientDeleteResponse{}, nil } @@ -130,6 +148,9 @@ func (client *BackupPoliciesClient) Delete(ctx context.Context, resourceGroupNam // deleteCreateRequest creates the Delete request. func (client *BackupPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, options *BackupPoliciesClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -148,7 +169,7 @@ func (client *BackupPoliciesClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -157,28 +178,38 @@ func (client *BackupPoliciesClient) deleteCreateRequest(ctx context.Context, res // Get - Gets a backup policy belonging to a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - BackupPoliciesClientGetOptions contains the optional parameters for the BackupPoliciesClient.Get method. func (client *BackupPoliciesClient) Get(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, options *BackupPoliciesClientGetOptions) (BackupPoliciesClientGetResponse, error) { + var err error + const operationName = "BackupPoliciesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, backupPolicyName, options) if err != nil { return BackupPoliciesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupPoliciesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupPoliciesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BackupPoliciesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *BackupPoliciesClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, options *BackupPoliciesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies/{backupPolicyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -197,7 +228,7 @@ func (client *BackupPoliciesClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -214,7 +245,7 @@ func (client *BackupPoliciesClient) getHandleResponse(resp *http.Response) (Back // NewListPager - Returns list of backup policies belonging to a backup vault // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - BackupPoliciesClientListOptions contains the optional parameters for the BackupPoliciesClient.NewListPager method. @@ -224,31 +255,29 @@ func (client *BackupPoliciesClient) NewListPager(resourceGroupName string, vault return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *BackupPoliciesClientListResponse) (BackupPoliciesClientListResponse, 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) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BackupPoliciesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + }, nil) if err != nil { return BackupPoliciesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return BackupPoliciesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupPoliciesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. func (client *BackupPoliciesClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *BackupPoliciesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupPolicies" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -263,7 +292,7 @@ func (client *BackupPoliciesClient) listCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backuppolicies_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/backuppolicies_client_example_test.go deleted file mode 100644 index 9e40ed9c9f64..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backuppolicies_client_example_test.go +++ /dev/null @@ -1,448 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/PolicyCRUD/ListBackupPolicy.json -func ExampleBackupPoliciesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBackupPoliciesClient().NewListPager("000pikumar", "PrivatePreviewVault", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BaseBackupPolicyResourceList = armdataprotection.BaseBackupPolicyResourceList{ - // Value: []*armdataprotection.BaseBackupPolicyResource{ - // { - // Name: to.Ptr("OSSDBPolicy"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PrivatePreviewVault/backupPolicies/OSSDBPolicy"), - // Properties: &armdataprotection.BackupPolicy{ - // DatasourceTypes: []*string{ - // to.Ptr("OssDB")}, - // ObjectType: to.Ptr("BackupPolicy"), - // PolicyRules: []armdataprotection.BasePolicyRuleClassification{ - // &armdataprotection.AzureBackupRule{ - // Name: to.Ptr("BackupWeekly"), - // ObjectType: to.Ptr("AzureBackupRule"), - // BackupParameters: &armdataprotection.AzureBackupParams{ - // ObjectType: to.Ptr("AzureBackupParams"), - // BackupType: to.Ptr("Full"), - // }, - // DataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // Trigger: &armdataprotection.ScheduleBasedTriggerContext{ - // ObjectType: to.Ptr("ScheduleBasedTriggerContext"), - // Schedule: &armdataprotection.BackupSchedule{ - // RepeatingTimeIntervals: []*string{ - // to.Ptr("R/2019-11-20T08:00:00-08:00/P1W")}, - // }, - // TaggingCriteria: []*armdataprotection.TaggingCriteria{ - // { - // IsDefault: to.Ptr(true), - // TagInfo: &armdataprotection.RetentionTag{ - // ID: to.Ptr("Default_"), - // TagName: to.Ptr("Default"), - // }, - // TaggingPriority: to.Ptr[int64](99), - // }, - // { - // Criteria: []armdataprotection.BackupCriteriaClassification{ - // &armdataprotection.ScheduleBasedBackupCriteria{ - // ObjectType: to.Ptr("ScheduleBasedBackupCriteria"), - // DaysOfTheWeek: []*armdataprotection.DayOfWeek{ - // to.Ptr(armdataprotection.DayOfWeekSunday)}, - // ScheduleTimes: []*time.Time{ - // to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}())}, - // }}, - // IsDefault: to.Ptr(false), - // TagInfo: &armdataprotection.RetentionTag{ - // ID: to.Ptr("Weekly_"), - // TagName: to.Ptr("Weekly"), - // }, - // TaggingPriority: to.Ptr[int64](20), - // }}, - // }, - // }, - // &armdataprotection.AzureRetentionRule{ - // Name: to.Ptr("Default"), - // ObjectType: to.Ptr("AzureRetentionRule"), - // IsDefault: to.Ptr(true), - // Lifecycles: []*armdataprotection.SourceLifeCycle{ - // { - // DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - // Duration: to.Ptr("P1W"), - // ObjectType: to.Ptr("AbsoluteDeleteOption"), - // }, - // SourceDataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // }}, - // }, - // &armdataprotection.AzureRetentionRule{ - // Name: to.Ptr("Weekly"), - // ObjectType: to.Ptr("AzureRetentionRule"), - // IsDefault: to.Ptr(false), - // Lifecycles: []*armdataprotection.SourceLifeCycle{ - // { - // DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - // Duration: to.Ptr("P12W"), - // ObjectType: to.Ptr("AbsoluteDeleteOption"), - // }, - // SourceDataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // }}, - // }}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/PolicyCRUD/GetBackupPolicy.json -func ExampleBackupPoliciesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupPoliciesClient().Get(ctx, "000pikumar", "PrivatePreviewVault", "OSSDBPolicy", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BaseBackupPolicyResource = armdataprotection.BaseBackupPolicyResource{ - // Name: to.Ptr("OSSDBPolicy"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PrivatePreviewVault/backupPolicies/OSSDBPolicy"), - // Properties: &armdataprotection.BackupPolicy{ - // DatasourceTypes: []*string{ - // to.Ptr("OssDB")}, - // ObjectType: to.Ptr("BackupPolicy"), - // PolicyRules: []armdataprotection.BasePolicyRuleClassification{ - // &armdataprotection.AzureBackupRule{ - // Name: to.Ptr("BackupWeekly"), - // ObjectType: to.Ptr("AzureBackupRule"), - // BackupParameters: &armdataprotection.AzureBackupParams{ - // ObjectType: to.Ptr("AzureBackupParams"), - // BackupType: to.Ptr("Full"), - // }, - // DataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // Trigger: &armdataprotection.ScheduleBasedTriggerContext{ - // ObjectType: to.Ptr("ScheduleBasedTriggerContext"), - // Schedule: &armdataprotection.BackupSchedule{ - // RepeatingTimeIntervals: []*string{ - // to.Ptr("R/2019-11-20T08:00:00-08:00/P1W")}, - // }, - // TaggingCriteria: []*armdataprotection.TaggingCriteria{ - // { - // IsDefault: to.Ptr(true), - // TagInfo: &armdataprotection.RetentionTag{ - // ID: to.Ptr("Default_"), - // TagName: to.Ptr("Default"), - // }, - // TaggingPriority: to.Ptr[int64](99), - // }, - // { - // Criteria: []armdataprotection.BackupCriteriaClassification{ - // &armdataprotection.ScheduleBasedBackupCriteria{ - // ObjectType: to.Ptr("ScheduleBasedBackupCriteria"), - // DaysOfTheWeek: []*armdataprotection.DayOfWeek{ - // to.Ptr(armdataprotection.DayOfWeekSunday)}, - // ScheduleTimes: []*time.Time{ - // to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}())}, - // }}, - // IsDefault: to.Ptr(false), - // TagInfo: &armdataprotection.RetentionTag{ - // ID: to.Ptr("Weekly_"), - // TagName: to.Ptr("Weekly"), - // }, - // TaggingPriority: to.Ptr[int64](20), - // }}, - // }, - // }, - // &armdataprotection.AzureRetentionRule{ - // Name: to.Ptr("Default"), - // ObjectType: to.Ptr("AzureRetentionRule"), - // IsDefault: to.Ptr(true), - // Lifecycles: []*armdataprotection.SourceLifeCycle{ - // { - // DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - // Duration: to.Ptr("P1W"), - // ObjectType: to.Ptr("AbsoluteDeleteOption"), - // }, - // SourceDataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // }}, - // }, - // &armdataprotection.AzureRetentionRule{ - // Name: to.Ptr("Weekly"), - // ObjectType: to.Ptr("AzureRetentionRule"), - // IsDefault: to.Ptr(false), - // Lifecycles: []*armdataprotection.SourceLifeCycle{ - // { - // DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - // Duration: to.Ptr("P12W"), - // ObjectType: to.Ptr("AbsoluteDeleteOption"), - // }, - // SourceDataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // }}, - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/PolicyCRUD/CreateOrUpdateBackupPolicy.json -func ExampleBackupPoliciesClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupPoliciesClient().CreateOrUpdate(ctx, "000pikumar", "PrivatePreviewVault", "OSSDBPolicy", armdataprotection.BaseBackupPolicyResource{ - Properties: &armdataprotection.BackupPolicy{ - DatasourceTypes: []*string{ - to.Ptr("OssDB")}, - ObjectType: to.Ptr("BackupPolicy"), - PolicyRules: []armdataprotection.BasePolicyRuleClassification{ - &armdataprotection.AzureBackupRule{ - Name: to.Ptr("BackupWeekly"), - ObjectType: to.Ptr("AzureBackupRule"), - BackupParameters: &armdataprotection.AzureBackupParams{ - ObjectType: to.Ptr("AzureBackupParams"), - BackupType: to.Ptr("Full"), - }, - DataStore: &armdataprotection.DataStoreInfoBase{ - DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - ObjectType: to.Ptr("DataStoreInfoBase"), - }, - Trigger: &armdataprotection.ScheduleBasedTriggerContext{ - ObjectType: to.Ptr("ScheduleBasedTriggerContext"), - Schedule: &armdataprotection.BackupSchedule{ - RepeatingTimeIntervals: []*string{ - to.Ptr("R/2019-11-20T08:00:00-08:00/P1W")}, - }, - TaggingCriteria: []*armdataprotection.TaggingCriteria{ - { - IsDefault: to.Ptr(true), - TagInfo: &armdataprotection.RetentionTag{ - TagName: to.Ptr("Default"), - }, - TaggingPriority: to.Ptr[int64](99), - }, - { - Criteria: []armdataprotection.BackupCriteriaClassification{ - &armdataprotection.ScheduleBasedBackupCriteria{ - ObjectType: to.Ptr("ScheduleBasedBackupCriteria"), - DaysOfTheWeek: []*armdataprotection.DayOfWeek{ - to.Ptr(armdataprotection.DayOfWeekSunday)}, - ScheduleTimes: []*time.Time{ - to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t }())}, - }}, - IsDefault: to.Ptr(false), - TagInfo: &armdataprotection.RetentionTag{ - TagName: to.Ptr("Weekly"), - }, - TaggingPriority: to.Ptr[int64](20), - }}, - }, - }, - &armdataprotection.AzureRetentionRule{ - Name: to.Ptr("Default"), - ObjectType: to.Ptr("AzureRetentionRule"), - IsDefault: to.Ptr(true), - Lifecycles: []*armdataprotection.SourceLifeCycle{ - { - DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - Duration: to.Ptr("P1W"), - ObjectType: to.Ptr("AbsoluteDeleteOption"), - }, - SourceDataStore: &armdataprotection.DataStoreInfoBase{ - DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - ObjectType: to.Ptr("DataStoreInfoBase"), - }, - }}, - }, - &armdataprotection.AzureRetentionRule{ - Name: to.Ptr("Weekly"), - ObjectType: to.Ptr("AzureRetentionRule"), - IsDefault: to.Ptr(false), - Lifecycles: []*armdataprotection.SourceLifeCycle{ - { - DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - Duration: to.Ptr("P12W"), - ObjectType: to.Ptr("AbsoluteDeleteOption"), - }, - SourceDataStore: &armdataprotection.DataStoreInfoBase{ - DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - ObjectType: to.Ptr("DataStoreInfoBase"), - }, - }}, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BaseBackupPolicyResource = armdataprotection.BaseBackupPolicyResource{ - // Name: to.Ptr("OSSDBPolicy"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PrivatePreviewVault/backupPolicies/OSSDBPolicy"), - // Properties: &armdataprotection.BackupPolicy{ - // DatasourceTypes: []*string{ - // to.Ptr("OssDB")}, - // ObjectType: to.Ptr("BackupPolicy"), - // PolicyRules: []armdataprotection.BasePolicyRuleClassification{ - // &armdataprotection.AzureBackupRule{ - // Name: to.Ptr("BackupWeekly"), - // ObjectType: to.Ptr("AzureBackupRule"), - // BackupParameters: &armdataprotection.AzureBackupParams{ - // ObjectType: to.Ptr("AzureBackupParams"), - // BackupType: to.Ptr("Full"), - // }, - // DataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // Trigger: &armdataprotection.ScheduleBasedTriggerContext{ - // ObjectType: to.Ptr("ScheduleBasedTriggerContext"), - // Schedule: &armdataprotection.BackupSchedule{ - // RepeatingTimeIntervals: []*string{ - // to.Ptr("R/2019-11-20T08:00:00-08:00/P1W")}, - // }, - // TaggingCriteria: []*armdataprotection.TaggingCriteria{ - // { - // IsDefault: to.Ptr(true), - // TagInfo: &armdataprotection.RetentionTag{ - // ID: to.Ptr("Default_"), - // TagName: to.Ptr("Default"), - // }, - // TaggingPriority: to.Ptr[int64](99), - // }, - // { - // Criteria: []armdataprotection.BackupCriteriaClassification{ - // &armdataprotection.ScheduleBasedBackupCriteria{ - // ObjectType: to.Ptr("ScheduleBasedBackupCriteria"), - // DaysOfTheWeek: []*armdataprotection.DayOfWeek{ - // to.Ptr(armdataprotection.DayOfWeekSunday)}, - // ScheduleTimes: []*time.Time{ - // to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}())}, - // }}, - // IsDefault: to.Ptr(false), - // TagInfo: &armdataprotection.RetentionTag{ - // ID: to.Ptr("Weekly_"), - // TagName: to.Ptr("Weekly"), - // }, - // TaggingPriority: to.Ptr[int64](20), - // }}, - // }, - // }, - // &armdataprotection.AzureRetentionRule{ - // Name: to.Ptr("Default"), - // ObjectType: to.Ptr("AzureRetentionRule"), - // IsDefault: to.Ptr(true), - // Lifecycles: []*armdataprotection.SourceLifeCycle{ - // { - // DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - // Duration: to.Ptr("P1W"), - // ObjectType: to.Ptr("AbsoluteDeleteOption"), - // }, - // SourceDataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // }}, - // }, - // &armdataprotection.AzureRetentionRule{ - // Name: to.Ptr("Weekly"), - // ObjectType: to.Ptr("AzureRetentionRule"), - // IsDefault: to.Ptr(false), - // Lifecycles: []*armdataprotection.SourceLifeCycle{ - // { - // DeleteAfter: &armdataprotection.AbsoluteDeleteOption{ - // Duration: to.Ptr("P12W"), - // ObjectType: to.Ptr("AbsoluteDeleteOption"), - // }, - // SourceDataStore: &armdataprotection.DataStoreInfoBase{ - // DataStoreType: to.Ptr(armdataprotection.DataStoreTypesVaultStore), - // ObjectType: to.Ptr("DataStoreInfoBase"), - // }, - // }}, - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/PolicyCRUD/DeleteBackupPolicy.json -func ExampleBackupPoliciesClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewBackupPoliciesClient().Delete(ctx, "000pikumar", "PrivatePreviewVault", "OSSDBPolicy", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaultoperationresults_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/backupvaultoperationresults_client.go index 5793e6759231..0ee1a1acd1d4 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaultoperationresults_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/backupvaultoperationresults_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -34,7 +33,7 @@ type BackupVaultOperationResultsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewBackupVaultOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackupVaultOperationResultsClient, error) { - cl, err := arm.NewClient(moduleName+".BackupVaultOperationResultsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,29 +47,39 @@ func NewBackupVaultOperationResultsClient(subscriptionID string, credential azco // Get - // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - BackupVaultOperationResultsClientGetOptions contains the optional parameters for the BackupVaultOperationResultsClient.Get // method. func (client *BackupVaultOperationResultsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *BackupVaultOperationResultsClientGetOptions) (BackupVaultOperationResultsClientGetResponse, error) { + var err error + const operationName = "BackupVaultOperationResultsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, operationID, options) if err != nil { return BackupVaultOperationResultsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupVaultOperationResultsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return BackupVaultOperationResultsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return BackupVaultOperationResultsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *BackupVaultOperationResultsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *BackupVaultOperationResultsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationResults/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -89,7 +98,7 @@ func (client *BackupVaultOperationResultsClient) getCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -98,12 +107,12 @@ func (client *BackupVaultOperationResultsClient) getCreateRequest(ctx context.Co // getHandleResponse handles the Get response. func (client *BackupVaultOperationResultsClient) getHandleResponse(resp *http.Response) (BackupVaultOperationResultsClientGetResponse, error) { result := BackupVaultOperationResultsClientGetResponse{} - if val := resp.Header.Get("Location"); val != "" { - result.Location = &val - } if val := resp.Header.Get("Azure-AsyncOperation"); val != "" { result.AzureAsyncOperation = &val } + if val := resp.Header.Get("Location"); val != "" { + result.Location = &val + } if val := resp.Header.Get("Retry-After"); val != "" { retryAfter32, err := strconv.ParseInt(val, 10, 32) retryAfter := int32(retryAfter32) diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaultoperationresults_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/backupvaultoperationresults_client_example_test.go deleted file mode 100644 index 6b0ae60efce5..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaultoperationresults_client_example_test.go +++ /dev/null @@ -1,58 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/GetOperationResultPatch.json -func ExampleBackupVaultOperationResultsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupVaultOperationResultsClient().Get(ctx, "SampleResourceGroup", "swaggerExample", "YWUzNDFkMzQtZmM5OS00MmUyLWEzNDMtZGJkMDIxZjlmZjgzOzdmYzBiMzhmLTc2NmItNDM5NS05OWQ1LTVmOGEzNzg4MWQzNA==", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupVaultResource = armdataprotection.BackupVaultResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/Backupvaults/swaggerExample"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("None"), - // }, - // Properties: &armdataprotection.BackupVault{ - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaults_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/backupvaults_client.go index 20ea159cef12..58bedb505621 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaults_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/backupvaults_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type BackupVaultsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewBackupVaultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BackupVaultsClient, error) { - cl, err := arm.NewClient(moduleName+".BackupVaultsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,25 +46,32 @@ func NewBackupVaultsClient(subscriptionID string, credential azcore.TokenCredent // CheckNameAvailability - API to check for resource name availability // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - location - The location in which uniqueness will be verified. // - parameters - Check name availability request // - options - BackupVaultsClientCheckNameAvailabilityOptions contains the optional parameters for the BackupVaultsClient.CheckNameAvailability // method. func (client *BackupVaultsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, location string, parameters CheckNameAvailabilityRequest, options *BackupVaultsClientCheckNameAvailabilityOptions) (BackupVaultsClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "BackupVaultsClient.CheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.checkNameAvailabilityCreateRequest(ctx, resourceGroupName, location, parameters, options) if err != nil { return BackupVaultsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupVaultsClientCheckNameAvailabilityResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupVaultsClientCheckNameAvailabilityResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BackupVaultsClientCheckNameAvailabilityResponse{}, err } - return client.checkNameAvailabilityHandleResponse(resp) + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. @@ -75,6 +81,9 @@ func (client *BackupVaultsClient) checkNameAvailabilityCreateRequest(ctx context return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if location == "" { return nil, errors.New("parameter location cannot be empty") @@ -85,10 +94,13 @@ func (client *BackupVaultsClient) checkNameAvailabilityCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. @@ -103,7 +115,7 @@ func (client *BackupVaultsClient) checkNameAvailabilityHandleResponse(resp *http // BeginCreateOrUpdate - Creates or updates a BackupVault resource belonging to a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - parameters - Request body for operation @@ -115,34 +127,48 @@ func (client *BackupVaultsClient) BeginCreateOrUpdate(ctx context.Context, resou if err != nil { return nil, err } - return runtime.NewPoller[BackupVaultsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupVaultsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupVaultsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupVaultsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // CreateOrUpdate - Creates or updates a BackupVault resource belonging to a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupVaultsClient) createOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, parameters BackupVaultResource, options *BackupVaultsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "BackupVaultsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vaultName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *BackupVaultsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, parameters BackupVaultResource, options *BackupVaultsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -157,16 +183,19 @@ func (client *BackupVaultsClient) createOrUpdateCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Deletes a BackupVault resource from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - BackupVaultsClientBeginDeleteOptions contains the optional parameters for the BackupVaultsClient.BeginDelete @@ -177,34 +206,48 @@ func (client *BackupVaultsClient) BeginDelete(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller[BackupVaultsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupVaultsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupVaultsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupVaultsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Delete - Deletes a BackupVault resource from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupVaultsClient) deleteOperation(ctx context.Context, resourceGroupName string, vaultName string, options *BackupVaultsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "BackupVaultsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. func (client *BackupVaultsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *BackupVaultsClientBeginDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -219,7 +262,7 @@ func (client *BackupVaultsClient) deleteCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -228,28 +271,38 @@ func (client *BackupVaultsClient) deleteCreateRequest(ctx context.Context, resou // Get - Returns a resource belonging to a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - BackupVaultsClientGetOptions contains the optional parameters for the BackupVaultsClient.Get method. func (client *BackupVaultsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, options *BackupVaultsClientGetOptions) (BackupVaultsClientGetResponse, error) { + var err error + const operationName = "BackupVaultsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, options) if err != nil { return BackupVaultsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BackupVaultsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupVaultsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BackupVaultsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *BackupVaultsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *BackupVaultsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -264,7 +317,7 @@ func (client *BackupVaultsClient) getCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -281,7 +334,7 @@ func (client *BackupVaultsClient) getHandleResponse(resp *http.Response) (Backup // NewGetInResourceGroupPager - Returns resource collection belonging to a resource group. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - BackupVaultsClientGetInResourceGroupOptions contains the optional parameters for the BackupVaultsClient.NewGetInResourceGroupPager // method. @@ -291,25 +344,20 @@ func (client *BackupVaultsClient) NewGetInResourceGroupPager(resourceGroupName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *BackupVaultsClientGetInResourceGroupResponse) (BackupVaultsClientGetInResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getInResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BackupVaultsClient.NewGetInResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getInResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) if err != nil { return BackupVaultsClientGetInResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return BackupVaultsClientGetInResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupVaultsClientGetInResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.getInResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -320,13 +368,16 @@ func (client *BackupVaultsClient) getInResourceGroupCreateRequest(ctx context.Co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -343,7 +394,7 @@ func (client *BackupVaultsClient) getInResourceGroupHandleResponse(resp *http.Re // NewGetInSubscriptionPager - Returns resource collection belonging to a subscription. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - options - BackupVaultsClientGetInSubscriptionOptions contains the optional parameters for the BackupVaultsClient.NewGetInSubscriptionPager // method. func (client *BackupVaultsClient) NewGetInSubscriptionPager(options *BackupVaultsClientGetInSubscriptionOptions) *runtime.Pager[BackupVaultsClientGetInSubscriptionResponse] { @@ -352,38 +403,36 @@ func (client *BackupVaultsClient) NewGetInSubscriptionPager(options *BackupVault return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *BackupVaultsClientGetInSubscriptionResponse) (BackupVaultsClientGetInSubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getInSubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return BackupVaultsClientGetInSubscriptionResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BackupVaultsClient.NewGetInSubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getInSubscriptionCreateRequest(ctx, options) + }, nil) if err != nil { return BackupVaultsClientGetInSubscriptionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BackupVaultsClientGetInSubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.getInSubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // getInSubscriptionCreateRequest creates the GetInSubscription request. func (client *BackupVaultsClient) getInSubscriptionCreateRequest(ctx context.Context, options *BackupVaultsClientGetInSubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/backupVaults" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -401,7 +450,7 @@ func (client *BackupVaultsClient) getInSubscriptionHandleResponse(resp *http.Res // BeginUpdate - Updates a BackupVault resource belonging to a resource group. For example, updating tags for a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - parameters - Request body for operation @@ -413,34 +462,48 @@ func (client *BackupVaultsClient) BeginUpdate(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller[BackupVaultsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BackupVaultsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[BackupVaultsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[BackupVaultsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Update - Updates a BackupVault resource belonging to a resource group. For example, updating tags for a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *BackupVaultsClient) update(ctx context.Context, resourceGroupName string, vaultName string, parameters PatchResourceRequestInput, options *BackupVaultsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "BackupVaultsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, vaultName, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. func (client *BackupVaultsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, parameters PatchResourceRequestInput, options *BackupVaultsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -455,8 +518,11 @@ func (client *BackupVaultsClient) updateCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaults_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/backupvaults_client_example_test.go deleted file mode 100644 index 258872b9c5ec..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/backupvaults_client_example_test.go +++ /dev/null @@ -1,611 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/GetBackupVaultsInSubscription.json -func ExampleBackupVaultsClient_NewGetInSubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBackupVaultsClient().NewGetInSubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BackupVaultResourceList = armdataprotection.BackupVaultResourceList{ - // Value: []*armdataprotection.BackupVaultResource{ - // { - // Name: to.Ptr("ExampleVault1"), - // Type: to.Ptr("Microsoft.DataProtection/BackupVaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup2/providers/Microsoft.DataProtection/BackupVaults/ExampleVault1"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("None"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // }, - // { - // Name: to.Ptr("ExampleVault2"), - // Type: to.Ptr("Microsoft.DataProtection/BackupVaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/BackupVaults/ExampleVault2"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("None"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/GetBackupVaultsInResourceGroup.json -func ExampleBackupVaultsClient_NewGetInResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBackupVaultsClient().NewGetInResourceGroupPager("SampleResourceGroup", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BackupVaultResourceList = armdataprotection.BackupVaultResourceList{ - // Value: []*armdataprotection.BackupVaultResource{ - // { - // Name: to.Ptr("ExampleVault1"), - // Type: to.Ptr("Microsoft.DataProtection/BackupVaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/BackupVaults/ExampleVault1"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("None"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // }, - // { - // Name: to.Ptr("ExampleVault2"), - // Type: to.Ptr("Microsoft.DataProtection/BackupVaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/BackupVaults/ExampleVault2"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("SystemAssigned"), - // PrincipalID: to.Ptr("c009b9a0-0024-417c-83cd-025d3776045d"), - // TenantID: to.Ptr("83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // MonitoringSettings: &armdataprotection.MonitoringSettings{ - // AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - // AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/GetBackupVault.json -func ExampleBackupVaultsClient_Get_getBackupVault() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupVaultsClient().Get(ctx, "SampleResourceGroup", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupVaultResource = armdataprotection.BackupVaultResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/Backupvaults/swaggerExample"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("None"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // MonitoringSettings: &armdataprotection.MonitoringSettings{ - // AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - // AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/GetBackupVaultWithMSI.json -func ExampleBackupVaultsClient_Get_getBackupVaultWithMsi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupVaultsClient().Get(ctx, "SampleResourceGroup", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupVaultResource = armdataprotection.BackupVaultResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/Backupvaults/swaggerExample"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("SystemAssigned"), - // PrincipalID: to.Ptr("c009b9a0-0024-417c-83cd-025d3776045d"), - // TenantID: to.Ptr("83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/PutBackupVault.json -func ExampleBackupVaultsClient_BeginCreateOrUpdate_createBackupVault() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupVaultsClient().BeginCreateOrUpdate(ctx, "SampleResourceGroup", "swaggerExample", armdataprotection.BackupVaultResource{ - Location: to.Ptr("WestUS"), - Tags: map[string]*string{ - "key1": to.Ptr("val1"), - }, - Identity: &armdataprotection.DppIdentityDetails{ - Type: to.Ptr("None"), - }, - Properties: &armdataprotection.BackupVault{ - FeatureSettings: &armdataprotection.FeatureSettings{ - CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - }, - }, - MonitoringSettings: &armdataprotection.MonitoringSettings{ - AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - }, - }, - SecuritySettings: &armdataprotection.SecuritySettings{ - SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - RetentionDurationInDays: to.Ptr[float64](14), - State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - }, - }, - StorageSettings: []*armdataprotection.StorageSetting{ - { - Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupVaultResource = armdataprotection.BackupVaultResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/Backupvaults/swaggerExample"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("None"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // MonitoringSettings: &armdataprotection.MonitoringSettings{ - // AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - // AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/PutBackupVaultWithMSI.json -func ExampleBackupVaultsClient_BeginCreateOrUpdate_createBackupVaultWithMsi() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupVaultsClient().BeginCreateOrUpdate(ctx, "SampleResourceGroup", "swaggerExample", armdataprotection.BackupVaultResource{ - Location: to.Ptr("WestUS"), - Tags: map[string]*string{ - "key1": to.Ptr("val1"), - }, - Identity: &armdataprotection.DppIdentityDetails{ - Type: to.Ptr("systemAssigned"), - }, - Properties: &armdataprotection.BackupVault{ - FeatureSettings: &armdataprotection.FeatureSettings{ - CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - }, - }, - MonitoringSettings: &armdataprotection.MonitoringSettings{ - AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - }, - }, - SecuritySettings: &armdataprotection.SecuritySettings{ - SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - RetentionDurationInDays: to.Ptr[float64](14), - State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - }, - }, - StorageSettings: []*armdataprotection.StorageSetting{ - { - Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupVaultResource = armdataprotection.BackupVaultResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/Backupvaults/swaggerExample"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "key1": to.Ptr("val1"), - // }, - // Identity: &armdataprotection.DppIdentityDetails{ - // Type: to.Ptr("SystemAssigned"), - // PrincipalID: to.Ptr("c009b9a0-0024-417c-83cd-025d3776045d"), - // TenantID: to.Ptr("83abe5cd-bcc3-441a-bd86-e6a75360cecc"), - // }, - // Properties: &armdataprotection.BackupVault{ - // FeatureSettings: &armdataprotection.FeatureSettings{ - // CrossRegionRestoreSettings: &armdataprotection.CrossRegionRestoreSettings{ - // State: to.Ptr(armdataprotection.CrossRegionRestoreStateEnabled), - // }, - // }, - // MonitoringSettings: &armdataprotection.MonitoringSettings{ - // AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - // AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // SecureScore: to.Ptr(armdataprotection.SecureScoreLevelAdequate), - // SecuritySettings: &armdataprotection.SecuritySettings{ - // SoftDeleteSettings: &armdataprotection.SoftDeleteSettings{ - // RetentionDurationInDays: to.Ptr[float64](14), - // State: to.Ptr(armdataprotection.SoftDeleteState("Enabled")), - // }, - // }, - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/DeleteBackupVault.json -func ExampleBackupVaultsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupVaultsClient().BeginDelete(ctx, "SampleResourceGroup", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/PatchBackupVault.json -func ExampleBackupVaultsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewBackupVaultsClient().BeginUpdate(ctx, "SampleResourceGroup", "swaggerExample", armdataprotection.PatchResourceRequestInput{ - Properties: &armdataprotection.PatchBackupVaultInput{ - MonitoringSettings: &armdataprotection.MonitoringSettings{ - AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - }, - }, - }, - Tags: map[string]*string{ - "newKey": to.Ptr("newVal"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.BackupVaultResource = armdataprotection.BackupVaultResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults"), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/Backupvaults/swaggerExample"), - // Location: to.Ptr("WestUS"), - // Tags: map[string]*string{ - // "newKey": to.Ptr("newVal"), - // }, - // Properties: &armdataprotection.BackupVault{ - // MonitoringSettings: &armdataprotection.MonitoringSettings{ - // AzureMonitorAlertSettings: &armdataprotection.AzureMonitorAlertSettings{ - // AlertsForAllJobFailures: to.Ptr(armdataprotection.AlertsStateEnabled), - // }, - // }, - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // StorageSettings: []*armdataprotection.StorageSetting{ - // { - // Type: to.Ptr(armdataprotection.StorageSettingTypesLocallyRedundant), - // DatastoreType: to.Ptr(armdataprotection.StorageSettingStoreTypesVaultStore), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/VaultCRUD/CheckBackupVaultsNameAvailability.json -func ExampleBackupVaultsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBackupVaultsClient().CheckNameAvailability(ctx, "SampleResourceGroup", "westus", armdataprotection.CheckNameAvailabilityRequest{ - Name: to.Ptr("swaggerExample"), - Type: to.Ptr("Microsoft.DataProtection/BackupVaults"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckNameAvailabilityResult = armdataprotection.CheckNameAvailabilityResult{ - // NameAvailable: to.Ptr(true), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/client.go b/sdk/resourcemanager/dataprotection/armdataprotection/client.go index dc81e1dbe77f..4426c0dc1d21 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type Client struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,27 +46,37 @@ func NewClient(subscriptionID string, credential azcore.TokenCredential, options // CheckFeatureSupport - Validates if a feature is supported // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - parameters - Feature support request object // - options - ClientCheckFeatureSupportOptions contains the optional parameters for the Client.CheckFeatureSupport method. func (client *Client) CheckFeatureSupport(ctx context.Context, location string, parameters FeatureValidationRequestBaseClassification, options *ClientCheckFeatureSupportOptions) (ClientCheckFeatureSupportResponse, error) { + var err error + const operationName = "Client.CheckFeatureSupport" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.checkFeatureSupportCreateRequest(ctx, location, parameters, options) if err != nil { return ClientCheckFeatureSupportResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientCheckFeatureSupportResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientCheckFeatureSupportResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientCheckFeatureSupportResponse{}, err } - return client.checkFeatureSupportHandleResponse(resp) + resp, err := client.checkFeatureSupportHandleResponse(httpResp) + return resp, err } // checkFeatureSupportCreateRequest creates the CheckFeatureSupport request. func (client *Client) checkFeatureSupportCreateRequest(ctx context.Context, location string, parameters FeatureValidationRequestBaseClassification, options *ClientCheckFeatureSupportOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/checkFeatureSupport" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if location == "" { return nil, errors.New("parameter location cannot be empty") @@ -78,10 +87,13 @@ func (client *Client) checkFeatureSupportCreateRequest(ctx context.Context, loca return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // checkFeatureSupportHandleResponse handles the CheckFeatureSupport response. diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/client_example_test.go deleted file mode 100644 index 86b0a330a23d..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/client_example_test.go +++ /dev/null @@ -1,61 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/CheckfeatureSupport.json -func ExampleClient_CheckFeatureSupport() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewClient().CheckFeatureSupport(ctx, "WestUS", &armdataprotection.FeatureValidationRequest{ - ObjectType: to.Ptr("FeatureValidationRequest"), - FeatureType: to.Ptr(armdataprotection.FeatureTypeDataSourceType), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res = armdataprotection.ClientCheckFeatureSupportResponse{ - // FeatureValidationResponseBaseClassification: &armdataprotection.FeatureValidationResponse{ - // ObjectType: to.Ptr("FeatureValidationResponse"), - // FeatureType: to.Ptr(armdataprotection.FeatureTypeDataSourceType), - // Features: []*armdataprotection.SupportedFeature{ - // { - // ExposureControlledFeatures: []*string{ - // }, - // FeatureName: to.Ptr("Microsoft.Storage/storageAccounts/blobServices"), - // SupportStatus: to.Ptr(armdataprotection.FeatureSupportStatusPrivatePreview), - // }, - // { - // ExposureControlledFeatures: []*string{ - // }, - // FeatureName: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // SupportStatus: to.Ptr(armdataprotection.FeatureSupportStatusPublicPreview), - // }}, - // }, - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/client_factory.go b/sdk/resourcemanager/dataprotection/armdataprotection/client_factory.go index f72158f5a7f1..bc966608bfaa 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/client_factory.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/client_factory.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -28,7 +27,7 @@ type ClientFactory struct { // - 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) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,92 +37,128 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewBackupVaultsClient() *BackupVaultsClient { - subClient, _ := NewBackupVaultsClient(c.subscriptionID, c.credential, c.options) +// NewBackupInstancesClient creates a new instance of BackupInstancesClient. +func (c *ClientFactory) NewBackupInstancesClient() *BackupInstancesClient { + subClient, _ := NewBackupInstancesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationResultClient() *OperationResultClient { - subClient, _ := NewOperationResultClient(c.subscriptionID, c.credential, c.options) +// NewBackupPoliciesClient creates a new instance of BackupPoliciesClient. +func (c *ClientFactory) NewBackupPoliciesClient() *BackupPoliciesClient { + subClient, _ := NewBackupPoliciesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationStatusClient() *OperationStatusClient { - subClient, _ := NewOperationStatusClient(c.subscriptionID, c.credential, c.options) +// NewBackupVaultOperationResultsClient creates a new instance of BackupVaultOperationResultsClient. +func (c *ClientFactory) NewBackupVaultOperationResultsClient() *BackupVaultOperationResultsClient { + subClient, _ := NewBackupVaultOperationResultsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationStatusBackupVaultContextClient() *OperationStatusBackupVaultContextClient { - subClient, _ := NewOperationStatusBackupVaultContextClient(c.subscriptionID, c.credential, c.options) +// NewBackupVaultsClient creates a new instance of BackupVaultsClient. +func (c *ClientFactory) NewBackupVaultsClient() *BackupVaultsClient { + subClient, _ := NewBackupVaultsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationStatusResourceGroupContextClient() *OperationStatusResourceGroupContextClient { - subClient, _ := NewOperationStatusResourceGroupContextClient(c.subscriptionID, c.credential, c.options) +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewBackupVaultOperationResultsClient() *BackupVaultOperationResultsClient { - subClient, _ := NewBackupVaultOperationResultsClient(c.subscriptionID, c.credential, c.options) +// NewCrossRegionRestoreJobClient creates a new instance of CrossRegionRestoreJobClient. +func (c *ClientFactory) NewCrossRegionRestoreJobClient() *CrossRegionRestoreJobClient { + subClient, _ := NewCrossRegionRestoreJobClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewClient() *Client { - subClient, _ := NewClient(c.subscriptionID, c.credential, c.options) +// NewCrossRegionRestoreJobsClient creates a new instance of CrossRegionRestoreJobsClient. +func (c *ClientFactory) NewCrossRegionRestoreJobsClient() *CrossRegionRestoreJobsClient { + subClient, _ := NewCrossRegionRestoreJobsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) +// NewDeletedBackupInstancesClient creates a new instance of DeletedBackupInstancesClient. +func (c *ClientFactory) NewDeletedBackupInstancesClient() *DeletedBackupInstancesClient { + subClient, _ := NewDeletedBackupInstancesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewBackupPoliciesClient() *BackupPoliciesClient { - subClient, _ := NewBackupPoliciesClient(c.subscriptionID, c.credential, c.options) +// NewDppResourceGuardProxyClient creates a new instance of DppResourceGuardProxyClient. +func (c *ClientFactory) NewDppResourceGuardProxyClient() *DppResourceGuardProxyClient { + subClient, _ := NewDppResourceGuardProxyClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewBackupInstancesClient() *BackupInstancesClient { - subClient, _ := NewBackupInstancesClient(c.subscriptionID, c.credential, c.options) +// NewExportJobsClient creates a new instance of ExportJobsClient. +func (c *ClientFactory) NewExportJobsClient() *ExportJobsClient { + subClient, _ := NewExportJobsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewRecoveryPointsClient() *RecoveryPointsClient { - subClient, _ := NewRecoveryPointsClient(c.subscriptionID, c.credential, c.options) +// NewExportJobsOperationResultClient creates a new instance of ExportJobsOperationResultClient. +func (c *ClientFactory) NewExportJobsOperationResultClient() *ExportJobsOperationResultClient { + subClient, _ := NewExportJobsOperationResultClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewJobsClient creates a new instance of JobsClient. func (c *ClientFactory) NewJobsClient() *JobsClient { subClient, _ := NewJobsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewRestorableTimeRangesClient() *RestorableTimeRangesClient { - subClient, _ := NewRestorableTimeRangesClient(c.subscriptionID, c.credential, c.options) +// NewOperationResultClient creates a new instance of OperationResultClient. +func (c *ClientFactory) NewOperationResultClient() *OperationResultClient { + subClient, _ := NewOperationResultClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewExportJobsClient() *ExportJobsClient { - subClient, _ := NewExportJobsClient(c.subscriptionID, c.credential, c.options) +// NewOperationStatusBackupVaultContextClient creates a new instance of OperationStatusBackupVaultContextClient. +func (c *ClientFactory) NewOperationStatusBackupVaultContextClient() *OperationStatusBackupVaultContextClient { + subClient, _ := NewOperationStatusBackupVaultContextClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewExportJobsOperationResultClient() *ExportJobsOperationResultClient { - subClient, _ := NewExportJobsOperationResultClient(c.subscriptionID, c.credential, c.options) +// NewOperationStatusClient creates a new instance of OperationStatusClient. +func (c *ClientFactory) NewOperationStatusClient() *OperationStatusClient { + subClient, _ := NewOperationStatusClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewDeletedBackupInstancesClient() *DeletedBackupInstancesClient { - subClient, _ := NewDeletedBackupInstancesClient(c.subscriptionID, c.credential, c.options) +// NewOperationStatusResourceGroupContextClient creates a new instance of OperationStatusResourceGroupContextClient. +func (c *ClientFactory) NewOperationStatusResourceGroupContextClient() *OperationStatusResourceGroupContextClient { + subClient, _ := NewOperationStatusResourceGroupContextClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +// NewRecoveryPointsClient creates a new instance of RecoveryPointsClient. +func (c *ClientFactory) NewRecoveryPointsClient() *RecoveryPointsClient { + subClient, _ := NewRecoveryPointsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewResourceGuardsClient creates a new instance of ResourceGuardsClient. func (c *ClientFactory) NewResourceGuardsClient() *ResourceGuardsClient { subClient, _ := NewResourceGuardsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewDppResourceGuardProxyClient() *DppResourceGuardProxyClient { - subClient, _ := NewDppResourceGuardProxyClient(c.subscriptionID, c.credential, c.options) +// NewRestorableTimeRangesClient creates a new instance of RestorableTimeRangesClient. +func (c *ClientFactory) NewRestorableTimeRangesClient() *RestorableTimeRangesClient { + subClient, _ := NewRestorableTimeRangesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewSecondaryRPsClient creates a new instance of SecondaryRPsClient. +func (c *ClientFactory) NewSecondaryRPsClient() *SecondaryRPsClient { + subClient, _ := NewSecondaryRPsClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/constants.go b/sdk/resourcemanager/dataprotection/armdataprotection/constants.go index 7aa33104d47a..fdc7cfd40496 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/constants.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/constants.go @@ -3,15 +3,14 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection const ( - moduleName = "armdataprotection" - moduleVersion = "v2.3.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection" + moduleVersion = "v3.0.0" ) type AbsoluteMarker string @@ -346,6 +345,23 @@ func PossibleRecoveryOptionValues() []RecoveryOption { } } +// RecoveryPointCompletionState - Specifies recovery point completeness. Partial (i.e., only some of the intended items were +// backed up), or Completed (i.e., ALL intended items were backed up). +type RecoveryPointCompletionState string + +const ( + RecoveryPointCompletionStateCompleted RecoveryPointCompletionState = "Completed" + RecoveryPointCompletionStatePartial RecoveryPointCompletionState = "Partial" +) + +// PossibleRecoveryPointCompletionStateValues returns the possible values for the RecoveryPointCompletionState const type. +func PossibleRecoveryPointCompletionStateValues() []RecoveryPointCompletionState { + return []RecoveryPointCompletionState{ + RecoveryPointCompletionStateCompleted, + RecoveryPointCompletionStatePartial, + } +} + // RehydrationPriority - Priority to be used for rehydration. Values High or Standard type RehydrationPriority string @@ -417,6 +433,20 @@ func PossibleResourceMoveStateValues() []ResourceMoveState { } } +// ResourcePropertiesObjectType - Type of the specific object - used for deserializing +type ResourcePropertiesObjectType string + +const ( + ResourcePropertiesObjectTypeDefaultResourceProperties ResourcePropertiesObjectType = "DefaultResourceProperties" +) + +// PossibleResourcePropertiesObjectTypeValues returns the possible values for the ResourcePropertiesObjectType const type. +func PossibleResourcePropertiesObjectTypeValues() []ResourcePropertiesObjectType { + return []ResourcePropertiesObjectType{ + ResourcePropertiesObjectTypeDefaultResourceProperties, + } +} + // RestoreSourceDataStoreType - Gets or sets the type of the source data store. type RestoreSourceDataStoreType string diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/crossregionrestorejob_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/crossregionrestorejob_client.go new file mode 100644 index 000000000000..595d7885cce2 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/crossregionrestorejob_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 armdataprotection + +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" +) + +// CrossRegionRestoreJobClient contains the methods for the CrossRegionRestoreJob group. +// Don't use this type directly, use NewCrossRegionRestoreJobClient() instead. +type CrossRegionRestoreJobClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCrossRegionRestoreJobClient creates a new instance of CrossRegionRestoreJobClient 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 NewCrossRegionRestoreJobClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CrossRegionRestoreJobClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CrossRegionRestoreJobClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - parameters - Request body for operation +// - options - CrossRegionRestoreJobClientGetOptions contains the optional parameters for the CrossRegionRestoreJobClient.Get +// method. +func (client *CrossRegionRestoreJobClient) Get(ctx context.Context, resourceGroupName string, location string, parameters CrossRegionRestoreJobRequest, options *CrossRegionRestoreJobClientGetOptions) (CrossRegionRestoreJobClientGetResponse, error) { + var err error + const operationName = "CrossRegionRestoreJobClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, location, parameters, options) + if err != nil { + return CrossRegionRestoreJobClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CrossRegionRestoreJobClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CrossRegionRestoreJobClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *CrossRegionRestoreJobClient) getCreateRequest(ctx context.Context, resourceGroupName string, location string, parameters CrossRegionRestoreJobRequest, options *CrossRegionRestoreJobClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/fetchCrossRegionRestoreJob" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CrossRegionRestoreJobClient) getHandleResponse(resp *http.Response) (CrossRegionRestoreJobClientGetResponse, error) { + result := CrossRegionRestoreJobClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureBackupJobResource); err != nil { + return CrossRegionRestoreJobClientGetResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/crossregionrestorejobs_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/crossregionrestorejobs_client.go new file mode 100644 index 000000000000..fc8a5d101302 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/crossregionrestorejobs_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 armdataprotection + +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" +) + +// CrossRegionRestoreJobsClient contains the methods for the CrossRegionRestoreJobs group. +// Don't use this type directly, use NewCrossRegionRestoreJobsClient() instead. +type CrossRegionRestoreJobsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewCrossRegionRestoreJobsClient creates a new instance of CrossRegionRestoreJobsClient 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 NewCrossRegionRestoreJobsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CrossRegionRestoreJobsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CrossRegionRestoreJobsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - parameters - Request body for operation +// - options - CrossRegionRestoreJobsClientListOptions contains the optional parameters for the CrossRegionRestoreJobsClient.NewListPager +// method. +func (client *CrossRegionRestoreJobsClient) NewListPager(resourceGroupName string, location string, parameters CrossRegionRestoreJobsRequest, options *CrossRegionRestoreJobsClientListOptions) *runtime.Pager[CrossRegionRestoreJobsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[CrossRegionRestoreJobsClientListResponse]{ + More: func(page CrossRegionRestoreJobsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CrossRegionRestoreJobsClientListResponse) (CrossRegionRestoreJobsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CrossRegionRestoreJobsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, location, parameters, options) + }, nil) + if err != nil { + return CrossRegionRestoreJobsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *CrossRegionRestoreJobsClient) listCreateRequest(ctx context.Context, resourceGroupName string, location string, parameters CrossRegionRestoreJobsRequest, options *CrossRegionRestoreJobsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/fetchCrossRegionRestoreJobs" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CrossRegionRestoreJobsClient) listHandleResponse(resp *http.Response) (CrossRegionRestoreJobsClientListResponse, error) { + result := CrossRegionRestoreJobsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureBackupJobResourceList); err != nil { + return CrossRegionRestoreJobsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/deletedbackupinstances_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/deletedbackupinstances_client.go index 49112d51b22d..e074440a91f9 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/deletedbackupinstances_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/deletedbackupinstances_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type DeletedBackupInstancesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDeletedBackupInstancesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeletedBackupInstancesClient, error) { - cl, err := arm.NewClient(moduleName+".DeletedBackupInstancesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,30 +46,40 @@ func NewDeletedBackupInstancesClient(subscriptionID string, credential azcore.To // Get - Gets a deleted backup instance with name in a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the deleted backup instance // - options - DeletedBackupInstancesClientGetOptions contains the optional parameters for the DeletedBackupInstancesClient.Get // method. func (client *DeletedBackupInstancesClient) Get(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *DeletedBackupInstancesClientGetOptions) (DeletedBackupInstancesClientGetResponse, error) { + var err error + const operationName = "DeletedBackupInstancesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return DeletedBackupInstancesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DeletedBackupInstancesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DeletedBackupInstancesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DeletedBackupInstancesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *DeletedBackupInstancesClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *DeletedBackupInstancesClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -89,7 +98,7 @@ func (client *DeletedBackupInstancesClient) getCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -106,7 +115,7 @@ func (client *DeletedBackupInstancesClient) getHandleResponse(resp *http.Respons // NewListPager - Gets deleted backup instances belonging to a backup vault // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - DeletedBackupInstancesClientListOptions contains the optional parameters for the DeletedBackupInstancesClient.NewListPager @@ -117,31 +126,29 @@ func (client *DeletedBackupInstancesClient) NewListPager(resourceGroupName strin return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DeletedBackupInstancesClientListResponse) (DeletedBackupInstancesClientListResponse, 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 DeletedBackupInstancesClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeletedBackupInstancesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + }, nil) if err != nil { return DeletedBackupInstancesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DeletedBackupInstancesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. func (client *DeletedBackupInstancesClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *DeletedBackupInstancesClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -156,7 +163,7 @@ func (client *DeletedBackupInstancesClient) listCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -174,7 +181,7 @@ func (client *DeletedBackupInstancesClient) listHandleResponse(resp *http.Respon // BeginUndelete - // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the deleted backup instance @@ -186,34 +193,48 @@ func (client *DeletedBackupInstancesClient) BeginUndelete(ctx context.Context, r if err != nil { return nil, err } - return runtime.NewPoller[DeletedBackupInstancesClientUndeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DeletedBackupInstancesClientUndeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[DeletedBackupInstancesClientUndeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DeletedBackupInstancesClientUndeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Undelete - // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *DeletedBackupInstancesClient) undelete(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *DeletedBackupInstancesClientBeginUndeleteOptions) (*http.Response, error) { + var err error + const operationName = "DeletedBackupInstancesClient.BeginUndelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.undeleteCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // undeleteCreateRequest creates the Undelete request. func (client *DeletedBackupInstancesClient) undeleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *DeletedBackupInstancesClientBeginUndeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/deletedBackupInstances/{backupInstanceName}/undelete" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -232,7 +253,7 @@ func (client *DeletedBackupInstancesClient) undeleteCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/deletedbackupinstances_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/deletedbackupinstances_client_example_test.go deleted file mode 100644 index 570fc2e6f478..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/deletedbackupinstances_client_example_test.go +++ /dev/null @@ -1,167 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/DeletedBackupInstanceOperations/ListDeletedBackupInstances.json -func ExampleDeletedBackupInstancesClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDeletedBackupInstancesClient().NewListPager("000pikumar", "PratikPrivatePreviewVault1", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DeletedBackupInstanceResourceList = armdataprotection.DeletedBackupInstanceResourceList{ - // Value: []*armdataprotection.DeletedBackupInstanceResource{ - // { - // Name: to.Ptr("testInstance1"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/deletedBackupInstances"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/deletedBackupInstances/testInstance1"), - // Properties: &armdataprotection.DeletedBackupInstance{ - // DataSourceInfo: &armdataprotection.Datasource{ - // DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // ObjectType: to.Ptr("Datasource"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("testdb"), - // ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // ResourceURI: to.Ptr(""), - // }, - // DataSourceSetInfo: &armdataprotection.DatasourceSet{ - // DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // ObjectType: to.Ptr("DatasourceSet"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("viveksipgtest"), - // ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"), - // ResourceURI: to.Ptr(""), - // }, - // FriendlyName: to.Ptr("testInstance1"), - // ObjectType: to.Ptr("DeletedBackupInstance"), - // PolicyInfo: &armdataprotection.PolicyInfo{ - // PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1"), - // }, - // ProtectionStatus: &armdataprotection.ProtectionStatusDetails{ - // Status: to.Ptr(armdataprotection.StatusSoftDeleted), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // DeletionInfo: &armdataprotection.DeletionInfo{ - // BillingEndDate: to.Ptr("2022-05-06T00:00:36.6660445Z"), - // DeleteActivityID: to.Ptr("1e9ec790-d198-4efb-bbd7-e4669d5351a4"), - // DeletionTime: to.Ptr("2022-05-04T00:00:36.6660445Z"), - // ScheduledPurgeTime: to.Ptr("2022-05-20T00:00:36.6660445Z"), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/DeletedBackupInstanceOperations/GetDeletedBackupInstance.json -func ExampleDeletedBackupInstancesClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDeletedBackupInstancesClient().Get(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DeletedBackupInstanceResource = armdataprotection.DeletedBackupInstanceResource{ - // Name: to.Ptr("testInstance1"), - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/deletedBackupInstances"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/deletedBackupInstances/testInstance1"), - // Properties: &armdataprotection.DeletedBackupInstance{ - // DataSourceInfo: &armdataprotection.Datasource{ - // DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // ObjectType: to.Ptr("Datasource"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest/databases/testdb"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("testdb"), - // ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // ResourceURI: to.Ptr(""), - // }, - // DataSourceSetInfo: &armdataprotection.DatasourceSet{ - // DatasourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // ObjectType: to.Ptr("DatasourceSet"), - // ResourceID: to.Ptr("/subscriptions/f75d8d8b-6735-4697-82e1-1a7a3ff0d5d4/resourceGroups/viveksipgtest/providers/Microsoft.DBforPostgreSQL/servers/viveksipgtest"), - // ResourceLocation: to.Ptr(""), - // ResourceName: to.Ptr("viveksipgtest"), - // ResourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers"), - // ResourceURI: to.Ptr(""), - // }, - // FriendlyName: to.Ptr("testInstance1"), - // ObjectType: to.Ptr("DeletedBackupInstance"), - // PolicyInfo: &armdataprotection.PolicyInfo{ - // PolicyID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/000pikumar/providers/Microsoft.DataProtection/backupVaults/PratikPrivatePreviewVault1/backupPolicies/PratikPolicy1"), - // }, - // ProtectionStatus: &armdataprotection.ProtectionStatusDetails{ - // Status: to.Ptr(armdataprotection.StatusSoftDeleted), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // DeletionInfo: &armdataprotection.DeletionInfo{ - // BillingEndDate: to.Ptr("2022-05-06T00:00:36.6660445Z"), - // DeleteActivityID: to.Ptr("1e9ec790-d198-4efb-bbd7-e4669d5351a4"), - // DeletionTime: to.Ptr("2022-05-04T00:00:36.6660445Z"), - // ScheduledPurgeTime: to.Ptr("2022-05-20T00:00:36.6660445Z"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/DeletedBackupInstanceOperations/UndeleteDeletedBackupInstance.json -func ExampleDeletedBackupInstancesClient_BeginUndelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewDeletedBackupInstancesClient().BeginUndelete(ctx, "testrg", "testvault", "testbi", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/dppresourceguardproxy_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/dppresourceguardproxy_client.go index 7c78c3598fd0..98c8699acb3c 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/dppresourceguardproxy_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/dppresourceguardproxy_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type DppResourceGuardProxyClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDppResourceGuardProxyClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DppResourceGuardProxyClient, error) { - cl, err := arm.NewClient(moduleName+".DppResourceGuardProxyClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,7 +46,7 @@ func NewDppResourceGuardProxyClient(subscriptionID string, credential azcore.Tok // CreateOrUpdate - Creates or Updates a ResourceGuardProxy // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - resourceGuardProxyName - name of the resource guard proxy @@ -55,23 +54,33 @@ func NewDppResourceGuardProxyClient(subscriptionID string, credential azcore.Tok // - options - DppResourceGuardProxyClientCreateOrUpdateOptions contains the optional parameters for the DppResourceGuardProxyClient.CreateOrUpdate // method. func (client *DppResourceGuardProxyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, parameters ResourceGuardProxyBaseResource, options *DppResourceGuardProxyClientCreateOrUpdateOptions) (DppResourceGuardProxyClientCreateOrUpdateResponse, error) { + var err error + const operationName = "DppResourceGuardProxyClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, vaultName, resourceGuardProxyName, parameters, options) if err != nil { return DppResourceGuardProxyClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DppResourceGuardProxyClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DppResourceGuardProxyClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DppResourceGuardProxyClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. func (client *DppResourceGuardProxyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, parameters ResourceGuardProxyBaseResource, options *DppResourceGuardProxyClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -90,10 +99,13 @@ func (client *DppResourceGuardProxyClient) createOrUpdateCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -108,23 +120,29 @@ func (client *DppResourceGuardProxyClient) createOrUpdateHandleResponse(resp *ht // Delete - Deletes the ResourceGuardProxy // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - resourceGuardProxyName - name of the resource guard proxy // - options - DppResourceGuardProxyClientDeleteOptions contains the optional parameters for the DppResourceGuardProxyClient.Delete // method. func (client *DppResourceGuardProxyClient) Delete(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, options *DppResourceGuardProxyClientDeleteOptions) (DppResourceGuardProxyClientDeleteResponse, error) { + var err error + const operationName = "DppResourceGuardProxyClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, vaultName, resourceGuardProxyName, options) if err != nil { return DppResourceGuardProxyClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DppResourceGuardProxyClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return DppResourceGuardProxyClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DppResourceGuardProxyClientDeleteResponse{}, err } return DppResourceGuardProxyClientDeleteResponse{}, nil } @@ -132,6 +150,9 @@ func (client *DppResourceGuardProxyClient) Delete(ctx context.Context, resourceG // deleteCreateRequest creates the Delete request. func (client *DppResourceGuardProxyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, options *DppResourceGuardProxyClientDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -150,7 +171,7 @@ func (client *DppResourceGuardProxyClient) deleteCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -159,30 +180,40 @@ func (client *DppResourceGuardProxyClient) deleteCreateRequest(ctx context.Conte // Get - Returns the ResourceGuardProxy object associated with the vault, and that matches the name in the request // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - resourceGuardProxyName - name of the resource guard proxy // - options - DppResourceGuardProxyClientGetOptions contains the optional parameters for the DppResourceGuardProxyClient.Get // method. func (client *DppResourceGuardProxyClient) Get(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, options *DppResourceGuardProxyClientGetOptions) (DppResourceGuardProxyClientGetResponse, error) { + var err error + const operationName = "DppResourceGuardProxyClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, resourceGuardProxyName, options) if err != nil { return DppResourceGuardProxyClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DppResourceGuardProxyClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DppResourceGuardProxyClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DppResourceGuardProxyClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *DppResourceGuardProxyClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, options *DppResourceGuardProxyClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -201,7 +232,7 @@ func (client *DppResourceGuardProxyClient) getCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -218,7 +249,7 @@ func (client *DppResourceGuardProxyClient) getHandleResponse(resp *http.Response // NewListPager - Returns the list of ResourceGuardProxies associated with the vault // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - DppResourceGuardProxyClientListOptions contains the optional parameters for the DppResourceGuardProxyClient.NewListPager @@ -229,31 +260,29 @@ func (client *DppResourceGuardProxyClient) NewListPager(resourceGroupName string return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DppResourceGuardProxyClientListResponse) (DppResourceGuardProxyClientListResponse, 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) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DppResourceGuardProxyClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + }, nil) if err != nil { return DppResourceGuardProxyClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DppResourceGuardProxyClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DppResourceGuardProxyClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. func (client *DppResourceGuardProxyClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *DppResourceGuardProxyClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -268,7 +297,7 @@ func (client *DppResourceGuardProxyClient) listCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -286,7 +315,7 @@ func (client *DppResourceGuardProxyClient) listHandleResponse(resp *http.Respons // UnlockDelete - UnlockDelete call for ResourceGuardProxy, executed before one can delete it // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - resourceGuardProxyName - name of the resource guard proxy @@ -294,23 +323,33 @@ func (client *DppResourceGuardProxyClient) listHandleResponse(resp *http.Respons // - options - DppResourceGuardProxyClientUnlockDeleteOptions contains the optional parameters for the DppResourceGuardProxyClient.UnlockDelete // method. func (client *DppResourceGuardProxyClient) UnlockDelete(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, parameters UnlockDeleteRequest, options *DppResourceGuardProxyClientUnlockDeleteOptions) (DppResourceGuardProxyClientUnlockDeleteResponse, error) { + var err error + const operationName = "DppResourceGuardProxyClient.UnlockDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.unlockDeleteCreateRequest(ctx, resourceGroupName, vaultName, resourceGuardProxyName, parameters, options) if err != nil { return DppResourceGuardProxyClientUnlockDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DppResourceGuardProxyClientUnlockDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DppResourceGuardProxyClientUnlockDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DppResourceGuardProxyClientUnlockDeleteResponse{}, err } - return client.unlockDeleteHandleResponse(resp) + resp, err := client.unlockDeleteHandleResponse(httpResp) + return resp, err } // unlockDeleteCreateRequest creates the UnlockDelete request. func (client *DppResourceGuardProxyClient) unlockDeleteCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, parameters UnlockDeleteRequest, options *DppResourceGuardProxyClientUnlockDeleteOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupResourceGuardProxies/{resourceGuardProxyName}/unlockDelete" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -329,10 +368,13 @@ func (client *DppResourceGuardProxyClient) unlockDeleteCreateRequest(ctx context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // unlockDeleteHandleResponse handles the UnlockDelete response. diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/dppresourceguardproxy_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/dppresourceguardproxy_client_example_test.go deleted file mode 100644 index aa51eb9f6a5e..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/dppresourceguardproxy_client_example_test.go +++ /dev/null @@ -1,192 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardProxyCRUD/ListResourceGuardProxy.json -func ExampleDppResourceGuardProxyClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDppResourceGuardProxyClient().NewListPager("SampleResourceGroup", "sampleVault", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourceGuardProxyBaseResourceList = armdataprotection.ResourceGuardProxyBaseResourceList{ - // Value: []*armdataprotection.ResourceGuardProxyBaseResource{ - // { - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/vaults/backupResourceGuardProxies"), - // ID: to.Ptr("/subscriptions/5e13b949-1218-4d18-8b99-7e12155ec4f7/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/sampleVault/backupResourceGuardProxies/swaggerExample"), - // Properties: &armdataprotection.ResourceGuardProxyBase{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // LastUpdatedTime: to.Ptr("2022-09-16T11:44:37.6130487Z"), - // ResourceGuardOperationDetails: []*armdataprotection.ResourceGuardOperationDetail{ - // { - // DefaultResourceRequest: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteBackupInstanceRequests/default"), - // VaultCriticalOperation: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/delete"), - // }, - // { - // DefaultResourceRequest: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteResourceGuardProxyRequests/default"), - // VaultCriticalOperation: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/delete"), - // }}, - // ResourceGuardResourceID: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardProxyCRUD/GetResourceGuardProxy.json -func ExampleDppResourceGuardProxyClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDppResourceGuardProxyClient().Get(ctx, "SampleResourceGroup", "sampleVault", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourceGuardProxyBaseResource = armdataprotection.ResourceGuardProxyBaseResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/vaults/backupResourceGuardProxies"), - // ID: to.Ptr("/subscriptions/5e13b949-1218-4d18-8b99-7e12155ec4f7/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/sampleVault/backupResourceGuardProxies/swaggerExample"), - // Properties: &armdataprotection.ResourceGuardProxyBase{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // LastUpdatedTime: to.Ptr("2022-09-16T11:44:37.6130487Z"), - // ResourceGuardOperationDetails: []*armdataprotection.ResourceGuardOperationDetail{ - // { - // DefaultResourceRequest: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteBackupInstanceRequests/default"), - // VaultCriticalOperation: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/delete"), - // }, - // { - // DefaultResourceRequest: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteResourceGuardProxyRequests/default"), - // VaultCriticalOperation: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/delete"), - // }}, - // ResourceGuardResourceID: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json -func ExampleDppResourceGuardProxyClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDppResourceGuardProxyClient().CreateOrUpdate(ctx, "SampleResourceGroup", "sampleVault", "swaggerExample", armdataprotection.ResourceGuardProxyBaseResource{ - Properties: &armdataprotection.ResourceGuardProxyBase{ - ResourceGuardResourceID: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourceGuardProxyBaseResource = armdataprotection.ResourceGuardProxyBaseResource{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.DataProtection/vaults/backupResourceGuardProxies"), - // ID: to.Ptr("/subscriptions/5e13b949-1218-4d18-8b99-7e12155ec4f7/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/sampleVault/backupResourceGuardProxies/swaggerExample"), - // Properties: &armdataprotection.ResourceGuardProxyBase{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // LastUpdatedTime: to.Ptr("2022-09-16T11:44:37.6130487Z"), - // ResourceGuardOperationDetails: []*armdataprotection.ResourceGuardOperationDetail{ - // { - // DefaultResourceRequest: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteBackupInstanceRequests/default"), - // VaultCriticalOperation: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/delete"), - // }, - // { - // DefaultResourceRequest: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteResourceGuardProxyRequests/default"), - // VaultCriticalOperation: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/delete"), - // }}, - // ResourceGuardResourceID: to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardProxyCRUD/DeleteResourceGuardProxy.json -func ExampleDppResourceGuardProxyClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewDppResourceGuardProxyClient().Delete(ctx, "SampleResourceGroup", "sampleVault", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardProxyCRUD/UnlockDeleteResourceGuardProxy.json -func ExampleDppResourceGuardProxyClient_UnlockDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewDppResourceGuardProxyClient().UnlockDelete(ctx, "SampleResourceGroup", "sampleVault", "swaggerExample", armdataprotection.UnlockDeleteRequest{ - ResourceGuardOperationRequests: []*string{ - to.Ptr("/subscriptions/f9e67185-f313-4e79-aa71-6458d429369d/resourceGroups/ResourceGuardSecurityAdminRG/providers/Microsoft.DataProtection/resourceGuards/ResourceGuardTestResource/deleteBackupInstanceRequests/default")}, - ResourceToBeDeleted: to.Ptr("/subscriptions/5e13b949-1218-4d18-8b99-7e12155ec4f7/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/sampleVault/backupInstances/TestBI9779f4de"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.UnlockDeleteResponse = armdataprotection.UnlockDeleteResponse{ - // UnlockDeleteExpiryTime: to.Ptr("2022-09-16T12:50:10.7039695Z"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobs_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/exportjobs_client.go index bc6873de3eb7..01656e3ad197 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobs_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/exportjobs_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type ExportJobsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExportJobsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExportJobsClient, error) { - cl, err := arm.NewClient(moduleName+".ExportJobsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,7 +46,7 @@ func NewExportJobsClient(subscriptionID string, credential azcore.TokenCredentia // BeginTrigger - Triggers export of jobs and returns an OperationID to track. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - ExportJobsClientBeginTriggerOptions contains the optional parameters for the ExportJobsClient.BeginTrigger method. @@ -57,36 +56,49 @@ func (client *ExportJobsClient) BeginTrigger(ctx context.Context, resourceGroupN if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExportJobsClientTriggerResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExportJobsClientTriggerResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[ExportJobsClientTriggerResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExportJobsClientTriggerResponse]{ + Tracer: client.internal.Tracer(), + }) } } // Trigger - Triggers export of jobs and returns an OperationID to track. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 func (client *ExportJobsClient) trigger(ctx context.Context, resourceGroupName string, vaultName string, options *ExportJobsClientBeginTriggerOptions) (*http.Response, error) { + var err error + const operationName = "ExportJobsClient.BeginTrigger" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.triggerCreateRequest(ctx, resourceGroupName, vaultName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // triggerCreateRequest creates the Trigger request. func (client *ExportJobsClient) triggerCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *ExportJobsClientBeginTriggerOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/exportBackupJobs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -101,7 +113,7 @@ func (client *ExportJobsClient) triggerCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobs_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/exportjobs_client_example_test.go deleted file mode 100644 index a32b697c436a..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobs_client_example_test.go +++ /dev/null @@ -1,39 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/JobCRUD/TriggerExportJobs.json -func ExampleExportJobsClient_BeginTrigger() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewExportJobsClient().BeginTrigger(ctx, "SwaggerTestRg", "NetSDKTestRsVault", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobsoperationresult_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/exportjobsoperationresult_client.go index f04608bd0035..2ac6b3afd18a 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobsoperationresult_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/exportjobsoperationresult_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type ExportJobsOperationResultClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExportJobsOperationResultClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExportJobsOperationResultClient, error) { - cl, err := arm.NewClient(moduleName+".ExportJobsOperationResultClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -49,30 +48,40 @@ func NewExportJobsOperationResultClient(subscriptionID string, credential azcore // jobs in JSON serialized format. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - operationID - OperationID which represents the export job. // - options - ExportJobsOperationResultClientGetOptions contains the optional parameters for the ExportJobsOperationResultClient.Get // method. func (client *ExportJobsOperationResultClient) Get(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *ExportJobsOperationResultClientGetOptions) (ExportJobsOperationResultClientGetResponse, error) { + var err error + const operationName = "ExportJobsOperationResultClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, operationID, options) if err != nil { return ExportJobsOperationResultClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportJobsOperationResultClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return ExportJobsOperationResultClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ExportJobsOperationResultClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *ExportJobsOperationResultClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *ExportJobsOperationResultClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/operations/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -91,7 +100,7 @@ func (client *ExportJobsOperationResultClient) getCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobsoperationresult_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/exportjobsoperationresult_client_example_test.go deleted file mode 100644 index 77bf9c1d347a..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/exportjobsoperationresult_client_example_test.go +++ /dev/null @@ -1,44 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/JobCRUD/GetExportJobsOperationResult.json -func ExampleExportJobsOperationResultClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportJobsOperationResultClient().Get(ctx, "SwaggerTestRg", "NetSDKTestRsVault", "00000000-0000-0000-0000-000000000000", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportJobsResult = armdataprotection.ExportJobsResult{ - // BlobSasKey: to.Ptr("someKey"), - // BlobURL: to.Ptr("https://azureblob.blob.core.windows.net/reportcontainer/exportjobsreport00000000-0000-0000-0000-000000000000"), - // ExcelFileBlobSasKey: to.Ptr("someKey"), - // ExcelFileBlobURL: to.Ptr("https://azureblob.blob.core.windows.net/reportcontainer/exportjobsreport00000000-0000-0000-0000-000000000000_ExcelFile.xlsx"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupinstances_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupinstances_server.go new file mode 100644 index 000000000000..b8a26931206a --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupinstances_server.go @@ -0,0 +1,1015 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// BackupInstancesServer is a fake server for instances of the armdataprotection.BackupInstancesClient type. +type BackupInstancesServer struct { + // BeginAdhocBackup is the fake for method BackupInstancesClient.BeginAdhocBackup + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginAdhocBackup func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters armdataprotection.TriggerBackupRequest, options *armdataprotection.BackupInstancesClientBeginAdhocBackupOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientAdhocBackupResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method BackupInstancesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters armdataprotection.BackupInstanceResource, options *armdataprotection.BackupInstancesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method BackupInstancesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.BackupInstancesClientBeginDeleteOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BackupInstancesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.BackupInstancesClientGetOptions) (resp azfake.Responder[armdataprotection.BackupInstancesClientGetResponse], errResp azfake.ErrorResponder) + + // GetBackupInstanceOperationResult is the fake for method BackupInstancesClient.GetBackupInstanceOperationResult + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + GetBackupInstanceOperationResult func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, operationID string, options *armdataprotection.BackupInstancesClientGetBackupInstanceOperationResultOptions) (resp azfake.Responder[armdataprotection.BackupInstancesClientGetBackupInstanceOperationResultResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method BackupInstancesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, options *armdataprotection.BackupInstancesClientListOptions) (resp azfake.PagerResponder[armdataprotection.BackupInstancesClientListResponse]) + + // BeginResumeBackups is the fake for method BackupInstancesClient.BeginResumeBackups + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginResumeBackups func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.BackupInstancesClientBeginResumeBackupsOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientResumeBackupsResponse], errResp azfake.ErrorResponder) + + // BeginResumeProtection is the fake for method BackupInstancesClient.BeginResumeProtection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginResumeProtection func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.BackupInstancesClientBeginResumeProtectionOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientResumeProtectionResponse], errResp azfake.ErrorResponder) + + // BeginStopProtection is the fake for method BackupInstancesClient.BeginStopProtection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginStopProtection func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.BackupInstancesClientBeginStopProtectionOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientStopProtectionResponse], errResp azfake.ErrorResponder) + + // BeginSuspendBackups is the fake for method BackupInstancesClient.BeginSuspendBackups + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSuspendBackups func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.BackupInstancesClientBeginSuspendBackupsOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientSuspendBackupsResponse], errResp azfake.ErrorResponder) + + // BeginSyncBackupInstance is the fake for method BackupInstancesClient.BeginSyncBackupInstance + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSyncBackupInstance func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters armdataprotection.SyncBackupInstanceRequest, options *armdataprotection.BackupInstancesClientBeginSyncBackupInstanceOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientSyncBackupInstanceResponse], errResp azfake.ErrorResponder) + + // BeginTriggerCrossRegionRestore is the fake for method BackupInstancesClient.BeginTriggerCrossRegionRestore + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginTriggerCrossRegionRestore func(ctx context.Context, resourceGroupName string, location string, parameters armdataprotection.CrossRegionRestoreRequestObject, options *armdataprotection.BackupInstancesClientBeginTriggerCrossRegionRestoreOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerCrossRegionRestoreResponse], errResp azfake.ErrorResponder) + + // BeginTriggerRehydrate is the fake for method BackupInstancesClient.BeginTriggerRehydrate + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginTriggerRehydrate func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters armdataprotection.AzureBackupRehydrationRequest, options *armdataprotection.BackupInstancesClientBeginTriggerRehydrateOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerRehydrateResponse], errResp azfake.ErrorResponder) + + // BeginTriggerRestore is the fake for method BackupInstancesClient.BeginTriggerRestore + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginTriggerRestore func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters armdataprotection.AzureBackupRestoreRequestClassification, options *armdataprotection.BackupInstancesClientBeginTriggerRestoreOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerRestoreResponse], errResp azfake.ErrorResponder) + + // BeginValidateCrossRegionRestore is the fake for method BackupInstancesClient.BeginValidateCrossRegionRestore + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginValidateCrossRegionRestore func(ctx context.Context, resourceGroupName string, location string, parameters armdataprotection.ValidateCrossRegionRestoreRequestObject, options *armdataprotection.BackupInstancesClientBeginValidateCrossRegionRestoreOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateCrossRegionRestoreResponse], errResp azfake.ErrorResponder) + + // BeginValidateForBackup is the fake for method BackupInstancesClient.BeginValidateForBackup + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginValidateForBackup func(ctx context.Context, resourceGroupName string, vaultName string, parameters armdataprotection.ValidateForBackupRequest, options *armdataprotection.BackupInstancesClientBeginValidateForBackupOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateForBackupResponse], errResp azfake.ErrorResponder) + + // BeginValidateForRestore is the fake for method BackupInstancesClient.BeginValidateForRestore + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginValidateForRestore func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters armdataprotection.ValidateRestoreRequestObject, options *armdataprotection.BackupInstancesClientBeginValidateForRestoreOptions) (resp azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateForRestoreResponse], errResp azfake.ErrorResponder) +} + +// NewBackupInstancesServerTransport creates a new instance of BackupInstancesServerTransport with the provided implementation. +// The returned BackupInstancesServerTransport instance is connected to an instance of armdataprotection.BackupInstancesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBackupInstancesServerTransport(srv *BackupInstancesServer) *BackupInstancesServerTransport { + return &BackupInstancesServerTransport{ + srv: srv, + beginAdhocBackup: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientAdhocBackupResponse]](), + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armdataprotection.BackupInstancesClientListResponse]](), + beginResumeBackups: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientResumeBackupsResponse]](), + beginResumeProtection: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientResumeProtectionResponse]](), + beginStopProtection: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientStopProtectionResponse]](), + beginSuspendBackups: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientSuspendBackupsResponse]](), + beginSyncBackupInstance: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientSyncBackupInstanceResponse]](), + beginTriggerCrossRegionRestore: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerCrossRegionRestoreResponse]](), + beginTriggerRehydrate: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerRehydrateResponse]](), + beginTriggerRestore: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerRestoreResponse]](), + beginValidateCrossRegionRestore: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateCrossRegionRestoreResponse]](), + beginValidateForBackup: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateForBackupResponse]](), + beginValidateForRestore: newTracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateForRestoreResponse]](), + } +} + +// BackupInstancesServerTransport connects instances of armdataprotection.BackupInstancesClient to instances of BackupInstancesServer. +// Don't use this type directly, use NewBackupInstancesServerTransport instead. +type BackupInstancesServerTransport struct { + srv *BackupInstancesServer + beginAdhocBackup *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientAdhocBackupResponse]] + beginCreateOrUpdate *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armdataprotection.BackupInstancesClientListResponse]] + beginResumeBackups *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientResumeBackupsResponse]] + beginResumeProtection *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientResumeProtectionResponse]] + beginStopProtection *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientStopProtectionResponse]] + beginSuspendBackups *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientSuspendBackupsResponse]] + beginSyncBackupInstance *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientSyncBackupInstanceResponse]] + beginTriggerCrossRegionRestore *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerCrossRegionRestoreResponse]] + beginTriggerRehydrate *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerRehydrateResponse]] + beginTriggerRestore *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientTriggerRestoreResponse]] + beginValidateCrossRegionRestore *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateCrossRegionRestoreResponse]] + beginValidateForBackup *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateForBackupResponse]] + beginValidateForRestore *tracker[azfake.PollerResponder[armdataprotection.BackupInstancesClientValidateForRestoreResponse]] +} + +// Do implements the policy.Transporter interface for BackupInstancesServerTransport. +func (b *BackupInstancesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BackupInstancesClient.BeginAdhocBackup": + resp, err = b.dispatchBeginAdhocBackup(req) + case "BackupInstancesClient.BeginCreateOrUpdate": + resp, err = b.dispatchBeginCreateOrUpdate(req) + case "BackupInstancesClient.BeginDelete": + resp, err = b.dispatchBeginDelete(req) + case "BackupInstancesClient.Get": + resp, err = b.dispatchGet(req) + case "BackupInstancesClient.GetBackupInstanceOperationResult": + resp, err = b.dispatchGetBackupInstanceOperationResult(req) + case "BackupInstancesClient.NewListPager": + resp, err = b.dispatchNewListPager(req) + case "BackupInstancesClient.BeginResumeBackups": + resp, err = b.dispatchBeginResumeBackups(req) + case "BackupInstancesClient.BeginResumeProtection": + resp, err = b.dispatchBeginResumeProtection(req) + case "BackupInstancesClient.BeginStopProtection": + resp, err = b.dispatchBeginStopProtection(req) + case "BackupInstancesClient.BeginSuspendBackups": + resp, err = b.dispatchBeginSuspendBackups(req) + case "BackupInstancesClient.BeginSyncBackupInstance": + resp, err = b.dispatchBeginSyncBackupInstance(req) + case "BackupInstancesClient.BeginTriggerCrossRegionRestore": + resp, err = b.dispatchBeginTriggerCrossRegionRestore(req) + case "BackupInstancesClient.BeginTriggerRehydrate": + resp, err = b.dispatchBeginTriggerRehydrate(req) + case "BackupInstancesClient.BeginTriggerRestore": + resp, err = b.dispatchBeginTriggerRestore(req) + case "BackupInstancesClient.BeginValidateCrossRegionRestore": + resp, err = b.dispatchBeginValidateCrossRegionRestore(req) + case "BackupInstancesClient.BeginValidateForBackup": + resp, err = b.dispatchBeginValidateForBackup(req) + case "BackupInstancesClient.BeginValidateForRestore": + resp, err = b.dispatchBeginValidateForRestore(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginAdhocBackup(req *http.Request) (*http.Response, error) { + if b.srv.BeginAdhocBackup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginAdhocBackup not implemented")} + } + beginAdhocBackup := b.beginAdhocBackup.get(req) + if beginAdhocBackup == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backup` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.TriggerBackupRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginAdhocBackup(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginAdhocBackup = &respr + b.beginAdhocBackup.add(req, beginAdhocBackup) + } + + resp, err := server.PollerResponderNext(beginAdhocBackup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginAdhocBackup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginAdhocBackup) { + b.beginAdhocBackup.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if b.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := b.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.BackupInstanceResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + b.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + b.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + b.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if b.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := b.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginDelete(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + b.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + b.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + b.beginDelete.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackupInstanceResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchGetBackupInstanceOperationResult(req *http.Request) (*http.Response, error) { + if b.srv.GetBackupInstanceOperationResult == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBackupInstanceOperationResult not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.GetBackupInstanceOperationResult(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackupInstanceResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := b.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resp := b.srv.NewListPager(resourceGroupNameParam, vaultNameParam, nil) + newListPager = &resp + b.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.BackupInstancesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + b.newListPager.remove(req) + } + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginResumeBackups(req *http.Request) (*http.Response, error) { + if b.srv.BeginResumeBackups == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResumeBackups not implemented")} + } + beginResumeBackups := b.beginResumeBackups.get(req) + if beginResumeBackups == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resumeBackups` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginResumeBackups(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResumeBackups = &respr + b.beginResumeBackups.add(req, beginResumeBackups) + } + + resp, err := server.PollerResponderNext(beginResumeBackups, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginResumeBackups.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResumeBackups) { + b.beginResumeBackups.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginResumeProtection(req *http.Request) (*http.Response, error) { + if b.srv.BeginResumeProtection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResumeProtection not implemented")} + } + beginResumeProtection := b.beginResumeProtection.get(req) + if beginResumeProtection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resumeProtection` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginResumeProtection(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResumeProtection = &respr + b.beginResumeProtection.add(req, beginResumeProtection) + } + + resp, err := server.PollerResponderNext(beginResumeProtection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginResumeProtection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResumeProtection) { + b.beginResumeProtection.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginStopProtection(req *http.Request) (*http.Response, error) { + if b.srv.BeginStopProtection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStopProtection not implemented")} + } + beginStopProtection := b.beginStopProtection.get(req) + if beginStopProtection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/stopProtection` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginStopProtection(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStopProtection = &respr + b.beginStopProtection.add(req, beginStopProtection) + } + + resp, err := server.PollerResponderNext(beginStopProtection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginStopProtection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStopProtection) { + b.beginStopProtection.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginSuspendBackups(req *http.Request) (*http.Response, error) { + if b.srv.BeginSuspendBackups == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSuspendBackups not implemented")} + } + beginSuspendBackups := b.beginSuspendBackups.get(req) + if beginSuspendBackups == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/suspendBackups` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginSuspendBackups(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSuspendBackups = &respr + b.beginSuspendBackups.add(req, beginSuspendBackups) + } + + resp, err := server.PollerResponderNext(beginSuspendBackups, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginSuspendBackups.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSuspendBackups) { + b.beginSuspendBackups.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginSyncBackupInstance(req *http.Request) (*http.Response, error) { + if b.srv.BeginSyncBackupInstance == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSyncBackupInstance not implemented")} + } + beginSyncBackupInstance := b.beginSyncBackupInstance.get(req) + if beginSyncBackupInstance == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sync` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.SyncBackupInstanceRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginSyncBackupInstance(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSyncBackupInstance = &respr + b.beginSyncBackupInstance.add(req, beginSyncBackupInstance) + } + + resp, err := server.PollerResponderNext(beginSyncBackupInstance, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginSyncBackupInstance.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSyncBackupInstance) { + b.beginSyncBackupInstance.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginTriggerCrossRegionRestore(req *http.Request) (*http.Response, error) { + if b.srv.BeginTriggerCrossRegionRestore == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginTriggerCrossRegionRestore not implemented")} + } + beginTriggerCrossRegionRestore := b.beginTriggerCrossRegionRestore.get(req) + if beginTriggerCrossRegionRestore == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/crossRegionRestore` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.CrossRegionRestoreRequestObject](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginTriggerCrossRegionRestore(req.Context(), resourceGroupNameParam, locationParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginTriggerCrossRegionRestore = &respr + b.beginTriggerCrossRegionRestore.add(req, beginTriggerCrossRegionRestore) + } + + resp, err := server.PollerResponderNext(beginTriggerCrossRegionRestore, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginTriggerCrossRegionRestore.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginTriggerCrossRegionRestore) { + b.beginTriggerCrossRegionRestore.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginTriggerRehydrate(req *http.Request) (*http.Response, error) { + if b.srv.BeginTriggerRehydrate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginTriggerRehydrate not implemented")} + } + beginTriggerRehydrate := b.beginTriggerRehydrate.get(req) + if beginTriggerRehydrate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/rehydrate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.AzureBackupRehydrationRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginTriggerRehydrate(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginTriggerRehydrate = &respr + b.beginTriggerRehydrate.add(req, beginTriggerRehydrate) + } + + resp, err := server.PollerResponderNext(beginTriggerRehydrate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + b.beginTriggerRehydrate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginTriggerRehydrate) { + b.beginTriggerRehydrate.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginTriggerRestore(req *http.Request) (*http.Response, error) { + if b.srv.BeginTriggerRestore == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginTriggerRestore not implemented")} + } + beginTriggerRestore := b.beginTriggerRestore.get(req) + if beginTriggerRestore == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/restore` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalAzureBackupRestoreRequestClassification(raw) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginTriggerRestore(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginTriggerRestore = &respr + b.beginTriggerRestore.add(req, beginTriggerRestore) + } + + resp, err := server.PollerResponderNext(beginTriggerRestore, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginTriggerRestore.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginTriggerRestore) { + b.beginTriggerRestore.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginValidateCrossRegionRestore(req *http.Request) (*http.Response, error) { + if b.srv.BeginValidateCrossRegionRestore == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginValidateCrossRegionRestore not implemented")} + } + beginValidateCrossRegionRestore := b.beginValidateCrossRegionRestore.get(req) + if beginValidateCrossRegionRestore == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateCrossRegionRestore` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.ValidateCrossRegionRestoreRequestObject](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginValidateCrossRegionRestore(req.Context(), resourceGroupNameParam, locationParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginValidateCrossRegionRestore = &respr + b.beginValidateCrossRegionRestore.add(req, beginValidateCrossRegionRestore) + } + + resp, err := server.PollerResponderNext(beginValidateCrossRegionRestore, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginValidateCrossRegionRestore.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginValidateCrossRegionRestore) { + b.beginValidateCrossRegionRestore.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginValidateForBackup(req *http.Request) (*http.Response, error) { + if b.srv.BeginValidateForBackup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginValidateForBackup not implemented")} + } + beginValidateForBackup := b.beginValidateForBackup.get(req) + if beginValidateForBackup == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateForBackup` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.ValidateForBackupRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginValidateForBackup(req.Context(), resourceGroupNameParam, vaultNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginValidateForBackup = &respr + b.beginValidateForBackup.add(req, beginValidateForBackup) + } + + resp, err := server.PollerResponderNext(beginValidateForBackup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginValidateForBackup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginValidateForBackup) { + b.beginValidateForBackup.remove(req) + } + + return resp, nil +} + +func (b *BackupInstancesServerTransport) dispatchBeginValidateForRestore(req *http.Request) (*http.Response, error) { + if b.srv.BeginValidateForRestore == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginValidateForRestore not implemented")} + } + beginValidateForRestore := b.beginValidateForRestore.get(req) + if beginValidateForRestore == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateRestore` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.ValidateRestoreRequestObject](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginValidateForRestore(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginValidateForRestore = &respr + b.beginValidateForRestore.add(req, beginValidateForRestore) + } + + resp, err := server.PollerResponderNext(beginValidateForRestore, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginValidateForRestore.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginValidateForRestore) { + b.beginValidateForRestore.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/backuppolicies_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backuppolicies_server.go new file mode 100644 index 000000000000..3f17e723affa --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backuppolicies_server.go @@ -0,0 +1,246 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// BackupPoliciesServer is a fake server for instances of the armdataprotection.BackupPoliciesClient type. +type BackupPoliciesServer struct { + // CreateOrUpdate is the fake for method BackupPoliciesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, parameters armdataprotection.BaseBackupPolicyResource, options *armdataprotection.BackupPoliciesClientCreateOrUpdateOptions) (resp azfake.Responder[armdataprotection.BackupPoliciesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method BackupPoliciesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, options *armdataprotection.BackupPoliciesClientDeleteOptions) (resp azfake.Responder[armdataprotection.BackupPoliciesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BackupPoliciesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, backupPolicyName string, options *armdataprotection.BackupPoliciesClientGetOptions) (resp azfake.Responder[armdataprotection.BackupPoliciesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method BackupPoliciesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, options *armdataprotection.BackupPoliciesClientListOptions) (resp azfake.PagerResponder[armdataprotection.BackupPoliciesClientListResponse]) +} + +// NewBackupPoliciesServerTransport creates a new instance of BackupPoliciesServerTransport with the provided implementation. +// The returned BackupPoliciesServerTransport instance is connected to an instance of armdataprotection.BackupPoliciesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBackupPoliciesServerTransport(srv *BackupPoliciesServer) *BackupPoliciesServerTransport { + return &BackupPoliciesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataprotection.BackupPoliciesClientListResponse]](), + } +} + +// BackupPoliciesServerTransport connects instances of armdataprotection.BackupPoliciesClient to instances of BackupPoliciesServer. +// Don't use this type directly, use NewBackupPoliciesServerTransport instead. +type BackupPoliciesServerTransport struct { + srv *BackupPoliciesServer + newListPager *tracker[azfake.PagerResponder[armdataprotection.BackupPoliciesClientListResponse]] +} + +// Do implements the policy.Transporter interface for BackupPoliciesServerTransport. +func (b *BackupPoliciesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BackupPoliciesClient.CreateOrUpdate": + resp, err = b.dispatchCreateOrUpdate(req) + case "BackupPoliciesClient.Delete": + resp, err = b.dispatchDelete(req) + case "BackupPoliciesClient.Get": + resp, err = b.dispatchGet(req) + case "BackupPoliciesClient.NewListPager": + resp, err = b.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BackupPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if b.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.BaseBackupPolicyResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, vaultNameParam, backupPolicyNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BaseBackupPolicyResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BackupPoliciesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameParam, vaultNameParam, backupPolicyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BackupPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupPolicyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, backupPolicyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BaseBackupPolicyResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BackupPoliciesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := b.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupPolicies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resp := b.srv.NewListPager(resourceGroupNameParam, vaultNameParam, nil) + newListPager = &resp + b.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.BackupPoliciesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + b.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupvaultoperationresults_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupvaultoperationresults_server.go new file mode 100644 index 000000000000..ddc02308aca2 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupvaultoperationresults_server.go @@ -0,0 +1,114 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// BackupVaultOperationResultsServer is a fake server for instances of the armdataprotection.BackupVaultOperationResultsClient type. +type BackupVaultOperationResultsServer struct { + // Get is the fake for method BackupVaultOperationResultsClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + Get func(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *armdataprotection.BackupVaultOperationResultsClientGetOptions) (resp azfake.Responder[armdataprotection.BackupVaultOperationResultsClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewBackupVaultOperationResultsServerTransport creates a new instance of BackupVaultOperationResultsServerTransport with the provided implementation. +// The returned BackupVaultOperationResultsServerTransport instance is connected to an instance of armdataprotection.BackupVaultOperationResultsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBackupVaultOperationResultsServerTransport(srv *BackupVaultOperationResultsServer) *BackupVaultOperationResultsServerTransport { + return &BackupVaultOperationResultsServerTransport{srv: srv} +} + +// BackupVaultOperationResultsServerTransport connects instances of armdataprotection.BackupVaultOperationResultsClient to instances of BackupVaultOperationResultsServer. +// Don't use this type directly, use NewBackupVaultOperationResultsServerTransport instead. +type BackupVaultOperationResultsServerTransport struct { + srv *BackupVaultOperationResultsServer +} + +// Do implements the policy.Transporter interface for BackupVaultOperationResultsServerTransport. +func (b *BackupVaultOperationResultsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BackupVaultOperationResultsClient.Get": + resp, err = b.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BackupVaultOperationResultsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackupVaultResource, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).AzureAsyncOperation; val != nil { + resp.Header.Set("Azure-AsyncOperation", *val) + } + if val := server.GetResponse(respr).Location; val != nil { + resp.Header.Set("Location", *val) + } + if val := server.GetResponse(respr).RetryAfter; val != nil { + resp.Header.Set("Retry-After", strconv.FormatInt(int64(*val), 10)) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupvaults_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupvaults_server.go new file mode 100644 index 000000000000..24ed16ab18a6 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/backupvaults_server.go @@ -0,0 +1,396 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// BackupVaultsServer is a fake server for instances of the armdataprotection.BackupVaultsClient type. +type BackupVaultsServer struct { + // CheckNameAvailability is the fake for method BackupVaultsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, location string, parameters armdataprotection.CheckNameAvailabilityRequest, options *armdataprotection.BackupVaultsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armdataprotection.BackupVaultsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method BackupVaultsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, vaultName string, parameters armdataprotection.BackupVaultResource, options *armdataprotection.BackupVaultsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armdataprotection.BackupVaultsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method BackupVaultsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, vaultName string, options *armdataprotection.BackupVaultsClientBeginDeleteOptions) (resp azfake.PollerResponder[armdataprotection.BackupVaultsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BackupVaultsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, options *armdataprotection.BackupVaultsClientGetOptions) (resp azfake.Responder[armdataprotection.BackupVaultsClientGetResponse], errResp azfake.ErrorResponder) + + // NewGetInResourceGroupPager is the fake for method BackupVaultsClient.NewGetInResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewGetInResourceGroupPager func(resourceGroupName string, options *armdataprotection.BackupVaultsClientGetInResourceGroupOptions) (resp azfake.PagerResponder[armdataprotection.BackupVaultsClientGetInResourceGroupResponse]) + + // NewGetInSubscriptionPager is the fake for method BackupVaultsClient.NewGetInSubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewGetInSubscriptionPager func(options *armdataprotection.BackupVaultsClientGetInSubscriptionOptions) (resp azfake.PagerResponder[armdataprotection.BackupVaultsClientGetInSubscriptionResponse]) + + // BeginUpdate is the fake for method BackupVaultsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, vaultName string, parameters armdataprotection.PatchResourceRequestInput, options *armdataprotection.BackupVaultsClientBeginUpdateOptions) (resp azfake.PollerResponder[armdataprotection.BackupVaultsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewBackupVaultsServerTransport creates a new instance of BackupVaultsServerTransport with the provided implementation. +// The returned BackupVaultsServerTransport instance is connected to an instance of armdataprotection.BackupVaultsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBackupVaultsServerTransport(srv *BackupVaultsServer) *BackupVaultsServerTransport { + return &BackupVaultsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armdataprotection.BackupVaultsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armdataprotection.BackupVaultsClientDeleteResponse]](), + newGetInResourceGroupPager: newTracker[azfake.PagerResponder[armdataprotection.BackupVaultsClientGetInResourceGroupResponse]](), + newGetInSubscriptionPager: newTracker[azfake.PagerResponder[armdataprotection.BackupVaultsClientGetInSubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armdataprotection.BackupVaultsClientUpdateResponse]](), + } +} + +// BackupVaultsServerTransport connects instances of armdataprotection.BackupVaultsClient to instances of BackupVaultsServer. +// Don't use this type directly, use NewBackupVaultsServerTransport instead. +type BackupVaultsServerTransport struct { + srv *BackupVaultsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armdataprotection.BackupVaultsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armdataprotection.BackupVaultsClientDeleteResponse]] + newGetInResourceGroupPager *tracker[azfake.PagerResponder[armdataprotection.BackupVaultsClientGetInResourceGroupResponse]] + newGetInSubscriptionPager *tracker[azfake.PagerResponder[armdataprotection.BackupVaultsClientGetInSubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armdataprotection.BackupVaultsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for BackupVaultsServerTransport. +func (b *BackupVaultsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BackupVaultsClient.CheckNameAvailability": + resp, err = b.dispatchCheckNameAvailability(req) + case "BackupVaultsClient.BeginCreateOrUpdate": + resp, err = b.dispatchBeginCreateOrUpdate(req) + case "BackupVaultsClient.BeginDelete": + resp, err = b.dispatchBeginDelete(req) + case "BackupVaultsClient.Get": + resp, err = b.dispatchGet(req) + case "BackupVaultsClient.NewGetInResourceGroupPager": + resp, err = b.dispatchNewGetInResourceGroupPager(req) + case "BackupVaultsClient.NewGetInSubscriptionPager": + resp, err = b.dispatchNewGetInSubscriptionPager(req) + case "BackupVaultsClient.BeginUpdate": + resp, err = b.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BackupVaultsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if b.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.CheckNameAvailabilityRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, locationParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BackupVaultsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if b.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := b.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.BackupVaultResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, vaultNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + b.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + b.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + b.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (b *BackupVaultsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if b.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := b.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginDelete(req.Context(), resourceGroupNameParam, vaultNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + b.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + b.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + b.beginDelete.remove(req) + } + + return resp, nil +} + +func (b *BackupVaultsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BackupVaultResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BackupVaultsServerTransport) dispatchNewGetInResourceGroupPager(req *http.Request) (*http.Response, error) { + if b.srv.NewGetInResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetInResourceGroupPager not implemented")} + } + newGetInResourceGroupPager := b.newGetInResourceGroupPager.get(req) + if newGetInResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := b.srv.NewGetInResourceGroupPager(resourceGroupNameParam, nil) + newGetInResourceGroupPager = &resp + b.newGetInResourceGroupPager.add(req, newGetInResourceGroupPager) + server.PagerResponderInjectNextLinks(newGetInResourceGroupPager, req, func(page *armdataprotection.BackupVaultsClientGetInResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetInResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newGetInResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetInResourceGroupPager) { + b.newGetInResourceGroupPager.remove(req) + } + return resp, nil +} + +func (b *BackupVaultsServerTransport) dispatchNewGetInSubscriptionPager(req *http.Request) (*http.Response, error) { + if b.srv.NewGetInSubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetInSubscriptionPager not implemented")} + } + newGetInSubscriptionPager := b.newGetInSubscriptionPager.get(req) + if newGetInSubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := b.srv.NewGetInSubscriptionPager(nil) + newGetInSubscriptionPager = &resp + b.newGetInSubscriptionPager.add(req, newGetInSubscriptionPager) + server.PagerResponderInjectNextLinks(newGetInSubscriptionPager, req, func(page *armdataprotection.BackupVaultsClientGetInSubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetInSubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newGetInSubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetInSubscriptionPager) { + b.newGetInSubscriptionPager.remove(req) + } + return resp, nil +} + +func (b *BackupVaultsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if b.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := b.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.PatchResourceRequestInput](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginUpdate(req.Context(), resourceGroupNameParam, vaultNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + b.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + b.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + b.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/crossregionrestorejob_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/crossregionrestorejob_server.go new file mode 100644 index 000000000000..48b55f1dbb88 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/crossregionrestorejob_server.go @@ -0,0 +1,104 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// CrossRegionRestoreJobServer is a fake server for instances of the armdataprotection.CrossRegionRestoreJobClient type. +type CrossRegionRestoreJobServer struct { + // Get is the fake for method CrossRegionRestoreJobClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, location string, parameters armdataprotection.CrossRegionRestoreJobRequest, options *armdataprotection.CrossRegionRestoreJobClientGetOptions) (resp azfake.Responder[armdataprotection.CrossRegionRestoreJobClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewCrossRegionRestoreJobServerTransport creates a new instance of CrossRegionRestoreJobServerTransport with the provided implementation. +// The returned CrossRegionRestoreJobServerTransport instance is connected to an instance of armdataprotection.CrossRegionRestoreJobClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCrossRegionRestoreJobServerTransport(srv *CrossRegionRestoreJobServer) *CrossRegionRestoreJobServerTransport { + return &CrossRegionRestoreJobServerTransport{srv: srv} +} + +// CrossRegionRestoreJobServerTransport connects instances of armdataprotection.CrossRegionRestoreJobClient to instances of CrossRegionRestoreJobServer. +// Don't use this type directly, use NewCrossRegionRestoreJobServerTransport instead. +type CrossRegionRestoreJobServerTransport struct { + srv *CrossRegionRestoreJobServer +} + +// Do implements the policy.Transporter interface for CrossRegionRestoreJobServerTransport. +func (c *CrossRegionRestoreJobServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "CrossRegionRestoreJobClient.Get": + resp, err = c.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CrossRegionRestoreJobServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fetchCrossRegionRestoreJob` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.CrossRegionRestoreJobRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, locationParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureBackupJobResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/crossregionrestorejobs_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/crossregionrestorejobs_server.go new file mode 100644 index 000000000000..c99898a7e797 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/crossregionrestorejobs_server.go @@ -0,0 +1,128 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// CrossRegionRestoreJobsServer is a fake server for instances of the armdataprotection.CrossRegionRestoreJobsClient type. +type CrossRegionRestoreJobsServer struct { + // NewListPager is the fake for method CrossRegionRestoreJobsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, location string, parameters armdataprotection.CrossRegionRestoreJobsRequest, options *armdataprotection.CrossRegionRestoreJobsClientListOptions) (resp azfake.PagerResponder[armdataprotection.CrossRegionRestoreJobsClientListResponse]) +} + +// NewCrossRegionRestoreJobsServerTransport creates a new instance of CrossRegionRestoreJobsServerTransport with the provided implementation. +// The returned CrossRegionRestoreJobsServerTransport instance is connected to an instance of armdataprotection.CrossRegionRestoreJobsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCrossRegionRestoreJobsServerTransport(srv *CrossRegionRestoreJobsServer) *CrossRegionRestoreJobsServerTransport { + return &CrossRegionRestoreJobsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataprotection.CrossRegionRestoreJobsClientListResponse]](), + } +} + +// CrossRegionRestoreJobsServerTransport connects instances of armdataprotection.CrossRegionRestoreJobsClient to instances of CrossRegionRestoreJobsServer. +// Don't use this type directly, use NewCrossRegionRestoreJobsServerTransport instead. +type CrossRegionRestoreJobsServerTransport struct { + srv *CrossRegionRestoreJobsServer + newListPager *tracker[azfake.PagerResponder[armdataprotection.CrossRegionRestoreJobsClientListResponse]] +} + +// Do implements the policy.Transporter interface for CrossRegionRestoreJobsServerTransport. +func (c *CrossRegionRestoreJobsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "CrossRegionRestoreJobsClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CrossRegionRestoreJobsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fetchCrossRegionRestoreJobs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + body, err := server.UnmarshalRequestAsJSON[armdataprotection.CrossRegionRestoreJobsRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armdataprotection.CrossRegionRestoreJobsClientListOptions + if filterParam != nil { + options = &armdataprotection.CrossRegionRestoreJobsClientListOptions{ + Filter: filterParam, + } + } + resp := c.srv.NewListPager(resourceGroupNameParam, locationParam, body, options) + newListPager = &resp + c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.CrossRegionRestoreJobsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/deletedbackupinstances_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/deletedbackupinstances_server.go new file mode 100644 index 000000000000..cab8f23d38da --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/deletedbackupinstances_server.go @@ -0,0 +1,212 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// DeletedBackupInstancesServer is a fake server for instances of the armdataprotection.DeletedBackupInstancesClient type. +type DeletedBackupInstancesServer struct { + // Get is the fake for method DeletedBackupInstancesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.DeletedBackupInstancesClientGetOptions) (resp azfake.Responder[armdataprotection.DeletedBackupInstancesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DeletedBackupInstancesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, options *armdataprotection.DeletedBackupInstancesClientListOptions) (resp azfake.PagerResponder[armdataprotection.DeletedBackupInstancesClientListResponse]) + + // BeginUndelete is the fake for method DeletedBackupInstancesClient.BeginUndelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUndelete func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.DeletedBackupInstancesClientBeginUndeleteOptions) (resp azfake.PollerResponder[armdataprotection.DeletedBackupInstancesClientUndeleteResponse], errResp azfake.ErrorResponder) +} + +// NewDeletedBackupInstancesServerTransport creates a new instance of DeletedBackupInstancesServerTransport with the provided implementation. +// The returned DeletedBackupInstancesServerTransport instance is connected to an instance of armdataprotection.DeletedBackupInstancesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDeletedBackupInstancesServerTransport(srv *DeletedBackupInstancesServer) *DeletedBackupInstancesServerTransport { + return &DeletedBackupInstancesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataprotection.DeletedBackupInstancesClientListResponse]](), + beginUndelete: newTracker[azfake.PollerResponder[armdataprotection.DeletedBackupInstancesClientUndeleteResponse]](), + } +} + +// DeletedBackupInstancesServerTransport connects instances of armdataprotection.DeletedBackupInstancesClient to instances of DeletedBackupInstancesServer. +// Don't use this type directly, use NewDeletedBackupInstancesServerTransport instead. +type DeletedBackupInstancesServerTransport struct { + srv *DeletedBackupInstancesServer + newListPager *tracker[azfake.PagerResponder[armdataprotection.DeletedBackupInstancesClientListResponse]] + beginUndelete *tracker[azfake.PollerResponder[armdataprotection.DeletedBackupInstancesClientUndeleteResponse]] +} + +// Do implements the policy.Transporter interface for DeletedBackupInstancesServerTransport. +func (d *DeletedBackupInstancesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DeletedBackupInstancesClient.Get": + resp, err = d.dispatchGet(req) + case "DeletedBackupInstancesClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + case "DeletedBackupInstancesClient.BeginUndelete": + resp, err = d.dispatchBeginUndelete(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DeletedBackupInstancesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedBackupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeletedBackupInstanceResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DeletedBackupInstancesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedBackupInstances` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListPager(resourceGroupNameParam, vaultNameParam, nil) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.DeletedBackupInstancesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} + +func (d *DeletedBackupInstancesServerTransport) dispatchBeginUndelete(req *http.Request) (*http.Response, error) { + if d.srv.BeginUndelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUndelete not implemented")} + } + beginUndelete := d.beginUndelete.get(req) + if beginUndelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedBackupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/undelete` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginUndelete(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUndelete = &respr + d.beginUndelete.add(req, beginUndelete) + } + + resp, err := server.PollerResponderNext(beginUndelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + d.beginUndelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUndelete) { + d.beginUndelete.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/dppresourceguardproxy_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/dppresourceguardproxy_server.go new file mode 100644 index 000000000000..1fb98618e4e0 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/dppresourceguardproxy_server.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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// DppResourceGuardProxyServer is a fake server for instances of the armdataprotection.DppResourceGuardProxyClient type. +type DppResourceGuardProxyServer struct { + // CreateOrUpdate is the fake for method DppResourceGuardProxyClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, parameters armdataprotection.ResourceGuardProxyBaseResource, options *armdataprotection.DppResourceGuardProxyClientCreateOrUpdateOptions) (resp azfake.Responder[armdataprotection.DppResourceGuardProxyClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method DppResourceGuardProxyClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, options *armdataprotection.DppResourceGuardProxyClientDeleteOptions) (resp azfake.Responder[armdataprotection.DppResourceGuardProxyClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DppResourceGuardProxyClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, options *armdataprotection.DppResourceGuardProxyClientGetOptions) (resp azfake.Responder[armdataprotection.DppResourceGuardProxyClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DppResourceGuardProxyClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, options *armdataprotection.DppResourceGuardProxyClientListOptions) (resp azfake.PagerResponder[armdataprotection.DppResourceGuardProxyClientListResponse]) + + // UnlockDelete is the fake for method DppResourceGuardProxyClient.UnlockDelete + // HTTP status codes to indicate success: http.StatusOK + UnlockDelete func(ctx context.Context, resourceGroupName string, vaultName string, resourceGuardProxyName string, parameters armdataprotection.UnlockDeleteRequest, options *armdataprotection.DppResourceGuardProxyClientUnlockDeleteOptions) (resp azfake.Responder[armdataprotection.DppResourceGuardProxyClientUnlockDeleteResponse], errResp azfake.ErrorResponder) +} + +// NewDppResourceGuardProxyServerTransport creates a new instance of DppResourceGuardProxyServerTransport with the provided implementation. +// The returned DppResourceGuardProxyServerTransport instance is connected to an instance of armdataprotection.DppResourceGuardProxyClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDppResourceGuardProxyServerTransport(srv *DppResourceGuardProxyServer) *DppResourceGuardProxyServerTransport { + return &DppResourceGuardProxyServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataprotection.DppResourceGuardProxyClientListResponse]](), + } +} + +// DppResourceGuardProxyServerTransport connects instances of armdataprotection.DppResourceGuardProxyClient to instances of DppResourceGuardProxyServer. +// Don't use this type directly, use NewDppResourceGuardProxyServerTransport instead. +type DppResourceGuardProxyServerTransport struct { + srv *DppResourceGuardProxyServer + newListPager *tracker[azfake.PagerResponder[armdataprotection.DppResourceGuardProxyClientListResponse]] +} + +// Do implements the policy.Transporter interface for DppResourceGuardProxyServerTransport. +func (d *DppResourceGuardProxyServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DppResourceGuardProxyClient.CreateOrUpdate": + resp, err = d.dispatchCreateOrUpdate(req) + case "DppResourceGuardProxyClient.Delete": + resp, err = d.dispatchDelete(req) + case "DppResourceGuardProxyClient.Get": + resp, err = d.dispatchGet(req) + case "DppResourceGuardProxyClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + case "DppResourceGuardProxyClient.UnlockDelete": + resp, err = d.dispatchUnlockDelete(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DppResourceGuardProxyServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupResourceGuardProxies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.ResourceGuardProxyBaseResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resourceGuardProxyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardProxyName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, vaultNameParam, resourceGuardProxyNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ResourceGuardProxyBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DppResourceGuardProxyServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if d.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupResourceGuardProxies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resourceGuardProxyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardProxyName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Delete(req.Context(), resourceGroupNameParam, vaultNameParam, resourceGuardProxyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DppResourceGuardProxyServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupResourceGuardProxies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resourceGuardProxyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardProxyName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, resourceGuardProxyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ResourceGuardProxyBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DppResourceGuardProxyServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupResourceGuardProxies` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListPager(resourceGroupNameParam, vaultNameParam, nil) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.DppResourceGuardProxyClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} + +func (d *DppResourceGuardProxyServerTransport) dispatchUnlockDelete(req *http.Request) (*http.Response, error) { + if d.srv.UnlockDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method UnlockDelete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupResourceGuardProxies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/unlockDelete` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.UnlockDeleteRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resourceGuardProxyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardProxyName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.UnlockDelete(req.Context(), resourceGroupNameParam, vaultNameParam, resourceGuardProxyNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).UnlockDeleteResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/exportjobs_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/exportjobs_server.go new file mode 100644 index 000000000000..e8f65e96b728 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/exportjobs_server.go @@ -0,0 +1,115 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// ExportJobsServer is a fake server for instances of the armdataprotection.ExportJobsClient type. +type ExportJobsServer struct { + // BeginTrigger is the fake for method ExportJobsClient.BeginTrigger + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginTrigger func(ctx context.Context, resourceGroupName string, vaultName string, options *armdataprotection.ExportJobsClientBeginTriggerOptions) (resp azfake.PollerResponder[armdataprotection.ExportJobsClientTriggerResponse], errResp azfake.ErrorResponder) +} + +// NewExportJobsServerTransport creates a new instance of ExportJobsServerTransport with the provided implementation. +// The returned ExportJobsServerTransport instance is connected to an instance of armdataprotection.ExportJobsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewExportJobsServerTransport(srv *ExportJobsServer) *ExportJobsServerTransport { + return &ExportJobsServerTransport{ + srv: srv, + beginTrigger: newTracker[azfake.PollerResponder[armdataprotection.ExportJobsClientTriggerResponse]](), + } +} + +// ExportJobsServerTransport connects instances of armdataprotection.ExportJobsClient to instances of ExportJobsServer. +// Don't use this type directly, use NewExportJobsServerTransport instead. +type ExportJobsServerTransport struct { + srv *ExportJobsServer + beginTrigger *tracker[azfake.PollerResponder[armdataprotection.ExportJobsClientTriggerResponse]] +} + +// Do implements the policy.Transporter interface for ExportJobsServerTransport. +func (e *ExportJobsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ExportJobsClient.BeginTrigger": + resp, err = e.dispatchBeginTrigger(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *ExportJobsServerTransport) dispatchBeginTrigger(req *http.Request) (*http.Response, error) { + if e.srv.BeginTrigger == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginTrigger not implemented")} + } + beginTrigger := e.beginTrigger.get(req) + if beginTrigger == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportBackupJobs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginTrigger(req.Context(), resourceGroupNameParam, vaultNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginTrigger = &respr + e.beginTrigger.add(req, beginTrigger) + } + + resp, err := server.PollerResponderNext(beginTrigger, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + e.beginTrigger.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginTrigger) { + e.beginTrigger.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/exportjobsoperationresult_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/exportjobsoperationresult_server.go new file mode 100644 index 000000000000..7ea5fe7f4cc9 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/exportjobsoperationresult_server.go @@ -0,0 +1,104 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// ExportJobsOperationResultServer is a fake server for instances of the armdataprotection.ExportJobsOperationResultClient type. +type ExportJobsOperationResultServer struct { + // Get is the fake for method ExportJobsOperationResultClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + Get func(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *armdataprotection.ExportJobsOperationResultClientGetOptions) (resp azfake.Responder[armdataprotection.ExportJobsOperationResultClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewExportJobsOperationResultServerTransport creates a new instance of ExportJobsOperationResultServerTransport with the provided implementation. +// The returned ExportJobsOperationResultServerTransport instance is connected to an instance of armdataprotection.ExportJobsOperationResultClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewExportJobsOperationResultServerTransport(srv *ExportJobsOperationResultServer) *ExportJobsOperationResultServerTransport { + return &ExportJobsOperationResultServerTransport{srv: srv} +} + +// ExportJobsOperationResultServerTransport connects instances of armdataprotection.ExportJobsOperationResultClient to instances of ExportJobsOperationResultServer. +// Don't use this type directly, use NewExportJobsOperationResultServerTransport instead. +type ExportJobsOperationResultServerTransport struct { + srv *ExportJobsOperationResultServer +} + +// Do implements the policy.Transporter interface for ExportJobsOperationResultServerTransport. +func (e *ExportJobsOperationResultServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ExportJobsOperationResultClient.Get": + resp, err = e.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *ExportJobsOperationResultServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupJobs/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ExportJobsResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/internal.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/internal.go new file mode 100644 index 000000000000..ff215a58f44d --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/internal.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "io" + "net/http" + "reflect" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func readRequestBody(req *http.Request) ([]byte, error) { + if req.Body == nil { + return nil, nil + } + body, err := io.ReadAll(req.Body) + if err != nil { + return nil, err + } + req.Body.Close() + return body, nil +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/jobs_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/jobs_server.go new file mode 100644 index 000000000000..628d1ef633c6 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/jobs_server.go @@ -0,0 +1,156 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// JobsServer is a fake server for instances of the armdataprotection.JobsClient type. +type JobsServer struct { + // Get is the fake for method JobsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, jobID string, options *armdataprotection.JobsClientGetOptions) (resp azfake.Responder[armdataprotection.JobsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method JobsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, options *armdataprotection.JobsClientListOptions) (resp azfake.PagerResponder[armdataprotection.JobsClientListResponse]) +} + +// NewJobsServerTransport creates a new instance of JobsServerTransport with the provided implementation. +// The returned JobsServerTransport instance is connected to an instance of armdataprotection.JobsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewJobsServerTransport(srv *JobsServer) *JobsServerTransport { + return &JobsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataprotection.JobsClientListResponse]](), + } +} + +// JobsServerTransport connects instances of armdataprotection.JobsClient to instances of JobsServer. +// Don't use this type directly, use NewJobsServerTransport instead. +type JobsServerTransport struct { + srv *JobsServer + newListPager *tracker[azfake.PagerResponder[armdataprotection.JobsClientListResponse]] +} + +// Do implements the policy.Transporter interface for JobsServerTransport. +func (j *JobsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "JobsClient.Get": + resp, err = j.dispatchGet(req) + case "JobsClient.NewListPager": + resp, err = j.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (j *JobsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if j.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupJobs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + jobIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("jobId")]) + if err != nil { + return nil, err + } + respr, errRespr := j.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, jobIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureBackupJobResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (j *JobsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if j.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := j.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupJobs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resp := j.srv.NewListPager(resourceGroupNameParam, vaultNameParam, nil) + newListPager = &resp + j.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.JobsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + j.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + j.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationresult_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationresult_server.go new file mode 100644 index 000000000000..a0aad3e64261 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationresult_server.go @@ -0,0 +1,110 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// OperationResultServer is a fake server for instances of the armdataprotection.OperationResultClient type. +type OperationResultServer struct { + // Get is the fake for method OperationResultClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + Get func(ctx context.Context, operationID string, location string, options *armdataprotection.OperationResultClientGetOptions) (resp azfake.Responder[armdataprotection.OperationResultClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationResultServerTransport creates a new instance of OperationResultServerTransport with the provided implementation. +// The returned OperationResultServerTransport instance is connected to an instance of armdataprotection.OperationResultClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationResultServerTransport(srv *OperationResultServer) *OperationResultServerTransport { + return &OperationResultServerTransport{srv: srv} +} + +// OperationResultServerTransport connects instances of armdataprotection.OperationResultClient to instances of OperationResultServer. +// Don't use this type directly, use NewOperationResultServerTransport instead. +type OperationResultServerTransport struct { + srv *OperationResultServer +} + +// Do implements the policy.Transporter interface for OperationResultServerTransport. +func (o *OperationResultServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationResultClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationResultServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), operationIDParam, locationParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationJobExtendedInfo, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).AzureAsyncOperation; val != nil { + resp.Header.Set("Azure-AsyncOperation", *val) + } + if val := server.GetResponse(respr).Location; val != nil { + resp.Header.Set("Location", *val) + } + if val := server.GetResponse(respr).RetryAfter; val != nil { + resp.Header.Set("Retry-After", strconv.FormatInt(int64(*val), 10)) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/operations_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operations_server.go new file mode 100644 index 000000000000..5f4d8f1cafe1 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" +) + +// OperationsServer is a fake server for instances of the armdataprotection.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armdataprotection.OperationsClientListOptions) (resp azfake.PagerResponder[armdataprotection.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armdataprotection.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataprotection.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armdataprotection.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armdataprotection.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatus_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatus_server.go new file mode 100644 index 000000000000..58d3fd477637 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatus_server.go @@ -0,0 +1,100 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// OperationStatusServer is a fake server for instances of the armdataprotection.OperationStatusClient type. +type OperationStatusServer struct { + // Get is the fake for method OperationStatusClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, location string, operationID string, options *armdataprotection.OperationStatusClientGetOptions) (resp azfake.Responder[armdataprotection.OperationStatusClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationStatusServerTransport creates a new instance of OperationStatusServerTransport with the provided implementation. +// The returned OperationStatusServerTransport instance is connected to an instance of armdataprotection.OperationStatusClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationStatusServerTransport(srv *OperationStatusServer) *OperationStatusServerTransport { + return &OperationStatusServerTransport{srv: srv} +} + +// OperationStatusServerTransport connects instances of armdataprotection.OperationStatusClient to instances of OperationStatusServer. +// Don't use this type directly, use NewOperationStatusServerTransport instead. +type OperationStatusServerTransport struct { + srv *OperationStatusServer +} + +// Do implements the policy.Transporter interface for OperationStatusServerTransport. +func (o *OperationStatusServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationStatusClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationStatusServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationStatus/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), locationParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatusbackupvaultcontext_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatusbackupvaultcontext_server.go new file mode 100644 index 000000000000..2882d69b48d8 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatusbackupvaultcontext_server.go @@ -0,0 +1,104 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// OperationStatusBackupVaultContextServer is a fake server for instances of the armdataprotection.OperationStatusBackupVaultContextClient type. +type OperationStatusBackupVaultContextServer struct { + // Get is the fake for method OperationStatusBackupVaultContextClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *armdataprotection.OperationStatusBackupVaultContextClientGetOptions) (resp azfake.Responder[armdataprotection.OperationStatusBackupVaultContextClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationStatusBackupVaultContextServerTransport creates a new instance of OperationStatusBackupVaultContextServerTransport with the provided implementation. +// The returned OperationStatusBackupVaultContextServerTransport instance is connected to an instance of armdataprotection.OperationStatusBackupVaultContextClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationStatusBackupVaultContextServerTransport(srv *OperationStatusBackupVaultContextServer) *OperationStatusBackupVaultContextServerTransport { + return &OperationStatusBackupVaultContextServerTransport{srv: srv} +} + +// OperationStatusBackupVaultContextServerTransport connects instances of armdataprotection.OperationStatusBackupVaultContextClient to instances of OperationStatusBackupVaultContextServer. +// Don't use this type directly, use NewOperationStatusBackupVaultContextServerTransport instead. +type OperationStatusBackupVaultContextServerTransport struct { + srv *OperationStatusBackupVaultContextServer +} + +// Do implements the policy.Transporter interface for OperationStatusBackupVaultContextServerTransport. +func (o *OperationStatusBackupVaultContextServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationStatusBackupVaultContextClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationStatusBackupVaultContextServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationStatus/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatusresourcegroupcontext_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatusresourcegroupcontext_server.go new file mode 100644 index 000000000000..4fae784f7d8f --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/operationstatusresourcegroupcontext_server.go @@ -0,0 +1,100 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// OperationStatusResourceGroupContextServer is a fake server for instances of the armdataprotection.OperationStatusResourceGroupContextClient type. +type OperationStatusResourceGroupContextServer struct { + // Get is the fake for method OperationStatusResourceGroupContextClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, operationID string, options *armdataprotection.OperationStatusResourceGroupContextClientGetOptions) (resp azfake.Responder[armdataprotection.OperationStatusResourceGroupContextClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationStatusResourceGroupContextServerTransport creates a new instance of OperationStatusResourceGroupContextServerTransport with the provided implementation. +// The returned OperationStatusResourceGroupContextServerTransport instance is connected to an instance of armdataprotection.OperationStatusResourceGroupContextClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationStatusResourceGroupContextServerTransport(srv *OperationStatusResourceGroupContextServer) *OperationStatusResourceGroupContextServerTransport { + return &OperationStatusResourceGroupContextServerTransport{srv: srv} +} + +// OperationStatusResourceGroupContextServerTransport connects instances of armdataprotection.OperationStatusResourceGroupContextClient to instances of OperationStatusResourceGroupContextServer. +// Don't use this type directly, use NewOperationStatusResourceGroupContextServerTransport instead. +type OperationStatusResourceGroupContextServerTransport struct { + srv *OperationStatusResourceGroupContextServer +} + +// Do implements the policy.Transporter interface for OperationStatusResourceGroupContextServerTransport. +func (o *OperationStatusResourceGroupContextServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationStatusResourceGroupContextClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationStatusResourceGroupContextServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/operationStatus/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), resourceGroupNameParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/polymorphic_helpers.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/polymorphic_helpers.go new file mode 100644 index 000000000000..6fa90c166be8 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/polymorphic_helpers.go @@ -0,0 +1,60 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" +) + +func unmarshalAzureBackupRestoreRequestClassification(rawMsg json.RawMessage) (armdataprotection.AzureBackupRestoreRequestClassification, 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 armdataprotection.AzureBackupRestoreRequestClassification + switch m["objectType"] { + case "AzureBackupRecoveryPointBasedRestoreRequest": + b = &armdataprotection.AzureBackupRecoveryPointBasedRestoreRequest{} + case "AzureBackupRecoveryTimeBasedRestoreRequest": + b = &armdataprotection.AzureBackupRecoveryTimeBasedRestoreRequest{} + case "AzureBackupRestoreWithRehydrationRequest": + b = &armdataprotection.AzureBackupRestoreWithRehydrationRequest{} + default: + b = &armdataprotection.AzureBackupRestoreRequest{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalFeatureValidationRequestBaseClassification(rawMsg json.RawMessage) (armdataprotection.FeatureValidationRequestBaseClassification, 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 armdataprotection.FeatureValidationRequestBaseClassification + switch m["objectType"] { + case "FeatureValidationRequest": + b = &armdataprotection.FeatureValidationRequest{} + default: + b = &armdataprotection.FeatureValidationRequestBase{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/recoverypoints_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/recoverypoints_server.go new file mode 100644 index 000000000000..c2f142113a27 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/recoverypoints_server.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 fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// RecoveryPointsServer is a fake server for instances of the armdataprotection.RecoveryPointsClient type. +type RecoveryPointsServer struct { + // Get is the fake for method RecoveryPointsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, recoveryPointID string, options *armdataprotection.RecoveryPointsClientGetOptions) (resp azfake.Responder[armdataprotection.RecoveryPointsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method RecoveryPointsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, backupInstanceName string, options *armdataprotection.RecoveryPointsClientListOptions) (resp azfake.PagerResponder[armdataprotection.RecoveryPointsClientListResponse]) +} + +// NewRecoveryPointsServerTransport creates a new instance of RecoveryPointsServerTransport with the provided implementation. +// The returned RecoveryPointsServerTransport instance is connected to an instance of armdataprotection.RecoveryPointsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRecoveryPointsServerTransport(srv *RecoveryPointsServer) *RecoveryPointsServerTransport { + return &RecoveryPointsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armdataprotection.RecoveryPointsClientListResponse]](), + } +} + +// RecoveryPointsServerTransport connects instances of armdataprotection.RecoveryPointsClient to instances of RecoveryPointsServer. +// Don't use this type directly, use NewRecoveryPointsServerTransport instead. +type RecoveryPointsServerTransport struct { + srv *RecoveryPointsServer + newListPager *tracker[azfake.PagerResponder[armdataprotection.RecoveryPointsClientListResponse]] +} + +// Do implements the policy.Transporter interface for RecoveryPointsServerTransport. +func (r *RecoveryPointsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "RecoveryPointsClient.Get": + resp, err = r.dispatchGet(req) + case "RecoveryPointsClient.NewListPager": + resp, err = r.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RecoveryPointsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recoveryPoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + recoveryPointIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("recoveryPointId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, recoveryPointIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureBackupRecoveryPointResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *RecoveryPointsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := r.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/recoveryPoints` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + var options *armdataprotection.RecoveryPointsClientListOptions + if filterParam != nil || skipTokenParam != nil { + options = &armdataprotection.RecoveryPointsClientListOptions{ + Filter: filterParam, + SkipToken: skipTokenParam, + } + } + resp := r.srv.NewListPager(resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, options) + newListPager = &resp + r.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armdataprotection.RecoveryPointsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + r.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/resourceguards_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/resourceguards_server.go new file mode 100644 index 000000000000..eb4acbc676ee --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/resourceguards_server.go @@ -0,0 +1,866 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// ResourceGuardsServer is a fake server for instances of the armdataprotection.ResourceGuardsClient type. +type ResourceGuardsServer struct { + // Delete is the fake for method ResourceGuardsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientDeleteOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ResourceGuardsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientGetOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientGetResponse], errResp azfake.ErrorResponder) + + // NewGetBackupSecurityPINRequestsObjectsPager is the fake for method ResourceGuardsClient.NewGetBackupSecurityPINRequestsObjectsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetBackupSecurityPINRequestsObjectsPager func(resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientGetBackupSecurityPINRequestsObjectsOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse]) + + // GetDefaultBackupSecurityPINRequestsObject is the fake for method ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject + // HTTP status codes to indicate success: http.StatusOK + GetDefaultBackupSecurityPINRequestsObject func(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *armdataprotection.ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse], errResp azfake.ErrorResponder) + + // GetDefaultDeleteProtectedItemRequestsObject is the fake for method ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject + // HTTP status codes to indicate success: http.StatusOK + GetDefaultDeleteProtectedItemRequestsObject func(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *armdataprotection.ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse], errResp azfake.ErrorResponder) + + // GetDefaultDeleteResourceGuardProxyRequestsObject is the fake for method ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject + // HTTP status codes to indicate success: http.StatusOK + GetDefaultDeleteResourceGuardProxyRequestsObject func(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *armdataprotection.ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse], errResp azfake.ErrorResponder) + + // GetDefaultDisableSoftDeleteRequestsObject is the fake for method ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject + // HTTP status codes to indicate success: http.StatusOK + GetDefaultDisableSoftDeleteRequestsObject func(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *armdataprotection.ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse], errResp azfake.ErrorResponder) + + // GetDefaultUpdateProtectedItemRequestsObject is the fake for method ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject + // HTTP status codes to indicate success: http.StatusOK + GetDefaultUpdateProtectedItemRequestsObject func(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *armdataprotection.ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse], errResp azfake.ErrorResponder) + + // GetDefaultUpdateProtectionPolicyRequestsObject is the fake for method ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject + // HTTP status codes to indicate success: http.StatusOK + GetDefaultUpdateProtectionPolicyRequestsObject func(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *armdataprotection.ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse], errResp azfake.ErrorResponder) + + // NewGetDeleteProtectedItemRequestsObjectsPager is the fake for method ResourceGuardsClient.NewGetDeleteProtectedItemRequestsObjectsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetDeleteProtectedItemRequestsObjectsPager func(resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse]) + + // NewGetDeleteResourceGuardProxyRequestsObjectsPager is the fake for method ResourceGuardsClient.NewGetDeleteResourceGuardProxyRequestsObjectsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetDeleteResourceGuardProxyRequestsObjectsPager func(resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse]) + + // NewGetDisableSoftDeleteRequestsObjectsPager is the fake for method ResourceGuardsClient.NewGetDisableSoftDeleteRequestsObjectsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetDisableSoftDeleteRequestsObjectsPager func(resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse]) + + // NewGetResourcesInResourceGroupPager is the fake for method ResourceGuardsClient.NewGetResourcesInResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewGetResourcesInResourceGroupPager func(resourceGroupName string, options *armdataprotection.ResourceGuardsClientGetResourcesInResourceGroupOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetResourcesInResourceGroupResponse]) + + // NewGetResourcesInSubscriptionPager is the fake for method ResourceGuardsClient.NewGetResourcesInSubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewGetResourcesInSubscriptionPager func(options *armdataprotection.ResourceGuardsClientGetResourcesInSubscriptionOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetResourcesInSubscriptionResponse]) + + // NewGetUpdateProtectedItemRequestsObjectsPager is the fake for method ResourceGuardsClient.NewGetUpdateProtectedItemRequestsObjectsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetUpdateProtectedItemRequestsObjectsPager func(resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse]) + + // NewGetUpdateProtectionPolicyRequestsObjectsPager is the fake for method ResourceGuardsClient.NewGetUpdateProtectionPolicyRequestsObjectsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetUpdateProtectionPolicyRequestsObjectsPager func(resourceGroupName string, resourceGuardsName string, options *armdataprotection.ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsOptions) (resp azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse]) + + // Patch is the fake for method ResourceGuardsClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, resourceGuardsName string, parameters armdataprotection.PatchResourceGuardInput, options *armdataprotection.ResourceGuardsClientPatchOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientPatchResponse], errResp azfake.ErrorResponder) + + // Put is the fake for method ResourceGuardsClient.Put + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Put func(ctx context.Context, resourceGroupName string, resourceGuardsName string, parameters armdataprotection.ResourceGuardResource, options *armdataprotection.ResourceGuardsClientPutOptions) (resp azfake.Responder[armdataprotection.ResourceGuardsClientPutResponse], errResp azfake.ErrorResponder) +} + +// NewResourceGuardsServerTransport creates a new instance of ResourceGuardsServerTransport with the provided implementation. +// The returned ResourceGuardsServerTransport instance is connected to an instance of armdataprotection.ResourceGuardsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewResourceGuardsServerTransport(srv *ResourceGuardsServer) *ResourceGuardsServerTransport { + return &ResourceGuardsServerTransport{ + srv: srv, + newGetBackupSecurityPINRequestsObjectsPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse]](), + newGetDeleteProtectedItemRequestsObjectsPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse]](), + newGetDeleteResourceGuardProxyRequestsObjectsPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse]](), + newGetDisableSoftDeleteRequestsObjectsPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse]](), + newGetResourcesInResourceGroupPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetResourcesInResourceGroupResponse]](), + newGetResourcesInSubscriptionPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetResourcesInSubscriptionResponse]](), + newGetUpdateProtectedItemRequestsObjectsPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse]](), + newGetUpdateProtectionPolicyRequestsObjectsPager: newTracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse]](), + } +} + +// ResourceGuardsServerTransport connects instances of armdataprotection.ResourceGuardsClient to instances of ResourceGuardsServer. +// Don't use this type directly, use NewResourceGuardsServerTransport instead. +type ResourceGuardsServerTransport struct { + srv *ResourceGuardsServer + newGetBackupSecurityPINRequestsObjectsPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse]] + newGetDeleteProtectedItemRequestsObjectsPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse]] + newGetDeleteResourceGuardProxyRequestsObjectsPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse]] + newGetDisableSoftDeleteRequestsObjectsPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse]] + newGetResourcesInResourceGroupPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetResourcesInResourceGroupResponse]] + newGetResourcesInSubscriptionPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetResourcesInSubscriptionResponse]] + newGetUpdateProtectedItemRequestsObjectsPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse]] + newGetUpdateProtectionPolicyRequestsObjectsPager *tracker[azfake.PagerResponder[armdataprotection.ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse]] +} + +// Do implements the policy.Transporter interface for ResourceGuardsServerTransport. +func (r *ResourceGuardsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ResourceGuardsClient.Delete": + resp, err = r.dispatchDelete(req) + case "ResourceGuardsClient.Get": + resp, err = r.dispatchGet(req) + case "ResourceGuardsClient.NewGetBackupSecurityPINRequestsObjectsPager": + resp, err = r.dispatchNewGetBackupSecurityPINRequestsObjectsPager(req) + case "ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject": + resp, err = r.dispatchGetDefaultBackupSecurityPINRequestsObject(req) + case "ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject": + resp, err = r.dispatchGetDefaultDeleteProtectedItemRequestsObject(req) + case "ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject": + resp, err = r.dispatchGetDefaultDeleteResourceGuardProxyRequestsObject(req) + case "ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject": + resp, err = r.dispatchGetDefaultDisableSoftDeleteRequestsObject(req) + case "ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject": + resp, err = r.dispatchGetDefaultUpdateProtectedItemRequestsObject(req) + case "ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject": + resp, err = r.dispatchGetDefaultUpdateProtectionPolicyRequestsObject(req) + case "ResourceGuardsClient.NewGetDeleteProtectedItemRequestsObjectsPager": + resp, err = r.dispatchNewGetDeleteProtectedItemRequestsObjectsPager(req) + case "ResourceGuardsClient.NewGetDeleteResourceGuardProxyRequestsObjectsPager": + resp, err = r.dispatchNewGetDeleteResourceGuardProxyRequestsObjectsPager(req) + case "ResourceGuardsClient.NewGetDisableSoftDeleteRequestsObjectsPager": + resp, err = r.dispatchNewGetDisableSoftDeleteRequestsObjectsPager(req) + case "ResourceGuardsClient.NewGetResourcesInResourceGroupPager": + resp, err = r.dispatchNewGetResourcesInResourceGroupPager(req) + case "ResourceGuardsClient.NewGetResourcesInSubscriptionPager": + resp, err = r.dispatchNewGetResourcesInSubscriptionPager(req) + case "ResourceGuardsClient.NewGetUpdateProtectedItemRequestsObjectsPager": + resp, err = r.dispatchNewGetUpdateProtectedItemRequestsObjectsPager(req) + case "ResourceGuardsClient.NewGetUpdateProtectionPolicyRequestsObjectsPager": + resp, err = r.dispatchNewGetUpdateProtectionPolicyRequestsObjectsPager(req) + case "ResourceGuardsClient.Patch": + resp, err = r.dispatchPatch(req) + case "ResourceGuardsClient.Put": + resp, err = r.dispatchPut(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if r.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Delete(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ResourceGuardResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetBackupSecurityPINRequestsObjectsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetBackupSecurityPINRequestsObjectsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetBackupSecurityPINRequestsObjectsPager not implemented")} + } + newGetBackupSecurityPINRequestsObjectsPager := r.newGetBackupSecurityPINRequestsObjectsPager.get(req) + if newGetBackupSecurityPINRequestsObjectsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBackupSecurityPINRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetBackupSecurityPINRequestsObjectsPager(resourceGroupNameParam, resourceGuardsNameParam, nil) + newGetBackupSecurityPINRequestsObjectsPager = &resp + r.newGetBackupSecurityPINRequestsObjectsPager.add(req, newGetBackupSecurityPINRequestsObjectsPager) + server.PagerResponderInjectNextLinks(newGetBackupSecurityPINRequestsObjectsPager, req, func(page *armdataprotection.ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetBackupSecurityPINRequestsObjectsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetBackupSecurityPINRequestsObjectsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetBackupSecurityPINRequestsObjectsPager) { + r.newGetBackupSecurityPINRequestsObjectsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchGetDefaultBackupSecurityPINRequestsObject(req *http.Request) (*http.Response, error) { + if r.srv.GetDefaultBackupSecurityPINRequestsObject == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDefaultBackupSecurityPINRequestsObject not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBackupSecurityPINRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + requestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetDefaultBackupSecurityPINRequestsObject(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, requestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DppBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchGetDefaultDeleteProtectedItemRequestsObject(req *http.Request) (*http.Response, error) { + if r.srv.GetDefaultDeleteProtectedItemRequestsObject == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDefaultDeleteProtectedItemRequestsObject not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteProtectedItemRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + requestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetDefaultDeleteProtectedItemRequestsObject(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, requestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DppBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchGetDefaultDeleteResourceGuardProxyRequestsObject(req *http.Request) (*http.Response, error) { + if r.srv.GetDefaultDeleteResourceGuardProxyRequestsObject == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDefaultDeleteResourceGuardProxyRequestsObject not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteResourceGuardProxyRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + requestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetDefaultDeleteResourceGuardProxyRequestsObject(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, requestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DppBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchGetDefaultDisableSoftDeleteRequestsObject(req *http.Request) (*http.Response, error) { + if r.srv.GetDefaultDisableSoftDeleteRequestsObject == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDefaultDisableSoftDeleteRequestsObject not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/disableSoftDeleteRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + requestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetDefaultDisableSoftDeleteRequestsObject(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, requestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DppBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchGetDefaultUpdateProtectedItemRequestsObject(req *http.Request) (*http.Response, error) { + if r.srv.GetDefaultUpdateProtectedItemRequestsObject == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDefaultUpdateProtectedItemRequestsObject not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/updateProtectedItemRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + requestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetDefaultUpdateProtectedItemRequestsObject(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, requestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DppBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchGetDefaultUpdateProtectionPolicyRequestsObject(req *http.Request) (*http.Response, error) { + if r.srv.GetDefaultUpdateProtectionPolicyRequestsObject == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDefaultUpdateProtectionPolicyRequestsObject not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/updateProtectionPolicyRequests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + requestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetDefaultUpdateProtectionPolicyRequestsObject(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, requestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DppBaseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetDeleteProtectedItemRequestsObjectsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetDeleteProtectedItemRequestsObjectsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetDeleteProtectedItemRequestsObjectsPager not implemented")} + } + newGetDeleteProtectedItemRequestsObjectsPager := r.newGetDeleteProtectedItemRequestsObjectsPager.get(req) + if newGetDeleteProtectedItemRequestsObjectsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteProtectedItemRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetDeleteProtectedItemRequestsObjectsPager(resourceGroupNameParam, resourceGuardsNameParam, nil) + newGetDeleteProtectedItemRequestsObjectsPager = &resp + r.newGetDeleteProtectedItemRequestsObjectsPager.add(req, newGetDeleteProtectedItemRequestsObjectsPager) + server.PagerResponderInjectNextLinks(newGetDeleteProtectedItemRequestsObjectsPager, req, func(page *armdataprotection.ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetDeleteProtectedItemRequestsObjectsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetDeleteProtectedItemRequestsObjectsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetDeleteProtectedItemRequestsObjectsPager) { + r.newGetDeleteProtectedItemRequestsObjectsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetDeleteResourceGuardProxyRequestsObjectsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetDeleteResourceGuardProxyRequestsObjectsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetDeleteResourceGuardProxyRequestsObjectsPager not implemented")} + } + newGetDeleteResourceGuardProxyRequestsObjectsPager := r.newGetDeleteResourceGuardProxyRequestsObjectsPager.get(req) + if newGetDeleteResourceGuardProxyRequestsObjectsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteResourceGuardProxyRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetDeleteResourceGuardProxyRequestsObjectsPager(resourceGroupNameParam, resourceGuardsNameParam, nil) + newGetDeleteResourceGuardProxyRequestsObjectsPager = &resp + r.newGetDeleteResourceGuardProxyRequestsObjectsPager.add(req, newGetDeleteResourceGuardProxyRequestsObjectsPager) + server.PagerResponderInjectNextLinks(newGetDeleteResourceGuardProxyRequestsObjectsPager, req, func(page *armdataprotection.ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetDeleteResourceGuardProxyRequestsObjectsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetDeleteResourceGuardProxyRequestsObjectsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetDeleteResourceGuardProxyRequestsObjectsPager) { + r.newGetDeleteResourceGuardProxyRequestsObjectsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetDisableSoftDeleteRequestsObjectsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetDisableSoftDeleteRequestsObjectsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetDisableSoftDeleteRequestsObjectsPager not implemented")} + } + newGetDisableSoftDeleteRequestsObjectsPager := r.newGetDisableSoftDeleteRequestsObjectsPager.get(req) + if newGetDisableSoftDeleteRequestsObjectsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/disableSoftDeleteRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetDisableSoftDeleteRequestsObjectsPager(resourceGroupNameParam, resourceGuardsNameParam, nil) + newGetDisableSoftDeleteRequestsObjectsPager = &resp + r.newGetDisableSoftDeleteRequestsObjectsPager.add(req, newGetDisableSoftDeleteRequestsObjectsPager) + server.PagerResponderInjectNextLinks(newGetDisableSoftDeleteRequestsObjectsPager, req, func(page *armdataprotection.ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetDisableSoftDeleteRequestsObjectsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetDisableSoftDeleteRequestsObjectsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetDisableSoftDeleteRequestsObjectsPager) { + r.newGetDisableSoftDeleteRequestsObjectsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetResourcesInResourceGroupPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetResourcesInResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetResourcesInResourceGroupPager not implemented")} + } + newGetResourcesInResourceGroupPager := r.newGetResourcesInResourceGroupPager.get(req) + if newGetResourcesInResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetResourcesInResourceGroupPager(resourceGroupNameParam, nil) + newGetResourcesInResourceGroupPager = &resp + r.newGetResourcesInResourceGroupPager.add(req, newGetResourcesInResourceGroupPager) + server.PagerResponderInjectNextLinks(newGetResourcesInResourceGroupPager, req, func(page *armdataprotection.ResourceGuardsClientGetResourcesInResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetResourcesInResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetResourcesInResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetResourcesInResourceGroupPager) { + r.newGetResourcesInResourceGroupPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetResourcesInSubscriptionPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetResourcesInSubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetResourcesInSubscriptionPager not implemented")} + } + newGetResourcesInSubscriptionPager := r.newGetResourcesInSubscriptionPager.get(req) + if newGetResourcesInSubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := r.srv.NewGetResourcesInSubscriptionPager(nil) + newGetResourcesInSubscriptionPager = &resp + r.newGetResourcesInSubscriptionPager.add(req, newGetResourcesInSubscriptionPager) + server.PagerResponderInjectNextLinks(newGetResourcesInSubscriptionPager, req, func(page *armdataprotection.ResourceGuardsClientGetResourcesInSubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetResourcesInSubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetResourcesInSubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetResourcesInSubscriptionPager) { + r.newGetResourcesInSubscriptionPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetUpdateProtectedItemRequestsObjectsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetUpdateProtectedItemRequestsObjectsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetUpdateProtectedItemRequestsObjectsPager not implemented")} + } + newGetUpdateProtectedItemRequestsObjectsPager := r.newGetUpdateProtectedItemRequestsObjectsPager.get(req) + if newGetUpdateProtectedItemRequestsObjectsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/updateProtectedItemRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetUpdateProtectedItemRequestsObjectsPager(resourceGroupNameParam, resourceGuardsNameParam, nil) + newGetUpdateProtectedItemRequestsObjectsPager = &resp + r.newGetUpdateProtectedItemRequestsObjectsPager.add(req, newGetUpdateProtectedItemRequestsObjectsPager) + server.PagerResponderInjectNextLinks(newGetUpdateProtectedItemRequestsObjectsPager, req, func(page *armdataprotection.ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetUpdateProtectedItemRequestsObjectsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetUpdateProtectedItemRequestsObjectsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetUpdateProtectedItemRequestsObjectsPager) { + r.newGetUpdateProtectedItemRequestsObjectsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchNewGetUpdateProtectionPolicyRequestsObjectsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetUpdateProtectionPolicyRequestsObjectsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetUpdateProtectionPolicyRequestsObjectsPager not implemented")} + } + newGetUpdateProtectionPolicyRequestsObjectsPager := r.newGetUpdateProtectionPolicyRequestsObjectsPager.get(req) + if newGetUpdateProtectionPolicyRequestsObjectsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/updateProtectionPolicyRequests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetUpdateProtectionPolicyRequestsObjectsPager(resourceGroupNameParam, resourceGuardsNameParam, nil) + newGetUpdateProtectionPolicyRequestsObjectsPager = &resp + r.newGetUpdateProtectionPolicyRequestsObjectsPager.add(req, newGetUpdateProtectionPolicyRequestsObjectsPager) + server.PagerResponderInjectNextLinks(newGetUpdateProtectionPolicyRequestsObjectsPager, req, func(page *armdataprotection.ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetUpdateProtectionPolicyRequestsObjectsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetUpdateProtectionPolicyRequestsObjectsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetUpdateProtectionPolicyRequestsObjectsPager) { + r.newGetUpdateProtectionPolicyRequestsObjectsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if r.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("fake for method Patch not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.PatchResourceGuardInput](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Patch(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ResourceGuardResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceGuardsServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { + if r.srv.Put == nil { + return nil, &nonRetriableError{errors.New("fake for method Put not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/resourceGuards/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.ResourceGuardResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceGuardsNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGuardsName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Put(req.Context(), resourceGroupNameParam, resourceGuardsNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ResourceGuardResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/restorabletimeranges_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/restorabletimeranges_server.go new file mode 100644 index 000000000000..c8f21f2662f8 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/restorabletimeranges_server.go @@ -0,0 +1,108 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// RestorableTimeRangesServer is a fake server for instances of the armdataprotection.RestorableTimeRangesClient type. +type RestorableTimeRangesServer struct { + // Find is the fake for method RestorableTimeRangesClient.Find + // HTTP status codes to indicate success: http.StatusOK + Find func(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters armdataprotection.AzureBackupFindRestorableTimeRangesRequest, options *armdataprotection.RestorableTimeRangesClientFindOptions) (resp azfake.Responder[armdataprotection.RestorableTimeRangesClientFindResponse], errResp azfake.ErrorResponder) +} + +// NewRestorableTimeRangesServerTransport creates a new instance of RestorableTimeRangesServerTransport with the provided implementation. +// The returned RestorableTimeRangesServerTransport instance is connected to an instance of armdataprotection.RestorableTimeRangesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewRestorableTimeRangesServerTransport(srv *RestorableTimeRangesServer) *RestorableTimeRangesServerTransport { + return &RestorableTimeRangesServerTransport{srv: srv} +} + +// RestorableTimeRangesServerTransport connects instances of armdataprotection.RestorableTimeRangesClient to instances of RestorableTimeRangesServer. +// Don't use this type directly, use NewRestorableTimeRangesServerTransport instead. +type RestorableTimeRangesServerTransport struct { + srv *RestorableTimeRangesServer +} + +// Do implements the policy.Transporter interface for RestorableTimeRangesServerTransport. +func (r *RestorableTimeRangesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "RestorableTimeRangesClient.Find": + resp, err = r.dispatchFind(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *RestorableTimeRangesServerTransport) dispatchFind(req *http.Request) (*http.Response, error) { + if r.srv.Find == nil { + return nil, &nonRetriableError{errors.New("fake for method Find not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/backupVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/backupInstances/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/findRestorableTimeRanges` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armdataprotection.AzureBackupFindRestorableTimeRangesRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + backupInstanceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("backupInstanceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Find(req.Context(), resourceGroupNameParam, vaultNameParam, backupInstanceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AzureBackupFindRestorableTimeRangesResponseResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/secondaryrps_server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/secondaryrps_server.go new file mode 100644 index 000000000000..6fb441ac8315 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/secondaryrps_server.go @@ -0,0 +1,134 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// SecondaryRPsServer is a fake server for instances of the armdataprotection.SecondaryRPsClient type. +type SecondaryRPsServer struct { + // NewFetchPager is the fake for method SecondaryRPsClient.NewFetchPager + // HTTP status codes to indicate success: http.StatusOK + NewFetchPager func(resourceGroupName string, location string, parameters armdataprotection.FetchSecondaryRPsRequestParameters, options *armdataprotection.SecondaryRPsClientFetchOptions) (resp azfake.PagerResponder[armdataprotection.SecondaryRPsClientFetchResponse]) +} + +// NewSecondaryRPsServerTransport creates a new instance of SecondaryRPsServerTransport with the provided implementation. +// The returned SecondaryRPsServerTransport instance is connected to an instance of armdataprotection.SecondaryRPsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSecondaryRPsServerTransport(srv *SecondaryRPsServer) *SecondaryRPsServerTransport { + return &SecondaryRPsServerTransport{ + srv: srv, + newFetchPager: newTracker[azfake.PagerResponder[armdataprotection.SecondaryRPsClientFetchResponse]](), + } +} + +// SecondaryRPsServerTransport connects instances of armdataprotection.SecondaryRPsClient to instances of SecondaryRPsServer. +// Don't use this type directly, use NewSecondaryRPsServerTransport instead. +type SecondaryRPsServerTransport struct { + srv *SecondaryRPsServer + newFetchPager *tracker[azfake.PagerResponder[armdataprotection.SecondaryRPsClientFetchResponse]] +} + +// Do implements the policy.Transporter interface for SecondaryRPsServerTransport. +func (s *SecondaryRPsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SecondaryRPsClient.NewFetchPager": + resp, err = s.dispatchNewFetchPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SecondaryRPsServerTransport) dispatchNewFetchPager(req *http.Request) (*http.Response, error) { + if s.srv.NewFetchPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewFetchPager not implemented")} + } + newFetchPager := s.newFetchPager.get(req) + if newFetchPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fetchSecondaryRecoveryPoints` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + body, err := server.UnmarshalRequestAsJSON[armdataprotection.FetchSecondaryRPsRequestParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + var options *armdataprotection.SecondaryRPsClientFetchOptions + if filterParam != nil || skipTokenParam != nil { + options = &armdataprotection.SecondaryRPsClientFetchOptions{ + Filter: filterParam, + SkipToken: skipTokenParam, + } + } + resp := s.srv.NewFetchPager(resourceGroupNameParam, locationParam, body, options) + newFetchPager = &resp + s.newFetchPager.add(req, newFetchPager) + server.PagerResponderInjectNextLinks(newFetchPager, req, func(page *armdataprotection.SecondaryRPsClientFetchResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newFetchPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newFetchPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newFetchPager) { + s.newFetchPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/server.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/server.go new file mode 100644 index 000000000000..af070c21e012 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/server.go @@ -0,0 +1,104 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" + "net/http" + "net/url" + "regexp" +) + +// Server is a fake server for instances of the armdataprotection.Client type. +type Server struct { + // CheckFeatureSupport is the fake for method Client.CheckFeatureSupport + // HTTP status codes to indicate success: http.StatusOK + CheckFeatureSupport func(ctx context.Context, location string, parameters armdataprotection.FeatureValidationRequestBaseClassification, options *armdataprotection.ClientCheckFeatureSupportOptions) (resp azfake.Responder[armdataprotection.ClientCheckFeatureSupportResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armdataprotection.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{srv: srv} +} + +// ServerTransport connects instances of armdataprotection.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "Client.CheckFeatureSupport": + resp, err = s.dispatchCheckFeatureSupport(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ServerTransport) dispatchCheckFeatureSupport(req *http.Request) (*http.Response, error) { + if s.srv.CheckFeatureSupport == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckFeatureSupport not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.DataProtection/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkFeatureSupport` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalFeatureValidationRequestBaseClassification(raw) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CheckFeatureSupport(req.Context(), locationParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).FeatureValidationResponseBaseClassification, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/server_factory.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/server_factory.go new file mode 100644 index 000000000000..0ac0ec656593 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/server_factory.go @@ -0,0 +1,205 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armdataprotection.ClientFactory type. +type ServerFactory struct { + BackupInstancesServer BackupInstancesServer + BackupPoliciesServer BackupPoliciesServer + BackupVaultOperationResultsServer BackupVaultOperationResultsServer + BackupVaultsServer BackupVaultsServer + Server Server + CrossRegionRestoreJobServer CrossRegionRestoreJobServer + CrossRegionRestoreJobsServer CrossRegionRestoreJobsServer + DeletedBackupInstancesServer DeletedBackupInstancesServer + DppResourceGuardProxyServer DppResourceGuardProxyServer + ExportJobsServer ExportJobsServer + ExportJobsOperationResultServer ExportJobsOperationResultServer + JobsServer JobsServer + OperationResultServer OperationResultServer + OperationStatusBackupVaultContextServer OperationStatusBackupVaultContextServer + OperationStatusServer OperationStatusServer + OperationStatusResourceGroupContextServer OperationStatusResourceGroupContextServer + OperationsServer OperationsServer + RecoveryPointsServer RecoveryPointsServer + ResourceGuardsServer ResourceGuardsServer + RestorableTimeRangesServer RestorableTimeRangesServer + SecondaryRPsServer SecondaryRPsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armdataprotection.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armdataprotection.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trBackupInstancesServer *BackupInstancesServerTransport + trBackupPoliciesServer *BackupPoliciesServerTransport + trBackupVaultOperationResultsServer *BackupVaultOperationResultsServerTransport + trBackupVaultsServer *BackupVaultsServerTransport + trServer *ServerTransport + trCrossRegionRestoreJobServer *CrossRegionRestoreJobServerTransport + trCrossRegionRestoreJobsServer *CrossRegionRestoreJobsServerTransport + trDeletedBackupInstancesServer *DeletedBackupInstancesServerTransport + trDppResourceGuardProxyServer *DppResourceGuardProxyServerTransport + trExportJobsServer *ExportJobsServerTransport + trExportJobsOperationResultServer *ExportJobsOperationResultServerTransport + trJobsServer *JobsServerTransport + trOperationResultServer *OperationResultServerTransport + trOperationStatusBackupVaultContextServer *OperationStatusBackupVaultContextServerTransport + trOperationStatusServer *OperationStatusServerTransport + trOperationStatusResourceGroupContextServer *OperationStatusResourceGroupContextServerTransport + trOperationsServer *OperationsServerTransport + trRecoveryPointsServer *RecoveryPointsServerTransport + trResourceGuardsServer *ResourceGuardsServerTransport + trRestorableTimeRangesServer *RestorableTimeRangesServerTransport + trSecondaryRPsServer *SecondaryRPsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "BackupInstancesClient": + initServer(s, &s.trBackupInstancesServer, func() *BackupInstancesServerTransport { + return NewBackupInstancesServerTransport(&s.srv.BackupInstancesServer) + }) + resp, err = s.trBackupInstancesServer.Do(req) + case "BackupPoliciesClient": + initServer(s, &s.trBackupPoliciesServer, func() *BackupPoliciesServerTransport { + return NewBackupPoliciesServerTransport(&s.srv.BackupPoliciesServer) + }) + resp, err = s.trBackupPoliciesServer.Do(req) + case "BackupVaultOperationResultsClient": + initServer(s, &s.trBackupVaultOperationResultsServer, func() *BackupVaultOperationResultsServerTransport { + return NewBackupVaultOperationResultsServerTransport(&s.srv.BackupVaultOperationResultsServer) + }) + resp, err = s.trBackupVaultOperationResultsServer.Do(req) + case "BackupVaultsClient": + initServer(s, &s.trBackupVaultsServer, func() *BackupVaultsServerTransport { return NewBackupVaultsServerTransport(&s.srv.BackupVaultsServer) }) + resp, err = s.trBackupVaultsServer.Do(req) + case "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "CrossRegionRestoreJobClient": + initServer(s, &s.trCrossRegionRestoreJobServer, func() *CrossRegionRestoreJobServerTransport { + return NewCrossRegionRestoreJobServerTransport(&s.srv.CrossRegionRestoreJobServer) + }) + resp, err = s.trCrossRegionRestoreJobServer.Do(req) + case "CrossRegionRestoreJobsClient": + initServer(s, &s.trCrossRegionRestoreJobsServer, func() *CrossRegionRestoreJobsServerTransport { + return NewCrossRegionRestoreJobsServerTransport(&s.srv.CrossRegionRestoreJobsServer) + }) + resp, err = s.trCrossRegionRestoreJobsServer.Do(req) + case "DeletedBackupInstancesClient": + initServer(s, &s.trDeletedBackupInstancesServer, func() *DeletedBackupInstancesServerTransport { + return NewDeletedBackupInstancesServerTransport(&s.srv.DeletedBackupInstancesServer) + }) + resp, err = s.trDeletedBackupInstancesServer.Do(req) + case "DppResourceGuardProxyClient": + initServer(s, &s.trDppResourceGuardProxyServer, func() *DppResourceGuardProxyServerTransport { + return NewDppResourceGuardProxyServerTransport(&s.srv.DppResourceGuardProxyServer) + }) + resp, err = s.trDppResourceGuardProxyServer.Do(req) + case "ExportJobsClient": + initServer(s, &s.trExportJobsServer, func() *ExportJobsServerTransport { return NewExportJobsServerTransport(&s.srv.ExportJobsServer) }) + resp, err = s.trExportJobsServer.Do(req) + case "ExportJobsOperationResultClient": + initServer(s, &s.trExportJobsOperationResultServer, func() *ExportJobsOperationResultServerTransport { + return NewExportJobsOperationResultServerTransport(&s.srv.ExportJobsOperationResultServer) + }) + resp, err = s.trExportJobsOperationResultServer.Do(req) + case "JobsClient": + initServer(s, &s.trJobsServer, func() *JobsServerTransport { return NewJobsServerTransport(&s.srv.JobsServer) }) + resp, err = s.trJobsServer.Do(req) + case "OperationResultClient": + initServer(s, &s.trOperationResultServer, func() *OperationResultServerTransport { + return NewOperationResultServerTransport(&s.srv.OperationResultServer) + }) + resp, err = s.trOperationResultServer.Do(req) + case "OperationStatusBackupVaultContextClient": + initServer(s, &s.trOperationStatusBackupVaultContextServer, func() *OperationStatusBackupVaultContextServerTransport { + return NewOperationStatusBackupVaultContextServerTransport(&s.srv.OperationStatusBackupVaultContextServer) + }) + resp, err = s.trOperationStatusBackupVaultContextServer.Do(req) + case "OperationStatusClient": + initServer(s, &s.trOperationStatusServer, func() *OperationStatusServerTransport { + return NewOperationStatusServerTransport(&s.srv.OperationStatusServer) + }) + resp, err = s.trOperationStatusServer.Do(req) + case "OperationStatusResourceGroupContextClient": + initServer(s, &s.trOperationStatusResourceGroupContextServer, func() *OperationStatusResourceGroupContextServerTransport { + return NewOperationStatusResourceGroupContextServerTransport(&s.srv.OperationStatusResourceGroupContextServer) + }) + resp, err = s.trOperationStatusResourceGroupContextServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "RecoveryPointsClient": + initServer(s, &s.trRecoveryPointsServer, func() *RecoveryPointsServerTransport { + return NewRecoveryPointsServerTransport(&s.srv.RecoveryPointsServer) + }) + resp, err = s.trRecoveryPointsServer.Do(req) + case "ResourceGuardsClient": + initServer(s, &s.trResourceGuardsServer, func() *ResourceGuardsServerTransport { + return NewResourceGuardsServerTransport(&s.srv.ResourceGuardsServer) + }) + resp, err = s.trResourceGuardsServer.Do(req) + case "RestorableTimeRangesClient": + initServer(s, &s.trRestorableTimeRangesServer, func() *RestorableTimeRangesServerTransport { + return NewRestorableTimeRangesServerTransport(&s.srv.RestorableTimeRangesServer) + }) + resp, err = s.trRestorableTimeRangesServer.Do(req) + case "SecondaryRPsClient": + initServer(s, &s.trSecondaryRPsServer, func() *SecondaryRPsServerTransport { return NewSecondaryRPsServerTransport(&s.srv.SecondaryRPsServer) }) + resp, err = s.trSecondaryRPsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/fake/time_rfc3339.go b/sdk/resourcemanager/dataprotection/armdataprotection/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/fake/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 fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/go.mod b/sdk/resourcemanager/dataprotection/armdataprotection/go.mod index daa213aaf5dd..f8ff535b3eb8 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/go.mod +++ b/sdk/resourcemanager/dataprotection/armdataprotection/go.mod @@ -1,21 +1,11 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2 +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v3 go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/go.sum b/sdk/resourcemanager/dataprotection/armdataprotection/go.sum index 21718b486698..428cd71de305 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/go.sum +++ b/sdk/resourcemanager/dataprotection/armdataprotection/go.sum @@ -1,31 +1,12 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= -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/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -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/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/interfaces.go b/sdk/resourcemanager/dataprotection/armdataprotection/interfaces.go new file mode 100644 index 000000000000..9156f01015dd --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/interfaces.go @@ -0,0 +1,183 @@ +//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 armdataprotection + +// AuthCredentialsClassification provides polymorphic access to related types. +// Call the interface's GetAuthCredentials() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AuthCredentials, *SecretStoreBasedAuthCredentials +type AuthCredentialsClassification interface { + // GetAuthCredentials returns the AuthCredentials content of the underlying type. + GetAuthCredentials() *AuthCredentials +} + +// AzureBackupRecoveryPointBasedRestoreRequestClassification provides polymorphic access to related types. +// Call the interface's GetAzureBackupRecoveryPointBasedRestoreRequest() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureBackupRecoveryPointBasedRestoreRequest, *AzureBackupRestoreWithRehydrationRequest +type AzureBackupRecoveryPointBasedRestoreRequestClassification interface { + AzureBackupRestoreRequestClassification + // GetAzureBackupRecoveryPointBasedRestoreRequest returns the AzureBackupRecoveryPointBasedRestoreRequest content of the underlying type. + GetAzureBackupRecoveryPointBasedRestoreRequest() *AzureBackupRecoveryPointBasedRestoreRequest +} + +// AzureBackupRecoveryPointClassification provides polymorphic access to related types. +// Call the interface's GetAzureBackupRecoveryPoint() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureBackupDiscreteRecoveryPoint, *AzureBackupRecoveryPoint +type AzureBackupRecoveryPointClassification interface { + // GetAzureBackupRecoveryPoint returns the AzureBackupRecoveryPoint content of the underlying type. + GetAzureBackupRecoveryPoint() *AzureBackupRecoveryPoint +} + +// AzureBackupRestoreRequestClassification provides polymorphic access to related types. +// Call the interface's GetAzureBackupRestoreRequest() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureBackupRecoveryPointBasedRestoreRequest, *AzureBackupRecoveryTimeBasedRestoreRequest, *AzureBackupRestoreRequest, +// - *AzureBackupRestoreWithRehydrationRequest +type AzureBackupRestoreRequestClassification interface { + // GetAzureBackupRestoreRequest returns the AzureBackupRestoreRequest content of the underlying type. + GetAzureBackupRestoreRequest() *AzureBackupRestoreRequest +} + +// BackupCriteriaClassification provides polymorphic access to related types. +// Call the interface's GetBackupCriteria() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BackupCriteria, *ScheduleBasedBackupCriteria +type BackupCriteriaClassification interface { + // GetBackupCriteria returns the BackupCriteria content of the underlying type. + GetBackupCriteria() *BackupCriteria +} + +// BackupDatasourceParametersClassification provides polymorphic access to related types. +// Call the interface's GetBackupDatasourceParameters() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BackupDatasourceParameters, *BlobBackupDatasourceParameters, *KubernetesClusterBackupDatasourceParameters +type BackupDatasourceParametersClassification interface { + // GetBackupDatasourceParameters returns the BackupDatasourceParameters content of the underlying type. + GetBackupDatasourceParameters() *BackupDatasourceParameters +} + +// BackupParametersClassification provides polymorphic access to related types. +// Call the interface's GetBackupParameters() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureBackupParams, *BackupParameters +type BackupParametersClassification interface { + // GetBackupParameters returns the BackupParameters content of the underlying type. + GetBackupParameters() *BackupParameters +} + +// BaseBackupPolicyClassification provides polymorphic access to related types. +// Call the interface's GetBaseBackupPolicy() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BackupPolicy, *BaseBackupPolicy +type BaseBackupPolicyClassification interface { + // GetBaseBackupPolicy returns the BaseBackupPolicy content of the underlying type. + GetBaseBackupPolicy() *BaseBackupPolicy +} + +// BasePolicyRuleClassification provides polymorphic access to related types. +// Call the interface's GetBasePolicyRule() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureBackupRule, *AzureRetentionRule, *BasePolicyRule +type BasePolicyRuleClassification interface { + // GetBasePolicyRule returns the BasePolicyRule content of the underlying type. + GetBasePolicyRule() *BasePolicyRule +} + +// BaseResourcePropertiesClassification provides polymorphic access to related types. +// Call the interface's GetBaseResourceProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BaseResourceProperties, *DefaultResourceProperties +type BaseResourcePropertiesClassification interface { + // GetBaseResourceProperties returns the BaseResourceProperties content of the underlying type. + GetBaseResourceProperties() *BaseResourceProperties +} + +// CopyOptionClassification provides polymorphic access to related types. +// Call the interface's GetCopyOption() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *CopyOnExpiryOption, *CopyOption, *CustomCopyOption, *ImmediateCopyOption +type CopyOptionClassification interface { + // GetCopyOption returns the CopyOption content of the underlying type. + GetCopyOption() *CopyOption +} + +// DataStoreParametersClassification provides polymorphic access to related types. +// Call the interface's GetDataStoreParameters() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AzureOperationalStoreParameters, *DataStoreParameters +type DataStoreParametersClassification interface { + // GetDataStoreParameters returns the DataStoreParameters content of the underlying type. + GetDataStoreParameters() *DataStoreParameters +} + +// DeleteOptionClassification provides polymorphic access to related types. +// Call the interface's GetDeleteOption() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AbsoluteDeleteOption, *DeleteOption +type DeleteOptionClassification interface { + // GetDeleteOption returns the DeleteOption content of the underlying type. + GetDeleteOption() *DeleteOption +} + +// FeatureValidationRequestBaseClassification provides polymorphic access to related types. +// Call the interface's GetFeatureValidationRequestBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *FeatureValidationRequest, *FeatureValidationRequestBase +type FeatureValidationRequestBaseClassification interface { + // GetFeatureValidationRequestBase returns the FeatureValidationRequestBase content of the underlying type. + GetFeatureValidationRequestBase() *FeatureValidationRequestBase +} + +// FeatureValidationResponseBaseClassification provides polymorphic access to related types. +// Call the interface's GetFeatureValidationResponseBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *FeatureValidationResponse, *FeatureValidationResponseBase +type FeatureValidationResponseBaseClassification interface { + // GetFeatureValidationResponseBase returns the FeatureValidationResponseBase content of the underlying type. + GetFeatureValidationResponseBase() *FeatureValidationResponseBase +} + +// ItemLevelRestoreCriteriaClassification provides polymorphic access to related types. +// Call the interface's GetItemLevelRestoreCriteria() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *ItemLevelRestoreCriteria, *ItemPathBasedRestoreCriteria, *KubernetesClusterRestoreCriteria, *KubernetesClusterVaultTierRestoreCriteria, +// - *KubernetesPVRestoreCriteria, *KubernetesStorageClassRestoreCriteria, *RangeBasedItemLevelRestoreCriteria +type ItemLevelRestoreCriteriaClassification interface { + // GetItemLevelRestoreCriteria returns the ItemLevelRestoreCriteria content of the underlying type. + GetItemLevelRestoreCriteria() *ItemLevelRestoreCriteria +} + +// OperationExtendedInfoClassification provides polymorphic access to related types. +// Call the interface's GetOperationExtendedInfo() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *OperationExtendedInfo, *OperationJobExtendedInfo +type OperationExtendedInfoClassification interface { + // GetOperationExtendedInfo returns the OperationExtendedInfo content of the underlying type. + GetOperationExtendedInfo() *OperationExtendedInfo +} + +// RestoreTargetInfoBaseClassification provides polymorphic access to related types. +// Call the interface's GetRestoreTargetInfoBase() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *ItemLevelRestoreTargetInfo, *RestoreFilesTargetInfo, *RestoreTargetInfo, *RestoreTargetInfoBase +type RestoreTargetInfoBaseClassification interface { + // GetRestoreTargetInfoBase returns the RestoreTargetInfoBase content of the underlying type. + GetRestoreTargetInfoBase() *RestoreTargetInfoBase +} + +// TriggerContextClassification provides polymorphic access to related types. +// Call the interface's GetTriggerContext() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *AdhocBasedTriggerContext, *ScheduleBasedTriggerContext, *TriggerContext +type TriggerContextClassification interface { + // GetTriggerContext returns the TriggerContext content of the underlying type. + GetTriggerContext() *TriggerContext +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/jobs_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/jobs_client.go index 1b73de0f4d41..33356aefed42 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/jobs_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/jobs_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type JobsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewJobsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*JobsClient, error) { - cl, err := arm.NewClient(moduleName+".JobsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,29 +46,39 @@ func NewJobsClient(subscriptionID string, credential azcore.TokenCredential, opt // Get - Gets a job with id in a backup vault // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - jobID - The Job ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). // - options - JobsClientGetOptions contains the optional parameters for the JobsClient.Get method. func (client *JobsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, jobID string, options *JobsClientGetOptions) (JobsClientGetResponse, error) { + var err error + const operationName = "JobsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, jobID, options) if err != nil { return JobsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return JobsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return JobsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return JobsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *JobsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, jobID string, options *JobsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs/{jobId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -88,7 +97,7 @@ func (client *JobsClient) getCreateRequest(ctx context.Context, resourceGroupNam return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -105,7 +114,7 @@ func (client *JobsClient) getHandleResponse(resp *http.Response) (JobsClientGetR // NewListPager - Returns list of jobs belonging to a backup vault // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - JobsClientListOptions contains the optional parameters for the JobsClient.NewListPager method. @@ -115,31 +124,29 @@ func (client *JobsClient) NewListPager(resourceGroupName string, vaultName strin return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *JobsClientListResponse) (JobsClientListResponse, 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) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "JobsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, vaultName, options) + }, nil) if err != nil { return JobsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return JobsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return JobsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. func (client *JobsClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, options *JobsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupJobs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -154,7 +161,7 @@ func (client *JobsClient) listCreateRequest(ctx context.Context, resourceGroupNa return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/jobs_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/jobs_client_example_test.go deleted file mode 100644 index 21c69c858ba6..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/jobs_client_example_test.go +++ /dev/null @@ -1,230 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/JobCRUD/ListJobs.json -func ExampleJobsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewJobsClient().NewListPager("BugBash1", "BugBashVaultForCCYv11", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AzureBackupJobResourceList = armdataprotection.AzureBackupJobResourceList{ - // Value: []*armdataprotection.AzureBackupJobResource{ - // { - // Name: to.Ptr("8989416e-7573-4836-8cf1-0e90954f1002"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults/backupJobs"), - // ID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/Backupvaults/BugBashVaultForCCYv11/backupJobs/8989416e-7573-4836-8cf1-0e90954f1002"), - // Properties: &armdataprotection.AzureBackupJob{ - // ActivityID: to.Ptr("932925c4-3d81-4550-8105-c7f7b0a934c5"), - // BackupInstanceFriendlyName: to.Ptr("mabtestingccybasicv11\\bugbashdb4"), - // BackupInstanceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupInstances/3048870f-b1b7-44c4-b078-368da3fd000e"), - // DataSourceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/DppPostgresTestingCcy/providers/Microsoft.DBforPostgreSQL/servers/mabtestingccybasicv11/databases/bugbashdb4"), - // DataSourceLocation: to.Ptr("centraluseuap"), - // DataSourceName: to.Ptr("bugbashdb4"), - // DataSourceSetName: to.Ptr("mabtestingccybasicv11"), - // DataSourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // Duration: to.Ptr("00:00:00"), - // IsUserTriggered: to.Ptr(false), - // Operation: to.Ptr("Backup"), - // OperationCategory: to.Ptr("Backup"), - // PolicyID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupPolicies/jakavetPolicy2"), - // PolicyName: to.Ptr("jakavetPolicy2"), - // ProgressEnabled: to.Ptr(false), - // SourceResourceGroup: to.Ptr("DppPostgresTestingCcy"), - // SourceSubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-03-16T05:00:08.1746833Z"); return t}()), - // Status: to.Ptr("Started"), - // SubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // SupportedActions: []*string{ - // }, - // VaultName: to.Ptr("BugBashVaultForCCYv11"), - // }, - // }, - // { - // Name: to.Ptr("ad218c05-242a-47c2-b7b7-c16bd0f8870c"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults/backupJobs"), - // ID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/Backupvaults/BugBashVaultForCCYv11/backupJobs/ad218c05-242a-47c2-b7b7-c16bd0f8870c"), - // Properties: &armdataprotection.AzureBackupJob{ - // ActivityID: to.Ptr("b4f32e03-ded0-46fc-9afc-91853878efcd"), - // BackupInstanceFriendlyName: to.Ptr("mabtestingccybasicv11\\bugbashdb5"), - // BackupInstanceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupInstances/943c60db-c033-4d93-bb00-66048474e00e"), - // DataSourceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/DppPostgresTestingCcy/providers/Microsoft.DBforPostgreSQL/servers/mabtestingccybasicv11/databases/bugbashdb5"), - // DataSourceLocation: to.Ptr("centraluseuap"), - // DataSourceName: to.Ptr("bugbashdb5"), - // DataSourceSetName: to.Ptr("mabtestingccybasicv11"), - // DataSourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // Duration: to.Ptr("00:00:00"), - // IsUserTriggered: to.Ptr(false), - // Operation: to.Ptr("Backup"), - // OperationCategory: to.Ptr("Backup"), - // PolicyID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupPolicies/jakavetPolicy3"), - // PolicyName: to.Ptr("jakavetPolicy3"), - // ProgressEnabled: to.Ptr(false), - // SourceResourceGroup: to.Ptr("DppPostgresTestingCcy"), - // SourceSubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-03-16T18:00:03.6660733Z"); return t}()), - // Status: to.Ptr("Started"), - // SubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // SupportedActions: []*string{ - // }, - // VaultName: to.Ptr("BugBashVaultForCCYv11"), - // }, - // }, - // { - // Name: to.Ptr("3c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults/backupJobs"), - // ID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/Backupvaults/BugBashVaultForCCYv11/backupJobs/3c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // Properties: &armdataprotection.AzureBackupJob{ - // ActivityID: to.Ptr("c4344fb4-7c11-43a4-8307-7ae7c7fb09b9"), - // BackupInstanceFriendlyName: to.Ptr("mabtestingccybasicv11\\bugbashdb2"), - // BackupInstanceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupInstances/28460a9d-707a-45f3-ace6-b16284c2900e"), - // DataSourceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/DppPostgresTestingCcy/providers/Microsoft.DBforPostgreSQL/servers/mabtestingccybasicv11/databases/bugbashdb2"), - // DataSourceLocation: to.Ptr("centraluseuap"), - // DataSourceName: to.Ptr("bugbashdb2"), - // DataSourceSetName: to.Ptr("mabtestingccybasicv11"), - // DataSourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // Duration: to.Ptr("00:00:00"), - // IsUserTriggered: to.Ptr(false), - // Operation: to.Ptr("Backup"), - // OperationCategory: to.Ptr("Backup"), - // PolicyID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupPolicies/jakavetdailypolicy"), - // PolicyName: to.Ptr("jakavetdailypolicy"), - // ProgressEnabled: to.Ptr(false), - // SourceResourceGroup: to.Ptr("DppPostgresTestingCcy"), - // SourceSubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-03-17T03:00:03.7604146Z"); return t}()), - // Status: to.Ptr("Started"), - // SubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // SupportedActions: []*string{ - // }, - // VaultName: to.Ptr("BugBashVaultForCCYv11"), - // }, - // }, - // { - // Name: to.Ptr("43252662-1b43-44fd-a856-0055665cb097"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults/backupJobs"), - // ID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/Backupvaults/BugBashVaultForCCYv11/backupJobs/43252662-1b43-44fd-a856-0055665cb097"), - // Properties: &armdataprotection.AzureBackupJob{ - // ActivityID: to.Ptr("94052cf1-a47f-4c1b-93e7-79e07b2bd008-Tue Mar 17 2021 11:11:48 GMT+0530 (India Standard Time)-Ibz"), - // BackupInstanceFriendlyName: to.Ptr("mabtestingccybasicv11\\bugbashdb3"), - // BackupInstanceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupInstances/0b247869-b8be-4885-b832-8ac4cdf5b00e"), - // DataSourceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/DppPostgresTestingCcy/providers/Microsoft.DBforPostgreSQL/servers/mabtestingccybasicv11/databases/bugbashdb3"), - // DataSourceLocation: to.Ptr("centraluseuap"), - // DataSourceName: to.Ptr("bugbashdb3"), - // DataSourceSetName: to.Ptr("mabtestingccybasicv11"), - // DataSourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // Duration: to.Ptr("00:02:11.9724387"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-03-17T11:14:02.5319646Z"); return t}()), - // IsUserTriggered: to.Ptr(true), - // Operation: to.Ptr("Backup"), - // OperationCategory: to.Ptr("Backup"), - // PolicyID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupPolicies/jakavetPolicy1"), - // PolicyName: to.Ptr("jakavetPolicy1"), - // ProgressEnabled: to.Ptr(false), - // SourceResourceGroup: to.Ptr("DppPostgresTestingCcy"), - // SourceSubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-03-17T11:11:50.5595259Z"); return t}()), - // Status: to.Ptr("Succeeded"), - // SubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // SupportedActions: []*string{ - // to.Ptr("")}, - // VaultName: to.Ptr("BugBashVaultForCCYv11"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/JobCRUD/GetJob.json -func ExampleJobsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewJobsClient().Get(ctx, "BugBash1", "BugBashVaultForCCYv11", "3c60cb49-63e8-4b21-b9bd-26277b3fdfae", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AzureBackupJobResource = armdataprotection.AzureBackupJobResource{ - // Name: to.Ptr("3c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // Type: to.Ptr("Microsoft.DataProtection/Backupvaults/backupJobs"), - // ID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/Backupvaults/BugBashVaultForCCYv11/backupJobs/3c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // Properties: &armdataprotection.AzureBackupJob{ - // ActivityID: to.Ptr("c4344fb4-7c11-43a4-8307-7ae7c7fb09b9"), - // BackupInstanceFriendlyName: to.Ptr("mabtestingccybasicv11\\bugbashdb2"), - // BackupInstanceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupInstances/28460a9d-707a-45f3-ace6-b16284c2900e"), - // DataSourceID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/DppPostgresTestingCcy/providers/Microsoft.DBforPostgreSQL/servers/mabtestingccybasicv11/databases/bugbashdb2"), - // DataSourceLocation: to.Ptr("centraluseuap"), - // DataSourceName: to.Ptr("bugbashdb2"), - // DataSourceSetName: to.Ptr("mabtestingccybasicv11"), - // DataSourceType: to.Ptr("Microsoft.DBforPostgreSQL/servers/databases"), - // Duration: to.Ptr("00:00:00"), - // ExtendedInfo: &armdataprotection.JobExtendedInfo{ - // AdditionalDetails: map[string]*string{ - // "PolicyRuleName": to.Ptr("BackupWeekly"), - // "RetentionTag": to.Ptr("Default"), - // "TaskId": to.Ptr("c4344fb4-7c11-43a4-8307-7ae7c7fb09b9"), - // }, - // SubTasks: []*armdataprotection.JobSubTask{ - // { - // TaskID: to.Ptr[int32](1), - // TaskName: to.Ptr("Trigger Backup"), - // TaskStatus: to.Ptr("Started"), - // }}, - // }, - // IsUserTriggered: to.Ptr(false), - // Operation: to.Ptr("Backup"), - // OperationCategory: to.Ptr("Backup"), - // PolicyID: to.Ptr("/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/BugBash1/providers/Microsoft.DataProtection/backupVaults/BugBashVaultForCCYv11/backupPolicies/jakavetdailypolicy"), - // PolicyName: to.Ptr("jakavetdailypolicy"), - // ProgressEnabled: to.Ptr(false), - // SourceResourceGroup: to.Ptr("DppPostgresTestingCcy"), - // SourceSubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-03-17T03:00:03.7604146Z"); return t}()), - // Status: to.Ptr("Started"), - // SubscriptionID: to.Ptr("62b829ee-7936-40c9-a1c9-47a93f9f3965"), - // SupportedActions: []*string{ - // }, - // VaultName: to.Ptr("BugBashVaultForCCYv11"), - // }, - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/models.go b/sdk/resourcemanager/dataprotection/armdataprotection/models.go index de92f5af4573..58d537e6a55b 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/models.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/models.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -64,15 +63,6 @@ func (a *AdhocBasedTriggerContext) GetTriggerContext() *TriggerContext { } } -// AuthCredentialsClassification provides polymorphic access to related types. -// Call the interface's GetAuthCredentials() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AuthCredentials, *SecretStoreBasedAuthCredentials -type AuthCredentialsClassification interface { - // GetAuthCredentials returns the AuthCredentials content of the underlying type. - GetAuthCredentials() *AuthCredentials -} - // AuthCredentials - Base class for different types of authentication credentials. type AuthCredentials struct { // REQUIRED; Type of the specific object - used for deserializing @@ -94,9 +84,13 @@ type AzureBackupDiscreteRecoveryPoint struct { PolicyVersion *string RecoveryPointDataStoresDetails []*RecoveryPointDataStoreDetails RecoveryPointID *string - RecoveryPointType *string - RetentionTagName *string - RetentionTagVersion *string + + // Specifies recovery point completeness. Partial (i.e., only some of the intended items were backed up), or Completed (i.e., + // ALL intended items were backed up). + RecoveryPointState *RecoveryPointCompletionState + RecoveryPointType *string + RetentionTagName *string + RetentionTagVersion *string // READ-ONLY ExpiryTime *time.Time @@ -297,15 +291,6 @@ func (a *AzureBackupParams) GetBackupParameters() *BackupParameters { } } -// AzureBackupRecoveryPointClassification provides polymorphic access to related types. -// Call the interface's GetAzureBackupRecoveryPoint() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AzureBackupDiscreteRecoveryPoint, *AzureBackupRecoveryPoint -type AzureBackupRecoveryPointClassification interface { - // GetAzureBackupRecoveryPoint returns the AzureBackupRecoveryPoint content of the underlying type. - GetAzureBackupRecoveryPoint() *AzureBackupRecoveryPoint -} - // AzureBackupRecoveryPoint - Azure backup recoveryPoint type AzureBackupRecoveryPoint struct { // REQUIRED @@ -315,16 +300,6 @@ type AzureBackupRecoveryPoint struct { // GetAzureBackupRecoveryPoint implements the AzureBackupRecoveryPointClassification interface for type AzureBackupRecoveryPoint. func (a *AzureBackupRecoveryPoint) GetAzureBackupRecoveryPoint() *AzureBackupRecoveryPoint { return a } -// AzureBackupRecoveryPointBasedRestoreRequestClassification provides polymorphic access to related types. -// Call the interface's GetAzureBackupRecoveryPointBasedRestoreRequest() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AzureBackupRecoveryPointBasedRestoreRequest, *AzureBackupRestoreWithRehydrationRequest -type AzureBackupRecoveryPointBasedRestoreRequestClassification interface { - AzureBackupRestoreRequestClassification - // GetAzureBackupRecoveryPointBasedRestoreRequest returns the AzureBackupRecoveryPointBasedRestoreRequest content of the underlying type. - GetAzureBackupRecoveryPointBasedRestoreRequest() *AzureBackupRecoveryPointBasedRestoreRequest -} - // AzureBackupRecoveryPointBasedRestoreRequest - Azure backup recoveryPoint based restore request type AzureBackupRecoveryPointBasedRestoreRequest struct { // REQUIRED @@ -355,11 +330,11 @@ func (a *AzureBackupRecoveryPointBasedRestoreRequest) GetAzureBackupRecoveryPoin // GetAzureBackupRestoreRequest implements the AzureBackupRestoreRequestClassification interface for type AzureBackupRecoveryPointBasedRestoreRequest. func (a *AzureBackupRecoveryPointBasedRestoreRequest) GetAzureBackupRestoreRequest() *AzureBackupRestoreRequest { return &AzureBackupRestoreRequest{ + IdentityDetails: a.IdentityDetails, ObjectType: a.ObjectType, RestoreTargetInfo: a.RestoreTargetInfo, SourceDataStoreType: a.SourceDataStoreType, SourceResourceID: a.SourceResourceID, - IdentityDetails: a.IdentityDetails, } } @@ -414,11 +389,11 @@ type AzureBackupRecoveryTimeBasedRestoreRequest struct { // GetAzureBackupRestoreRequest implements the AzureBackupRestoreRequestClassification interface for type AzureBackupRecoveryTimeBasedRestoreRequest. func (a *AzureBackupRecoveryTimeBasedRestoreRequest) GetAzureBackupRestoreRequest() *AzureBackupRestoreRequest { return &AzureBackupRestoreRequest{ + IdentityDetails: a.IdentityDetails, ObjectType: a.ObjectType, RestoreTargetInfo: a.RestoreTargetInfo, SourceDataStoreType: a.SourceDataStoreType, SourceResourceID: a.SourceResourceID, - IdentityDetails: a.IdentityDetails, } } @@ -434,16 +409,6 @@ type AzureBackupRehydrationRequest struct { RehydrationPriority *RehydrationPriority } -// AzureBackupRestoreRequestClassification provides polymorphic access to related types. -// Call the interface's GetAzureBackupRestoreRequest() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AzureBackupRecoveryPointBasedRestoreRequest, *AzureBackupRecoveryTimeBasedRestoreRequest, *AzureBackupRestoreRequest, -// - *AzureBackupRestoreWithRehydrationRequest -type AzureBackupRestoreRequestClassification interface { - // GetAzureBackupRestoreRequest returns the AzureBackupRestoreRequest content of the underlying type. - GetAzureBackupRestoreRequest() *AzureBackupRestoreRequest -} - // AzureBackupRestoreRequest - Azure backup restore request type AzureBackupRestoreRequest struct { // REQUIRED @@ -498,23 +463,23 @@ type AzureBackupRestoreWithRehydrationRequest struct { // interface for type AzureBackupRestoreWithRehydrationRequest. func (a *AzureBackupRestoreWithRehydrationRequest) GetAzureBackupRecoveryPointBasedRestoreRequest() *AzureBackupRecoveryPointBasedRestoreRequest { return &AzureBackupRecoveryPointBasedRestoreRequest{ - RecoveryPointID: a.RecoveryPointID, + IdentityDetails: a.IdentityDetails, ObjectType: a.ObjectType, + RecoveryPointID: a.RecoveryPointID, RestoreTargetInfo: a.RestoreTargetInfo, SourceDataStoreType: a.SourceDataStoreType, SourceResourceID: a.SourceResourceID, - IdentityDetails: a.IdentityDetails, } } // GetAzureBackupRestoreRequest implements the AzureBackupRestoreRequestClassification interface for type AzureBackupRestoreWithRehydrationRequest. func (a *AzureBackupRestoreWithRehydrationRequest) GetAzureBackupRestoreRequest() *AzureBackupRestoreRequest { return &AzureBackupRestoreRequest{ + IdentityDetails: a.IdentityDetails, ObjectType: a.ObjectType, RestoreTargetInfo: a.RestoreTargetInfo, SourceDataStoreType: a.SourceDataStoreType, SourceResourceID: a.SourceResourceID, - IdentityDetails: a.IdentityDetails, } } @@ -564,8 +529,8 @@ type AzureOperationalStoreParameters struct { // GetDataStoreParameters implements the DataStoreParametersClassification interface for type AzureOperationalStoreParameters. func (a *AzureOperationalStoreParameters) GetDataStoreParameters() *DataStoreParameters { return &DataStoreParameters{ - ObjectType: a.ObjectType, DataStoreType: a.DataStoreType, + ObjectType: a.ObjectType, } } @@ -590,15 +555,6 @@ func (a *AzureRetentionRule) GetBasePolicyRule() *BasePolicyRule { } } -// BackupCriteriaClassification provides polymorphic access to related types. -// Call the interface's GetBackupCriteria() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *BackupCriteria, *ScheduleBasedBackupCriteria -type BackupCriteriaClassification interface { - // GetBackupCriteria returns the BackupCriteria content of the underlying type. - GetBackupCriteria() *BackupCriteria -} - // BackupCriteria base class type BackupCriteria struct { // REQUIRED; Type of the specific object - used for deserializing @@ -608,15 +564,6 @@ type BackupCriteria struct { // GetBackupCriteria implements the BackupCriteriaClassification interface for type BackupCriteria. func (b *BackupCriteria) GetBackupCriteria() *BackupCriteria { return b } -// BackupDatasourceParametersClassification provides polymorphic access to related types. -// Call the interface's GetBackupDatasourceParameters() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *BackupDatasourceParameters, *BlobBackupDatasourceParameters, *KubernetesClusterBackupDatasourceParameters -type BackupDatasourceParametersClassification interface { - // GetBackupDatasourceParameters returns the BackupDatasourceParameters content of the underlying type. - GetBackupDatasourceParameters() *BackupDatasourceParameters -} - // BackupDatasourceParameters - Parameters for Backup Datasource type BackupDatasourceParameters struct { // REQUIRED; Type of the specific object - used for deserializing @@ -697,114 +644,6 @@ type BackupInstanceResourceList struct { Value []*BackupInstanceResource } -// BackupInstancesClientBeginAdhocBackupOptions contains the optional parameters for the BackupInstancesClient.BeginAdhocBackup -// method. -type BackupInstancesClientBeginAdhocBackupOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginCreateOrUpdateOptions contains the optional parameters for the BackupInstancesClient.BeginCreateOrUpdate -// method. -type BackupInstancesClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginDeleteOptions contains the optional parameters for the BackupInstancesClient.BeginDelete method. -type BackupInstancesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginResumeBackupsOptions contains the optional parameters for the BackupInstancesClient.BeginResumeBackups -// method. -type BackupInstancesClientBeginResumeBackupsOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginResumeProtectionOptions contains the optional parameters for the BackupInstancesClient.BeginResumeProtection -// method. -type BackupInstancesClientBeginResumeProtectionOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginStopProtectionOptions contains the optional parameters for the BackupInstancesClient.BeginStopProtection -// method. -type BackupInstancesClientBeginStopProtectionOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginSuspendBackupsOptions contains the optional parameters for the BackupInstancesClient.BeginSuspendBackups -// method. -type BackupInstancesClientBeginSuspendBackupsOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginSyncBackupInstanceOptions contains the optional parameters for the BackupInstancesClient.BeginSyncBackupInstance -// method. -type BackupInstancesClientBeginSyncBackupInstanceOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginTriggerRehydrateOptions contains the optional parameters for the BackupInstancesClient.BeginTriggerRehydrate -// method. -type BackupInstancesClientBeginTriggerRehydrateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginTriggerRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginTriggerRestore -// method. -type BackupInstancesClientBeginTriggerRestoreOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginValidateForBackupOptions contains the optional parameters for the BackupInstancesClient.BeginValidateForBackup -// method. -type BackupInstancesClientBeginValidateForBackupOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientBeginValidateForRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginValidateForRestore -// method. -type BackupInstancesClientBeginValidateForRestoreOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupInstancesClientGetBackupInstanceOperationResultOptions contains the optional parameters for the BackupInstancesClient.GetBackupInstanceOperationResult -// method. -type BackupInstancesClientGetBackupInstanceOperationResultOptions struct { - // placeholder for future optional parameters -} - -// BackupInstancesClientGetOptions contains the optional parameters for the BackupInstancesClient.Get method. -type BackupInstancesClientGetOptions struct { - // placeholder for future optional parameters -} - -// BackupInstancesClientListOptions contains the optional parameters for the BackupInstancesClient.NewListPager method. -type BackupInstancesClientListOptions struct { - // placeholder for future optional parameters -} - -// BackupParametersClassification provides polymorphic access to related types. -// Call the interface's GetBackupParameters() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AzureBackupParams, *BackupParameters -type BackupParametersClassification interface { - // GetBackupParameters returns the BackupParameters content of the underlying type. - GetBackupParameters() *BackupParameters -} - // BackupParameters base type BackupParameters struct { // REQUIRED; Type of the specific object - used for deserializing @@ -814,27 +653,6 @@ type BackupParameters struct { // GetBackupParameters implements the BackupParametersClassification interface for type BackupParameters. func (b *BackupParameters) GetBackupParameters() *BackupParameters { return b } -// BackupPoliciesClientCreateOrUpdateOptions contains the optional parameters for the BackupPoliciesClient.CreateOrUpdate -// method. -type BackupPoliciesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// BackupPoliciesClientDeleteOptions contains the optional parameters for the BackupPoliciesClient.Delete method. -type BackupPoliciesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// BackupPoliciesClientGetOptions contains the optional parameters for the BackupPoliciesClient.Get method. -type BackupPoliciesClientGetOptions struct { - // placeholder for future optional parameters -} - -// BackupPoliciesClientListOptions contains the optional parameters for the BackupPoliciesClient.NewListPager method. -type BackupPoliciesClientListOptions struct { - // placeholder for future optional parameters -} - // BackupPolicy - Rule based backup policy type BackupPolicy struct { // REQUIRED; Type of datasource for the backup management @@ -875,6 +693,9 @@ type BackupVault struct { // Monitoring Settings MonitoringSettings *MonitoringSettings + // List of replicated regions for Backup Vault + ReplicatedRegions []*string + // Security Settings SecuritySettings *SecuritySettings @@ -894,12 +715,6 @@ type BackupVault struct { SecureScore *SecureScoreLevel } -// BackupVaultOperationResultsClientGetOptions contains the optional parameters for the BackupVaultOperationResultsClient.Get -// method. -type BackupVaultOperationResultsClientGetOptions struct { - // placeholder for future optional parameters -} - // BackupVaultResource - Backup Vault Resource type BackupVaultResource struct { // REQUIRED; BackupVaultResource properties @@ -939,57 +754,6 @@ type BackupVaultResourceList struct { Value []*BackupVaultResource } -// BackupVaultsClientBeginCreateOrUpdateOptions contains the optional parameters for the BackupVaultsClient.BeginCreateOrUpdate -// method. -type BackupVaultsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupVaultsClientBeginDeleteOptions contains the optional parameters for the BackupVaultsClient.BeginDelete method. -type BackupVaultsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupVaultsClientBeginUpdateOptions contains the optional parameters for the BackupVaultsClient.BeginUpdate method. -type BackupVaultsClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// BackupVaultsClientCheckNameAvailabilityOptions contains the optional parameters for the BackupVaultsClient.CheckNameAvailability -// method. -type BackupVaultsClientCheckNameAvailabilityOptions struct { - // placeholder for future optional parameters -} - -// BackupVaultsClientGetInResourceGroupOptions contains the optional parameters for the BackupVaultsClient.NewGetInResourceGroupPager -// method. -type BackupVaultsClientGetInResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// BackupVaultsClientGetInSubscriptionOptions contains the optional parameters for the BackupVaultsClient.NewGetInSubscriptionPager -// method. -type BackupVaultsClientGetInSubscriptionOptions struct { - // placeholder for future optional parameters -} - -// BackupVaultsClientGetOptions contains the optional parameters for the BackupVaultsClient.Get method. -type BackupVaultsClientGetOptions struct { - // placeholder for future optional parameters -} - -// BaseBackupPolicyClassification provides polymorphic access to related types. -// Call the interface's GetBaseBackupPolicy() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *BackupPolicy, *BaseBackupPolicy -type BaseBackupPolicyClassification interface { - // GetBaseBackupPolicy returns the BaseBackupPolicy content of the underlying type. - GetBaseBackupPolicy() *BaseBackupPolicy -} - // BaseBackupPolicy - BackupPolicy base type BaseBackupPolicy struct { // REQUIRED; Type of datasource for the backup management @@ -1029,15 +793,6 @@ type BaseBackupPolicyResourceList struct { Value []*BaseBackupPolicyResource } -// BasePolicyRuleClassification provides polymorphic access to related types. -// Call the interface's GetBasePolicyRule() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AzureBackupRule, *AzureRetentionRule, *BasePolicyRule -type BasePolicyRuleClassification interface { - // GetBasePolicyRule returns the BasePolicyRule content of the underlying type. - GetBasePolicyRule() *BasePolicyRule -} - // BasePolicyRule - BasePolicy Rule type BasePolicyRule struct { // REQUIRED @@ -1050,19 +805,10 @@ type BasePolicyRule struct { // GetBasePolicyRule implements the BasePolicyRuleClassification interface for type BasePolicyRule. func (b *BasePolicyRule) GetBasePolicyRule() *BasePolicyRule { return b } -// BaseResourcePropertiesClassification provides polymorphic access to related types. -// Call the interface's GetBaseResourceProperties() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *BaseResourceProperties -type BaseResourcePropertiesClassification interface { - // GetBaseResourceProperties returns the BaseResourceProperties content of the underlying type. - GetBaseResourceProperties() *BaseResourceProperties -} - // BaseResourceProperties - Properties which are specific to datasource/datasourceSets type BaseResourceProperties struct { // REQUIRED; Type of the specific object - used for deserializing - ObjectType *string + ObjectType *ResourcePropertiesObjectType } // GetBaseResourceProperties implements the BaseResourcePropertiesClassification interface for type BaseResourceProperties. @@ -1105,11 +851,6 @@ type CheckNameAvailabilityResult struct { Reason *string } -// ClientCheckFeatureSupportOptions contains the optional parameters for the Client.CheckFeatureSupport method. -type ClientCheckFeatureSupportOptions struct { - // placeholder for future optional parameters -} - // ClientDiscoveryDisplay - Localized display information of an operation. type ClientDiscoveryDisplay struct { // Description of the operation having details of what operation is about. @@ -1189,15 +930,6 @@ func (c *CopyOnExpiryOption) GetCopyOption() *CopyOption { } } -// CopyOptionClassification provides polymorphic access to related types. -// Call the interface's GetCopyOption() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *CopyOnExpiryOption, *CopyOption, *CustomCopyOption, *ImmediateCopyOption -type CopyOptionClassification interface { - // GetCopyOption returns the CopyOption content of the underlying type. - GetCopyOption() *CopyOption -} - // CopyOption - Options to copy type CopyOption struct { // REQUIRED; Type of the specific object - used for deserializing @@ -1207,6 +939,43 @@ type CopyOption struct { // GetCopyOption implements the CopyOptionClassification interface for type CopyOption. func (c *CopyOption) GetCopyOption() *CopyOption { return c } +// CrossRegionRestoreDetails - Cross Region Restore details +type CrossRegionRestoreDetails struct { + // REQUIRED + SourceBackupInstanceID *string + + // REQUIRED + SourceRegion *string +} + +type CrossRegionRestoreJobRequest struct { + // REQUIRED + JobID *string + + // REQUIRED + SourceBackupVaultID *string + + // REQUIRED + SourceRegion *string +} + +type CrossRegionRestoreJobsRequest struct { + // REQUIRED + SourceBackupVaultID *string + + // REQUIRED + SourceRegion *string +} + +// CrossRegionRestoreRequestObject - Cross Region Restore Request Object +type CrossRegionRestoreRequestObject struct { + // REQUIRED; Cross region restore details. + CrossRegionRestoreDetails *CrossRegionRestoreDetails + + // REQUIRED; Gets or sets the restore request object. + RestoreRequestObject AzureBackupRestoreRequestClassification +} + type CrossRegionRestoreSettings struct { // CrossRegionRestore state State *CrossRegionRestoreState @@ -1243,15 +1012,6 @@ type DataStoreInfoBase struct { ObjectType *string } -// DataStoreParametersClassification provides polymorphic access to related types. -// Call the interface's GetDataStoreParameters() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AzureOperationalStoreParameters, *DataStoreParameters -type DataStoreParametersClassification interface { - // GetDataStoreParameters returns the DataStoreParameters content of the underlying type. - GetDataStoreParameters() *DataStoreParameters -} - // DataStoreParameters - Parameters for DataStore type DataStoreParameters struct { // REQUIRED; type of datastore; Operational/Vault/Archive @@ -1329,13 +1089,17 @@ type Day struct { IsLast *bool } -// DeleteOptionClassification provides polymorphic access to related types. -// Call the interface's GetDeleteOption() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AbsoluteDeleteOption, *DeleteOption -type DeleteOptionClassification interface { - // GetDeleteOption returns the DeleteOption content of the underlying type. - GetDeleteOption() *DeleteOption +// DefaultResourceProperties - Default source properties +type DefaultResourceProperties struct { + // REQUIRED; Type of the specific object - used for deserializing + ObjectType *ResourcePropertiesObjectType +} + +// GetBaseResourceProperties implements the BaseResourcePropertiesClassification interface for type DefaultResourceProperties. +func (d *DefaultResourceProperties) GetBaseResourceProperties() *BaseResourceProperties { + return &BaseResourceProperties{ + ObjectType: d.ObjectType, + } } // DeleteOption - Delete Option @@ -1419,24 +1183,6 @@ type DeletedBackupInstanceResourceList struct { Value []*DeletedBackupInstanceResource } -// DeletedBackupInstancesClientBeginUndeleteOptions contains the optional parameters for the DeletedBackupInstancesClient.BeginUndelete -// method. -type DeletedBackupInstancesClientBeginUndeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// DeletedBackupInstancesClientGetOptions contains the optional parameters for the DeletedBackupInstancesClient.Get method. -type DeletedBackupInstancesClientGetOptions struct { - // placeholder for future optional parameters -} - -// DeletedBackupInstancesClientListOptions contains the optional parameters for the DeletedBackupInstancesClient.NewListPager -// method. -type DeletedBackupInstancesClientListOptions struct { - // placeholder for future optional parameters -} - // DeletionInfo - Deletion Info type DeletionInfo struct { // READ-ONLY; Specifies billing end date @@ -1544,34 +1290,6 @@ type DppResource struct { Type *string } -// DppResourceGuardProxyClientCreateOrUpdateOptions contains the optional parameters for the DppResourceGuardProxyClient.CreateOrUpdate -// method. -type DppResourceGuardProxyClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// DppResourceGuardProxyClientDeleteOptions contains the optional parameters for the DppResourceGuardProxyClient.Delete method. -type DppResourceGuardProxyClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// DppResourceGuardProxyClientGetOptions contains the optional parameters for the DppResourceGuardProxyClient.Get method. -type DppResourceGuardProxyClientGetOptions struct { - // placeholder for future optional parameters -} - -// DppResourceGuardProxyClientListOptions contains the optional parameters for the DppResourceGuardProxyClient.NewListPager -// method. -type DppResourceGuardProxyClientListOptions struct { - // placeholder for future optional parameters -} - -// DppResourceGuardProxyClientUnlockDeleteOptions contains the optional parameters for the DppResourceGuardProxyClient.UnlockDelete -// method. -type DppResourceGuardProxyClientUnlockDeleteOptions struct { - // placeholder for future optional parameters -} - // DppResourceList - ListResource type DppResourceList struct { // The uri to fetch the next page of resources. Call ListNext() fetches next page of resources. @@ -1650,18 +1368,6 @@ type ErrorAdditionalInfo struct { Type *string } -// ExportJobsClientBeginTriggerOptions contains the optional parameters for the ExportJobsClient.BeginTrigger method. -type ExportJobsClientBeginTriggerOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ExportJobsOperationResultClientGetOptions contains the optional parameters for the ExportJobsOperationResultClient.Get -// method. -type ExportJobsOperationResultClientGetOptions struct { - // placeholder for future optional parameters -} - // ExportJobsResult - The result for export jobs containing blob details. type ExportJobsResult struct { // READ-ONLY; SAS key to access the blob. @@ -1704,15 +1410,6 @@ func (f *FeatureValidationRequest) GetFeatureValidationRequestBase() *FeatureVal } } -// FeatureValidationRequestBaseClassification provides polymorphic access to related types. -// Call the interface's GetFeatureValidationRequestBase() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *FeatureValidationRequest, *FeatureValidationRequestBase -type FeatureValidationRequestBaseClassification interface { - // GetFeatureValidationRequestBase returns the FeatureValidationRequestBase content of the underlying type. - GetFeatureValidationRequestBase() *FeatureValidationRequestBase -} - // FeatureValidationRequestBase - Base class for Backup Feature support type FeatureValidationRequestBase struct { // REQUIRED; Type of the specific object - used for deserializing @@ -1743,15 +1440,6 @@ func (f *FeatureValidationResponse) GetFeatureValidationResponseBase() *FeatureV } } -// FeatureValidationResponseBaseClassification provides polymorphic access to related types. -// Call the interface's GetFeatureValidationResponseBase() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *FeatureValidationResponse, *FeatureValidationResponseBase -type FeatureValidationResponseBaseClassification interface { - // GetFeatureValidationResponseBase returns the FeatureValidationResponseBase content of the underlying type. - GetFeatureValidationResponseBase() *FeatureValidationResponseBase -} - // FeatureValidationResponseBase - Base class for Backup Feature support type FeatureValidationResponseBase struct { // REQUIRED; Type of the specific object - used for deserializing @@ -1763,6 +1451,16 @@ func (f *FeatureValidationResponseBase) GetFeatureValidationResponseBase() *Feat return f } +// FetchSecondaryRPsRequestParameters - Information about BI whose secondary RecoveryPoints are requested Source region and +// BI ARM path +type FetchSecondaryRPsRequestParameters struct { + // ARM Path of BackupInstance + SourceBackupInstanceID *string + + // Source region in which BackupInstance is located + SourceRegion *string +} + type IdentityDetails struct { // Specifies if the BI is protected by System Identity. UseSystemAssignedIdentity *bool @@ -1802,16 +1500,6 @@ type InnerError struct { EmbeddedInnerError *InnerError } -// ItemLevelRestoreCriteriaClassification provides polymorphic access to related types. -// Call the interface's GetItemLevelRestoreCriteria() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *ItemLevelRestoreCriteria, *ItemPathBasedRestoreCriteria, *KubernetesClusterRestoreCriteria, *KubernetesPVRestoreCriteria, -// - *KubernetesStorageClassRestoreCriteria, *RangeBasedItemLevelRestoreCriteria -type ItemLevelRestoreCriteriaClassification interface { - // GetItemLevelRestoreCriteria returns the ItemLevelRestoreCriteria content of the underlying type. - GetItemLevelRestoreCriteria() *ItemLevelRestoreCriteria -} - // ItemLevelRestoreCriteria - Class to contain criteria for item level restore type ItemLevelRestoreCriteria struct { // REQUIRED; Type of the specific object - used for deserializing @@ -1899,6 +1587,9 @@ type JobExtendedInfo struct { // READ-ONLY; Details of the Target Recovery Point TargetRecoverPoint *RestoreJobRecoveryPointDetails + + // READ-ONLY; A List, detailing the warnings related to the job + WarningDetails []*UserFacingWarningDetail } // JobSubTask - Details of Job's Sub Task @@ -1919,16 +1610,6 @@ type JobSubTask struct { TaskProgress *string } -// JobsClientGetOptions contains the optional parameters for the JobsClient.Get method. -type JobsClientGetOptions struct { - // placeholder for future optional parameters -} - -// JobsClientListOptions contains the optional parameters for the JobsClient.NewListPager method. -type JobsClientListOptions struct { - // placeholder for future optional parameters -} - // KubernetesClusterBackupDatasourceParameters - Parameters for Kubernetes Cluster Backup Datasource type KubernetesClusterBackupDatasourceParameters struct { // REQUIRED; Gets or sets the include cluster resources property. This property if enabled will include cluster scope resources @@ -2013,6 +1694,60 @@ func (k *KubernetesClusterRestoreCriteria) GetItemLevelRestoreCriteria() *ItemLe } } +// KubernetesClusterVaultTierRestoreCriteria - kubernetes Cluster Backup target info for restore operation from vault +type KubernetesClusterVaultTierRestoreCriteria struct { + // REQUIRED; Gets or sets the include cluster resources property. This property if enabled will include cluster scope resources + // during restore from vault. + IncludeClusterScopeResources *bool + + // REQUIRED; Type of the specific object - used for deserializing + ObjectType *string + + // Gets or sets the Conflict Policy property. This property sets policy during conflict of resources during restore from vault. + ConflictPolicy *ExistingResourcePolicy + + // Gets or sets the exclude namespaces property. This property sets the namespaces to be excluded during restore from vault. + ExcludedNamespaces []*string + + // Gets or sets the exclude resource types property. This property sets the resource types to be excluded during restore from + // vault. + ExcludedResourceTypes []*string + + // Gets or sets the include namespaces property. This property sets the namespaces to be included during restore from vault. + IncludedNamespaces []*string + + // Gets or sets the include resource types property. This property sets the resource types to be included during restore from + // vault. + IncludedResourceTypes []*string + + // Gets or sets the LabelSelectors property. This property sets the resource with such label selectors to be included during + // restore from vault. + LabelSelectors []*string + + // Gets or sets the Namespace Mappings property. This property sets if namespace needs to be change during restore from vault. + NamespaceMappings map[string]*string + + // Gets or sets the PV (Persistent Volume) Restore Mode property. This property sets whether volumes needs to be restored + // from vault. + PersistentVolumeRestoreMode *PersistentVolumeRestoreMode + + // Gets or sets the restore hook references. This property sets the hook reference to be executed during restore from vault. + RestoreHookReferences []*NamespacedNameResource + + // Gets or sets the staging RG Id for creating staging disks and snapshots during restore from vault. + StagingResourceGroupID *string + + // Gets or sets the staging Storage Account Id for creating backup extension object store data during restore from vault. + StagingStorageAccountID *string +} + +// GetItemLevelRestoreCriteria implements the ItemLevelRestoreCriteriaClassification interface for type KubernetesClusterVaultTierRestoreCriteria. +func (k *KubernetesClusterVaultTierRestoreCriteria) GetItemLevelRestoreCriteria() *ItemLevelRestoreCriteria { + return &ItemLevelRestoreCriteria{ + ObjectType: k.ObjectType, + } +} + // KubernetesPVRestoreCriteria - Item Level kubernetes persistent volume target info for restore operation type KubernetesPVRestoreCriteria struct { // REQUIRED; Type of the specific object - used for deserializing @@ -2066,15 +1801,6 @@ type NamespacedNameResource struct { Namespace *string } -// OperationExtendedInfoClassification provides polymorphic access to related types. -// Call the interface's GetOperationExtendedInfo() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *OperationExtendedInfo, *OperationJobExtendedInfo -type OperationExtendedInfoClassification interface { - // GetOperationExtendedInfo returns the OperationExtendedInfo content of the underlying type. - GetOperationExtendedInfo() *OperationExtendedInfo -} - // OperationExtendedInfo - Operation Extended Info type OperationExtendedInfo struct { // REQUIRED; This property will be used as the discriminator for deciding the specific types in the polymorphic chain of types. @@ -2089,7 +1815,7 @@ type OperationJobExtendedInfo struct { // REQUIRED; This property will be used as the discriminator for deciding the specific types in the polymorphic chain of types. ObjectType *string - // Arm Id of the job created for this operation. + // Name or Arm Id of the job created for this operation. JobID *string } @@ -2124,33 +1850,6 @@ type OperationResource struct { Status *string } -// OperationResultClientGetOptions contains the optional parameters for the OperationResultClient.Get method. -type OperationResultClientGetOptions struct { - // placeholder for future optional parameters -} - -// OperationStatusBackupVaultContextClientGetOptions contains the optional parameters for the OperationStatusBackupVaultContextClient.Get -// method. -type OperationStatusBackupVaultContextClientGetOptions struct { - // placeholder for future optional parameters -} - -// OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. -type OperationStatusClientGetOptions struct { - // placeholder for future optional parameters -} - -// OperationStatusResourceGroupContextClientGetOptions contains the optional parameters for the OperationStatusResourceGroupContextClient.Get -// method. -type OperationStatusResourceGroupContextClientGetOptions struct { - // placeholder for future optional parameters -} - -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // PatchBackupVaultInput - Backup Vault Contract for Patch Backup Vault API. type PatchBackupVaultInput struct { // Feature Settings @@ -2247,19 +1946,6 @@ type RecoveryPointDataStoreDetails struct { RehydrationStatus *RehydrationStatus } -// 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 { - // OData filter options. - Filter *string - // skipToken Filter. - SkipToken *string -} - type RecoveryPointsFilters struct { EndDate *string ExtendedInfo *bool @@ -2371,110 +2057,6 @@ type ResourceGuardResourceList struct { Value []*ResourceGuardResource } -// ResourceGuardsClientDeleteOptions contains the optional parameters for the ResourceGuardsClient.Delete method. -type ResourceGuardsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetBackupSecurityPINRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetBackupSecurityPINRequestsObjectsPager -// method. -type ResourceGuardsClientGetBackupSecurityPINRequestsObjectsOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject -// method. -type ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject -// method. -type ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject -// method. -type ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject -// method. -type ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject -// method. -type ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject -// method. -type ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDeleteProtectedItemRequestsObjectsPager -// method. -type ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDeleteResourceGuardProxyRequestsObjectsPager -// method. -type ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDisableSoftDeleteRequestsObjectsPager -// method. -type ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetOptions contains the optional parameters for the ResourceGuardsClient.Get method. -type ResourceGuardsClientGetOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetResourcesInResourceGroupOptions contains the optional parameters for the ResourceGuardsClient.NewGetResourcesInResourceGroupPager -// method. -type ResourceGuardsClientGetResourcesInResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetResourcesInSubscriptionOptions contains the optional parameters for the ResourceGuardsClient.NewGetResourcesInSubscriptionPager -// method. -type ResourceGuardsClientGetResourcesInSubscriptionOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetUpdateProtectedItemRequestsObjectsPager -// method. -type ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetUpdateProtectionPolicyRequestsObjectsPager -// method. -type ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientPatchOptions contains the optional parameters for the ResourceGuardsClient.Patch method. -type ResourceGuardsClientPatchOptions struct { - // placeholder for future optional parameters -} - -// ResourceGuardsClientPutOptions contains the optional parameters for the ResourceGuardsClient.Put method. -type ResourceGuardsClientPutOptions struct { - // placeholder for future optional parameters -} - // ResourceMoveDetails will be returned in response to GetResource call from ARM type ResourceMoveDetails struct { // Completion time in UTC of latest ResourceMove operation attempted. ISO 8601 format. @@ -2502,11 +2084,6 @@ type RestorableTimeRange struct { ObjectType *string } -// RestorableTimeRangesClientFindOptions contains the optional parameters for the RestorableTimeRangesClient.Find method. -type RestorableTimeRangesClientFindOptions struct { - // placeholder for future optional parameters -} - // RestoreFilesTargetInfo - Class encapsulating restore as files target parameters type RestoreFilesTargetInfo struct { // REQUIRED; Type of Datasource object, used to initialize the right inherited type @@ -2566,15 +2143,6 @@ func (r *RestoreTargetInfo) GetRestoreTargetInfoBase() *RestoreTargetInfoBase { } } -// RestoreTargetInfoBaseClassification provides polymorphic access to related types. -// Call the interface's GetRestoreTargetInfoBase() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *ItemLevelRestoreTargetInfo, *RestoreFilesTargetInfo, *RestoreTargetInfo, *RestoreTargetInfoBase -type RestoreTargetInfoBaseClassification interface { - // GetRestoreTargetInfoBase returns the RestoreTargetInfoBase content of the underlying type. - GetRestoreTargetInfoBase() *RestoreTargetInfoBase -} - // RestoreTargetInfoBase - Base class common to RestoreTargetInfo and RestoreFilesTargetInfo type RestoreTargetInfoBase struct { // REQUIRED; Type of Datasource object, used to initialize the right inherited type @@ -2805,15 +2373,6 @@ type TriggerBackupRequest struct { BackupRuleOptions *AdHocBackupRuleOptions } -// TriggerContextClassification provides polymorphic access to related types. -// Call the interface's GetTriggerContext() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *AdhocBasedTriggerContext, *ScheduleBasedTriggerContext, *TriggerContext -type TriggerContextClassification interface { - // GetTriggerContext returns the TriggerContext content of the underlying type. - GetTriggerContext() *TriggerContext -} - // TriggerContext - Trigger context type TriggerContext struct { // REQUIRED; Type of the specific object - used for deserializing @@ -2872,6 +2431,24 @@ type UserFacingError struct { Target *string } +// UserFacingWarningDetail - Warning object used by layers that have access to localized content, and propagate that to user +type UserFacingWarningDetail struct { + // REQUIRED; Error details for the warning. + Warning *UserFacingError + + // Name of resource for which warning is raised. + ResourceName *string +} + +// ValidateCrossRegionRestoreRequestObject - Cross Region Restore Request Object +type ValidateCrossRegionRestoreRequestObject struct { + // REQUIRED; Cross region restore details. + CrossRegionRestoreDetails *CrossRegionRestoreDetails + + // REQUIRED; Gets or sets the restore request object. + RestoreRequestObject AzureBackupRestoreRequestClassification +} + // ValidateForBackupRequest - Validate for backup request type ValidateForBackupRequest struct { // REQUIRED; Backup Instance diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/models_serde.go b/sdk/resourcemanager/dataprotection/armdataprotection/models_serde.go index 5d7ded859860..e51b6cef5d22 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/models_serde.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/models_serde.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -194,14 +193,15 @@ func (a *AuthCredentials) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type AzureBackupDiscreteRecoveryPoint. func (a AzureBackupDiscreteRecoveryPoint) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "expiryTime", a.ExpiryTime) + populateDateTimeRFC3339(objectMap, "expiryTime", a.ExpiryTime) populate(objectMap, "friendlyName", a.FriendlyName) objectMap["objectType"] = "AzureBackupDiscreteRecoveryPoint" populate(objectMap, "policyName", a.PolicyName) populate(objectMap, "policyVersion", a.PolicyVersion) populate(objectMap, "recoveryPointDataStoresDetails", a.RecoveryPointDataStoresDetails) populate(objectMap, "recoveryPointId", a.RecoveryPointID) - populateTimeRFC3339(objectMap, "recoveryPointTime", a.RecoveryPointTime) + populate(objectMap, "recoveryPointState", a.RecoveryPointState) + populateDateTimeRFC3339(objectMap, "recoveryPointTime", a.RecoveryPointTime) populate(objectMap, "recoveryPointType", a.RecoveryPointType) populate(objectMap, "retentionTagName", a.RetentionTagName) populate(objectMap, "retentionTagVersion", a.RetentionTagVersion) @@ -218,7 +218,7 @@ func (a *AzureBackupDiscreteRecoveryPoint) UnmarshalJSON(data []byte) error { var err error switch key { case "expiryTime": - err = unpopulateTimeRFC3339(val, "ExpiryTime", &a.ExpiryTime) + err = unpopulateDateTimeRFC3339(val, "ExpiryTime", &a.ExpiryTime) delete(rawMsg, key) case "friendlyName": err = unpopulate(val, "FriendlyName", &a.FriendlyName) @@ -238,8 +238,11 @@ func (a *AzureBackupDiscreteRecoveryPoint) UnmarshalJSON(data []byte) error { case "recoveryPointId": err = unpopulate(val, "RecoveryPointID", &a.RecoveryPointID) delete(rawMsg, key) + case "recoveryPointState": + err = unpopulate(val, "RecoveryPointState", &a.RecoveryPointState) + delete(rawMsg, key) case "recoveryPointTime": - err = unpopulateTimeRFC3339(val, "RecoveryPointTime", &a.RecoveryPointTime) + err = unpopulateDateTimeRFC3339(val, "RecoveryPointTime", &a.RecoveryPointTime) delete(rawMsg, key) case "recoveryPointType": err = unpopulate(val, "RecoveryPointType", &a.RecoveryPointType) @@ -435,7 +438,7 @@ func (a AzureBackupJob) MarshalJSON() ([]byte, error) { populate(objectMap, "dataSourceType", a.DataSourceType) populate(objectMap, "destinationDataStoreName", a.DestinationDataStoreName) populate(objectMap, "duration", a.Duration) - populateTimeRFC3339(objectMap, "endTime", a.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", a.EndTime) populate(objectMap, "errorDetails", a.ErrorDetails) populate(objectMap, "etag", a.Etag) populate(objectMap, "extendedInfo", a.ExtendedInfo) @@ -451,7 +454,7 @@ func (a AzureBackupJob) MarshalJSON() ([]byte, error) { populate(objectMap, "sourceDataStoreName", a.SourceDataStoreName) populate(objectMap, "sourceResourceGroup", a.SourceResourceGroup) populate(objectMap, "sourceSubscriptionID", a.SourceSubscriptionID) - populateTimeRFC3339(objectMap, "startTime", a.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", a.StartTime) populate(objectMap, "status", a.Status) populate(objectMap, "subscriptionId", a.SubscriptionID) populate(objectMap, "supportedActions", a.SupportedActions) @@ -499,7 +502,7 @@ func (a *AzureBackupJob) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Duration", &a.Duration) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &a.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &a.EndTime) delete(rawMsg, key) case "errorDetails": err = unpopulate(val, "ErrorDetails", &a.ErrorDetails) @@ -547,7 +550,7 @@ func (a *AzureBackupJob) UnmarshalJSON(data []byte) error { err = unpopulate(val, "SourceSubscriptionID", &a.SourceSubscriptionID) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &a.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &a.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &a.Status) @@ -1449,6 +1452,7 @@ func (b BackupVault) MarshalJSON() ([]byte, error) { populate(objectMap, "isVaultProtectedByResourceGuard", b.IsVaultProtectedByResourceGuard) populate(objectMap, "monitoringSettings", b.MonitoringSettings) populate(objectMap, "provisioningState", b.ProvisioningState) + populate(objectMap, "replicatedRegions", b.ReplicatedRegions) populate(objectMap, "resourceMoveDetails", b.ResourceMoveDetails) populate(objectMap, "resourceMoveState", b.ResourceMoveState) populate(objectMap, "secureScore", b.SecureScore) @@ -1478,6 +1482,9 @@ func (b *BackupVault) UnmarshalJSON(data []byte) error { case "provisioningState": err = unpopulate(val, "ProvisioningState", &b.ProvisioningState) delete(rawMsg, key) + case "replicatedRegions": + err = unpopulate(val, "ReplicatedRegions", &b.ReplicatedRegions) + delete(rawMsg, key) case "resourceMoveDetails": err = unpopulate(val, "ResourceMoveDetails", &b.ResourceMoveDetails) delete(rawMsg, key) @@ -2107,6 +2114,134 @@ func (c *CopyOption) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type CrossRegionRestoreDetails. +func (c CrossRegionRestoreDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sourceBackupInstanceId", c.SourceBackupInstanceID) + populate(objectMap, "sourceRegion", c.SourceRegion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CrossRegionRestoreDetails. +func (c *CrossRegionRestoreDetails) UnmarshalJSON(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 "sourceBackupInstanceId": + err = unpopulate(val, "SourceBackupInstanceID", &c.SourceBackupInstanceID) + delete(rawMsg, key) + case "sourceRegion": + err = unpopulate(val, "SourceRegion", &c.SourceRegion) + 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 CrossRegionRestoreJobRequest. +func (c CrossRegionRestoreJobRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "jobId", c.JobID) + populate(objectMap, "sourceBackupVaultId", c.SourceBackupVaultID) + populate(objectMap, "sourceRegion", c.SourceRegion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CrossRegionRestoreJobRequest. +func (c *CrossRegionRestoreJobRequest) UnmarshalJSON(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 "jobId": + err = unpopulate(val, "JobID", &c.JobID) + delete(rawMsg, key) + case "sourceBackupVaultId": + err = unpopulate(val, "SourceBackupVaultID", &c.SourceBackupVaultID) + delete(rawMsg, key) + case "sourceRegion": + err = unpopulate(val, "SourceRegion", &c.SourceRegion) + 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 CrossRegionRestoreJobsRequest. +func (c CrossRegionRestoreJobsRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sourceBackupVaultId", c.SourceBackupVaultID) + populate(objectMap, "sourceRegion", c.SourceRegion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CrossRegionRestoreJobsRequest. +func (c *CrossRegionRestoreJobsRequest) UnmarshalJSON(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 "sourceBackupVaultId": + err = unpopulate(val, "SourceBackupVaultID", &c.SourceBackupVaultID) + delete(rawMsg, key) + case "sourceRegion": + err = unpopulate(val, "SourceRegion", &c.SourceRegion) + 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 CrossRegionRestoreRequestObject. +func (c CrossRegionRestoreRequestObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "crossRegionRestoreDetails", c.CrossRegionRestoreDetails) + populate(objectMap, "restoreRequestObject", c.RestoreRequestObject) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CrossRegionRestoreRequestObject. +func (c *CrossRegionRestoreRequestObject) UnmarshalJSON(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 "crossRegionRestoreDetails": + err = unpopulate(val, "CrossRegionRestoreDetails", &c.CrossRegionRestoreDetails) + delete(rawMsg, key) + case "restoreRequestObject": + c.RestoreRequestObject, err = unmarshalAzureBackupRestoreRequestClassification(val) + 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 CrossRegionRestoreSettings. func (c CrossRegionRestoreSettings) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2395,6 +2530,33 @@ func (d *Day) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type DefaultResourceProperties. +func (d DefaultResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + objectMap["objectType"] = ResourcePropertiesObjectTypeDefaultResourceProperties + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DefaultResourceProperties. +func (d *DefaultResourceProperties) UnmarshalJSON(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 "objectType": + err = unpopulate(val, "ObjectType", &d.ObjectType) + 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 DeleteOption. func (d DeleteOption) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3280,6 +3442,37 @@ func (f *FeatureValidationResponseBase) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type FetchSecondaryRPsRequestParameters. +func (f FetchSecondaryRPsRequestParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sourceBackupInstanceId", f.SourceBackupInstanceID) + populate(objectMap, "sourceRegion", f.SourceRegion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FetchSecondaryRPsRequestParameters. +func (f *FetchSecondaryRPsRequestParameters) UnmarshalJSON(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 "sourceBackupInstanceId": + err = unpopulate(val, "SourceBackupInstanceID", &f.SourceBackupInstanceID) + delete(rawMsg, key) + case "sourceRegion": + err = unpopulate(val, "SourceRegion", &f.SourceRegion) + 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 IdentityDetails. func (i IdentityDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3527,6 +3720,7 @@ func (j JobExtendedInfo) MarshalJSON() ([]byte, error) { populate(objectMap, "sourceRecoverPoint", j.SourceRecoverPoint) populate(objectMap, "subTasks", j.SubTasks) populate(objectMap, "targetRecoverPoint", j.TargetRecoverPoint) + populate(objectMap, "warningDetails", j.WarningDetails) return json.Marshal(objectMap) } @@ -3560,6 +3754,9 @@ func (j *JobExtendedInfo) UnmarshalJSON(data []byte) error { case "targetRecoverPoint": err = unpopulate(val, "TargetRecoverPoint", &j.TargetRecoverPoint) delete(rawMsg, key) + case "warningDetails": + err = unpopulate(val, "WarningDetails", &j.WarningDetails) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", j, err) @@ -3737,6 +3934,81 @@ func (k *KubernetesClusterRestoreCriteria) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type KubernetesClusterVaultTierRestoreCriteria. +func (k KubernetesClusterVaultTierRestoreCriteria) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "conflictPolicy", k.ConflictPolicy) + populate(objectMap, "excludedNamespaces", k.ExcludedNamespaces) + populate(objectMap, "excludedResourceTypes", k.ExcludedResourceTypes) + populate(objectMap, "includeClusterScopeResources", k.IncludeClusterScopeResources) + populate(objectMap, "includedNamespaces", k.IncludedNamespaces) + populate(objectMap, "includedResourceTypes", k.IncludedResourceTypes) + populate(objectMap, "labelSelectors", k.LabelSelectors) + populate(objectMap, "namespaceMappings", k.NamespaceMappings) + objectMap["objectType"] = "KubernetesClusterVaultTierRestoreCriteria" + populate(objectMap, "persistentVolumeRestoreMode", k.PersistentVolumeRestoreMode) + populate(objectMap, "restoreHookReferences", k.RestoreHookReferences) + populate(objectMap, "stagingResourceGroupId", k.StagingResourceGroupID) + populate(objectMap, "stagingStorageAccountId", k.StagingStorageAccountID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KubernetesClusterVaultTierRestoreCriteria. +func (k *KubernetesClusterVaultTierRestoreCriteria) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "conflictPolicy": + err = unpopulate(val, "ConflictPolicy", &k.ConflictPolicy) + delete(rawMsg, key) + case "excludedNamespaces": + err = unpopulate(val, "ExcludedNamespaces", &k.ExcludedNamespaces) + delete(rawMsg, key) + case "excludedResourceTypes": + err = unpopulate(val, "ExcludedResourceTypes", &k.ExcludedResourceTypes) + delete(rawMsg, key) + case "includeClusterScopeResources": + err = unpopulate(val, "IncludeClusterScopeResources", &k.IncludeClusterScopeResources) + delete(rawMsg, key) + case "includedNamespaces": + err = unpopulate(val, "IncludedNamespaces", &k.IncludedNamespaces) + delete(rawMsg, key) + case "includedResourceTypes": + err = unpopulate(val, "IncludedResourceTypes", &k.IncludedResourceTypes) + delete(rawMsg, key) + case "labelSelectors": + err = unpopulate(val, "LabelSelectors", &k.LabelSelectors) + delete(rawMsg, key) + case "namespaceMappings": + err = unpopulate(val, "NamespaceMappings", &k.NamespaceMappings) + delete(rawMsg, key) + case "objectType": + err = unpopulate(val, "ObjectType", &k.ObjectType) + delete(rawMsg, key) + case "persistentVolumeRestoreMode": + err = unpopulate(val, "PersistentVolumeRestoreMode", &k.PersistentVolumeRestoreMode) + delete(rawMsg, key) + case "restoreHookReferences": + err = unpopulate(val, "RestoreHookReferences", &k.RestoreHookReferences) + delete(rawMsg, key) + case "stagingResourceGroupId": + err = unpopulate(val, "StagingResourceGroupID", &k.StagingResourceGroupID) + delete(rawMsg, key) + case "stagingStorageAccountId": + err = unpopulate(val, "StagingStorageAccountID", &k.StagingStorageAccountID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type KubernetesPVRestoreCriteria. func (k KubernetesPVRestoreCriteria) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3926,12 +4198,12 @@ func (o *OperationJobExtendedInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationResource. func (o OperationResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", o.EndTime) populate(objectMap, "error", o.Error) populate(objectMap, "id", o.ID) populate(objectMap, "name", o.Name) populate(objectMap, "properties", o.Properties) - populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", o.StartTime) populate(objectMap, "status", o.Status) return json.Marshal(objectMap) } @@ -3946,7 +4218,7 @@ func (o *OperationResource) UnmarshalJSON(data []byte) error { var err error switch key { case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &o.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &o.Error) @@ -3961,7 +4233,7 @@ func (o *OperationResource) UnmarshalJSON(data []byte) error { o.Properties, err = unmarshalOperationExtendedInfoClassification(val) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &o.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &o.Status) @@ -4206,11 +4478,11 @@ func (r *RangeBasedItemLevelRestoreCriteria) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RecoveryPointDataStoreDetails. func (r RecoveryPointDataStoreDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "creationTime", r.CreationTime) - populateTimeRFC3339(objectMap, "expiryTime", r.ExpiryTime) + populateDateTimeRFC3339(objectMap, "creationTime", r.CreationTime) + populateDateTimeRFC3339(objectMap, "expiryTime", r.ExpiryTime) populate(objectMap, "id", r.ID) populate(objectMap, "metaData", r.MetaData) - populateTimeRFC3339(objectMap, "rehydrationExpiryTime", r.RehydrationExpiryTime) + populateDateTimeRFC3339(objectMap, "rehydrationExpiryTime", r.RehydrationExpiryTime) populate(objectMap, "rehydrationStatus", r.RehydrationStatus) populate(objectMap, "state", r.State) populate(objectMap, "type", r.Type) @@ -4228,10 +4500,10 @@ func (r *RecoveryPointDataStoreDetails) UnmarshalJSON(data []byte) error { var err error switch key { case "creationTime": - err = unpopulateTimeRFC3339(val, "CreationTime", &r.CreationTime) + err = unpopulateDateTimeRFC3339(val, "CreationTime", &r.CreationTime) delete(rawMsg, key) case "expiryTime": - err = unpopulateTimeRFC3339(val, "ExpiryTime", &r.ExpiryTime) + err = unpopulateDateTimeRFC3339(val, "ExpiryTime", &r.ExpiryTime) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &r.ID) @@ -4240,7 +4512,7 @@ func (r *RecoveryPointDataStoreDetails) UnmarshalJSON(data []byte) error { err = unpopulate(val, "MetaData", &r.MetaData) delete(rawMsg, key) case "rehydrationExpiryTime": - err = unpopulateTimeRFC3339(val, "RehydrationExpiryTime", &r.RehydrationExpiryTime) + err = unpopulateDateTimeRFC3339(val, "RehydrationExpiryTime", &r.RehydrationExpiryTime) delete(rawMsg, key) case "rehydrationStatus": err = unpopulate(val, "RehydrationStatus", &r.RehydrationStatus) @@ -4734,7 +5006,7 @@ func (r *RestoreFilesTargetInfo) UnmarshalJSON(data []byte) error { func (r RestoreJobRecoveryPointDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "recoveryPointID", r.RecoveryPointID) - populateTimeRFC3339(objectMap, "recoveryPointTime", r.RecoveryPointTime) + populateDateTimeRFC3339(objectMap, "recoveryPointTime", r.RecoveryPointTime) return json.Marshal(objectMap) } @@ -4751,7 +5023,7 @@ func (r *RestoreJobRecoveryPointDetails) UnmarshalJSON(data []byte) error { err = unpopulate(val, "RecoveryPointID", &r.RecoveryPointID) delete(rawMsg, key) case "recoveryPointTime": - err = unpopulateTimeRFC3339(val, "RecoveryPointTime", &r.RecoveryPointTime) + err = unpopulateDateTimeRFC3339(val, "RecoveryPointTime", &r.RecoveryPointTime) delete(rawMsg, key) } if err != nil { @@ -4886,9 +5158,9 @@ func (s ScheduleBasedBackupCriteria) MarshalJSON() ([]byte, error) { populate(objectMap, "daysOfTheWeek", s.DaysOfTheWeek) populate(objectMap, "monthsOfYear", s.MonthsOfYear) objectMap["objectType"] = "ScheduleBasedBackupCriteria" - aux := make([]*timeRFC3339, len(s.ScheduleTimes), len(s.ScheduleTimes)) + aux := make([]*dateTimeRFC3339, len(s.ScheduleTimes), len(s.ScheduleTimes)) for i := 0; i < len(s.ScheduleTimes); i++ { - aux[i] = (*timeRFC3339)(s.ScheduleTimes[i]) + aux[i] = (*dateTimeRFC3339)(s.ScheduleTimes[i]) } populate(objectMap, "scheduleTimes", aux) populate(objectMap, "weeksOfTheMonth", s.WeeksOfTheMonth) @@ -4920,7 +5192,7 @@ func (s *ScheduleBasedBackupCriteria) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ObjectType", &s.ObjectType) delete(rawMsg, key) case "scheduleTimes": - var aux []*timeRFC3339 + var aux []*dateTimeRFC3339 err = unpopulate(val, "ScheduleTimes", &aux) for _, au := range aux { s.ScheduleTimes = append(s.ScheduleTimes, (*time.Time)(au)) @@ -5231,10 +5503,10 @@ func (s *SyncBackupInstanceRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -5250,7 +5522,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -5259,7 +5531,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) @@ -5586,6 +5858,68 @@ func (u *UserFacingError) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type UserFacingWarningDetail. +func (u UserFacingWarningDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceName", u.ResourceName) + populate(objectMap, "warning", u.Warning) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserFacingWarningDetail. +func (u *UserFacingWarningDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "resourceName": + err = unpopulate(val, "ResourceName", &u.ResourceName) + delete(rawMsg, key) + case "warning": + err = unpopulate(val, "Warning", &u.Warning) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ValidateCrossRegionRestoreRequestObject. +func (v ValidateCrossRegionRestoreRequestObject) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "crossRegionRestoreDetails", v.CrossRegionRestoreDetails) + populate(objectMap, "restoreRequestObject", v.RestoreRequestObject) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateCrossRegionRestoreRequestObject. +func (v *ValidateCrossRegionRestoreRequestObject) UnmarshalJSON(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 "crossRegionRestoreDetails": + err = unpopulate(val, "CrossRegionRestoreDetails", &v.CrossRegionRestoreDetails) + delete(rawMsg, key) + case "restoreRequestObject": + v.RestoreRequestObject, err = unmarshalAzureBackupRestoreRequestClassification(val) + 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 ValidateForBackupRequest. func (v ValidateForBackupRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationresult_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationresult_client.go index 9ffe5783e26b..b5020e688f0b 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationresult_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/operationresult_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -34,7 +33,7 @@ type OperationResultClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationResultClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationResultClient, error) { - cl, err := arm.NewClient(moduleName+".OperationResultClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,26 +47,36 @@ func NewOperationResultClient(subscriptionID string, credential azcore.TokenCred // Get - Gets the operation result for a resource // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - options - OperationResultClientGetOptions contains the optional parameters for the OperationResultClient.Get method. func (client *OperationResultClient) Get(ctx context.Context, operationID string, location string, options *OperationResultClientGetOptions) (OperationResultClientGetResponse, error) { + var err error + const operationName = "OperationResultClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, operationID, location, options) if err != nil { return OperationResultClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationResultClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return OperationResultClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return OperationResultClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *OperationResultClient) getCreateRequest(ctx context.Context, operationID string, location string, options *OperationResultClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationResults/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if operationID == "" { return nil, errors.New("parameter operationID cannot be empty") @@ -82,7 +91,7 @@ func (client *OperationResultClient) getCreateRequest(ctx context.Context, opera return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -91,12 +100,12 @@ func (client *OperationResultClient) getCreateRequest(ctx context.Context, opera // getHandleResponse handles the Get response. func (client *OperationResultClient) getHandleResponse(resp *http.Response) (OperationResultClientGetResponse, error) { result := OperationResultClientGetResponse{} - if val := resp.Header.Get("Location"); val != "" { - result.Location = &val - } if val := resp.Header.Get("Azure-AsyncOperation"); val != "" { result.AzureAsyncOperation = &val } + if val := resp.Header.Get("Location"); val != "" { + result.Location = &val + } if val := resp.Header.Get("Retry-After"); val != "" { retryAfter32, err := strconv.ParseInt(val, 10, 32) retryAfter := int32(retryAfter32) diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationresult_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationresult_client_example_test.go deleted file mode 100644 index db14d242e2f1..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationresult_client_example_test.go +++ /dev/null @@ -1,42 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/GetOperationResult.json -func ExampleOperationResultClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOperationResultClient().Get(ctx, "MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA==", "WestUS", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationJobExtendedInfo = armdataprotection.OperationJobExtendedInfo{ - // ObjectType: to.Ptr("OperationJobExtendedInfo"), - // JobID: to.Ptr("c60cb49-63e8-4b21-b9bd-26277b3fdfae"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operations_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/operations_client.go index ad22a3a579c4..4fd9921fbd2a 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operations_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/operations_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -28,7 +27,7 @@ type OperationsClient struct { // - 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) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -40,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Returns the list of available operations. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - 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]{ @@ -48,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption 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) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - 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) }, + Tracer: client.internal.Tracer(), }) } @@ -78,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operations_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/operations_client_example_test.go deleted file mode 100644 index 3bbf7ecbfd92..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operations_client_example_test.go +++ /dev/null @@ -1,566 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/Operations/List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ClientDiscoveryResponse = armdataprotection.ClientDiscoveryResponse{ - // Value: []*armdataprotection.ClientDiscoveryValueForSingleAPI{ - // { - // Name: to.Ptr("Microsoft.DataProtection/locations/getBackupStatus/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Check Backup Status for Recovery Services Vaults"), - // Operation: to.Ptr("Check Backup Status for Vault"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Status"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/write"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Creates a Backup Instance"), - // Operation: to.Ptr("Create a Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/delete"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Deletes the Backup Instance"), - // Operation: to.Ptr("Delete Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns details of the Backup Instance"), - // Operation: to.Ptr("Get Backup Instance Details"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns all Backup Instances"), - // Operation: to.Ptr("Get Backup Instances"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/backup/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Performs Backup on the Backup Instance"), - // Operation: to.Ptr("Backup Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/sync/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Sync operation retries last failed operation on backup instance to bring it to a valid state."), - // Operation: to.Ptr("Sync Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/operationResults/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns Backup Operation Result for Backup Vault."), - // Operation: to.Ptr("Get Backup Operation Result"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/stopProtection/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Stop Protection operation stops both backup and retention schedules of backup instance. Existing data will be retained forever."), - // Operation: to.Ptr("Stop Protection of Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/suspendBackups/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Suspend Backups operation stops only backups of backup instance. Retention activities will continue and hence data will be ratained as per policy."), - // Operation: to.Ptr("Suspend Backups of Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/resumeProtection/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Resume protection of a ProtectionStopped BI."), - // Operation: to.Ptr("Resume Protection of Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/resumeBackups/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Resume Backups for a BackupsSuspended BI."), - // Operation: to.Ptr("Resume Backups of Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/validateRestore/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Validates for Restore of the Backup Instance"), - // Operation: to.Ptr("Validate for Restore of Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/restore/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Triggers restore on the Backup Instance"), - // Operation: to.Ptr("Restore Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Instance"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies/write"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Creates Backup Policy"), - // Operation: to.Ptr("Create Backup Policy"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Policies"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies/delete"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Deletes the Backup Policy"), - // Operation: to.Ptr("Delete Backup Policy"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Policies"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns details of the Backup Policy"), - // Operation: to.Ptr("Get Backup Policy details"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Policies"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupPolicies/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns all Backup Policies"), - // Operation: to.Ptr("Get Backup Policies"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Policies"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Get the list of ResourceGuard proxies for a resource"), - // Operation: to.Ptr("Get the list of ResourceGuard proxies for a resource"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guard Proxy"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Get ResourceGuard proxy operation gets an object representing the Azure resource of type 'ResourceGuard proxy'"), - // Operation: to.Ptr("Get ResourceGuard proxy"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guard Proxy"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/write"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Create ResourceGuard proxy operation creates an Azure resource of type 'ResourceGuard Proxy'"), - // Operation: to.Ptr("Create ResourceGuard proxy"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guard Proxy"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/delete"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("The Delete ResourceGuard proxy operation deletes the specified Azure resource of type 'ResourceGuard proxy'"), - // Operation: to.Ptr("Delete ResourceGuard proxy"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guard Proxy"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupResourceGuardProxies/unlockDelete/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Unlock delete ResourceGuard proxy operation unlocks the next delete critical operation"), - // Operation: to.Ptr("Unlock delete ResourceGuard proxy operation unlocks the next delete critical operation"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guard Proxy"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/recoveryPoints/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns details of the Recovery Point"), - // Operation: to.Ptr("Get Recovery Point Details"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Recovery Points"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/recoveryPoints/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns all Recovery Points"), - // Operation: to.Ptr("Get Recovery Points"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Recovery Points"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/findRestorableTimeRanges/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Finds Restorable Time Ranges"), - // Operation: to.Ptr("Find Restorable Time Ranges"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Restorable Time Ranges"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/write"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Create BackupVault operation creates an Azure resource of type 'Backup Vault'"), - // Operation: to.Ptr("Create Backup Vault"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Vaults"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Create BackupVault operation creates an Azure resource of type 'Backup Vault'"), - // Operation: to.Ptr("Create Backup Vault"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Vaults"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/delete"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Create BackupVault operation creates an Azure resource of type 'Backup Vault'"), - // Operation: to.Ptr("Create Backup Vault"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Vaults"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/operationResults/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Gets Operation Result of a Patch Operation for a Backup Vault"), - // Operation: to.Ptr("Get Operation Result of a Patch Operation for a Backup Vault"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Vaults"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/locations/checkNameAvailability/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Checks if the requested BackupVault Name is Available"), - // Operation: to.Ptr("Check if the requested BackupVault Name is Available"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Vaults"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Gets list of Backup Vaults in a Resource Group"), - // Operation: to.Ptr("Get Backup Vaults in a Resource Group"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Vaults"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Gets list of Backup Vaults in a Subscription"), - // Operation: to.Ptr("Get Backup Vaults in a Subscription"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Vaults"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/resourceGuards/write"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Create ResourceGuard operation creates an Azure resource of type 'ResourceGuard'"), - // Operation: to.Ptr("Create ResourceGuard"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/resourceGuards/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("The Get ResourceGuard operation gets an object representing the Azure resource of type 'ResourceGuard'"), - // Operation: to.Ptr("Get ResourceGuard"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/resourceGuards/delete"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("The Delete ResourceGuard operation deletes the specified Azure resource of type 'ResourceGuard'"), - // Operation: to.Ptr("Delete ResourceGuard"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/resourceGuards/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Gets list of ResourceGuards in a Resource Group"), - // Operation: to.Ptr("Get ResourceGuards in a Resource Group"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/providers/resourceGuards/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Gets list of ResourceGuards in a Subscription"), - // Operation: to.Ptr("Get ResourceGuards in a Subscription"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/resourceGuards/write"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Update ResouceGuard operation updates an Azure resource of type 'ResourceGuard'"), - // Operation: to.Ptr("Update ResourceGuard"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/resourceGuards/{operationName}/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Gets ResourceGuard operation request info"), - // Operation: to.Ptr("Get ResourceGuard operation request info"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/resourceGuards/{operationName}/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Gets ResourceGuard default operation request info"), - // Operation: to.Ptr("Get ResourceGuard default operation request info"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Guards"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/providers/locations/checkFeatureSupport/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Validates if a feature is supported"), - // Operation: to.Ptr("Validate if a feature is supported"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Provider Operation"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/locations/operationStatus/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns Backup Operation Status for Backup Vault."), - // Operation: to.Ptr("Get Backup Operation Status"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Operation Status"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/operationStatus/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns Backup Operation Status for Backup Vault."), - // Operation: to.Ptr("Get Backup Operation Status"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Operation Status"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/subscriptions/resourceGroups/providers/operationStatus/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns Backup Operation Status for Backup Vault."), - // Operation: to.Ptr("Get Backup Operation Status"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Operation Status"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/locations/operationResults/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Returns Backup Operation Result for Backup Vault."), - // Operation: to.Ptr("Get Backup Operation Result"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Operation Results"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/validateForBackup/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Validates for backup of Backup Instance"), - // Operation: to.Ptr("Validate for backup of Backup Instance"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Validate Backup"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/backupVaults/backupJobs/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Get Jobs list"), - // Operation: to.Ptr("Backup Jobs"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Jobs"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.RecoveryServices/Vaults/backupJobs/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Get Job details"), - // Operation: to.Ptr("Backup Job Object"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Backup Jobs"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/register/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Registers subscription for given Resource Provider"), - // Operation: to.Ptr("Register Resource Provider"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Provider Operation"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/unregister/action"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Unregisters subscription for given Resource Provider"), - // Operation: to.Ptr("Unregister Resource Provider"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Provider Operation"), - // }, - // Origin: to.Ptr("user"), - // }, - // { - // Name: to.Ptr("Microsoft.DataProtection/operations/read"), - // Display: &armdataprotection.ClientDiscoveryDisplay{ - // Description: to.Ptr("Operation returns the list of Operations for a Resource Provider"), - // Operation: to.Ptr("List of Operations"), - // Provider: to.Ptr("Microsoft.DataProtection"), - // Resource: to.Ptr("Resource Provider Operation"), - // }, - // Origin: to.Ptr("user"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatus_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatus_client.go index 935403753a70..91de9a434577 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatus_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatus_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type OperationStatusClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusClient, error) { - cl, err := arm.NewClient(moduleName+".OperationStatusClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,26 +46,36 @@ func NewOperationStatusClient(subscriptionID string, credential azcore.TokenCred // Get - Gets the operation status for a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - options - OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. func (client *OperationStatusClient) Get(ctx context.Context, location string, operationID string, options *OperationStatusClientGetOptions) (OperationStatusClientGetResponse, error) { + var err error + const operationName = "OperationStatusClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, location, operationID, options) if err != nil { return OperationStatusClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationStatusClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationStatusClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OperationStatusClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *OperationStatusClient) getCreateRequest(ctx context.Context, location string, operationID string, options *OperationStatusClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/locations/{location}/operationStatus/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if location == "" { return nil, errors.New("parameter location cannot be empty") @@ -81,7 +90,7 @@ func (client *OperationStatusClient) getCreateRequest(ctx context.Context, locat return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatus_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatus_client_example_test.go deleted file mode 100644 index aa412c523588..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatus_client_example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/GetOperationStatus.json -func ExampleOperationStatusClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOperationStatusClient().Get(ctx, "WestUS", "MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA==", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationResource = armdataprotection.OperationResource{ - // Name: to.Ptr("MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA=="), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-20T09:49:46Z"); return t}()), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/providers/Microsoft.DataProtection/locations/WestUS/operationStatus/MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA=="), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-20T09:49:44.0478496Z"); return t}()), - // Status: to.Ptr("Succeeded"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusbackupvaultcontext_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusbackupvaultcontext_client.go index d039adafedd7..345ac40303a3 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusbackupvaultcontext_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusbackupvaultcontext_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type OperationStatusBackupVaultContextClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationStatusBackupVaultContextClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusBackupVaultContextClient, error) { - cl, err := arm.NewClient(moduleName+".OperationStatusBackupVaultContextClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,29 +46,39 @@ func NewOperationStatusBackupVaultContextClient(subscriptionID string, credentia // Get - Gets the operation status for an operation over a BackupVault's context. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - options - OperationStatusBackupVaultContextClientGetOptions contains the optional parameters for the OperationStatusBackupVaultContextClient.Get // method. func (client *OperationStatusBackupVaultContextClient) Get(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *OperationStatusBackupVaultContextClientGetOptions) (OperationStatusBackupVaultContextClientGetResponse, error) { + var err error + const operationName = "OperationStatusBackupVaultContextClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, operationID, options) if err != nil { return OperationStatusBackupVaultContextClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationStatusBackupVaultContextClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationStatusBackupVaultContextClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OperationStatusBackupVaultContextClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *OperationStatusBackupVaultContextClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, operationID string, options *OperationStatusBackupVaultContextClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/operationStatus/{operationId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -88,7 +97,7 @@ func (client *OperationStatusBackupVaultContextClient) getCreateRequest(ctx cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusbackupvaultcontext_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusbackupvaultcontext_client_example_test.go deleted file mode 100644 index 53d3b49cb99d..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusbackupvaultcontext_client_example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/GetOperationStatusVaultContext.json -func ExampleOperationStatusBackupVaultContextClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOperationStatusBackupVaultContextClient().Get(ctx, "SampleResourceGroup", "swaggerExample", "MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA==", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationResource = armdataprotection.OperationResource{ - // Name: to.Ptr("MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA=="), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-20T09:49:46Z"); return t}()), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/backupVaults/swaggerExample/operationStatus/MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA=="), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-20T09:49:44.0478496Z"); return t}()), - // Status: to.Ptr("Succeeded"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusresourcegroupcontext_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusresourcegroupcontext_client.go index a531d3e3e3fb..f6d960a1bb37 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusresourcegroupcontext_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusresourcegroupcontext_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type OperationStatusResourceGroupContextClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationStatusResourceGroupContextClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusResourceGroupContextClient, error) { - cl, err := arm.NewClient(moduleName+".OperationStatusResourceGroupContextClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,23 +46,30 @@ func NewOperationStatusResourceGroupContextClient(subscriptionID string, credent // Get - Gets the operation status for an operation over a ResourceGroup's context. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - OperationStatusResourceGroupContextClientGetOptions contains the optional parameters for the OperationStatusResourceGroupContextClient.Get // method. func (client *OperationStatusResourceGroupContextClient) Get(ctx context.Context, resourceGroupName string, operationID string, options *OperationStatusResourceGroupContextClientGetOptions) (OperationStatusResourceGroupContextClientGetResponse, error) { + var err error + const operationName = "OperationStatusResourceGroupContextClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, operationID, options) if err != nil { return OperationStatusResourceGroupContextClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationStatusResourceGroupContextClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationStatusResourceGroupContextClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OperationStatusResourceGroupContextClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -73,6 +79,9 @@ func (client *OperationStatusResourceGroupContextClient) getCreateRequest(ctx co return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if operationID == "" { return nil, errors.New("parameter operationID cannot be empty") @@ -83,7 +92,7 @@ func (client *OperationStatusResourceGroupContextClient) getCreateRequest(ctx co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusresourcegroupcontext_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusresourcegroupcontext_client_example_test.go deleted file mode 100644 index 037ce93e4183..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/operationstatusresourcegroupcontext_client_example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/GetOperationStatusRGContext.json -func ExampleOperationStatusResourceGroupContextClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewOperationStatusResourceGroupContextClient().Get(ctx, "SampleResourceGroup", "MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA==", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationResource = armdataprotection.OperationResource{ - // Name: to.Ptr("MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA=="), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-20T09:49:46Z"); return t}()), - // ID: to.Ptr("/subscriptions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/operationStatus/MjkxOTMyODMtYTE3My00YzJjLTg5NjctN2E4MDIxNDA3NjA2OzdjNGE2ZWRjLWJjMmItNDRkYi1hYzMzLWY1YzEwNzk5Y2EyOA=="), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-20T09:49:44.0478496Z"); return t}()), - // Status: to.Ptr("Succeeded"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/options.go b/sdk/resourcemanager/dataprotection/armdataprotection/options.go new file mode 100644 index 000000000000..0f981c67d70c --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/options.go @@ -0,0 +1,435 @@ +//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 armdataprotection + +// BackupInstancesClientBeginAdhocBackupOptions contains the optional parameters for the BackupInstancesClient.BeginAdhocBackup +// method. +type BackupInstancesClientBeginAdhocBackupOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginCreateOrUpdateOptions contains the optional parameters for the BackupInstancesClient.BeginCreateOrUpdate +// method. +type BackupInstancesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginDeleteOptions contains the optional parameters for the BackupInstancesClient.BeginDelete method. +type BackupInstancesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginResumeBackupsOptions contains the optional parameters for the BackupInstancesClient.BeginResumeBackups +// method. +type BackupInstancesClientBeginResumeBackupsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginResumeProtectionOptions contains the optional parameters for the BackupInstancesClient.BeginResumeProtection +// method. +type BackupInstancesClientBeginResumeProtectionOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginStopProtectionOptions contains the optional parameters for the BackupInstancesClient.BeginStopProtection +// method. +type BackupInstancesClientBeginStopProtectionOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginSuspendBackupsOptions contains the optional parameters for the BackupInstancesClient.BeginSuspendBackups +// method. +type BackupInstancesClientBeginSuspendBackupsOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginSyncBackupInstanceOptions contains the optional parameters for the BackupInstancesClient.BeginSyncBackupInstance +// method. +type BackupInstancesClientBeginSyncBackupInstanceOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginTriggerCrossRegionRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginTriggerCrossRegionRestore +// method. +type BackupInstancesClientBeginTriggerCrossRegionRestoreOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginTriggerRehydrateOptions contains the optional parameters for the BackupInstancesClient.BeginTriggerRehydrate +// method. +type BackupInstancesClientBeginTriggerRehydrateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginTriggerRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginTriggerRestore +// method. +type BackupInstancesClientBeginTriggerRestoreOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginValidateCrossRegionRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginValidateCrossRegionRestore +// method. +type BackupInstancesClientBeginValidateCrossRegionRestoreOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginValidateForBackupOptions contains the optional parameters for the BackupInstancesClient.BeginValidateForBackup +// method. +type BackupInstancesClientBeginValidateForBackupOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientBeginValidateForRestoreOptions contains the optional parameters for the BackupInstancesClient.BeginValidateForRestore +// method. +type BackupInstancesClientBeginValidateForRestoreOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupInstancesClientGetBackupInstanceOperationResultOptions contains the optional parameters for the BackupInstancesClient.GetBackupInstanceOperationResult +// method. +type BackupInstancesClientGetBackupInstanceOperationResultOptions struct { + // placeholder for future optional parameters +} + +// BackupInstancesClientGetOptions contains the optional parameters for the BackupInstancesClient.Get method. +type BackupInstancesClientGetOptions struct { + // placeholder for future optional parameters +} + +// BackupInstancesClientListOptions contains the optional parameters for the BackupInstancesClient.NewListPager method. +type BackupInstancesClientListOptions struct { + // placeholder for future optional parameters +} + +// BackupPoliciesClientCreateOrUpdateOptions contains the optional parameters for the BackupPoliciesClient.CreateOrUpdate +// method. +type BackupPoliciesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// BackupPoliciesClientDeleteOptions contains the optional parameters for the BackupPoliciesClient.Delete method. +type BackupPoliciesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// BackupPoliciesClientGetOptions contains the optional parameters for the BackupPoliciesClient.Get method. +type BackupPoliciesClientGetOptions struct { + // placeholder for future optional parameters +} + +// BackupPoliciesClientListOptions contains the optional parameters for the BackupPoliciesClient.NewListPager method. +type BackupPoliciesClientListOptions struct { + // placeholder for future optional parameters +} + +// BackupVaultOperationResultsClientGetOptions contains the optional parameters for the BackupVaultOperationResultsClient.Get +// method. +type BackupVaultOperationResultsClientGetOptions struct { + // placeholder for future optional parameters +} + +// BackupVaultsClientBeginCreateOrUpdateOptions contains the optional parameters for the BackupVaultsClient.BeginCreateOrUpdate +// method. +type BackupVaultsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupVaultsClientBeginDeleteOptions contains the optional parameters for the BackupVaultsClient.BeginDelete method. +type BackupVaultsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupVaultsClientBeginUpdateOptions contains the optional parameters for the BackupVaultsClient.BeginUpdate method. +type BackupVaultsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// BackupVaultsClientCheckNameAvailabilityOptions contains the optional parameters for the BackupVaultsClient.CheckNameAvailability +// method. +type BackupVaultsClientCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// BackupVaultsClientGetInResourceGroupOptions contains the optional parameters for the BackupVaultsClient.NewGetInResourceGroupPager +// method. +type BackupVaultsClientGetInResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// BackupVaultsClientGetInSubscriptionOptions contains the optional parameters for the BackupVaultsClient.NewGetInSubscriptionPager +// method. +type BackupVaultsClientGetInSubscriptionOptions struct { + // placeholder for future optional parameters +} + +// BackupVaultsClientGetOptions contains the optional parameters for the BackupVaultsClient.Get method. +type BackupVaultsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ClientCheckFeatureSupportOptions contains the optional parameters for the Client.CheckFeatureSupport method. +type ClientCheckFeatureSupportOptions struct { + // placeholder for future optional parameters +} + +// CrossRegionRestoreJobClientGetOptions contains the optional parameters for the CrossRegionRestoreJobClient.Get method. +type CrossRegionRestoreJobClientGetOptions struct { + // placeholder for future optional parameters +} + +// CrossRegionRestoreJobsClientListOptions contains the optional parameters for the CrossRegionRestoreJobsClient.NewListPager +// method. +type CrossRegionRestoreJobsClientListOptions struct { + // OData filter options. + Filter *string +} + +// DeletedBackupInstancesClientBeginUndeleteOptions contains the optional parameters for the DeletedBackupInstancesClient.BeginUndelete +// method. +type DeletedBackupInstancesClientBeginUndeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DeletedBackupInstancesClientGetOptions contains the optional parameters for the DeletedBackupInstancesClient.Get method. +type DeletedBackupInstancesClientGetOptions struct { + // placeholder for future optional parameters +} + +// DeletedBackupInstancesClientListOptions contains the optional parameters for the DeletedBackupInstancesClient.NewListPager +// method. +type DeletedBackupInstancesClientListOptions struct { + // placeholder for future optional parameters +} + +// DppResourceGuardProxyClientCreateOrUpdateOptions contains the optional parameters for the DppResourceGuardProxyClient.CreateOrUpdate +// method. +type DppResourceGuardProxyClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DppResourceGuardProxyClientDeleteOptions contains the optional parameters for the DppResourceGuardProxyClient.Delete method. +type DppResourceGuardProxyClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// DppResourceGuardProxyClientGetOptions contains the optional parameters for the DppResourceGuardProxyClient.Get method. +type DppResourceGuardProxyClientGetOptions struct { + // placeholder for future optional parameters +} + +// DppResourceGuardProxyClientListOptions contains the optional parameters for the DppResourceGuardProxyClient.NewListPager +// method. +type DppResourceGuardProxyClientListOptions struct { + // placeholder for future optional parameters +} + +// DppResourceGuardProxyClientUnlockDeleteOptions contains the optional parameters for the DppResourceGuardProxyClient.UnlockDelete +// method. +type DppResourceGuardProxyClientUnlockDeleteOptions struct { + // placeholder for future optional parameters +} + +// ExportJobsClientBeginTriggerOptions contains the optional parameters for the ExportJobsClient.BeginTrigger method. +type ExportJobsClientBeginTriggerOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ExportJobsOperationResultClientGetOptions contains the optional parameters for the ExportJobsOperationResultClient.Get +// method. +type ExportJobsOperationResultClientGetOptions struct { + // placeholder for future optional parameters +} + +// JobsClientGetOptions contains the optional parameters for the JobsClient.Get method. +type JobsClientGetOptions struct { + // placeholder for future optional parameters +} + +// JobsClientListOptions contains the optional parameters for the JobsClient.NewListPager method. +type JobsClientListOptions struct { + // placeholder for future optional parameters +} + +// OperationResultClientGetOptions contains the optional parameters for the OperationResultClient.Get method. +type OperationResultClientGetOptions struct { + // placeholder for future optional parameters +} + +// OperationStatusBackupVaultContextClientGetOptions contains the optional parameters for the OperationStatusBackupVaultContextClient.Get +// method. +type OperationStatusBackupVaultContextClientGetOptions struct { + // placeholder for future optional parameters +} + +// OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. +type OperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// OperationStatusResourceGroupContextClientGetOptions contains the optional parameters for the OperationStatusResourceGroupContextClient.Get +// method. +type OperationStatusResourceGroupContextClientGetOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions 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 { + // OData filter options. + Filter *string + + // skipToken Filter. + SkipToken *string +} + +// ResourceGuardsClientDeleteOptions contains the optional parameters for the ResourceGuardsClient.Delete method. +type ResourceGuardsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetBackupSecurityPINRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetBackupSecurityPINRequestsObjectsPager +// method. +type ResourceGuardsClientGetBackupSecurityPINRequestsObjectsOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject +// method. +type ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject +// method. +type ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject +// method. +type ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject +// method. +type ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject +// method. +type ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectOptions contains the optional parameters for the ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject +// method. +type ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDeleteProtectedItemRequestsObjectsPager +// method. +type ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDeleteResourceGuardProxyRequestsObjectsPager +// method. +type ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDisableSoftDeleteRequestsObjectsPager +// method. +type ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetOptions contains the optional parameters for the ResourceGuardsClient.Get method. +type ResourceGuardsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetResourcesInResourceGroupOptions contains the optional parameters for the ResourceGuardsClient.NewGetResourcesInResourceGroupPager +// method. +type ResourceGuardsClientGetResourcesInResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetResourcesInSubscriptionOptions contains the optional parameters for the ResourceGuardsClient.NewGetResourcesInSubscriptionPager +// method. +type ResourceGuardsClientGetResourcesInSubscriptionOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetUpdateProtectedItemRequestsObjectsPager +// method. +type ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetUpdateProtectionPolicyRequestsObjectsPager +// method. +type ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientPatchOptions contains the optional parameters for the ResourceGuardsClient.Patch method. +type ResourceGuardsClientPatchOptions struct { + // placeholder for future optional parameters +} + +// ResourceGuardsClientPutOptions contains the optional parameters for the ResourceGuardsClient.Put method. +type ResourceGuardsClientPutOptions struct { + // placeholder for future optional parameters +} + +// RestorableTimeRangesClientFindOptions contains the optional parameters for the RestorableTimeRangesClient.Find method. +type RestorableTimeRangesClientFindOptions struct { + // placeholder for future optional parameters +} + +// SecondaryRPsClientFetchOptions contains the optional parameters for the SecondaryRPsClient.NewFetchPager method. +type SecondaryRPsClientFetchOptions struct { + // OData filter options. + Filter *string + + // skipToken Filter. + SkipToken *string +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/polymorphic_helpers.go b/sdk/resourcemanager/dataprotection/armdataprotection/polymorphic_helpers.go index 91bb0473a888..33cf03d3a3b4 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/polymorphic_helpers.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/polymorphic_helpers.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -26,7 +25,10 @@ func unmarshalAuthCredentialsClassification(rawMsg json.RawMessage) (AuthCredent default: b = &AuthCredentials{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalAzureBackupRecoveryPointClassification(rawMsg json.RawMessage) (AzureBackupRecoveryPointClassification, error) { @@ -44,7 +46,10 @@ func unmarshalAzureBackupRecoveryPointClassification(rawMsg json.RawMessage) (Az default: b = &AzureBackupRecoveryPoint{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalAzureBackupRestoreRequestClassification(rawMsg json.RawMessage) (AzureBackupRestoreRequestClassification, error) { @@ -66,7 +71,10 @@ func unmarshalAzureBackupRestoreRequestClassification(rawMsg json.RawMessage) (A default: b = &AzureBackupRestoreRequest{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBackupCriteriaClassification(rawMsg json.RawMessage) (BackupCriteriaClassification, error) { @@ -84,7 +92,10 @@ func unmarshalBackupCriteriaClassification(rawMsg json.RawMessage) (BackupCriter default: b = &BackupCriteria{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBackupCriteriaClassificationArray(rawMsg json.RawMessage) ([]BackupCriteriaClassification, error) { @@ -123,7 +134,10 @@ func unmarshalBackupDatasourceParametersClassification(rawMsg json.RawMessage) ( default: b = &BackupDatasourceParameters{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBackupDatasourceParametersClassificationArray(rawMsg json.RawMessage) ([]BackupDatasourceParametersClassification, error) { @@ -160,7 +174,10 @@ func unmarshalBackupParametersClassification(rawMsg json.RawMessage) (BackupPara default: b = &BackupParameters{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBaseBackupPolicyClassification(rawMsg json.RawMessage) (BaseBackupPolicyClassification, error) { @@ -178,7 +195,10 @@ func unmarshalBaseBackupPolicyClassification(rawMsg json.RawMessage) (BaseBackup default: b = &BaseBackupPolicy{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBasePolicyRuleClassification(rawMsg json.RawMessage) (BasePolicyRuleClassification, error) { @@ -198,7 +218,10 @@ func unmarshalBasePolicyRuleClassification(rawMsg json.RawMessage) (BasePolicyRu default: b = &BasePolicyRule{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBasePolicyRuleClassificationArray(rawMsg json.RawMessage) ([]BasePolicyRuleClassification, error) { @@ -230,10 +253,15 @@ func unmarshalBaseResourcePropertiesClassification(rawMsg json.RawMessage) (Base } var b BaseResourcePropertiesClassification switch m["objectType"] { + case string(ResourcePropertiesObjectTypeDefaultResourceProperties): + b = &DefaultResourceProperties{} default: b = &BaseResourceProperties{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalCopyOptionClassification(rawMsg json.RawMessage) (CopyOptionClassification, error) { @@ -255,7 +283,10 @@ func unmarshalCopyOptionClassification(rawMsg json.RawMessage) (CopyOptionClassi default: b = &CopyOption{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalDataStoreParametersClassification(rawMsg json.RawMessage) (DataStoreParametersClassification, error) { @@ -273,7 +304,10 @@ func unmarshalDataStoreParametersClassification(rawMsg json.RawMessage) (DataSto default: b = &DataStoreParameters{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalDataStoreParametersClassificationArray(rawMsg json.RawMessage) ([]DataStoreParametersClassification, error) { @@ -310,7 +344,10 @@ func unmarshalDeleteOptionClassification(rawMsg json.RawMessage) (DeleteOptionCl default: b = &DeleteOption{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalFeatureValidationResponseBaseClassification(rawMsg json.RawMessage) (FeatureValidationResponseBaseClassification, error) { @@ -328,7 +365,10 @@ func unmarshalFeatureValidationResponseBaseClassification(rawMsg json.RawMessage default: b = &FeatureValidationResponseBase{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalItemLevelRestoreCriteriaClassification(rawMsg json.RawMessage) (ItemLevelRestoreCriteriaClassification, error) { @@ -345,6 +385,8 @@ func unmarshalItemLevelRestoreCriteriaClassification(rawMsg json.RawMessage) (It b = &ItemPathBasedRestoreCriteria{} case "KubernetesClusterRestoreCriteria": b = &KubernetesClusterRestoreCriteria{} + case "KubernetesClusterVaultTierRestoreCriteria": + b = &KubernetesClusterVaultTierRestoreCriteria{} case "KubernetesPVRestoreCriteria": b = &KubernetesPVRestoreCriteria{} case "KubernetesStorageClassRestoreCriteria": @@ -354,7 +396,10 @@ func unmarshalItemLevelRestoreCriteriaClassification(rawMsg json.RawMessage) (It default: b = &ItemLevelRestoreCriteria{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalItemLevelRestoreCriteriaClassificationArray(rawMsg json.RawMessage) ([]ItemLevelRestoreCriteriaClassification, error) { @@ -391,7 +436,10 @@ func unmarshalOperationExtendedInfoClassification(rawMsg json.RawMessage) (Opera default: b = &OperationExtendedInfo{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalRestoreTargetInfoBaseClassification(rawMsg json.RawMessage) (RestoreTargetInfoBaseClassification, error) { @@ -413,7 +461,10 @@ func unmarshalRestoreTargetInfoBaseClassification(rawMsg json.RawMessage) (Resto default: b = &RestoreTargetInfoBase{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalTriggerContextClassification(rawMsg json.RawMessage) (TriggerContextClassification, error) { @@ -433,5 +484,8 @@ func unmarshalTriggerContextClassification(rawMsg json.RawMessage) (TriggerConte default: b = &TriggerContext{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/recoverypoints_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/recoverypoints_client.go index 194676831677..61cdc1c550bd 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/recoverypoints_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/recoverypoints_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type RecoveryPointsClient struct { // - 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) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,29 +46,39 @@ func NewRecoveryPointsClient(subscriptionID string, credential azcore.TokenCrede // Get - Gets a Recovery Point using recoveryPointId for a Datasource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. // - options - RecoveryPointsClientGetOptions contains the optional parameters for the RecoveryPointsClient.Get method. func (client *RecoveryPointsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, recoveryPointID string, options *RecoveryPointsClientGetOptions) (RecoveryPointsClientGetResponse, error) { + var err error + const operationName = "RecoveryPointsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, recoveryPointID, options) if err != nil { return RecoveryPointsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RecoveryPointsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RecoveryPointsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RecoveryPointsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. func (client *RecoveryPointsClient) getCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, recoveryPointID string, options *RecoveryPointsClientGetOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints/{recoveryPointId}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -92,7 +101,7 @@ func (client *RecoveryPointsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -109,7 +118,7 @@ func (client *RecoveryPointsClient) getHandleResponse(resp *http.Response) (Reco // NewListPager - Returns a list of Recovery Points for a DataSource in a vault. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -120,31 +129,29 @@ func (client *RecoveryPointsClient) NewListPager(resourceGroupName string, vault 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, backupInstanceName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "RecoveryPointsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, options) + }, nil) 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) }, + Tracer: client.internal.Tracer(), }) } // listCreateRequest creates the List request. func (client *RecoveryPointsClient) listCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, options *RecoveryPointsClientListOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/recoveryPoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -163,7 +170,7 @@ func (client *RecoveryPointsClient) listCreateRequest(ctx context.Context, resou return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/recoverypoints_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/recoverypoints_client_example_test.go deleted file mode 100644 index bfcb99205a21..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/recoverypoints_client_example_test.go +++ /dev/null @@ -1,141 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/ListRecoveryPoints.json -func ExampleRecoveryPointsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewRecoveryPointsClient().NewListPager("000pikumar", "PratikPrivatePreviewVault1", "testInstance1", &armdataprotection.RecoveryPointsClientListOptions{Filter: nil, - SkipToken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.AzureBackupRecoveryPointResourceList = armdataprotection.AzureBackupRecoveryPointResourceList{ - // Value: []*armdataprotection.AzureBackupRecoveryPointResource{ - // { - // Name: to.Ptr("7fb2cddd-c5b3-44f6-a0d9-db3c4f9d5e35"), - // Type: to.Ptr("microsoft.dataprotection/backupvaults/backupInstances/recoveryPoints"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/HelloTest/providers/Microsoft.DataProtection/backupVaults/HelloTestVault/backupInstances/653213d-c5b3-44f6-a0d9-db3c4f9d8e34/recoveryPoints/7fb2cddd-c5b3-44f6-a0d9-db3c4f9d5f25"), - // Properties: &armdataprotection.AzureBackupDiscreteRecoveryPoint{ - // ObjectType: to.Ptr("AzureBackupDiscreteRecoveryPoint"), - // ExpiryTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-03-01T13:00:00Z"); return t}()), - // FriendlyName: to.Ptr("panbha4"), - // RecoveryPointDataStoresDetails: []*armdataprotection.RecoveryPointDataStoreDetails{ - // { - // Type: to.Ptr("Snapshot"), - // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // ID: to.Ptr("0ff03512-b333-4509-a6c7-12164c8b1dce"), - // MetaData: to.Ptr("123456"), - // }, - // { - // Type: to.Ptr("BackupStorage"), - // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // ID: to.Ptr("5d8cfd30-722e-4bab-85f6-4a9d01ffc6f1"), - // MetaData: to.Ptr("123456"), - // }}, - // RecoveryPointTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // RecoveryPointType: to.Ptr("Full"), - // }, - // }, - // { - // Name: to.Ptr("7fb2cddd-c5b3-44f6-a0d9-db3c4f9d5f25"), - // Type: to.Ptr("microsoft.dataprotection/backupvaults/backupInstances/recoveryPoints"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/HelloTest/providers/Microsoft.DataProtection/backupVaults/HelloTestVault/backupInstances/653213d-c5b3-44f6-a0d9-db3c4f9d8e34/recoveryPoints/7fb2cddd-c5b3-44f6-a0d9-db3c4f9d5f25"), - // Properties: &armdataprotection.AzureBackupDiscreteRecoveryPoint{ - // ObjectType: to.Ptr("AzureBackupDiscreteRecoveryPoint"), - // FriendlyName: to.Ptr("panbha4"), - // RecoveryPointDataStoresDetails: []*armdataprotection.RecoveryPointDataStoreDetails{ - // { - // Type: to.Ptr("Snapshot"), - // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // ID: to.Ptr("808cfd30-722e-4bab-85f6-4a9d01ffc6f2"), - // MetaData: to.Ptr("123456"), - // }, - // { - // Type: to.Ptr("BackupStorage"), - // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // ID: to.Ptr("798cfd30-722e-4bab-85f6-4a9d01ffc6f3"), - // MetaData: to.Ptr("123456"), - // }}, - // RecoveryPointTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // RecoveryPointType: to.Ptr("Full"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/GetRecoveryPoint.json -func ExampleRecoveryPointsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewRecoveryPointsClient().Get(ctx, "000pikumar", "PratikPrivatePreviewVault1", "testInstance1", "7fb2cddd-c5b3-44f6-a0d9-db3c4f9d5f25", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AzureBackupRecoveryPointResource = armdataprotection.AzureBackupRecoveryPointResource{ - // Name: to.Ptr("7fb2cddd-c5b3-44f6-a0d9-db3c4f9d5f25"), - // Type: to.Ptr("microsoft.dataprotection/backupvaults/backupInstances/recoveryPoints"), - // ID: to.Ptr("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/HelloTest/providers/Microsoft.DataProtection/backupVaults/HelloTestVault/backupInstances/653213d-c5b3-44f6-a0d9-db3c4f9d8e34/recoveryPoints/7fb2cddd-c5b3-44f6-a0d9-db3c4f9d5f25"), - // Properties: &armdataprotection.AzureBackupDiscreteRecoveryPoint{ - // ObjectType: to.Ptr("AzureBackupDiscreteRecoveryPoint"), - // FriendlyName: to.Ptr("panbha4"), - // RecoveryPointDataStoresDetails: []*armdataprotection.RecoveryPointDataStoreDetails{ - // { - // Type: to.Ptr("Snapshot"), - // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // ID: to.Ptr("0ff03512-b333-4509-a6c7-12164c8b1dce"), - // MetaData: to.Ptr("123456"), - // }, - // { - // Type: to.Ptr("BackupStorage"), - // CreationTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // ID: to.Ptr("5d8cfd30-722e-4bab-85f6-4a9d01ffc6f1"), - // MetaData: to.Ptr("123456"), - // }}, - // RecoveryPointTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T13:00:00Z"); return t}()), - // RecoveryPointType: to.Ptr("Full"), - // }, - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/resourceguards_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/resourceguards_client.go index 37e7c485e059..6f585cbc6307 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/resourceguards_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/resourceguards_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type ResourceGuardsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewResourceGuardsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceGuardsClient, error) { - cl, err := arm.NewClient(moduleName+".ResourceGuardsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,21 +46,27 @@ func NewResourceGuardsClient(subscriptionID string, credential azcore.TokenCrede // Delete - Deletes a ResourceGuard resource from the resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceGuardsName - The name of ResourceGuard // - options - ResourceGuardsClientDeleteOptions contains the optional parameters for the ResourceGuardsClient.Delete method. func (client *ResourceGuardsClient) Delete(ctx context.Context, resourceGroupName string, resourceGuardsName string, options *ResourceGuardsClientDeleteOptions) (ResourceGuardsClientDeleteResponse, error) { + var err error + const operationName = "ResourceGuardsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) if err != nil { return ResourceGuardsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ResourceGuardsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientDeleteResponse{}, err } return ResourceGuardsClientDeleteResponse{}, nil } @@ -73,6 +78,9 @@ func (client *ResourceGuardsClient) deleteCreateRequest(ctx context.Context, res return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -83,7 +91,7 @@ func (client *ResourceGuardsClient) deleteCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -92,23 +100,30 @@ func (client *ResourceGuardsClient) deleteCreateRequest(ctx context.Context, res // Get - Returns a ResourceGuard belonging to a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceGuardsName - The name of ResourceGuard // - options - ResourceGuardsClientGetOptions contains the optional parameters for the ResourceGuardsClient.Get method. func (client *ResourceGuardsClient) Get(ctx context.Context, resourceGroupName string, resourceGuardsName string, options *ResourceGuardsClientGetOptions) (ResourceGuardsClientGetResponse, error) { + var err error + const operationName = "ResourceGuardsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) if err != nil { return ResourceGuardsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -118,6 +133,9 @@ func (client *ResourceGuardsClient) getCreateRequest(ctx context.Context, resour return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -128,7 +146,7 @@ func (client *ResourceGuardsClient) getCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -146,7 +164,7 @@ func (client *ResourceGuardsClient) getHandleResponse(resp *http.Response) (Reso // NewGetBackupSecurityPINRequestsObjectsPager - Returns collection of operation request objects for a critical operation // protected by the given ResourceGuard resource. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetBackupSecurityPINRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetBackupSecurityPINRequestsObjectsPager // method. @@ -156,25 +174,20 @@ func (client *ResourceGuardsClient) NewGetBackupSecurityPINRequestsObjectsPager( return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse) (ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getBackupSecurityPINRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetBackupSecurityPINRequestsObjectsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getBackupSecurityPINRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) + }, nil) if err != nil { return ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse{}, runtime.NewResponseError(resp) - } return client.getBackupSecurityPINRequestsObjectsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -185,6 +198,9 @@ func (client *ResourceGuardsClient) getBackupSecurityPINRequestsObjectsCreateReq return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -195,7 +211,7 @@ func (client *ResourceGuardsClient) getBackupSecurityPINRequestsObjectsCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -214,23 +230,30 @@ func (client *ResourceGuardsClient) getBackupSecurityPINRequestsObjectsHandleRes // by the given ResourceGuard resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectOptions contains the optional parameters for the // ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject method. func (client *ResourceGuardsClient) GetDefaultBackupSecurityPINRequestsObject(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectOptions) (ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse, error) { + var err error + const operationName = "ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDefaultBackupSecurityPINRequestsObjectCreateRequest(ctx, resourceGroupName, resourceGuardsName, requestName, options) if err != nil { return ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse{}, err } - return client.getDefaultBackupSecurityPINRequestsObjectHandleResponse(resp) + resp, err := client.getDefaultBackupSecurityPINRequestsObjectHandleResponse(httpResp) + return resp, err } // getDefaultBackupSecurityPINRequestsObjectCreateRequest creates the GetDefaultBackupSecurityPINRequestsObject request. @@ -240,6 +263,9 @@ func (client *ResourceGuardsClient) getDefaultBackupSecurityPINRequestsObjectCre return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -254,7 +280,7 @@ func (client *ResourceGuardsClient) getDefaultBackupSecurityPINRequestsObjectCre return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -273,23 +299,30 @@ func (client *ResourceGuardsClient) getDefaultBackupSecurityPINRequestsObjectHan // protected by the given ResourceGuard resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectOptions contains the optional parameters for the // ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject method. func (client *ResourceGuardsClient) GetDefaultDeleteProtectedItemRequestsObject(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectOptions) (ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse, error) { + var err error + const operationName = "ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDefaultDeleteProtectedItemRequestsObjectCreateRequest(ctx, resourceGroupName, resourceGuardsName, requestName, options) if err != nil { return ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse{}, err } - return client.getDefaultDeleteProtectedItemRequestsObjectHandleResponse(resp) + resp, err := client.getDefaultDeleteProtectedItemRequestsObjectHandleResponse(httpResp) + return resp, err } // getDefaultDeleteProtectedItemRequestsObjectCreateRequest creates the GetDefaultDeleteProtectedItemRequestsObject request. @@ -299,6 +332,9 @@ func (client *ResourceGuardsClient) getDefaultDeleteProtectedItemRequestsObjectC return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -313,7 +349,7 @@ func (client *ResourceGuardsClient) getDefaultDeleteProtectedItemRequestsObjectC return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -332,23 +368,30 @@ func (client *ResourceGuardsClient) getDefaultDeleteProtectedItemRequestsObjectH // protected by the given ResourceGuard resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectOptions contains the optional parameters // for the ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject method. func (client *ResourceGuardsClient) GetDefaultDeleteResourceGuardProxyRequestsObject(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectOptions) (ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse, error) { + var err error + const operationName = "ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDefaultDeleteResourceGuardProxyRequestsObjectCreateRequest(ctx, resourceGroupName, resourceGuardsName, requestName, options) if err != nil { return ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse{}, err } - return client.getDefaultDeleteResourceGuardProxyRequestsObjectHandleResponse(resp) + resp, err := client.getDefaultDeleteResourceGuardProxyRequestsObjectHandleResponse(httpResp) + return resp, err } // getDefaultDeleteResourceGuardProxyRequestsObjectCreateRequest creates the GetDefaultDeleteResourceGuardProxyRequestsObject request. @@ -358,6 +401,9 @@ func (client *ResourceGuardsClient) getDefaultDeleteResourceGuardProxyRequestsOb return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -372,7 +418,7 @@ func (client *ResourceGuardsClient) getDefaultDeleteResourceGuardProxyRequestsOb return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -391,23 +437,30 @@ func (client *ResourceGuardsClient) getDefaultDeleteResourceGuardProxyRequestsOb // by the given ResourceGuard resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectOptions contains the optional parameters for the // ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject method. func (client *ResourceGuardsClient) GetDefaultDisableSoftDeleteRequestsObject(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectOptions) (ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse, error) { + var err error + const operationName = "ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDefaultDisableSoftDeleteRequestsObjectCreateRequest(ctx, resourceGroupName, resourceGuardsName, requestName, options) if err != nil { return ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse{}, err } - return client.getDefaultDisableSoftDeleteRequestsObjectHandleResponse(resp) + resp, err := client.getDefaultDisableSoftDeleteRequestsObjectHandleResponse(httpResp) + return resp, err } // getDefaultDisableSoftDeleteRequestsObjectCreateRequest creates the GetDefaultDisableSoftDeleteRequestsObject request. @@ -417,6 +470,9 @@ func (client *ResourceGuardsClient) getDefaultDisableSoftDeleteRequestsObjectCre return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -431,7 +487,7 @@ func (client *ResourceGuardsClient) getDefaultDisableSoftDeleteRequestsObjectCre return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -450,23 +506,30 @@ func (client *ResourceGuardsClient) getDefaultDisableSoftDeleteRequestsObjectHan // protected by the given ResourceGuard resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectOptions contains the optional parameters for the // ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject method. func (client *ResourceGuardsClient) GetDefaultUpdateProtectedItemRequestsObject(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectOptions) (ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse, error) { + var err error + const operationName = "ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDefaultUpdateProtectedItemRequestsObjectCreateRequest(ctx, resourceGroupName, resourceGuardsName, requestName, options) if err != nil { return ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse{}, err } - return client.getDefaultUpdateProtectedItemRequestsObjectHandleResponse(resp) + resp, err := client.getDefaultUpdateProtectedItemRequestsObjectHandleResponse(httpResp) + return resp, err } // getDefaultUpdateProtectedItemRequestsObjectCreateRequest creates the GetDefaultUpdateProtectedItemRequestsObject request. @@ -476,6 +539,9 @@ func (client *ResourceGuardsClient) getDefaultUpdateProtectedItemRequestsObjectC return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -490,7 +556,7 @@ func (client *ResourceGuardsClient) getDefaultUpdateProtectedItemRequestsObjectC return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -509,23 +575,30 @@ func (client *ResourceGuardsClient) getDefaultUpdateProtectedItemRequestsObjectH // protected by the given ResourceGuard resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectOptions contains the optional parameters for // the ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject method. func (client *ResourceGuardsClient) GetDefaultUpdateProtectionPolicyRequestsObject(ctx context.Context, resourceGroupName string, resourceGuardsName string, requestName string, options *ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectOptions) (ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse, error) { + var err error + const operationName = "ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDefaultUpdateProtectionPolicyRequestsObjectCreateRequest(ctx, resourceGroupName, resourceGuardsName, requestName, options) if err != nil { return ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse{}, err } - return client.getDefaultUpdateProtectionPolicyRequestsObjectHandleResponse(resp) + resp, err := client.getDefaultUpdateProtectionPolicyRequestsObjectHandleResponse(httpResp) + return resp, err } // getDefaultUpdateProtectionPolicyRequestsObjectCreateRequest creates the GetDefaultUpdateProtectionPolicyRequestsObject request. @@ -535,6 +608,9 @@ func (client *ResourceGuardsClient) getDefaultUpdateProtectionPolicyRequestsObje return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -549,7 +625,7 @@ func (client *ResourceGuardsClient) getDefaultUpdateProtectionPolicyRequestsObje return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -567,7 +643,7 @@ func (client *ResourceGuardsClient) getDefaultUpdateProtectionPolicyRequestsObje // NewGetDeleteProtectedItemRequestsObjectsPager - Returns collection of operation request objects for a critical operation // protected by the given ResourceGuard resource. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDeleteProtectedItemRequestsObjectsPager // method. @@ -577,25 +653,20 @@ func (client *ResourceGuardsClient) NewGetDeleteProtectedItemRequestsObjectsPage return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse) (ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getDeleteProtectedItemRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetDeleteProtectedItemRequestsObjectsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getDeleteProtectedItemRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) + }, nil) if err != nil { return ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse{}, runtime.NewResponseError(resp) - } return client.getDeleteProtectedItemRequestsObjectsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -606,6 +677,9 @@ func (client *ResourceGuardsClient) getDeleteProtectedItemRequestsObjectsCreateR return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -616,7 +690,7 @@ func (client *ResourceGuardsClient) getDeleteProtectedItemRequestsObjectsCreateR return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -634,7 +708,7 @@ func (client *ResourceGuardsClient) getDeleteProtectedItemRequestsObjectsHandleR // NewGetDeleteResourceGuardProxyRequestsObjectsPager - Returns collection of operation request objects for a critical operation // protected by the given ResourceGuard resource. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsOptions contains the optional parameters for the // ResourceGuardsClient.NewGetDeleteResourceGuardProxyRequestsObjectsPager method. @@ -644,25 +718,20 @@ func (client *ResourceGuardsClient) NewGetDeleteResourceGuardProxyRequestsObject return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse) (ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getDeleteResourceGuardProxyRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetDeleteResourceGuardProxyRequestsObjectsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getDeleteResourceGuardProxyRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) + }, nil) if err != nil { return ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse{}, runtime.NewResponseError(resp) - } return client.getDeleteResourceGuardProxyRequestsObjectsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -673,6 +742,9 @@ func (client *ResourceGuardsClient) getDeleteResourceGuardProxyRequestsObjectsCr return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -683,7 +755,7 @@ func (client *ResourceGuardsClient) getDeleteResourceGuardProxyRequestsObjectsCr return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -701,7 +773,7 @@ func (client *ResourceGuardsClient) getDeleteResourceGuardProxyRequestsObjectsHa // NewGetDisableSoftDeleteRequestsObjectsPager - Returns collection of operation request objects for a critical operation // protected by the given ResourceGuard resource. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetDisableSoftDeleteRequestsObjectsPager // method. @@ -711,25 +783,20 @@ func (client *ResourceGuardsClient) NewGetDisableSoftDeleteRequestsObjectsPager( return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse) (ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getDisableSoftDeleteRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetDisableSoftDeleteRequestsObjectsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getDisableSoftDeleteRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) + }, nil) if err != nil { return ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse{}, runtime.NewResponseError(resp) - } return client.getDisableSoftDeleteRequestsObjectsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -740,6 +807,9 @@ func (client *ResourceGuardsClient) getDisableSoftDeleteRequestsObjectsCreateReq return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -750,7 +820,7 @@ func (client *ResourceGuardsClient) getDisableSoftDeleteRequestsObjectsCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -767,7 +837,7 @@ func (client *ResourceGuardsClient) getDisableSoftDeleteRequestsObjectsHandleRes // NewGetResourcesInResourceGroupPager - Returns ResourceGuards collection belonging to a ResourceGroup. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetResourcesInResourceGroupOptions contains the optional parameters for the ResourceGuardsClient.NewGetResourcesInResourceGroupPager // method. @@ -777,31 +847,29 @@ func (client *ResourceGuardsClient) NewGetResourcesInResourceGroupPager(resource return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetResourcesInResourceGroupResponse) (ResourceGuardsClientGetResourcesInResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getResourcesInResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetResourcesInResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getResourcesInResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) if err != nil { return ResourceGuardsClientGetResourcesInResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceGuardsClientGetResourcesInResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetResourcesInResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.getResourcesInResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // getResourcesInResourceGroupCreateRequest creates the GetResourcesInResourceGroup request. func (client *ResourceGuardsClient) getResourcesInResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *ResourceGuardsClientGetResourcesInResourceGroupOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/resourceGuards" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -812,7 +880,7 @@ func (client *ResourceGuardsClient) getResourcesInResourceGroupCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -829,7 +897,7 @@ func (client *ResourceGuardsClient) getResourcesInResourceGroupHandleResponse(re // NewGetResourcesInSubscriptionPager - Returns ResourceGuards collection belonging to a subscription. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - options - ResourceGuardsClientGetResourcesInSubscriptionOptions contains the optional parameters for the ResourceGuardsClient.NewGetResourcesInSubscriptionPager // method. func (client *ResourceGuardsClient) NewGetResourcesInSubscriptionPager(options *ResourceGuardsClientGetResourcesInSubscriptionOptions) *runtime.Pager[ResourceGuardsClientGetResourcesInSubscriptionResponse] { @@ -838,38 +906,36 @@ func (client *ResourceGuardsClient) NewGetResourcesInSubscriptionPager(options * return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetResourcesInSubscriptionResponse) (ResourceGuardsClientGetResourcesInSubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getResourcesInSubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetResourcesInSubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getResourcesInSubscriptionCreateRequest(ctx, options) + }, nil) if err != nil { return ResourceGuardsClientGetResourcesInSubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceGuardsClientGetResourcesInSubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetResourcesInSubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.getResourcesInSubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } // getResourcesInSubscriptionCreateRequest creates the GetResourcesInSubscription request. func (client *ResourceGuardsClient) getResourcesInSubscriptionCreateRequest(ctx context.Context, options *ResourceGuardsClientGetResourcesInSubscriptionOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.DataProtection/resourceGuards" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -887,7 +953,7 @@ func (client *ResourceGuardsClient) getResourcesInSubscriptionHandleResponse(res // NewGetUpdateProtectedItemRequestsObjectsPager - Returns collection of operation request objects for a critical operation // protected by the given ResourceGuard resource. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsOptions contains the optional parameters for the ResourceGuardsClient.NewGetUpdateProtectedItemRequestsObjectsPager // method. @@ -897,25 +963,20 @@ func (client *ResourceGuardsClient) NewGetUpdateProtectedItemRequestsObjectsPage return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse) (ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getUpdateProtectedItemRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetUpdateProtectedItemRequestsObjectsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getUpdateProtectedItemRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) + }, nil) if err != nil { return ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse{}, runtime.NewResponseError(resp) - } return client.getUpdateProtectedItemRequestsObjectsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -926,6 +987,9 @@ func (client *ResourceGuardsClient) getUpdateProtectedItemRequestsObjectsCreateR return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -936,7 +1000,7 @@ func (client *ResourceGuardsClient) getUpdateProtectedItemRequestsObjectsCreateR return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -954,7 +1018,7 @@ func (client *ResourceGuardsClient) getUpdateProtectedItemRequestsObjectsHandleR // NewGetUpdateProtectionPolicyRequestsObjectsPager - Returns collection of operation request objects for a critical operation // protected by the given ResourceGuard resource. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - options - ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsOptions contains the optional parameters for the // ResourceGuardsClient.NewGetUpdateProtectionPolicyRequestsObjectsPager method. @@ -964,25 +1028,20 @@ func (client *ResourceGuardsClient) NewGetUpdateProtectionPolicyRequestsObjectsP return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse) (ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getUpdateProtectionPolicyRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceGuardsClient.NewGetUpdateProtectionPolicyRequestsObjectsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.getUpdateProtectionPolicyRequestsObjectsCreateRequest(ctx, resourceGroupName, resourceGuardsName, options) + }, nil) if err != nil { return ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse{}, runtime.NewResponseError(resp) - } return client.getUpdateProtectionPolicyRequestsObjectsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -993,6 +1052,9 @@ func (client *ResourceGuardsClient) getUpdateProtectionPolicyRequestsObjectsCrea return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -1003,7 +1065,7 @@ func (client *ResourceGuardsClient) getUpdateProtectionPolicyRequestsObjectsCrea return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -1021,24 +1083,31 @@ func (client *ResourceGuardsClient) getUpdateProtectionPolicyRequestsObjectsHand // Patch - Updates a ResourceGuard resource belonging to a resource group. For example, updating tags for a resource. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceGuardsName - The name of ResourceGuard // - parameters - Request body for operation // - options - ResourceGuardsClientPatchOptions contains the optional parameters for the ResourceGuardsClient.Patch method. func (client *ResourceGuardsClient) Patch(ctx context.Context, resourceGroupName string, resourceGuardsName string, parameters PatchResourceGuardInput, options *ResourceGuardsClientPatchOptions) (ResourceGuardsClientPatchResponse, error) { + var err error + const operationName = "ResourceGuardsClient.Patch" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.patchCreateRequest(ctx, resourceGroupName, resourceGuardsName, parameters, options) if err != nil { return ResourceGuardsClientPatchResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientPatchResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceGuardsClientPatchResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientPatchResponse{}, err } - return client.patchHandleResponse(resp) + resp, err := client.patchHandleResponse(httpResp) + return resp, err } // patchCreateRequest creates the Patch request. @@ -1048,6 +1117,9 @@ func (client *ResourceGuardsClient) patchCreateRequest(ctx context.Context, reso return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -1058,10 +1130,13 @@ func (client *ResourceGuardsClient) patchCreateRequest(ctx context.Context, reso return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // patchHandleResponse handles the Patch response. @@ -1076,24 +1151,31 @@ func (client *ResourceGuardsClient) patchHandleResponse(resp *http.Response) (Re // Put - Creates or updates a ResourceGuard resource belonging to a resource group. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - resourceGuardsName - The name of ResourceGuard // - parameters - Request body for operation // - options - ResourceGuardsClientPutOptions contains the optional parameters for the ResourceGuardsClient.Put method. func (client *ResourceGuardsClient) Put(ctx context.Context, resourceGroupName string, resourceGuardsName string, parameters ResourceGuardResource, options *ResourceGuardsClientPutOptions) (ResourceGuardsClientPutResponse, error) { + var err error + const operationName = "ResourceGuardsClient.Put" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.putCreateRequest(ctx, resourceGroupName, resourceGuardsName, parameters, options) if err != nil { return ResourceGuardsClientPutResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ResourceGuardsClientPutResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ResourceGuardsClientPutResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ResourceGuardsClientPutResponse{}, err } - return client.putHandleResponse(resp) + resp, err := client.putHandleResponse(httpResp) + return resp, err } // putCreateRequest creates the Put request. @@ -1103,6 +1185,9 @@ func (client *ResourceGuardsClient) putCreateRequest(ctx context.Context, resour return nil, errors.New("parameter resourceGroupName cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGuardsName == "" { return nil, errors.New("parameter resourceGuardsName cannot be empty") @@ -1113,10 +1198,13 @@ func (client *ResourceGuardsClient) putCreateRequest(ctx context.Context, resour return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // putHandleResponse handles the Put response. diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/resourceguards_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/resourceguards_client_example_test.go deleted file mode 100644 index f91551beb6f3..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/resourceguards_client_example_test.go +++ /dev/null @@ -1,632 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetResourceGuardsInSubscription.json -func ExampleResourceGuardsClient_NewGetResourcesInSubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetResourcesInSubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourceGuardResourceList = armdataprotection.ResourceGuardResourceList{ - // Value: []*armdataprotection.ResourceGuardResource{ - // { - // Name: to.Ptr("VaultGuardTestNew"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards"), - // ID: to.Ptr("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // "TestKey": to.Ptr("TestValue"), - // }, - // Properties: &armdataprotection.ResourceGuard{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // AllowAutoApprovals: to.Ptr(true), - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // ResourceGuardOperations: []*armdataprotection.ResourceGuardOperation{ - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteResourceGuardProxyRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupResourceGuardProxies/delete"), - // }, - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/disableSoftDeleteRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupconfig/write"), - // }}, - // VaultCriticalOperationExclusionList: []*string{ - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetResourceGuardsInResourceGroup.json -func ExampleResourceGuardsClient_NewGetResourcesInResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetResourcesInResourceGroupPager("SampleResourceGroup", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ResourceGuardResourceList = armdataprotection.ResourceGuardResourceList{ - // Value: []*armdataprotection.ResourceGuardResource{ - // { - // Name: to.Ptr("VaultGuardTestNew"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards"), - // ID: to.Ptr("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // "TestKey": to.Ptr("TestValue"), - // }, - // Properties: &armdataprotection.ResourceGuard{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // AllowAutoApprovals: to.Ptr(true), - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // ResourceGuardOperations: []*armdataprotection.ResourceGuardOperation{ - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteResourceGuardProxyRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupResourceGuardProxies/delete"), - // }, - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/disableSoftDeleteRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupconfig/write"), - // }}, - // VaultCriticalOperationExclusionList: []*string{ - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/PutResourceGuard.json -func ExampleResourceGuardsClient_Put() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().Put(ctx, "SampleResourceGroup", "swaggerExample", armdataprotection.ResourceGuardResource{ - Location: to.Ptr("WestUS"), - Tags: map[string]*string{ - "key1": to.Ptr("val1"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourceGuardResource = armdataprotection.ResourceGuardResource{ - // Name: to.Ptr("VaultGuardTestNew"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards"), - // ID: to.Ptr("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // "TestKey": to.Ptr("TestValue"), - // }, - // Properties: &armdataprotection.ResourceGuard{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // AllowAutoApprovals: to.Ptr(true), - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // ResourceGuardOperations: []*armdataprotection.ResourceGuardOperation{ - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteResourceGuardProxyRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupResourceGuardProxies/delete"), - // }, - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/disableSoftDeleteRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupconfig/write"), - // }}, - // VaultCriticalOperationExclusionList: []*string{ - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetResourceGuard.json -func ExampleResourceGuardsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().Get(ctx, "SampleResourceGroup", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourceGuardResource = armdataprotection.ResourceGuardResource{ - // Name: to.Ptr("ResourceGuardTestNew"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards"), - // ID: to.Ptr("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // "TestKey": to.Ptr("TestValue"), - // }, - // Properties: &armdataprotection.ResourceGuard{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // AllowAutoApprovals: to.Ptr(true), - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // ResourceGuardOperations: []*armdataprotection.ResourceGuardOperation{ - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteResourceGuardProxyRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupResourceGuardProxies/delete"), - // }, - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/disableSoftDeleteRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupconfig/write"), - // }}, - // VaultCriticalOperationExclusionList: []*string{ - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/DeleteResourceGuard.json -func ExampleResourceGuardsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewResourceGuardsClient().Delete(ctx, "SampleResourceGroup", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/PatchResourceGuard.json -func ExampleResourceGuardsClient_Patch() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().Patch(ctx, "SampleResourceGroup", "swaggerExample", armdataprotection.PatchResourceGuardInput{ - Tags: map[string]*string{ - "newKey": to.Ptr("newVal"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ResourceGuardResource = armdataprotection.ResourceGuardResource{ - // Name: to.Ptr("VaultGuardTestNew"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards"), - // ID: to.Ptr("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // "TestKey": to.Ptr("TestValue"), - // }, - // Properties: &armdataprotection.ResourceGuard{ - // Description: to.Ptr("Please take JIT access before performing any of the critical operation"), - // AllowAutoApprovals: to.Ptr(true), - // ProvisioningState: to.Ptr(armdataprotection.ProvisioningStateSucceeded), - // ResourceGuardOperations: []*armdataprotection.ResourceGuardOperation{ - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteResourceGuardProxyRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupResourceGuardProxies/delete"), - // }, - // { - // RequestResourceType: to.Ptr("Microsoft.DataProtection/resourceGuards/disableSoftDeleteRequests"), - // VaultCriticalOperation: to.Ptr("Microsoft.RecoveryServices/vaults/backupconfig/write"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/ListDisableSoftDeleteRequests.json -func ExampleResourceGuardsClient_NewGetDisableSoftDeleteRequestsObjectsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetDisableSoftDeleteRequestsObjectsPager("SampleResourceGroup", "swaggerExample", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DppBaseResourceList = armdataprotection.DppBaseResourceList{ - // Value: []*armdataprotection.DppBaseResource{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/disableSoftDeleteRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/disableSoftDeleteRequests/default"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/ListDeleteResourceGuardProxyRequests.json -func ExampleResourceGuardsClient_NewGetDeleteResourceGuardProxyRequestsObjectsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetDeleteResourceGuardProxyRequestsObjectsPager("SampleResourceGroup", "swaggerExample", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DppBaseResourceList = armdataprotection.DppBaseResourceList{ - // Value: []*armdataprotection.DppBaseResource{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteResourceGuardProxyRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/deleteResourceGuardProxyRequests/default"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/ListBackupSecurityPINRequests.json -func ExampleResourceGuardsClient_NewGetBackupSecurityPINRequestsObjectsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetBackupSecurityPINRequestsObjectsPager("SampleResourceGroup", "swaggerExample", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DppBaseResourceList = armdataprotection.DppBaseResourceList{ - // Value: []*armdataprotection.DppBaseResource{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/getBackupSecurityPINRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/getBackupSecurityPINRequests/default"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/ListDeleteProtectedItemRequests.json -func ExampleResourceGuardsClient_NewGetDeleteProtectedItemRequestsObjectsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetDeleteProtectedItemRequestsObjectsPager("SampleResourceGroup", "swaggerExample", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DppBaseResourceList = armdataprotection.DppBaseResourceList{ - // Value: []*armdataprotection.DppBaseResource{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteProtectedItemRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/deleteProtectedItemRequests/default"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/ListUpdateProtectionPolicyRequests.json -func ExampleResourceGuardsClient_NewGetUpdateProtectionPolicyRequestsObjectsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetUpdateProtectionPolicyRequestsObjectsPager("SampleResourceGroup", "swaggerExample", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DppBaseResourceList = armdataprotection.DppBaseResourceList{ - // Value: []*armdataprotection.DppBaseResource{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/updateProtectionPolicyRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/updateProtectionPolicyRequests/default"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/ListUpdateProtectedItemRequests.json -func ExampleResourceGuardsClient_NewGetUpdateProtectedItemRequestsObjectsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewResourceGuardsClient().NewGetUpdateProtectedItemRequestsObjectsPager("SampleResourceGroup", "swaggerExample", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DppBaseResourceList = armdataprotection.DppBaseResourceList{ - // Value: []*armdataprotection.DppBaseResource{ - // { - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/updateProtectedItemRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/updateProtectedItemRequests/default"), - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetDefaultDisableSoftDeleteRequests.json -func ExampleResourceGuardsClient_GetDefaultDisableSoftDeleteRequestsObject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().GetDefaultDisableSoftDeleteRequestsObject(ctx, "SampleResourceGroup", "swaggerExample", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DppBaseResource = armdataprotection.DppBaseResource{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/disableSoftDeleteRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/disableSoftDeleteRequests/default"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetDefaultDeleteResourceGuardProxyRequests.json -func ExampleResourceGuardsClient_GetDefaultDeleteResourceGuardProxyRequestsObject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().GetDefaultDeleteResourceGuardProxyRequestsObject(ctx, "SampleResourceGroup", "swaggerExample", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DppBaseResource = armdataprotection.DppBaseResource{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteResourceGuardProxyRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/deleteResourceGuardProxyRequests/default"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetDefaultBackupSecurityPINRequests.json -func ExampleResourceGuardsClient_GetDefaultBackupSecurityPINRequestsObject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().GetDefaultBackupSecurityPINRequestsObject(ctx, "SampleResourceGroup", "swaggerExample", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DppBaseResource = armdataprotection.DppBaseResource{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/getBackupSecurityPINRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/getBackupSecurityPINRequests/default"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetDefaultDeleteProtectedItemRequests.json -func ExampleResourceGuardsClient_GetDefaultDeleteProtectedItemRequestsObject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().GetDefaultDeleteProtectedItemRequestsObject(ctx, "SampleResourceGroup", "swaggerExample", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DppBaseResource = armdataprotection.DppBaseResource{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/deleteProtectedItemRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/deleteProtectedItemRequests/default"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetDefaultUpdateProtectionPolicyRequests.json -func ExampleResourceGuardsClient_GetDefaultUpdateProtectionPolicyRequestsObject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().GetDefaultUpdateProtectionPolicyRequestsObject(ctx, "SampleResourceGroup", "swaggerExample", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DppBaseResource = armdataprotection.DppBaseResource{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/updateProtectionPolicyRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/updateProtectionPolicyRequests/default"), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/ResourceGuardCRUD/GetDefaultUpdateProtectedItemRequests.json -func ExampleResourceGuardsClient_GetDefaultUpdateProtectedItemRequestsObject() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewResourceGuardsClient().GetDefaultUpdateProtectedItemRequestsObject(ctx, "SampleResourceGroup", "swaggerExample", "default", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DppBaseResource = armdataprotection.DppBaseResource{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.DataProtection/resourceGuards/updateProtectedItemRequests"), - // ID: to.Ptr("subscriotions/0b352192-dcac-4cc7-992e-a96190ccc68c/resourceGroups/SampleResourceGroup/providers/Microsoft.DataProtection/resourceGuards/swaggerExample/updateProtectedItemRequests/default"), - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/response_types.go b/sdk/resourcemanager/dataprotection/armdataprotection/response_types.go index fb6c0b00df93..09b94bd15e2f 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/response_types.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/response_types.go @@ -3,19 +3,20 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection // BackupInstancesClientAdhocBackupResponse contains the response from method BackupInstancesClient.BeginAdhocBackup. type BackupInstancesClientAdhocBackupResponse struct { + // Operation Job Extended Info OperationJobExtendedInfo } // BackupInstancesClientCreateOrUpdateResponse contains the response from method BackupInstancesClient.BeginCreateOrUpdate. type BackupInstancesClientCreateOrUpdateResponse struct { + // BackupInstance Resource BackupInstanceResource } @@ -26,16 +27,19 @@ type BackupInstancesClientDeleteResponse struct { // BackupInstancesClientGetBackupInstanceOperationResultResponse contains the response from method BackupInstancesClient.GetBackupInstanceOperationResult. type BackupInstancesClientGetBackupInstanceOperationResultResponse struct { + // BackupInstance Resource BackupInstanceResource } // BackupInstancesClientGetResponse contains the response from method BackupInstancesClient.Get. type BackupInstancesClientGetResponse struct { + // BackupInstance Resource BackupInstanceResource } // BackupInstancesClientListResponse contains the response from method BackupInstancesClient.NewListPager. type BackupInstancesClientListResponse struct { + // BackupInstance Resource list response BackupInstanceResourceList } @@ -64,6 +68,12 @@ type BackupInstancesClientSyncBackupInstanceResponse struct { // placeholder for future response values } +// BackupInstancesClientTriggerCrossRegionRestoreResponse contains the response from method BackupInstancesClient.BeginTriggerCrossRegionRestore. +type BackupInstancesClientTriggerCrossRegionRestoreResponse struct { + // Operation Job Extended Info + OperationJobExtendedInfo +} + // BackupInstancesClientTriggerRehydrateResponse contains the response from method BackupInstancesClient.BeginTriggerRehydrate. type BackupInstancesClientTriggerRehydrateResponse struct { // placeholder for future response values @@ -71,21 +81,31 @@ type BackupInstancesClientTriggerRehydrateResponse struct { // BackupInstancesClientTriggerRestoreResponse contains the response from method BackupInstancesClient.BeginTriggerRestore. type BackupInstancesClientTriggerRestoreResponse struct { + // Operation Job Extended Info + OperationJobExtendedInfo +} + +// BackupInstancesClientValidateCrossRegionRestoreResponse contains the response from method BackupInstancesClient.BeginValidateCrossRegionRestore. +type BackupInstancesClientValidateCrossRegionRestoreResponse struct { + // Operation Job Extended Info OperationJobExtendedInfo } // BackupInstancesClientValidateForBackupResponse contains the response from method BackupInstancesClient.BeginValidateForBackup. type BackupInstancesClientValidateForBackupResponse struct { + // Operation Job Extended Info OperationJobExtendedInfo } // BackupInstancesClientValidateForRestoreResponse contains the response from method BackupInstancesClient.BeginValidateForRestore. type BackupInstancesClientValidateForRestoreResponse struct { + // Operation Job Extended Info OperationJobExtendedInfo } // BackupPoliciesClientCreateOrUpdateResponse contains the response from method BackupPoliciesClient.CreateOrUpdate. type BackupPoliciesClientCreateOrUpdateResponse struct { + // BaseBackupPolicy resource BaseBackupPolicyResource } @@ -96,17 +116,21 @@ type BackupPoliciesClientDeleteResponse struct { // BackupPoliciesClientGetResponse contains the response from method BackupPoliciesClient.Get. type BackupPoliciesClientGetResponse struct { + // BaseBackupPolicy resource BaseBackupPolicyResource } // BackupPoliciesClientListResponse contains the response from method BackupPoliciesClient.NewListPager. type BackupPoliciesClientListResponse struct { + // List of BaseBackupPolicy resources BaseBackupPolicyResourceList } // BackupVaultOperationResultsClientGetResponse contains the response from method BackupVaultOperationResultsClient.Get. type BackupVaultOperationResultsClientGetResponse struct { + // Backup Vault Resource BackupVaultResource + // AzureAsyncOperation contains the information returned from the Azure-AsyncOperation header response. AzureAsyncOperation *string @@ -119,11 +143,13 @@ type BackupVaultOperationResultsClientGetResponse struct { // BackupVaultsClientCheckNameAvailabilityResponse contains the response from method BackupVaultsClient.CheckNameAvailability. type BackupVaultsClientCheckNameAvailabilityResponse struct { + // CheckNameAvailability Result CheckNameAvailabilityResult } // BackupVaultsClientCreateOrUpdateResponse contains the response from method BackupVaultsClient.BeginCreateOrUpdate. type BackupVaultsClientCreateOrUpdateResponse struct { + // Backup Vault Resource BackupVaultResource } @@ -134,26 +160,31 @@ type BackupVaultsClientDeleteResponse struct { // BackupVaultsClientGetInResourceGroupResponse contains the response from method BackupVaultsClient.NewGetInResourceGroupPager. type BackupVaultsClientGetInResourceGroupResponse struct { + // List of BackupVault resources BackupVaultResourceList } // BackupVaultsClientGetInSubscriptionResponse contains the response from method BackupVaultsClient.NewGetInSubscriptionPager. type BackupVaultsClientGetInSubscriptionResponse struct { + // List of BackupVault resources BackupVaultResourceList } // BackupVaultsClientGetResponse contains the response from method BackupVaultsClient.Get. type BackupVaultsClientGetResponse struct { + // Backup Vault Resource BackupVaultResource } // BackupVaultsClientUpdateResponse contains the response from method BackupVaultsClient.BeginUpdate. type BackupVaultsClientUpdateResponse struct { + // Backup Vault Resource BackupVaultResource } // ClientCheckFeatureSupportResponse contains the response from method Client.CheckFeatureSupport. type ClientCheckFeatureSupportResponse struct { + // Base class for Backup Feature support FeatureValidationResponseBaseClassification } @@ -167,13 +198,27 @@ func (c *ClientCheckFeatureSupportResponse) UnmarshalJSON(data []byte) error { return nil } +// CrossRegionRestoreJobClientGetResponse contains the response from method CrossRegionRestoreJobClient.Get. +type CrossRegionRestoreJobClientGetResponse struct { + // AzureBackup Job Resource Class + AzureBackupJobResource +} + +// CrossRegionRestoreJobsClientListResponse contains the response from method CrossRegionRestoreJobsClient.NewListPager. +type CrossRegionRestoreJobsClientListResponse struct { + // List of AzureBackup Job resources + AzureBackupJobResourceList +} + // DeletedBackupInstancesClientGetResponse contains the response from method DeletedBackupInstancesClient.Get. type DeletedBackupInstancesClientGetResponse struct { + // Deleted Backup Instance DeletedBackupInstanceResource } // DeletedBackupInstancesClientListResponse contains the response from method DeletedBackupInstancesClient.NewListPager. type DeletedBackupInstancesClientListResponse struct { + // List of DeletedBackupInstance resources DeletedBackupInstanceResourceList } @@ -184,6 +229,7 @@ type DeletedBackupInstancesClientUndeleteResponse struct { // DppResourceGuardProxyClientCreateOrUpdateResponse contains the response from method DppResourceGuardProxyClient.CreateOrUpdate. type DppResourceGuardProxyClientCreateOrUpdateResponse struct { + // ResourceGuardProxyBaseResource object, used for response and request bodies for ResourceGuardProxy APIs ResourceGuardProxyBaseResource } @@ -194,16 +240,19 @@ type DppResourceGuardProxyClientDeleteResponse struct { // DppResourceGuardProxyClientGetResponse contains the response from method DppResourceGuardProxyClient.Get. type DppResourceGuardProxyClientGetResponse struct { + // ResourceGuardProxyBaseResource object, used for response and request bodies for ResourceGuardProxy APIs ResourceGuardProxyBaseResource } // DppResourceGuardProxyClientListResponse contains the response from method DppResourceGuardProxyClient.NewListPager. type DppResourceGuardProxyClientListResponse struct { + // List of ResourceGuardProxyBase resources ResourceGuardProxyBaseResourceList } // DppResourceGuardProxyClientUnlockDeleteResponse contains the response from method DppResourceGuardProxyClient.UnlockDelete. type DppResourceGuardProxyClientUnlockDeleteResponse struct { + // Response of Unlock Delete API. UnlockDeleteResponse } @@ -214,22 +263,27 @@ type ExportJobsClientTriggerResponse struct { // ExportJobsOperationResultClientGetResponse contains the response from method ExportJobsOperationResultClient.Get. type ExportJobsOperationResultClientGetResponse struct { + // The result for export jobs containing blob details. ExportJobsResult } // JobsClientGetResponse contains the response from method JobsClient.Get. type JobsClientGetResponse struct { + // AzureBackup Job Resource Class AzureBackupJobResource } // JobsClientListResponse contains the response from method JobsClient.NewListPager. type JobsClientListResponse struct { + // List of AzureBackup Job resources AzureBackupJobResourceList } // OperationResultClientGetResponse contains the response from method OperationResultClient.Get. type OperationResultClientGetResponse struct { + // Operation Job Extended Info OperationJobExtendedInfo + // AzureAsyncOperation contains the information returned from the Azure-AsyncOperation header response. AzureAsyncOperation *string @@ -242,31 +296,37 @@ type OperationResultClientGetResponse struct { // OperationStatusBackupVaultContextClientGetResponse contains the response from method OperationStatusBackupVaultContextClient.Get. type OperationStatusBackupVaultContextClientGetResponse struct { + // Operation Resource OperationResource } // OperationStatusClientGetResponse contains the response from method OperationStatusClient.Get. type OperationStatusClientGetResponse struct { + // Operation Resource OperationResource } // OperationStatusResourceGroupContextClientGetResponse contains the response from method OperationStatusResourceGroupContextClient.Get. type OperationStatusResourceGroupContextClientGetResponse struct { + // Operation Resource OperationResource } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // Operations List response which contains list of available APIs. ClientDiscoveryResponse } // RecoveryPointsClientGetResponse contains the response from method RecoveryPointsClient.Get. type RecoveryPointsClientGetResponse struct { + // Azure backup recoveryPoint resource AzureBackupRecoveryPointResource } // RecoveryPointsClientListResponse contains the response from method RecoveryPointsClient.NewListPager. type RecoveryPointsClientListResponse struct { + // Azure backup recoveryPoint resource list AzureBackupRecoveryPointResourceList } @@ -277,61 +337,73 @@ type ResourceGuardsClientDeleteResponse struct { // ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse contains the response from method ResourceGuardsClient.NewGetBackupSecurityPINRequestsObjectsPager. type ResourceGuardsClientGetBackupSecurityPINRequestsObjectsResponse struct { + // Base for all lists of V2 resources. DppBaseResourceList } // ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse contains the response from method ResourceGuardsClient.GetDefaultBackupSecurityPINRequestsObject. type ResourceGuardsClientGetDefaultBackupSecurityPINRequestsObjectResponse struct { + // Base resource under Microsoft.DataProtection provider namespace DppBaseResource } // ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse contains the response from method ResourceGuardsClient.GetDefaultDeleteProtectedItemRequestsObject. type ResourceGuardsClientGetDefaultDeleteProtectedItemRequestsObjectResponse struct { + // Base resource under Microsoft.DataProtection provider namespace DppBaseResource } // ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse contains the response from method ResourceGuardsClient.GetDefaultDeleteResourceGuardProxyRequestsObject. type ResourceGuardsClientGetDefaultDeleteResourceGuardProxyRequestsObjectResponse struct { + // Base resource under Microsoft.DataProtection provider namespace DppBaseResource } // ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse contains the response from method ResourceGuardsClient.GetDefaultDisableSoftDeleteRequestsObject. type ResourceGuardsClientGetDefaultDisableSoftDeleteRequestsObjectResponse struct { + // Base resource under Microsoft.DataProtection provider namespace DppBaseResource } // ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse contains the response from method ResourceGuardsClient.GetDefaultUpdateProtectedItemRequestsObject. type ResourceGuardsClientGetDefaultUpdateProtectedItemRequestsObjectResponse struct { + // Base resource under Microsoft.DataProtection provider namespace DppBaseResource } // ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse contains the response from method ResourceGuardsClient.GetDefaultUpdateProtectionPolicyRequestsObject. type ResourceGuardsClientGetDefaultUpdateProtectionPolicyRequestsObjectResponse struct { + // Base resource under Microsoft.DataProtection provider namespace DppBaseResource } // ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse contains the response from method ResourceGuardsClient.NewGetDeleteProtectedItemRequestsObjectsPager. type ResourceGuardsClientGetDeleteProtectedItemRequestsObjectsResponse struct { + // Base for all lists of V2 resources. DppBaseResourceList } // ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse contains the response from method ResourceGuardsClient.NewGetDeleteResourceGuardProxyRequestsObjectsPager. type ResourceGuardsClientGetDeleteResourceGuardProxyRequestsObjectsResponse struct { + // Base for all lists of V2 resources. DppBaseResourceList } // ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse contains the response from method ResourceGuardsClient.NewGetDisableSoftDeleteRequestsObjectsPager. type ResourceGuardsClientGetDisableSoftDeleteRequestsObjectsResponse struct { + // Base for all lists of V2 resources. DppBaseResourceList } // ResourceGuardsClientGetResourcesInResourceGroupResponse contains the response from method ResourceGuardsClient.NewGetResourcesInResourceGroupPager. type ResourceGuardsClientGetResourcesInResourceGroupResponse struct { + // List of ResourceGuard resources ResourceGuardResourceList } // ResourceGuardsClientGetResourcesInSubscriptionResponse contains the response from method ResourceGuardsClient.NewGetResourcesInSubscriptionPager. type ResourceGuardsClientGetResourcesInSubscriptionResponse struct { + // List of ResourceGuard resources ResourceGuardResourceList } @@ -342,11 +414,13 @@ type ResourceGuardsClientGetResponse struct { // ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse contains the response from method ResourceGuardsClient.NewGetUpdateProtectedItemRequestsObjectsPager. type ResourceGuardsClientGetUpdateProtectedItemRequestsObjectsResponse struct { + // Base for all lists of V2 resources. DppBaseResourceList } // ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse contains the response from method ResourceGuardsClient.NewGetUpdateProtectionPolicyRequestsObjectsPager. type ResourceGuardsClientGetUpdateProtectionPolicyRequestsObjectsResponse struct { + // Base for all lists of V2 resources. DppBaseResourceList } @@ -362,5 +436,12 @@ type ResourceGuardsClientPutResponse struct { // RestorableTimeRangesClientFindResponse contains the response from method RestorableTimeRangesClient.Find. type RestorableTimeRangesClientFindResponse struct { + // List Restore Ranges Response AzureBackupFindRestorableTimeRangesResponseResource } + +// SecondaryRPsClientFetchResponse contains the response from method SecondaryRPsClient.NewFetchPager. +type SecondaryRPsClientFetchResponse struct { + // Azure backup recoveryPoint resource list + AzureBackupRecoveryPointResourceList +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/restorabletimeranges_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/restorabletimeranges_client.go index cce7f9553b08..ae5aba916be7 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/restorabletimeranges_client.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/restorabletimeranges_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -33,7 +32,7 @@ type RestorableTimeRangesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewRestorableTimeRangesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*RestorableTimeRangesClient, error) { - cl, err := arm.NewClient(moduleName+".RestorableTimeRangesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,7 +46,7 @@ func NewRestorableTimeRangesClient(subscriptionID string, credential azcore.Toke // Find - // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-05-01 +// Generated from API version 2023-11-01 // - resourceGroupName - The name of the resource group. The name is case insensitive. // - vaultName - The name of the backup vault. // - backupInstanceName - The name of the backup instance. @@ -55,23 +54,33 @@ func NewRestorableTimeRangesClient(subscriptionID string, credential azcore.Toke // - options - RestorableTimeRangesClientFindOptions contains the optional parameters for the RestorableTimeRangesClient.Find // method. func (client *RestorableTimeRangesClient) Find(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters AzureBackupFindRestorableTimeRangesRequest, options *RestorableTimeRangesClientFindOptions) (RestorableTimeRangesClientFindResponse, error) { + var err error + const operationName = "RestorableTimeRangesClient.Find" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.findCreateRequest(ctx, resourceGroupName, vaultName, backupInstanceName, parameters, options) if err != nil { return RestorableTimeRangesClientFindResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return RestorableTimeRangesClientFindResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return RestorableTimeRangesClientFindResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return RestorableTimeRangesClientFindResponse{}, err } - return client.findHandleResponse(resp) + resp, err := client.findHandleResponse(httpResp) + return resp, err } // findCreateRequest creates the Find request. func (client *RestorableTimeRangesClient) findCreateRequest(ctx context.Context, resourceGroupName string, vaultName string, backupInstanceName string, parameters AzureBackupFindRestorableTimeRangesRequest, options *RestorableTimeRangesClientFindOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/backupVaults/{vaultName}/backupInstances/{backupInstanceName}/findRestorableTimeRanges" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) if resourceGroupName == "" { return nil, errors.New("parameter resourceGroupName cannot be empty") @@ -90,10 +99,13 @@ func (client *RestorableTimeRangesClient) findCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2023-05-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // findHandleResponse handles the Find response. diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/restorabletimeranges_client_example_test.go b/sdk/resourcemanager/dataprotection/armdataprotection/restorabletimeranges_client_example_test.go deleted file mode 100644 index 19f3bad3a09a..000000000000 --- a/sdk/resourcemanager/dataprotection/armdataprotection/restorabletimeranges_client_example_test.go +++ /dev/null @@ -1,56 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armdataprotection_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/c53808ba54beef57059371708f1fa6949a11a280/specification/dataprotection/resource-manager/Microsoft.DataProtection/stable/2023-05-01/examples/BackupInstanceOperations/FindRestorableTimeRanges.json -func ExampleRestorableTimeRangesClient_Find() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armdataprotection.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewRestorableTimeRangesClient().Find(ctx, "Blob-Backup", "ZBlobBackupVaultBVTD3", "zblobbackuptestsa58", armdataprotection.AzureBackupFindRestorableTimeRangesRequest{ - EndTime: to.Ptr("2021-02-24T00:35:17.6829685Z"), - SourceDataStoreType: to.Ptr(armdataprotection.RestoreSourceDataStoreTypeOperationalStore), - StartTime: to.Ptr("2020-10-17T23:28:17.6829685Z"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AzureBackupFindRestorableTimeRangesResponseResource = armdataprotection.AzureBackupFindRestorableTimeRangesResponseResource{ - // Type: to.Ptr("Microsoft.DataProtection/backupVaults/backupInstances/findRestorableTimeRanges"), - // ID: to.Ptr("zblobbackuptestsa58"), - // Properties: &armdataprotection.AzureBackupFindRestorableTimeRangesResponse{ - // ObjectType: to.Ptr("AzureBackupFindRestorableTimeRangesResponse"), - // RestorableTimeRanges: []*armdataprotection.RestorableTimeRange{ - // { - // EndTime: to.Ptr("2021-02-24T00:35:17.0000000Z"), - // ObjectType: to.Ptr("RestorableTimeRange"), - // StartTime: to.Ptr("2021-02-23T18:33:51.6349708Z"), - // }}, - // }, - // } -} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/secondaryrps_client.go b/sdk/resourcemanager/dataprotection/armdataprotection/secondaryrps_client.go new file mode 100644 index 000000000000..042763718cf4 --- /dev/null +++ b/sdk/resourcemanager/dataprotection/armdataprotection/secondaryrps_client.go @@ -0,0 +1,118 @@ +//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 armdataprotection + +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" +) + +// SecondaryRPsClient contains the methods for the SecondaryRPs group. +// Don't use this type directly, use NewSecondaryRPsClient() instead. +type SecondaryRPsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewSecondaryRPsClient creates a new instance of SecondaryRPsClient 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 NewSecondaryRPsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecondaryRPsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SecondaryRPsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewFetchPager - Returns a list of Secondary Recovery Points for a DataSource in a vault, that can be used for Cross Region +// Restore. +// +// Generated from API version 2023-11-01 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - parameters - Request body for operation +// - options - SecondaryRPsClientFetchOptions contains the optional parameters for the SecondaryRPsClient.NewFetchPager method. +func (client *SecondaryRPsClient) NewFetchPager(resourceGroupName string, location string, parameters FetchSecondaryRPsRequestParameters, options *SecondaryRPsClientFetchOptions) *runtime.Pager[SecondaryRPsClientFetchResponse] { + return runtime.NewPager(runtime.PagingHandler[SecondaryRPsClientFetchResponse]{ + More: func(page SecondaryRPsClientFetchResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SecondaryRPsClientFetchResponse) (SecondaryRPsClientFetchResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SecondaryRPsClient.NewFetchPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.fetchCreateRequest(ctx, resourceGroupName, location, parameters, options) + }, nil) + if err != nil { + return SecondaryRPsClientFetchResponse{}, err + } + return client.fetchHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// fetchCreateRequest creates the Fetch request. +func (client *SecondaryRPsClient) fetchCreateRequest(ctx context.Context, resourceGroupName string, location string, parameters FetchSecondaryRPsRequestParameters, options *SecondaryRPsClientFetchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataProtection/locations/{location}/fetchSecondaryRecoveryPoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if 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", "2023-11-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.SkipToken != nil { + reqQP.Set("$skipToken", *options.SkipToken) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// fetchHandleResponse handles the Fetch response. +func (client *SecondaryRPsClient) fetchHandleResponse(resp *http.Response) (SecondaryRPsClientFetchResponse, error) { + result := SecondaryRPsClientFetchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AzureBackupRecoveryPointResourceList); err != nil { + return SecondaryRPsClientFetchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/time_rfc3339.go b/sdk/resourcemanager/dataprotection/armdataprotection/time_rfc3339.go index 8ee2848040f9..32fa29f1a250 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/time_rfc3339.go +++ b/sdk/resourcemanager/dataprotection/armdataprotection/time_rfc3339.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armdataprotection @@ -19,50 +18,50 @@ import ( "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 +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) }