From d18c32d6e61503aaeb0bb445a06918d2ae141e80 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Thu, 8 Jun 2023 10:18:58 -0700 Subject: [PATCH 1/2] armstorage 1.4.0-beta.1 release --- .../storage/armstorage/CHANGELOG.md | 6 + .../storage/armstorage/README.md | 25 + .../storage/armstorage/accounts_client.go | 256 +++- .../storage/armstorage/autorest.md | 8 +- .../armstorage/blobcontainers_client.go | 234 ++- .../blobinventorypolicies_client.go | 52 +- .../storage/armstorage/blobservices_client.go | 40 +- .../storage/armstorage/build.go | 2 +- .../storage/armstorage/client_factory.go | 3 +- .../storage/armstorage/constants.go | 45 +- .../armstorage/deletedaccounts_client.go | 20 +- .../armstorage/encryptionscopes_client.go | 60 +- .../armstorage/fake/accounts_server.go | 667 ++++++++ .../armstorage/fake/blobcontainers_server.go | 593 ++++++++ .../fake/blobinventorypolicies_server.go | 191 +++ .../armstorage/fake/blobservices_server.go | 160 ++ .../armstorage/fake/deletedaccounts_server.go | 129 ++ .../fake/encryptionscopes_server.go | 221 +++ .../armstorage/fake/fileservices_server.go | 157 ++ .../armstorage/fake/fileshares_server.go | 352 +++++ .../storage/armstorage/fake/internal.go | 78 + .../armstorage/fake/localusers_server.go | 253 ++++ .../fake/managementpolicies_server.go | 157 ++ .../fake/objectreplicationpolicies_server.go | 191 +++ .../armstorage/fake/operations_server.go | 86 ++ .../fake/privateendpointconnections_server.go | 191 +++ .../fake/privatelinkresources_server.go | 91 ++ .../storage/armstorage/fake/queue_server.go | 240 +++ .../armstorage/fake/queueservices_server.go | 157 ++ .../storage/armstorage/fake/skus_server.go | 93 ++ .../storage/armstorage/fake/table_server.go | 243 +++ .../armstorage/fake/tableservices_server.go | 157 ++ .../storage/armstorage/fake/time_rfc3339.go | 86 ++ .../storage/armstorage/fake/usages_server.go | 93 ++ .../storage/armstorage/fileservices_client.go | 53 +- .../storage/armstorage/fileshares_client.go | 109 +- sdk/resourcemanager/storage/armstorage/go.mod | 10 +- sdk/resourcemanager/storage/armstorage/go.sum | 20 +- .../storage/armstorage/localusers_client.go | 82 +- .../armstorage/managementpolicies_client.go | 50 +- .../storage/armstorage/models.go | 1347 ++++++++--------- .../storage/armstorage/models_serde.go | 3 +- .../objectreplicationpolicies_client.go | 52 +- .../storage/armstorage/operations_client.go | 5 +- .../privateendpointconnections_client.go | 52 +- .../armstorage/privatelinkresources_client.go | 18 +- .../storage/armstorage/queue_client.go | 72 +- .../armstorage/queueservices_client.go | 53 +- .../storage/armstorage/response_types.go | 3 +- .../storage/armstorage/skus_client.go | 5 +- .../storage/armstorage/table_client.go | 72 +- .../armstorage/tableservices_client.go | 53 +- .../storage/armstorage/time_rfc3339.go | 3 +- .../storage/armstorage/usages_client.go | 5 +- 54 files changed, 6318 insertions(+), 1086 deletions(-) create mode 100644 sdk/resourcemanager/storage/armstorage/fake/accounts_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/internal.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/localusers_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/operations_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/queue_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/skus_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/table_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/storage/armstorage/fake/usages_server.go diff --git a/sdk/resourcemanager/storage/armstorage/CHANGELOG.md b/sdk/resourcemanager/storage/armstorage/CHANGELOG.md index 3c41d4cacd83..0f3a865aafc3 100644 --- a/sdk/resourcemanager/storage/armstorage/CHANGELOG.md +++ b/sdk/resourcemanager/storage/armstorage/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.4.0-beta.1 (2023-06-08) + +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + ## 1.3.0 (2023-03-27) ### Features Added diff --git a/sdk/resourcemanager/storage/armstorage/README.md b/sdk/resourcemanager/storage/armstorage/README.md index ebc9171001d7..d55a2d64c97b 100644 --- a/sdk/resourcemanager/storage/armstorage/README.md +++ b/sdk/resourcemanager/storage/armstorage/README.md @@ -60,6 +60,31 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewAccountsClient() ``` +## Fakes +The `fake` package provides implementations for fake servers that can be used for testing. +To create a fake server, declare an instance of the required fake server type(s). +```go +myFakeAccountsServer := fake.AccountsServer{} +``` +Next, provide func implementations for the methods you wish to fake. +The named return variables can be used to simplify return value construction. +```go +myFakeAccountsServer.GetProperties = func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientGetPropertiesOptions) (resp azfake.Responder[armstorage.AccountsClientGetPropertiesResponse], errResp azfake.ErrorResponder) { + // TODO: resp.SetResponse(/* your fake AccountsClientGetPropertiesResponse response */) + return +} +``` +You connect the fake server to a client instance during construction through the optional transport. +Use `NewTokenCredential()` from `azcore/fake` to obtain a fake credential. +```go +import azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" +client, err := armstorage.NewAccountsClient("subscriptionID", azfake.NewTokenCredential(), &arm.ClientOptions{ + ClientOptions: azcore.ClientOptions{ + Transport: fake.NewAccountsServerTransport(&myFakeAccountsServer), + }, +}) +``` + ## More sample code - [Blob](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/storage/blob) diff --git a/sdk/resourcemanager/storage/armstorage/accounts_client.go b/sdk/resourcemanager/storage/armstorage/accounts_client.go index ad4cfd9016af..9e1f4d1d34a2 100644 --- a/sdk/resourcemanager/storage/armstorage/accounts_client.go +++ b/sdk/resourcemanager/storage/armstorage/accounts_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 armstorage @@ -59,9 +58,10 @@ func (client *AccountsClient) BeginAbortHierarchicalNamespaceMigration(ctx conte if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientAbortHierarchicalNamespaceMigrationResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientAbortHierarchicalNamespaceMigrationResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[AccountsClientAbortHierarchicalNamespaceMigrationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -72,18 +72,24 @@ func (client *AccountsClient) BeginAbortHierarchicalNamespaceMigration(ctx conte // // Generated from API version 2022-09-01 func (client *AccountsClient) abortHierarchicalNamespaceMigration(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginAbortHierarchicalNamespaceMigrationOptions) (*http.Response, error) { + var err error + const operationName = "AccountsClient.BeginAbortHierarchicalNamespaceMigration" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.abortHierarchicalNamespaceMigrationCreateRequest(ctx, resourceGroupName, accountName, 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 } // abortHierarchicalNamespaceMigrationCreateRequest creates the AbortHierarchicalNamespaceMigration request. @@ -121,18 +127,25 @@ func (client *AccountsClient) abortHierarchicalNamespaceMigrationCreateRequest(c // - options - AccountsClientCheckNameAvailabilityOptions contains the optional parameters for the AccountsClient.CheckNameAvailability // method. func (client *AccountsClient) CheckNameAvailability(ctx context.Context, accountName AccountCheckNameAvailabilityParameters, options *AccountsClientCheckNameAvailabilityOptions) (AccountsClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "AccountsClient.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, accountName, options) if err != nil { return AccountsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientCheckNameAvailabilityResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientCheckNameAvailabilityResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientCheckNameAvailabilityResponse{}, err } - return client.checkNameAvailabilityHandleResponse(resp) + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. @@ -150,7 +163,10 @@ func (client *AccountsClient) checkNameAvailabilityCreateRequest(ctx context.Con reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, accountName) + if err := runtime.MarshalAsJSON(req, accountName); err != nil { + return nil, err + } + return req, nil } // checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. @@ -180,7 +196,8 @@ func (client *AccountsClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[AccountsClientCreateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[AccountsClientCreateResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[AccountsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -194,18 +211,24 @@ func (client *AccountsClient) BeginCreate(ctx context.Context, resourceGroupName // // Generated from API version 2022-09-01 func (client *AccountsClient) create(ctx context.Context, resourceGroupName string, accountName string, parameters AccountCreateParameters, options *AccountsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "AccountsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, 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 } // createCreateRequest creates the Create request. @@ -231,7 +254,10 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2022-09-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 } // Delete - Deletes a storage account in Microsoft Azure. @@ -243,16 +269,22 @@ func (client *AccountsClient) createCreateRequest(ctx context.Context, resourceG // 3 and 24 characters in length and use numbers and lower-case letters only. // - options - AccountsClientDeleteOptions contains the optional parameters for the AccountsClient.Delete method. func (client *AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientDeleteOptions) (AccountsClientDeleteResponse, error) { + var err error + const operationName = "AccountsClient.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, accountName, options) if err != nil { return AccountsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return AccountsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return AccountsClientDeleteResponse{}, err } return AccountsClientDeleteResponse{}, nil } @@ -304,9 +336,10 @@ func (client *AccountsClient) BeginFailover(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientFailoverResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientFailoverResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[AccountsClientFailoverResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -325,18 +358,24 @@ func (client *AccountsClient) BeginFailover(ctx context.Context, resourceGroupNa // // Generated from API version 2022-09-01 func (client *AccountsClient) failover(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientBeginFailoverOptions) (*http.Response, error) { + var err error + const operationName = "AccountsClient.BeginFailover" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.failoverCreateRequest(ctx, resourceGroupName, accountName, 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 } // failoverCreateRequest creates the Failover request. @@ -377,18 +416,25 @@ func (client *AccountsClient) failoverCreateRequest(ctx context.Context, resourc // 3 and 24 characters in length and use numbers and lower-case letters only. // - options - AccountsClientGetPropertiesOptions contains the optional parameters for the AccountsClient.GetProperties method. func (client *AccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientGetPropertiesOptions) (AccountsClientGetPropertiesResponse, error) { + var err error + const operationName = "AccountsClient.GetProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getPropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -447,9 +493,10 @@ func (client *AccountsClient) BeginHierarchicalNamespaceMigration(ctx context.Co if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientHierarchicalNamespaceMigrationResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientHierarchicalNamespaceMigrationResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[AccountsClientHierarchicalNamespaceMigrationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -460,18 +507,24 @@ func (client *AccountsClient) BeginHierarchicalNamespaceMigration(ctx context.Co // // Generated from API version 2022-09-01 func (client *AccountsClient) hierarchicalNamespaceMigration(ctx context.Context, resourceGroupName string, accountName string, requestType string, options *AccountsClientBeginHierarchicalNamespaceMigrationOptions) (*http.Response, error) { + var err error + const operationName = "AccountsClient.BeginHierarchicalNamespaceMigration" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.hierarchicalNamespaceMigrationCreateRequest(ctx, resourceGroupName, accountName, requestType, 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 } // hierarchicalNamespaceMigrationCreateRequest creates the HierarchicalNamespaceMigration request. @@ -512,6 +565,7 @@ func (client *AccountsClient) NewListPager(options *AccountsClientListOptions) * return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *AccountsClientListResponse) (AccountsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AccountsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -531,6 +585,7 @@ func (client *AccountsClient) NewListPager(options *AccountsClientListOptions) * } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -571,18 +626,25 @@ func (client *AccountsClient) listHandleResponse(resp *http.Response) (AccountsC // - parameters - The parameters to provide to list SAS credentials for the storage account. // - options - AccountsClientListAccountSASOptions contains the optional parameters for the AccountsClient.ListAccountSAS method. func (client *AccountsClient) ListAccountSAS(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters, options *AccountsClientListAccountSASOptions) (AccountsClientListAccountSASResponse, error) { + var err error + const operationName = "AccountsClient.ListAccountSAS" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listAccountSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return AccountsClientListAccountSASResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListAccountSASResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientListAccountSASResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientListAccountSASResponse{}, err } - return client.listAccountSASHandleResponse(resp) + resp, err := client.listAccountSASHandleResponse(httpResp) + return resp, err } // listAccountSASCreateRequest creates the ListAccountSAS request. @@ -608,7 +670,10 @@ func (client *AccountsClient) listAccountSASCreateRequest(ctx context.Context, r reqQP.Set("api-version", "2022-09-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 } // listAccountSASHandleResponse handles the ListAccountSAS response. @@ -633,6 +698,7 @@ func (client *AccountsClient) NewListByResourceGroupPager(resourceGroupName stri return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *AccountsClientListByResourceGroupResponse) (AccountsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AccountsClient.NewListByResourceGroupPager") var req *policy.Request var err error if page == nil { @@ -652,6 +718,7 @@ func (client *AccountsClient) NewListByResourceGroupPager(resourceGroupName stri } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -695,18 +762,25 @@ func (client *AccountsClient) listByResourceGroupHandleResponse(resp *http.Respo // 3 and 24 characters in length and use numbers and lower-case letters only. // - options - AccountsClientListKeysOptions contains the optional parameters for the AccountsClient.ListKeys method. func (client *AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientListKeysOptions) (AccountsClientListKeysResponse, error) { + var err error + const operationName = "AccountsClient.ListKeys" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientListKeysResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListKeysResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientListKeysResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientListKeysResponse{}, err } - return client.listKeysHandleResponse(resp) + resp, err := client.listKeysHandleResponse(httpResp) + return resp, err } // listKeysCreateRequest creates the ListKeys request. @@ -757,18 +831,25 @@ func (client *AccountsClient) listKeysHandleResponse(resp *http.Response) (Accou // - parameters - The parameters to provide to list service SAS credentials. // - options - AccountsClientListServiceSASOptions contains the optional parameters for the AccountsClient.ListServiceSAS method. func (client *AccountsClient) ListServiceSAS(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters, options *AccountsClientListServiceSASOptions) (AccountsClientListServiceSASResponse, error) { + var err error + const operationName = "AccountsClient.ListServiceSAS" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listServiceSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return AccountsClientListServiceSASResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientListServiceSASResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientListServiceSASResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientListServiceSASResponse{}, err } - return client.listServiceSASHandleResponse(resp) + resp, err := client.listServiceSASHandleResponse(httpResp) + return resp, err } // listServiceSASCreateRequest creates the ListServiceSAS request. @@ -794,7 +875,10 @@ func (client *AccountsClient) listServiceSASCreateRequest(ctx context.Context, r reqQP.Set("api-version", "2022-09-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 } // listServiceSASHandleResponse handles the ListServiceSAS response. @@ -816,18 +900,25 @@ func (client *AccountsClient) listServiceSASHandleResponse(resp *http.Response) // - regenerateKey - Specifies name of the key which should be regenerated -- key1, key2, kerb1, kerb2. // - options - AccountsClientRegenerateKeyOptions contains the optional parameters for the AccountsClient.RegenerateKey method. func (client *AccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters, options *AccountsClientRegenerateKeyOptions) (AccountsClientRegenerateKeyResponse, error) { + var err error + const operationName = "AccountsClient.RegenerateKey" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.regenerateKeyCreateRequest(ctx, resourceGroupName, accountName, regenerateKey, options) if err != nil { return AccountsClientRegenerateKeyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientRegenerateKeyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientRegenerateKeyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientRegenerateKeyResponse{}, err } - return client.regenerateKeyHandleResponse(resp) + resp, err := client.regenerateKeyHandleResponse(httpResp) + return resp, err } // regenerateKeyCreateRequest creates the RegenerateKey request. @@ -853,7 +944,10 @@ func (client *AccountsClient) regenerateKeyCreateRequest(ctx context.Context, re reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, regenerateKey) + if err := runtime.MarshalAsJSON(req, regenerateKey); err != nil { + return nil, err + } + return req, nil } // regenerateKeyHandleResponse handles the RegenerateKey response. @@ -881,9 +975,10 @@ func (client *AccountsClient) BeginRestoreBlobRanges(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientRestoreBlobRangesResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AccountsClientRestoreBlobRangesResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[AccountsClientRestoreBlobRangesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -894,18 +989,24 @@ func (client *AccountsClient) BeginRestoreBlobRanges(ctx context.Context, resour // // Generated from API version 2022-09-01 func (client *AccountsClient) restoreBlobRanges(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *AccountsClientBeginRestoreBlobRangesOptions) (*http.Response, error) { + var err error + const operationName = "AccountsClient.BeginRestoreBlobRanges" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.restoreBlobRangesCreateRequest(ctx, resourceGroupName, accountName, 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 } // restoreBlobRangesCreateRequest creates the RestoreBlobRanges request. @@ -931,7 +1032,10 @@ func (client *AccountsClient) restoreBlobRangesCreateRequest(ctx context.Context reqQP.Set("api-version", "2022-09-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 } // RevokeUserDelegationKeys - Revoke user delegation keys. @@ -944,16 +1048,22 @@ func (client *AccountsClient) restoreBlobRangesCreateRequest(ctx context.Context // - options - AccountsClientRevokeUserDelegationKeysOptions contains the optional parameters for the AccountsClient.RevokeUserDelegationKeys // method. func (client *AccountsClient) RevokeUserDelegationKeys(ctx context.Context, resourceGroupName string, accountName string, options *AccountsClientRevokeUserDelegationKeysOptions) (AccountsClientRevokeUserDelegationKeysResponse, error) { + var err error + const operationName = "AccountsClient.RevokeUserDelegationKeys" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.revokeUserDelegationKeysCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return AccountsClientRevokeUserDelegationKeysResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientRevokeUserDelegationKeysResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientRevokeUserDelegationKeysResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientRevokeUserDelegationKeysResponse{}, err } return AccountsClientRevokeUserDelegationKeysResponse{}, nil } @@ -999,18 +1109,25 @@ func (client *AccountsClient) revokeUserDelegationKeysCreateRequest(ctx context. // - parameters - The parameters to provide for the updated account. // - options - AccountsClientUpdateOptions contains the optional parameters for the AccountsClient.Update method. func (client *AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters, options *AccountsClientUpdateOptions) (AccountsClientUpdateResponse, error) { + var err error + const operationName = "AccountsClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return AccountsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AccountsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AccountsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AccountsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -1036,7 +1153,10 @@ func (client *AccountsClient) updateCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2022-09-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 } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/storage/armstorage/autorest.md b/sdk/resourcemanager/storage/armstorage/autorest.md index 6dcab7721e0d..bdccfd3a0d64 100644 --- a/sdk/resourcemanager/storage/armstorage/autorest.md +++ b/sdk/resourcemanager/storage/armstorage/autorest.md @@ -8,7 +8,11 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/b32e1896f30e6ea155449cb49719a6286e32b961/specification/storage/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/b32e1896f30e6ea155449cb49719a6286e32b961/specification/storage/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.3.0 +module: github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage +module-version: 1.4.0-beta.1 +azcore-version: 1.7.0-beta.2 +generate-fakes: true +inject-spans: true modelerfour: seal-single-value-enum-by-default: true -``` \ No newline at end of file +``` diff --git a/sdk/resourcemanager/storage/armstorage/blobcontainers_client.go b/sdk/resourcemanager/storage/armstorage/blobcontainers_client.go index 0aca079339a6..42a0a4fa6f06 100644 --- a/sdk/resourcemanager/storage/armstorage/blobcontainers_client.go +++ b/sdk/resourcemanager/storage/armstorage/blobcontainers_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 armstorage @@ -59,18 +58,25 @@ func NewBlobContainersClient(subscriptionID string, credential azcore.TokenCrede // - options - BlobContainersClientClearLegalHoldOptions contains the optional parameters for the BlobContainersClient.ClearLegalHold // method. func (client *BlobContainersClient) ClearLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersClientClearLegalHoldOptions) (BlobContainersClientClearLegalHoldResponse, error) { + var err error + const operationName = "BlobContainersClient.ClearLegalHold" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.clearLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) if err != nil { return BlobContainersClientClearLegalHoldResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientClearLegalHoldResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientClearLegalHoldResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientClearLegalHoldResponse{}, err } - return client.clearLegalHoldHandleResponse(resp) + resp, err := client.clearLegalHoldHandleResponse(httpResp) + return resp, err } // clearLegalHoldCreateRequest creates the ClearLegalHold request. @@ -100,7 +106,10 @@ func (client *BlobContainersClient) clearLegalHoldCreateRequest(ctx context.Cont reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, legalHold) + if err := runtime.MarshalAsJSON(req, legalHold); err != nil { + return nil, err + } + return req, nil } // clearLegalHoldHandleResponse handles the ClearLegalHold response. @@ -127,18 +136,25 @@ func (client *BlobContainersClient) clearLegalHoldHandleResponse(resp *http.Resp // - blobContainer - Properties of the blob container to create. // - options - BlobContainersClientCreateOptions contains the optional parameters for the BlobContainersClient.Create method. func (client *BlobContainersClient) Create(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersClientCreateOptions) (BlobContainersClientCreateResponse, error) { + var err error + const operationName = "BlobContainersClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) if err != nil { return BlobContainersClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return BlobContainersClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -168,7 +184,10 @@ func (client *BlobContainersClient) createCreateRequest(ctx context.Context, res reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, blobContainer) + if err := runtime.MarshalAsJSON(req, blobContainer); err != nil { + return nil, err + } + return req, nil } // createHandleResponse handles the Create response. @@ -194,18 +213,25 @@ func (client *BlobContainersClient) createHandleResponse(resp *http.Response) (B // - options - BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.CreateOrUpdateImmutabilityPolicy // method. func (client *BlobContainersClient) CreateOrUpdateImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions) (BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse, error) { + var err error + const operationName = "BlobContainersClient.CreateOrUpdateImmutabilityPolicy" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createOrUpdateImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse{}, err } - return client.createOrUpdateImmutabilityPolicyHandleResponse(resp) + resp, err := client.createOrUpdateImmutabilityPolicyHandleResponse(httpResp) + return resp, err } // createOrUpdateImmutabilityPolicyCreateRequest creates the CreateOrUpdateImmutabilityPolicy request. @@ -240,7 +266,10 @@ func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyCreateReques } req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { - return req, runtime.MarshalAsJSON(req, *options.Parameters) + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -269,16 +298,22 @@ func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyHandleRespon // dash (-) character must be immediately preceded and followed by a letter or number. // - options - BlobContainersClientDeleteOptions contains the optional parameters for the BlobContainersClient.Delete method. func (client *BlobContainersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientDeleteOptions) (BlobContainersClientDeleteResponse, error) { + var err error + const operationName = "BlobContainersClient.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, accountName, containerName, options) if err != nil { return BlobContainersClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return BlobContainersClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientDeleteResponse{}, err } return BlobContainersClientDeleteResponse{}, nil } @@ -331,18 +366,25 @@ func (client *BlobContainersClient) deleteCreateRequest(ctx context.Context, res // - options - BlobContainersClientDeleteImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.DeleteImmutabilityPolicy // method. func (client *BlobContainersClient) DeleteImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersClientDeleteImmutabilityPolicyOptions) (BlobContainersClientDeleteImmutabilityPolicyResponse, error) { + var err error + const operationName = "BlobContainersClient.DeleteImmutabilityPolicy" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { return BlobContainersClientDeleteImmutabilityPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientDeleteImmutabilityPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientDeleteImmutabilityPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientDeleteImmutabilityPolicyResponse{}, err } - return client.deleteImmutabilityPolicyHandleResponse(resp) + resp, err := client.deleteImmutabilityPolicyHandleResponse(httpResp) + return resp, err } // deleteImmutabilityPolicyCreateRequest creates the DeleteImmutabilityPolicy request. @@ -406,18 +448,25 @@ func (client *BlobContainersClient) deleteImmutabilityPolicyHandleResponse(resp // - options - BlobContainersClientExtendImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.ExtendImmutabilityPolicy // method. func (client *BlobContainersClient) ExtendImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersClientExtendImmutabilityPolicyOptions) (BlobContainersClientExtendImmutabilityPolicyResponse, error) { + var err error + const operationName = "BlobContainersClient.ExtendImmutabilityPolicy" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.extendImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { return BlobContainersClientExtendImmutabilityPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientExtendImmutabilityPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientExtendImmutabilityPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientExtendImmutabilityPolicyResponse{}, err } - return client.extendImmutabilityPolicyHandleResponse(resp) + resp, err := client.extendImmutabilityPolicyHandleResponse(httpResp) + return resp, err } // extendImmutabilityPolicyCreateRequest creates the ExtendImmutabilityPolicy request. @@ -449,7 +498,10 @@ func (client *BlobContainersClient) extendImmutabilityPolicyCreateRequest(ctx co req.Raw().Header["If-Match"] = []string{ifMatch} req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { - return req, runtime.MarshalAsJSON(req, *options.Parameters) + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -478,18 +530,25 @@ func (client *BlobContainersClient) extendImmutabilityPolicyHandleResponse(resp // dash (-) character must be immediately preceded and followed by a letter or number. // - options - BlobContainersClientGetOptions contains the optional parameters for the BlobContainersClient.Get method. func (client *BlobContainersClient) Get(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientGetOptions) (BlobContainersClientGetResponse, error) { + var err error + const operationName = "BlobContainersClient.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, accountName, containerName, options) if err != nil { return BlobContainersClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -545,18 +604,25 @@ func (client *BlobContainersClient) getHandleResponse(resp *http.Response) (Blob // - options - BlobContainersClientGetImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.GetImmutabilityPolicy // method. func (client *BlobContainersClient) GetImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientGetImmutabilityPolicyOptions) (BlobContainersClientGetImmutabilityPolicyResponse, error) { + var err error + const operationName = "BlobContainersClient.GetImmutabilityPolicy" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return BlobContainersClientGetImmutabilityPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientGetImmutabilityPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientGetImmutabilityPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientGetImmutabilityPolicyResponse{}, err } - return client.getImmutabilityPolicyHandleResponse(resp) + resp, err := client.getImmutabilityPolicyHandleResponse(httpResp) + return resp, err } // getImmutabilityPolicyCreateRequest creates the GetImmutabilityPolicy request. @@ -618,18 +684,25 @@ func (client *BlobContainersClient) getImmutabilityPolicyHandleResponse(resp *ht // dash (-) character must be immediately preceded and followed by a letter or number. // - options - BlobContainersClientLeaseOptions contains the optional parameters for the BlobContainersClient.Lease method. func (client *BlobContainersClient) Lease(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientLeaseOptions) (BlobContainersClientLeaseResponse, error) { + var err error + const operationName = "BlobContainersClient.Lease" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.leaseCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { return BlobContainersClientLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientLeaseResponse{}, err } - return client.leaseHandleResponse(resp) + resp, err := client.leaseHandleResponse(httpResp) + return resp, err } // leaseCreateRequest creates the Lease request. @@ -660,7 +733,10 @@ func (client *BlobContainersClient) leaseCreateRequest(ctx context.Context, reso req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { - return req, runtime.MarshalAsJSON(req, *options.Parameters) + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -688,6 +764,7 @@ func (client *BlobContainersClient) NewListPager(resourceGroupName string, accou return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *BlobContainersClientListResponse) (BlobContainersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BlobContainersClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -707,6 +784,7 @@ func (client *BlobContainersClient) NewListPager(resourceGroupName string, accou } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -771,18 +849,25 @@ func (client *BlobContainersClient) listHandleResponse(resp *http.Response) (Blo // - options - BlobContainersClientLockImmutabilityPolicyOptions contains the optional parameters for the BlobContainersClient.LockImmutabilityPolicy // method. func (client *BlobContainersClient) LockImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersClientLockImmutabilityPolicyOptions) (BlobContainersClientLockImmutabilityPolicyResponse, error) { + var err error + const operationName = "BlobContainersClient.LockImmutabilityPolicy" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.lockImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { return BlobContainersClientLockImmutabilityPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientLockImmutabilityPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientLockImmutabilityPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientLockImmutabilityPolicyResponse{}, err } - return client.lockImmutabilityPolicyHandleResponse(resp) + resp, err := client.lockImmutabilityPolicyHandleResponse(httpResp) + return resp, err } // lockImmutabilityPolicyCreateRequest creates the LockImmutabilityPolicy request. @@ -848,9 +933,10 @@ func (client *BlobContainersClient) BeginObjectLevelWorm(ctx context.Context, re if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BlobContainersClientObjectLevelWormResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[BlobContainersClientObjectLevelWormResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[BlobContainersClientObjectLevelWormResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -863,18 +949,24 @@ func (client *BlobContainersClient) BeginObjectLevelWorm(ctx context.Context, re // // Generated from API version 2022-09-01 func (client *BlobContainersClient) objectLevelWorm(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersClientBeginObjectLevelWormOptions) (*http.Response, error) { + var err error + const operationName = "BlobContainersClient.BeginObjectLevelWorm" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.objectLevelWormCreateRequest(ctx, resourceGroupName, accountName, containerName, 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 } // objectLevelWormCreateRequest creates the ObjectLevelWorm request. @@ -922,18 +1014,25 @@ func (client *BlobContainersClient) objectLevelWormCreateRequest(ctx context.Con // - options - BlobContainersClientSetLegalHoldOptions contains the optional parameters for the BlobContainersClient.SetLegalHold // method. func (client *BlobContainersClient) SetLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersClientSetLegalHoldOptions) (BlobContainersClientSetLegalHoldResponse, error) { + var err error + const operationName = "BlobContainersClient.SetLegalHold" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.setLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) if err != nil { return BlobContainersClientSetLegalHoldResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientSetLegalHoldResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientSetLegalHoldResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientSetLegalHoldResponse{}, err } - return client.setLegalHoldHandleResponse(resp) + resp, err := client.setLegalHoldHandleResponse(httpResp) + return resp, err } // setLegalHoldCreateRequest creates the SetLegalHold request. @@ -963,7 +1062,10 @@ func (client *BlobContainersClient) setLegalHoldCreateRequest(ctx context.Contex reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, legalHold) + if err := runtime.MarshalAsJSON(req, legalHold); err != nil { + return nil, err + } + return req, nil } // setLegalHoldHandleResponse handles the SetLegalHold response. @@ -989,18 +1091,25 @@ func (client *BlobContainersClient) setLegalHoldHandleResponse(resp *http.Respon // - blobContainer - Properties to update for the blob container. // - options - BlobContainersClientUpdateOptions contains the optional parameters for the BlobContainersClient.Update method. func (client *BlobContainersClient) Update(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersClientUpdateOptions) (BlobContainersClientUpdateResponse, error) { + var err error + const operationName = "BlobContainersClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) if err != nil { return BlobContainersClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobContainersClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobContainersClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobContainersClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -1030,7 +1139,10 @@ func (client *BlobContainersClient) updateCreateRequest(ctx context.Context, res reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, blobContainer) + if err := runtime.MarshalAsJSON(req, blobContainer); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/storage/armstorage/blobinventorypolicies_client.go b/sdk/resourcemanager/storage/armstorage/blobinventorypolicies_client.go index b590d272820d..a6eae10fd1b7 100644 --- a/sdk/resourcemanager/storage/armstorage/blobinventorypolicies_client.go +++ b/sdk/resourcemanager/storage/armstorage/blobinventorypolicies_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 armstorage @@ -56,18 +55,25 @@ func NewBlobInventoryPoliciesClient(subscriptionID string, credential azcore.Tok // - options - BlobInventoryPoliciesClientCreateOrUpdateOptions contains the optional parameters for the BlobInventoryPoliciesClient.CreateOrUpdate // method. func (client *BlobInventoryPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName BlobInventoryPolicyName, properties BlobInventoryPolicy, options *BlobInventoryPoliciesClientCreateOrUpdateOptions) (BlobInventoryPoliciesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "BlobInventoryPoliciesClient.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, accountName, blobInventoryPolicyName, properties, options) if err != nil { return BlobInventoryPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobInventoryPoliciesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobInventoryPoliciesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobInventoryPoliciesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -97,7 +103,10 @@ func (client *BlobInventoryPoliciesClient) createOrUpdateCreateRequest(ctx conte reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, properties) + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -120,16 +129,22 @@ func (client *BlobInventoryPoliciesClient) createOrUpdateHandleResponse(resp *ht // - options - BlobInventoryPoliciesClientDeleteOptions contains the optional parameters for the BlobInventoryPoliciesClient.Delete // method. func (client *BlobInventoryPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName BlobInventoryPolicyName, options *BlobInventoryPoliciesClientDeleteOptions) (BlobInventoryPoliciesClientDeleteResponse, error) { + var err error + const operationName = "BlobInventoryPoliciesClient.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, accountName, blobInventoryPolicyName, options) if err != nil { return BlobInventoryPoliciesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobInventoryPoliciesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return BlobInventoryPoliciesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return BlobInventoryPoliciesClientDeleteResponse{}, err } return BlobInventoryPoliciesClientDeleteResponse{}, nil } @@ -175,18 +190,25 @@ func (client *BlobInventoryPoliciesClient) deleteCreateRequest(ctx context.Conte // - options - BlobInventoryPoliciesClientGetOptions contains the optional parameters for the BlobInventoryPoliciesClient.Get // method. func (client *BlobInventoryPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName BlobInventoryPolicyName, options *BlobInventoryPoliciesClientGetOptions) (BlobInventoryPoliciesClientGetResponse, error) { + var err error + const operationName = "BlobInventoryPoliciesClient.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, accountName, blobInventoryPolicyName, options) if err != nil { return BlobInventoryPoliciesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobInventoryPoliciesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobInventoryPoliciesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobInventoryPoliciesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -242,6 +264,7 @@ func (client *BlobInventoryPoliciesClient) NewListPager(resourceGroupName string return false }, Fetcher: func(ctx context.Context, page *BlobInventoryPoliciesClientListResponse) (BlobInventoryPoliciesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BlobInventoryPoliciesClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return BlobInventoryPoliciesClientListResponse{}, err @@ -255,6 +278,7 @@ func (client *BlobInventoryPoliciesClient) NewListPager(resourceGroupName string } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/storage/armstorage/blobservices_client.go b/sdk/resourcemanager/storage/armstorage/blobservices_client.go index a44211f7fe5f..924ca2af2908 100644 --- a/sdk/resourcemanager/storage/armstorage/blobservices_client.go +++ b/sdk/resourcemanager/storage/armstorage/blobservices_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 armstorage @@ -55,18 +54,25 @@ func NewBlobServicesClient(subscriptionID string, credential azcore.TokenCredent // - options - BlobServicesClientGetServicePropertiesOptions contains the optional parameters for the BlobServicesClient.GetServiceProperties // method. func (client *BlobServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *BlobServicesClientGetServicePropertiesOptions) (BlobServicesClientGetServicePropertiesResponse, error) { + var err error + const operationName = "BlobServicesClient.GetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return BlobServicesClientGetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobServicesClientGetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobServicesClientGetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobServicesClientGetServicePropertiesResponse{}, err } - return client.getServicePropertiesHandleResponse(resp) + resp, err := client.getServicePropertiesHandleResponse(httpResp) + return resp, err } // getServicePropertiesCreateRequest creates the GetServiceProperties request. @@ -118,6 +124,7 @@ func (client *BlobServicesClient) NewListPager(resourceGroupName string, account return false }, Fetcher: func(ctx context.Context, page *BlobServicesClientListResponse) (BlobServicesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BlobServicesClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return BlobServicesClientListResponse{}, err @@ -131,6 +138,7 @@ func (client *BlobServicesClient) NewListPager(resourceGroupName string, account } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -182,18 +190,25 @@ func (client *BlobServicesClient) listHandleResponse(resp *http.Response) (BlobS // - options - BlobServicesClientSetServicePropertiesOptions contains the optional parameters for the BlobServicesClient.SetServiceProperties // method. func (client *BlobServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters BlobServiceProperties, options *BlobServicesClientSetServicePropertiesOptions) (BlobServicesClientSetServicePropertiesResponse, error) { + var err error + const operationName = "BlobServicesClient.SetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return BlobServicesClientSetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobServicesClientSetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobServicesClientSetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobServicesClientSetServicePropertiesResponse{}, err } - return client.setServicePropertiesHandleResponse(resp) + resp, err := client.setServicePropertiesHandleResponse(httpResp) + return resp, err } // setServicePropertiesCreateRequest creates the SetServiceProperties request. @@ -220,7 +235,10 @@ func (client *BlobServicesClient) setServicePropertiesCreateRequest(ctx context. reqQP.Set("api-version", "2022-09-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 } // setServicePropertiesHandleResponse handles the SetServiceProperties response. diff --git a/sdk/resourcemanager/storage/armstorage/build.go b/sdk/resourcemanager/storage/armstorage/build.go index 9c22bcd53e83..93257c9e9c50 100644 --- a/sdk/resourcemanager/storage/armstorage/build.go +++ b/sdk/resourcemanager/storage/armstorage/build.go @@ -2,6 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/storage/armstorage +//go:generate pwsh ../../../../eng/scripts/build.ps1 -goExtension "@autorest/go@4.0.0-preview.50" -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/storage/armstorage package armstorage diff --git a/sdk/resourcemanager/storage/armstorage/client_factory.go b/sdk/resourcemanager/storage/armstorage/client_factory.go index 5172378653ad..12acb7ba89f0 100644 --- a/sdk/resourcemanager/storage/armstorage/client_factory.go +++ b/sdk/resourcemanager/storage/armstorage/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 armstorage diff --git a/sdk/resourcemanager/storage/armstorage/constants.go b/sdk/resourcemanager/storage/armstorage/constants.go index 6108502f33c2..a0098047ffcf 100644 --- a/sdk/resourcemanager/storage/armstorage/constants.go +++ b/sdk/resourcemanager/storage/armstorage/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 armstorage const ( moduleName = "armstorage" - moduleVersion = "v1.3.0" + moduleVersion = "v1.4.0-beta.1" ) // AccessTier - Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' @@ -20,16 +19,16 @@ const ( type AccessTier string const ( - AccessTierHot AccessTier = "Hot" AccessTierCool AccessTier = "Cool" + AccessTierHot AccessTier = "Hot" AccessTierPremium AccessTier = "Premium" ) // PossibleAccessTierValues returns the possible values for the AccessTier const type. func PossibleAccessTierValues() []AccessTier { return []AccessTier{ - AccessTierHot, AccessTierCool, + AccessTierHot, AccessTierPremium, } } @@ -397,15 +396,15 @@ func PossibleGeoReplicationStatusValues() []GeoReplicationStatus { type HTTPProtocol string const ( - HTTPProtocolHTTPSHTTP HTTPProtocol = "https,http" HTTPProtocolHTTPS HTTPProtocol = "https" + HTTPProtocolHTTPSHTTP HTTPProtocol = "https,http" ) // PossibleHTTPProtocolValues returns the possible values for the HTTPProtocol const type. func PossibleHTTPProtocolValues() []HTTPProtocol { return []HTTPProtocol{ - HTTPProtocolHTTPSHTTP, HTTPProtocolHTTPS, + HTTPProtocolHTTPSHTTP, } } @@ -482,15 +481,15 @@ func PossibleInventoryRuleTypeValues() []InventoryRuleType { type KeyPermission string const ( - KeyPermissionRead KeyPermission = "Read" KeyPermissionFull KeyPermission = "Full" + KeyPermissionRead KeyPermission = "Read" ) // PossibleKeyPermissionValues returns the possible values for the KeyPermission const type. func PossibleKeyPermissionValues() []KeyPermission { return []KeyPermission{ - KeyPermissionRead, KeyPermissionFull, + KeyPermissionRead, } } @@ -862,16 +861,16 @@ func PossibleProvisioningStateValues() []ProvisioningState { type PublicAccess string const ( - PublicAccessContainer PublicAccess = "Container" PublicAccessBlob PublicAccess = "Blob" + PublicAccessContainer PublicAccess = "Container" PublicAccessNone PublicAccess = "None" ) // PossiblePublicAccessValues returns the possible values for the PublicAccess const type. func PossiblePublicAccessValues() []PublicAccess { return []PublicAccess{ - PublicAccessContainer, PublicAccessBlob, + PublicAccessContainer, PublicAccessNone, } } @@ -1027,15 +1026,15 @@ func PossibleSKUNameValues() []SKUName { type SKUTier string const ( - SKUTierStandard SKUTier = "Standard" SKUTierPremium SKUTier = "Premium" + SKUTierStandard SKUTier = "Standard" ) // PossibleSKUTierValues returns the possible values for the SKUTier const type. func PossibleSKUTierValues() []SKUTier { return []SKUTier{ - SKUTierStandard, SKUTierPremium, + SKUTierStandard, } } @@ -1163,15 +1162,15 @@ func PossibleStateValues() []State { type StorageAccountExpand string const ( - StorageAccountExpandGeoReplicationStats StorageAccountExpand = "geoReplicationStats" StorageAccountExpandBlobRestoreStatus StorageAccountExpand = "blobRestoreStatus" + StorageAccountExpandGeoReplicationStats StorageAccountExpand = "geoReplicationStats" ) // PossibleStorageAccountExpandValues returns the possible values for the StorageAccountExpand const type. func PossibleStorageAccountExpandValues() []StorageAccountExpand { return []StorageAccountExpand{ - StorageAccountExpandGeoReplicationStats, StorageAccountExpandBlobRestoreStatus, + StorageAccountExpandGeoReplicationStats, } } @@ -1179,22 +1178,22 @@ func PossibleStorageAccountExpandValues() []StorageAccountExpand { type UsageUnit string const ( - UsageUnitCount UsageUnit = "Count" UsageUnitBytes UsageUnit = "Bytes" - UsageUnitSeconds UsageUnit = "Seconds" - UsageUnitPercent UsageUnit = "Percent" - UsageUnitCountsPerSecond UsageUnit = "CountsPerSecond" UsageUnitBytesPerSecond UsageUnit = "BytesPerSecond" + UsageUnitCount UsageUnit = "Count" + UsageUnitCountsPerSecond UsageUnit = "CountsPerSecond" + UsageUnitPercent UsageUnit = "Percent" + UsageUnitSeconds UsageUnit = "Seconds" ) // PossibleUsageUnitValues returns the possible values for the UsageUnit const type. func PossibleUsageUnitValues() []UsageUnit { return []UsageUnit{ - UsageUnitCount, UsageUnitBytes, - UsageUnitSeconds, - UsageUnitPercent, - UsageUnitCountsPerSecond, UsageUnitBytesPerSecond, + UsageUnitCount, + UsageUnitCountsPerSecond, + UsageUnitPercent, + UsageUnitSeconds, } } diff --git a/sdk/resourcemanager/storage/armstorage/deletedaccounts_client.go b/sdk/resourcemanager/storage/armstorage/deletedaccounts_client.go index 0d836b55c129..83878e23039c 100644 --- a/sdk/resourcemanager/storage/armstorage/deletedaccounts_client.go +++ b/sdk/resourcemanager/storage/armstorage/deletedaccounts_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 armstorage @@ -52,18 +51,25 @@ func NewDeletedAccountsClient(subscriptionID string, credential azcore.TokenCred // - location - The location of the deleted storage account. // - options - DeletedAccountsClientGetOptions contains the optional parameters for the DeletedAccountsClient.Get method. func (client *DeletedAccountsClient) Get(ctx context.Context, deletedAccountName string, location string, options *DeletedAccountsClientGetOptions) (DeletedAccountsClientGetResponse, error) { + var err error + const operationName = "DeletedAccountsClient.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, deletedAccountName, location, options) if err != nil { return DeletedAccountsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DeletedAccountsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DeletedAccountsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DeletedAccountsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -112,6 +118,7 @@ func (client *DeletedAccountsClient) NewListPager(options *DeletedAccountsClient return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DeletedAccountsClientListResponse) (DeletedAccountsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeletedAccountsClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -131,6 +138,7 @@ func (client *DeletedAccountsClient) NewListPager(options *DeletedAccountsClient } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/storage/armstorage/encryptionscopes_client.go b/sdk/resourcemanager/storage/armstorage/encryptionscopes_client.go index 9ea42a46b99f..d8c17bd3d700 100644 --- a/sdk/resourcemanager/storage/armstorage/encryptionscopes_client.go +++ b/sdk/resourcemanager/storage/armstorage/encryptionscopes_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 armstorage @@ -57,18 +56,25 @@ func NewEncryptionScopesClient(subscriptionID string, credential azcore.TokenCre // dash (-) character must be immediately preceded and followed by a letter or number. // - options - EncryptionScopesClientGetOptions contains the optional parameters for the EncryptionScopesClient.Get method. func (client *EncryptionScopesClient) Get(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesClientGetOptions) (EncryptionScopesClientGetResponse, error) { + var err error + const operationName = "EncryptionScopesClient.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, accountName, encryptionScopeName, options) if err != nil { return EncryptionScopesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return EncryptionScopesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return EncryptionScopesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EncryptionScopesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -124,6 +130,7 @@ func (client *EncryptionScopesClient) NewListPager(resourceGroupName string, acc return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *EncryptionScopesClientListResponse) (EncryptionScopesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "EncryptionScopesClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -143,6 +150,7 @@ func (client *EncryptionScopesClient) NewListPager(resourceGroupName string, acc } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -204,18 +212,25 @@ func (client *EncryptionScopesClient) listHandleResponse(resp *http.Response) (E // - encryptionScope - Encryption scope properties to be used for the update. // - options - EncryptionScopesClientPatchOptions contains the optional parameters for the EncryptionScopesClient.Patch method. func (client *EncryptionScopesClient) Patch(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesClientPatchOptions) (EncryptionScopesClientPatchResponse, error) { + var err error + const operationName = "EncryptionScopesClient.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, accountName, encryptionScopeName, encryptionScope, options) if err != nil { return EncryptionScopesClientPatchResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return EncryptionScopesClientPatchResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return EncryptionScopesClientPatchResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return EncryptionScopesClientPatchResponse{}, err } - return client.patchHandleResponse(resp) + resp, err := client.patchHandleResponse(httpResp) + return resp, err } // patchCreateRequest creates the Patch request. @@ -245,7 +260,10 @@ func (client *EncryptionScopesClient) patchCreateRequest(ctx context.Context, re reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, encryptionScope) + if err := runtime.MarshalAsJSON(req, encryptionScope); err != nil { + return nil, err + } + return req, nil } // patchHandleResponse handles the Patch response. @@ -272,18 +290,25 @@ func (client *EncryptionScopesClient) patchHandleResponse(resp *http.Response) ( // - encryptionScope - Encryption scope properties to be used for the create or update. // - options - EncryptionScopesClientPutOptions contains the optional parameters for the EncryptionScopesClient.Put method. func (client *EncryptionScopesClient) Put(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesClientPutOptions) (EncryptionScopesClientPutResponse, error) { + var err error + const operationName = "EncryptionScopesClient.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, accountName, encryptionScopeName, encryptionScope, options) if err != nil { return EncryptionScopesClientPutResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return EncryptionScopesClientPutResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return EncryptionScopesClientPutResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return EncryptionScopesClientPutResponse{}, err } - return client.putHandleResponse(resp) + resp, err := client.putHandleResponse(httpResp) + return resp, err } // putCreateRequest creates the Put request. @@ -313,7 +338,10 @@ func (client *EncryptionScopesClient) putCreateRequest(ctx context.Context, reso reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, encryptionScope) + if err := runtime.MarshalAsJSON(req, encryptionScope); err != nil { + return nil, err + } + return req, nil } // putHandleResponse handles the Put response. diff --git a/sdk/resourcemanager/storage/armstorage/fake/accounts_server.go b/sdk/resourcemanager/storage/armstorage/fake/accounts_server.go new file mode 100644 index 000000000000..eab8268d3b3c --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/accounts_server.go @@ -0,0 +1,667 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// AccountsServer is a fake server for instances of the armstorage.AccountsClient type. +type AccountsServer struct { + // BeginAbortHierarchicalNamespaceMigration is the fake for method AccountsClient.BeginAbortHierarchicalNamespaceMigration + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginAbortHierarchicalNamespaceMigration func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientBeginAbortHierarchicalNamespaceMigrationOptions) (resp azfake.PollerResponder[armstorage.AccountsClientAbortHierarchicalNamespaceMigrationResponse], errResp azfake.ErrorResponder) + + // CheckNameAvailability is the fake for method AccountsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, accountName armstorage.AccountCheckNameAvailabilityParameters, options *armstorage.AccountsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armstorage.AccountsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreate is the fake for method AccountsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreate func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.AccountCreateParameters, options *armstorage.AccountsClientBeginCreateOptions) (resp azfake.PollerResponder[armstorage.AccountsClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method AccountsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientDeleteOptions) (resp azfake.Responder[armstorage.AccountsClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginFailover is the fake for method AccountsClient.BeginFailover + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginFailover func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientBeginFailoverOptions) (resp azfake.PollerResponder[armstorage.AccountsClientFailoverResponse], errResp azfake.ErrorResponder) + + // GetProperties is the fake for method AccountsClient.GetProperties + // HTTP status codes to indicate success: http.StatusOK + GetProperties func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientGetPropertiesOptions) (resp azfake.Responder[armstorage.AccountsClientGetPropertiesResponse], errResp azfake.ErrorResponder) + + // BeginHierarchicalNamespaceMigration is the fake for method AccountsClient.BeginHierarchicalNamespaceMigration + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginHierarchicalNamespaceMigration func(ctx context.Context, resourceGroupName string, accountName string, requestType string, options *armstorage.AccountsClientBeginHierarchicalNamespaceMigrationOptions) (resp azfake.PollerResponder[armstorage.AccountsClientHierarchicalNamespaceMigrationResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method AccountsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armstorage.AccountsClientListOptions) (resp azfake.PagerResponder[armstorage.AccountsClientListResponse]) + + // ListAccountSAS is the fake for method AccountsClient.ListAccountSAS + // HTTP status codes to indicate success: http.StatusOK + ListAccountSAS func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.AccountSasParameters, options *armstorage.AccountsClientListAccountSASOptions) (resp azfake.Responder[armstorage.AccountsClientListAccountSASResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method AccountsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armstorage.AccountsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armstorage.AccountsClientListByResourceGroupResponse]) + + // ListKeys is the fake for method AccountsClient.ListKeys + // HTTP status codes to indicate success: http.StatusOK + ListKeys func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientListKeysOptions) (resp azfake.Responder[armstorage.AccountsClientListKeysResponse], errResp azfake.ErrorResponder) + + // ListServiceSAS is the fake for method AccountsClient.ListServiceSAS + // HTTP status codes to indicate success: http.StatusOK + ListServiceSAS func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.ServiceSasParameters, options *armstorage.AccountsClientListServiceSASOptions) (resp azfake.Responder[armstorage.AccountsClientListServiceSASResponse], errResp azfake.ErrorResponder) + + // RegenerateKey is the fake for method AccountsClient.RegenerateKey + // HTTP status codes to indicate success: http.StatusOK + RegenerateKey func(ctx context.Context, resourceGroupName string, accountName string, regenerateKey armstorage.AccountRegenerateKeyParameters, options *armstorage.AccountsClientRegenerateKeyOptions) (resp azfake.Responder[armstorage.AccountsClientRegenerateKeyResponse], errResp azfake.ErrorResponder) + + // BeginRestoreBlobRanges is the fake for method AccountsClient.BeginRestoreBlobRanges + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginRestoreBlobRanges func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.BlobRestoreParameters, options *armstorage.AccountsClientBeginRestoreBlobRangesOptions) (resp azfake.PollerResponder[armstorage.AccountsClientRestoreBlobRangesResponse], errResp azfake.ErrorResponder) + + // RevokeUserDelegationKeys is the fake for method AccountsClient.RevokeUserDelegationKeys + // HTTP status codes to indicate success: http.StatusOK + RevokeUserDelegationKeys func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientRevokeUserDelegationKeysOptions) (resp azfake.Responder[armstorage.AccountsClientRevokeUserDelegationKeysResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method AccountsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.AccountUpdateParameters, options *armstorage.AccountsClientUpdateOptions) (resp azfake.Responder[armstorage.AccountsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewAccountsServerTransport creates a new instance of AccountsServerTransport with the provided implementation. +// The returned AccountsServerTransport instance is connected to an instance of armstorage.AccountsClient by way of the +// undefined.Transporter field. +func NewAccountsServerTransport(srv *AccountsServer) *AccountsServerTransport { + return &AccountsServerTransport{srv: srv} +} + +// AccountsServerTransport connects instances of armstorage.AccountsClient to instances of AccountsServer. +// Don't use this type directly, use NewAccountsServerTransport instead. +type AccountsServerTransport struct { + srv *AccountsServer + beginAbortHierarchicalNamespaceMigration *azfake.PollerResponder[armstorage.AccountsClientAbortHierarchicalNamespaceMigrationResponse] + beginCreate *azfake.PollerResponder[armstorage.AccountsClientCreateResponse] + beginFailover *azfake.PollerResponder[armstorage.AccountsClientFailoverResponse] + beginHierarchicalNamespaceMigration *azfake.PollerResponder[armstorage.AccountsClientHierarchicalNamespaceMigrationResponse] + newListPager *azfake.PagerResponder[armstorage.AccountsClientListResponse] + newListByResourceGroupPager *azfake.PagerResponder[armstorage.AccountsClientListByResourceGroupResponse] + beginRestoreBlobRanges *azfake.PollerResponder[armstorage.AccountsClientRestoreBlobRangesResponse] +} + +// Do implements the policy.Transporter interface for AccountsServerTransport. +func (a *AccountsServerTransport) 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 "AccountsClient.BeginAbortHierarchicalNamespaceMigration": + resp, err = a.dispatchBeginAbortHierarchicalNamespaceMigration(req) + case "AccountsClient.CheckNameAvailability": + resp, err = a.dispatchCheckNameAvailability(req) + case "AccountsClient.BeginCreate": + resp, err = a.dispatchBeginCreate(req) + case "AccountsClient.Delete": + resp, err = a.dispatchDelete(req) + case "AccountsClient.BeginFailover": + resp, err = a.dispatchBeginFailover(req) + case "AccountsClient.GetProperties": + resp, err = a.dispatchGetProperties(req) + case "AccountsClient.BeginHierarchicalNamespaceMigration": + resp, err = a.dispatchBeginHierarchicalNamespaceMigration(req) + case "AccountsClient.NewListPager": + resp, err = a.dispatchNewListPager(req) + case "AccountsClient.ListAccountSAS": + resp, err = a.dispatchListAccountSAS(req) + case "AccountsClient.NewListByResourceGroupPager": + resp, err = a.dispatchNewListByResourceGroupPager(req) + case "AccountsClient.ListKeys": + resp, err = a.dispatchListKeys(req) + case "AccountsClient.ListServiceSAS": + resp, err = a.dispatchListServiceSAS(req) + case "AccountsClient.RegenerateKey": + resp, err = a.dispatchRegenerateKey(req) + case "AccountsClient.BeginRestoreBlobRanges": + resp, err = a.dispatchBeginRestoreBlobRanges(req) + case "AccountsClient.RevokeUserDelegationKeys": + resp, err = a.dispatchRevokeUserDelegationKeys(req) + case "AccountsClient.Update": + resp, err = a.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchBeginAbortHierarchicalNamespaceMigration(req *http.Request) (*http.Response, error) { + if a.srv.BeginAbortHierarchicalNamespaceMigration == nil { + return nil, &nonRetriableError{errors.New("method BeginAbortHierarchicalNamespaceMigration not implemented")} + } + if a.beginAbortHierarchicalNamespaceMigration == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourcegroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/aborthnsonmigration" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := a.srv.BeginAbortHierarchicalNamespaceMigration(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginAbortHierarchicalNamespaceMigration = &respr + } + + resp, err := server.PollerResponderNext(a.beginAbortHierarchicalNamespaceMigration, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginAbortHierarchicalNamespaceMigration) { + a.beginAbortHierarchicalNamespaceMigration = nil + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if a.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("method CheckNameAvailability not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/checkNameAvailability" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.AccountCheckNameAvailabilityParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.CheckNameAvailability(req.Context(), 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 (a *AccountsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + } + if a.beginCreate == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.AccountCreateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginCreate = &respr + } + + resp, err := server.PollerResponderNext(a.beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginCreate) { + a.beginCreate = nil + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if a.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := a.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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 (a *AccountsServerTransport) dispatchBeginFailover(req *http.Request) (*http.Response, error) { + if a.srv.BeginFailover == nil { + return nil, &nonRetriableError{errors.New("method BeginFailover not implemented")} + } + if a.beginFailover == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/failover" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + failoverTypeParam := getOptional(qp.Get("failoverType")) + var options *armstorage.AccountsClientBeginFailoverOptions + if failoverTypeParam != nil { + options = &armstorage.AccountsClientBeginFailoverOptions{ + FailoverType: failoverTypeParam, + } + } + respr, errRespr := a.srv.BeginFailover(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginFailover = &respr + } + + resp, err := server.PollerResponderNext(a.beginFailover, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginFailover) { + a.beginFailover = nil + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchGetProperties(req *http.Request) (*http.Response, error) { + if a.srv.GetProperties == nil { + return nil, &nonRetriableError{errors.New("method GetProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + expandParam := getOptional(armstorage.StorageAccountExpand(qp.Get("$expand"))) + var options *armstorage.AccountsClientGetPropertiesOptions + if expandParam != nil { + options = &armstorage.AccountsClientGetPropertiesOptions{ + Expand: expandParam, + } + } + respr, errRespr := a.srv.GetProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + 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).Account, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchBeginHierarchicalNamespaceMigration(req *http.Request) (*http.Response, error) { + if a.srv.BeginHierarchicalNamespaceMigration == nil { + return nil, &nonRetriableError{errors.New("method BeginHierarchicalNamespaceMigration not implemented")} + } + if a.beginHierarchicalNamespaceMigration == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourcegroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/hnsonmigration" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + respr, errRespr := a.srv.BeginHierarchicalNamespaceMigration(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], qp.Get("requestType"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginHierarchicalNamespaceMigration = &respr + } + + resp, err := server.PollerResponderNext(a.beginHierarchicalNamespaceMigration, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginHierarchicalNamespaceMigration) { + a.beginHierarchicalNamespaceMigration = nil + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if a.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := a.srv.NewListPager(nil) + a.newListPager = &resp + server.PagerResponderInjectNextLinks(a.newListPager, req, func(page *armstorage.AccountsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(a.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(a.newListPager) { + a.newListPager = nil + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchListAccountSAS(req *http.Request) (*http.Response, error) { + if a.srv.ListAccountSAS == nil { + return nil, &nonRetriableError{errors.New("method ListAccountSAS not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/ListAccountSas" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.AccountSasParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListAccountSAS(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).ListAccountSasResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("method NewListByResourceGroupPager not implemented")} + } + if a.newListByResourceGroupPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := a.srv.NewListByResourceGroupPager(matches[regex.SubexpIndex("resourceGroupName")], nil) + a.newListByResourceGroupPager = &resp + server.PagerResponderInjectNextLinks(a.newListByResourceGroupPager, req, func(page *armstorage.AccountsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(a.newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(a.newListByResourceGroupPager) { + a.newListByResourceGroupPager = nil + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchListKeys(req *http.Request) (*http.Response, error) { + if a.srv.ListKeys == nil { + return nil, &nonRetriableError{errors.New("method ListKeys not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/listKeys" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + expandParam := getOptional(qp.Get("$expand")) + var options *armstorage.AccountsClientListKeysOptions + if expandParam != nil { + options = &armstorage.AccountsClientListKeysOptions{ + Expand: expandParam, + } + } + respr, errRespr := a.srv.ListKeys(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + 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).AccountListKeysResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchListServiceSAS(req *http.Request) (*http.Response, error) { + if a.srv.ListServiceSAS == nil { + return nil, &nonRetriableError{errors.New("method ListServiceSAS not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/ListServiceSas" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.ServiceSasParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListServiceSAS(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).ListServiceSasResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchRegenerateKey(req *http.Request) (*http.Response, error) { + if a.srv.RegenerateKey == nil { + return nil, &nonRetriableError{errors.New("method RegenerateKey not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/regenerateKey" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.AccountRegenerateKeyParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.RegenerateKey(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).AccountListKeysResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchBeginRestoreBlobRanges(req *http.Request) (*http.Response, error) { + if a.srv.BeginRestoreBlobRanges == nil { + return nil, &nonRetriableError{errors.New("method BeginRestoreBlobRanges not implemented")} + } + if a.beginRestoreBlobRanges == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/restoreBlobRanges" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.BlobRestoreParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginRestoreBlobRanges(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + a.beginRestoreBlobRanges = &respr + } + + resp, err := server.PollerResponderNext(a.beginRestoreBlobRanges, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(a.beginRestoreBlobRanges) { + a.beginRestoreBlobRanges = nil + } + + return resp, nil +} + +func (a *AccountsServerTransport) dispatchRevokeUserDelegationKeys(req *http.Request) (*http.Response, error) { + if a.srv.RevokeUserDelegationKeys == nil { + return nil, &nonRetriableError{errors.New("method RevokeUserDelegationKeys not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/revokeUserDelegationKeys" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := a.srv.RevokeUserDelegationKeys(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AccountsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if a.srv.Update == nil { + return nil, &nonRetriableError{errors.New("method Update not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.AccountUpdateParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).Account, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go b/sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go new file mode 100644 index 000000000000..cabe0299c7bd --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go @@ -0,0 +1,593 @@ +//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/storage/armstorage" + "net/http" + "reflect" + "regexp" +) + +// BlobContainersServer is a fake server for instances of the armstorage.BlobContainersClient type. +type BlobContainersServer struct { + // ClearLegalHold is the fake for method BlobContainersClient.ClearLegalHold + // HTTP status codes to indicate success: http.StatusOK + ClearLegalHold func(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold armstorage.LegalHold, options *armstorage.BlobContainersClientClearLegalHoldOptions) (resp azfake.Responder[armstorage.BlobContainersClientClearLegalHoldResponse], errResp azfake.ErrorResponder) + + // Create is the fake for method BlobContainersClient.Create + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Create func(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer armstorage.BlobContainer, options *armstorage.BlobContainersClientCreateOptions) (resp azfake.Responder[armstorage.BlobContainersClientCreateResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdateImmutabilityPolicy is the fake for method BlobContainersClient.CreateOrUpdateImmutabilityPolicy + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdateImmutabilityPolicy func(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *armstorage.BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions) (resp azfake.Responder[armstorage.BlobContainersClientCreateOrUpdateImmutabilityPolicyResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method BlobContainersClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *armstorage.BlobContainersClientDeleteOptions) (resp azfake.Responder[armstorage.BlobContainersClientDeleteResponse], errResp azfake.ErrorResponder) + + // DeleteImmutabilityPolicy is the fake for method BlobContainersClient.DeleteImmutabilityPolicy + // HTTP status codes to indicate success: http.StatusOK + DeleteImmutabilityPolicy func(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *armstorage.BlobContainersClientDeleteImmutabilityPolicyOptions) (resp azfake.Responder[armstorage.BlobContainersClientDeleteImmutabilityPolicyResponse], errResp azfake.ErrorResponder) + + // ExtendImmutabilityPolicy is the fake for method BlobContainersClient.ExtendImmutabilityPolicy + // HTTP status codes to indicate success: http.StatusOK + ExtendImmutabilityPolicy func(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *armstorage.BlobContainersClientExtendImmutabilityPolicyOptions) (resp azfake.Responder[armstorage.BlobContainersClientExtendImmutabilityPolicyResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BlobContainersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *armstorage.BlobContainersClientGetOptions) (resp azfake.Responder[armstorage.BlobContainersClientGetResponse], errResp azfake.ErrorResponder) + + // GetImmutabilityPolicy is the fake for method BlobContainersClient.GetImmutabilityPolicy + // HTTP status codes to indicate success: http.StatusOK + GetImmutabilityPolicy func(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *armstorage.BlobContainersClientGetImmutabilityPolicyOptions) (resp azfake.Responder[armstorage.BlobContainersClientGetImmutabilityPolicyResponse], errResp azfake.ErrorResponder) + + // Lease is the fake for method BlobContainersClient.Lease + // HTTP status codes to indicate success: http.StatusOK + Lease func(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *armstorage.BlobContainersClientLeaseOptions) (resp azfake.Responder[armstorage.BlobContainersClientLeaseResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method BlobContainersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.BlobContainersClientListOptions) (resp azfake.PagerResponder[armstorage.BlobContainersClientListResponse]) + + // LockImmutabilityPolicy is the fake for method BlobContainersClient.LockImmutabilityPolicy + // HTTP status codes to indicate success: http.StatusOK + LockImmutabilityPolicy func(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *armstorage.BlobContainersClientLockImmutabilityPolicyOptions) (resp azfake.Responder[armstorage.BlobContainersClientLockImmutabilityPolicyResponse], errResp azfake.ErrorResponder) + + // BeginObjectLevelWorm is the fake for method BlobContainersClient.BeginObjectLevelWorm + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginObjectLevelWorm func(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *armstorage.BlobContainersClientBeginObjectLevelWormOptions) (resp azfake.PollerResponder[armstorage.BlobContainersClientObjectLevelWormResponse], errResp azfake.ErrorResponder) + + // SetLegalHold is the fake for method BlobContainersClient.SetLegalHold + // HTTP status codes to indicate success: http.StatusOK + SetLegalHold func(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold armstorage.LegalHold, options *armstorage.BlobContainersClientSetLegalHoldOptions) (resp azfake.Responder[armstorage.BlobContainersClientSetLegalHoldResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method BlobContainersClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer armstorage.BlobContainer, options *armstorage.BlobContainersClientUpdateOptions) (resp azfake.Responder[armstorage.BlobContainersClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewBlobContainersServerTransport creates a new instance of BlobContainersServerTransport with the provided implementation. +// The returned BlobContainersServerTransport instance is connected to an instance of armstorage.BlobContainersClient by way of the +// undefined.Transporter field. +func NewBlobContainersServerTransport(srv *BlobContainersServer) *BlobContainersServerTransport { + return &BlobContainersServerTransport{srv: srv} +} + +// BlobContainersServerTransport connects instances of armstorage.BlobContainersClient to instances of BlobContainersServer. +// Don't use this type directly, use NewBlobContainersServerTransport instead. +type BlobContainersServerTransport struct { + srv *BlobContainersServer + newListPager *azfake.PagerResponder[armstorage.BlobContainersClientListResponse] + beginObjectLevelWorm *azfake.PollerResponder[armstorage.BlobContainersClientObjectLevelWormResponse] +} + +// Do implements the policy.Transporter interface for BlobContainersServerTransport. +func (b *BlobContainersServerTransport) 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 "BlobContainersClient.ClearLegalHold": + resp, err = b.dispatchClearLegalHold(req) + case "BlobContainersClient.Create": + resp, err = b.dispatchCreate(req) + case "BlobContainersClient.CreateOrUpdateImmutabilityPolicy": + resp, err = b.dispatchCreateOrUpdateImmutabilityPolicy(req) + case "BlobContainersClient.Delete": + resp, err = b.dispatchDelete(req) + case "BlobContainersClient.DeleteImmutabilityPolicy": + resp, err = b.dispatchDeleteImmutabilityPolicy(req) + case "BlobContainersClient.ExtendImmutabilityPolicy": + resp, err = b.dispatchExtendImmutabilityPolicy(req) + case "BlobContainersClient.Get": + resp, err = b.dispatchGet(req) + case "BlobContainersClient.GetImmutabilityPolicy": + resp, err = b.dispatchGetImmutabilityPolicy(req) + case "BlobContainersClient.Lease": + resp, err = b.dispatchLease(req) + case "BlobContainersClient.NewListPager": + resp, err = b.dispatchNewListPager(req) + case "BlobContainersClient.LockImmutabilityPolicy": + resp, err = b.dispatchLockImmutabilityPolicy(req) + case "BlobContainersClient.BeginObjectLevelWorm": + resp, err = b.dispatchBeginObjectLevelWorm(req) + case "BlobContainersClient.SetLegalHold": + resp, err = b.dispatchSetLegalHold(req) + case "BlobContainersClient.Update": + resp, err = b.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchClearLegalHold(req *http.Request) (*http.Response, error) { + if b.srv.ClearLegalHold == nil { + return nil, &nonRetriableError{errors.New("method ClearLegalHold not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/clearLegalHold" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.LegalHold](req) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.ClearLegalHold(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], 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).LegalHold, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if b.srv.Create == nil { + return nil, &nonRetriableError{errors.New("method Create not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.BlobContainer](req) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], 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).BlobContainer, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchCreateOrUpdateImmutabilityPolicy(req *http.Request) (*http.Response, error) { + if b.srv.CreateOrUpdateImmutabilityPolicy == nil { + return nil, &nonRetriableError{errors.New("method CreateOrUpdateImmutabilityPolicy not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.ImmutabilityPolicy](req) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armstorage.BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions + if ifMatchParam != nil || !reflect.ValueOf(body).IsZero() { + options = &armstorage.BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions{ + IfMatch: ifMatchParam, + Parameters: &body, + } + } + respr, errRespr := b.srv.CreateOrUpdateImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], options) + 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).ImmutabilityPolicy, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], 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 *BlobContainersServerTransport) dispatchDeleteImmutabilityPolicy(req *http.Request) (*http.Response, error) { + if b.srv.DeleteImmutabilityPolicy == nil { + return nil, &nonRetriableError{errors.New("method DeleteImmutabilityPolicy not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.DeleteImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], getHeaderValue(req.Header, "If-Match"), 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).ImmutabilityPolicy, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchExtendImmutabilityPolicy(req *http.Request) (*http.Response, error) { + if b.srv.ExtendImmutabilityPolicy == nil { + return nil, &nonRetriableError{errors.New("method ExtendImmutabilityPolicy not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/default/extend" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.ImmutabilityPolicy](req) + if err != nil { + return nil, err + } + var options *armstorage.BlobContainersClientExtendImmutabilityPolicyOptions + if !reflect.ValueOf(body).IsZero() { + options = &armstorage.BlobContainersClientExtendImmutabilityPolicyOptions{ + Parameters: &body, + } + } + respr, errRespr := b.srv.ExtendImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], getHeaderValue(req.Header, "If-Match"), options) + 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).ImmutabilityPolicy, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], 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).BlobContainer, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchGetImmutabilityPolicy(req *http.Request) (*http.Response, error) { + if b.srv.GetImmutabilityPolicy == nil { + return nil, &nonRetriableError{errors.New("method GetImmutabilityPolicy not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armstorage.BlobContainersClientGetImmutabilityPolicyOptions + if ifMatchParam != nil { + options = &armstorage.BlobContainersClientGetImmutabilityPolicyOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := b.srv.GetImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], options) + 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).ImmutabilityPolicy, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchLease(req *http.Request) (*http.Response, error) { + if b.srv.Lease == nil { + return nil, &nonRetriableError{errors.New("method Lease not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/lease" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.LeaseContainerRequest](req) + if err != nil { + return nil, err + } + var options *armstorage.BlobContainersClientLeaseOptions + if !reflect.ValueOf(body).IsZero() { + options = &armstorage.BlobContainersClientLeaseOptions{ + Parameters: &body, + } + } + respr, errRespr := b.srv.Lease(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], options) + 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).LeaseContainerResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if b.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + maxpagesizeParam := getOptional(qp.Get("$maxpagesize")) + filterParam := getOptional(qp.Get("$filter")) + includeParam := getOptional(armstorage.ListContainersInclude(qp.Get("$include"))) + var options *armstorage.BlobContainersClientListOptions + if maxpagesizeParam != nil || filterParam != nil || includeParam != nil { + options = &armstorage.BlobContainersClientListOptions{ + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Include: includeParam, + } + } + resp := b.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + b.newListPager = &resp + server.PagerResponderInjectNextLinks(b.newListPager, req, func(page *armstorage.BlobContainersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(b.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(b.newListPager) { + b.newListPager = nil + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchLockImmutabilityPolicy(req *http.Request) (*http.Response, error) { + if b.srv.LockImmutabilityPolicy == nil { + return nil, &nonRetriableError{errors.New("method LockImmutabilityPolicy not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/default/lock" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.LockImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], getHeaderValue(req.Header, "If-Match"), 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).ImmutabilityPolicy, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchBeginObjectLevelWorm(req *http.Request) (*http.Response, error) { + if b.srv.BeginObjectLevelWorm == nil { + return nil, &nonRetriableError{errors.New("method BeginObjectLevelWorm not implemented")} + } + if b.beginObjectLevelWorm == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/migrate" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.BeginObjectLevelWorm(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + b.beginObjectLevelWorm = &respr + } + + resp, err := server.PollerResponderNext(b.beginObjectLevelWorm, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(b.beginObjectLevelWorm) { + b.beginObjectLevelWorm = nil + } + + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchSetLegalHold(req *http.Request) (*http.Response, error) { + if b.srv.SetLegalHold == nil { + return nil, &nonRetriableError{errors.New("method SetLegalHold not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/setLegalHold" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.LegalHold](req) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.SetLegalHold(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], 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).LegalHold, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobContainersServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if b.srv.Update == nil { + return nil, &nonRetriableError{errors.New("method Update not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.BlobContainer](req) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], 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).BlobContainer, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go b/sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go new file mode 100644 index 000000000000..370ec9c48da8 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go @@ -0,0 +1,191 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// BlobInventoryPoliciesServer is a fake server for instances of the armstorage.BlobInventoryPoliciesClient type. +type BlobInventoryPoliciesServer struct { + // CreateOrUpdate is the fake for method BlobInventoryPoliciesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName armstorage.BlobInventoryPolicyName, properties armstorage.BlobInventoryPolicy, options *armstorage.BlobInventoryPoliciesClientCreateOrUpdateOptions) (resp azfake.Responder[armstorage.BlobInventoryPoliciesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method BlobInventoryPoliciesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName armstorage.BlobInventoryPolicyName, options *armstorage.BlobInventoryPoliciesClientDeleteOptions) (resp azfake.Responder[armstorage.BlobInventoryPoliciesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BlobInventoryPoliciesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName armstorage.BlobInventoryPolicyName, options *armstorage.BlobInventoryPoliciesClientGetOptions) (resp azfake.Responder[armstorage.BlobInventoryPoliciesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method BlobInventoryPoliciesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.BlobInventoryPoliciesClientListOptions) (resp azfake.PagerResponder[armstorage.BlobInventoryPoliciesClientListResponse]) +} + +// NewBlobInventoryPoliciesServerTransport creates a new instance of BlobInventoryPoliciesServerTransport with the provided implementation. +// The returned BlobInventoryPoliciesServerTransport instance is connected to an instance of armstorage.BlobInventoryPoliciesClient by way of the +// undefined.Transporter field. +func NewBlobInventoryPoliciesServerTransport(srv *BlobInventoryPoliciesServer) *BlobInventoryPoliciesServerTransport { + return &BlobInventoryPoliciesServerTransport{srv: srv} +} + +// BlobInventoryPoliciesServerTransport connects instances of armstorage.BlobInventoryPoliciesClient to instances of BlobInventoryPoliciesServer. +// Don't use this type directly, use NewBlobInventoryPoliciesServerTransport instead. +type BlobInventoryPoliciesServerTransport struct { + srv *BlobInventoryPoliciesServer + newListPager *azfake.PagerResponder[armstorage.BlobInventoryPoliciesClientListResponse] +} + +// Do implements the policy.Transporter interface for BlobInventoryPoliciesServerTransport. +func (b *BlobInventoryPoliciesServerTransport) 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 "BlobInventoryPoliciesClient.CreateOrUpdate": + resp, err = b.dispatchCreateOrUpdate(req) + case "BlobInventoryPoliciesClient.Delete": + resp, err = b.dispatchDelete(req) + case "BlobInventoryPoliciesClient.Get": + resp, err = b.dispatchGet(req) + case "BlobInventoryPoliciesClient.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 *BlobInventoryPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if b.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.BlobInventoryPolicy](req) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.BlobInventoryPolicyName(matches[regex.SubexpIndex("blobInventoryPolicyName")]), 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).BlobInventoryPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobInventoryPoliciesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.BlobInventoryPolicyName(matches[regex.SubexpIndex("blobInventoryPolicyName")]), 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 *BlobInventoryPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.BlobInventoryPolicyName(matches[regex.SubexpIndex("blobInventoryPolicyName")]), 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).BlobInventoryPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobInventoryPoliciesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if b.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := b.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + b.newListPager = &resp + } + resp, err := server.PagerResponderNext(b.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(b.newListPager) { + b.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go new file mode 100644 index 000000000000..5f74cac8ec85 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go @@ -0,0 +1,160 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// BlobServicesServer is a fake server for instances of the armstorage.BlobServicesClient type. +type BlobServicesServer struct { + // GetServiceProperties is the fake for method BlobServicesClient.GetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + GetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.BlobServicesClientGetServicePropertiesOptions) (resp azfake.Responder[armstorage.BlobServicesClientGetServicePropertiesResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method BlobServicesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.BlobServicesClientListOptions) (resp azfake.PagerResponder[armstorage.BlobServicesClientListResponse]) + + // SetServiceProperties is the fake for method BlobServicesClient.SetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + SetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.BlobServiceProperties, options *armstorage.BlobServicesClientSetServicePropertiesOptions) (resp azfake.Responder[armstorage.BlobServicesClientSetServicePropertiesResponse], errResp azfake.ErrorResponder) +} + +// NewBlobServicesServerTransport creates a new instance of BlobServicesServerTransport with the provided implementation. +// The returned BlobServicesServerTransport instance is connected to an instance of armstorage.BlobServicesClient by way of the +// undefined.Transporter field. +func NewBlobServicesServerTransport(srv *BlobServicesServer) *BlobServicesServerTransport { + return &BlobServicesServerTransport{srv: srv} +} + +// BlobServicesServerTransport connects instances of armstorage.BlobServicesClient to instances of BlobServicesServer. +// Don't use this type directly, use NewBlobServicesServerTransport instead. +type BlobServicesServerTransport struct { + srv *BlobServicesServer + newListPager *azfake.PagerResponder[armstorage.BlobServicesClientListResponse] +} + +// Do implements the policy.Transporter interface for BlobServicesServerTransport. +func (b *BlobServicesServerTransport) 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 "BlobServicesClient.GetServiceProperties": + resp, err = b.dispatchGetServiceProperties(req) + case "BlobServicesClient.NewListPager": + resp, err = b.dispatchNewListPager(req) + case "BlobServicesClient.SetServiceProperties": + resp, err = b.dispatchSetServiceProperties(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BlobServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { + if b.srv.GetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := b.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).BlobServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BlobServicesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if b.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := b.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + b.newListPager = &resp + } + resp, err := server.PagerResponderNext(b.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(b.newListPager) { + b.newListPager = nil + } + return resp, nil +} + +func (b *BlobServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { + if b.srv.SetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.BlobServiceProperties](req) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).BlobServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go b/sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go new file mode 100644 index 000000000000..bcf2aeed5337 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go @@ -0,0 +1,129 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// DeletedAccountsServer is a fake server for instances of the armstorage.DeletedAccountsClient type. +type DeletedAccountsServer struct { + // Get is the fake for method DeletedAccountsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, deletedAccountName string, location string, options *armstorage.DeletedAccountsClientGetOptions) (resp azfake.Responder[armstorage.DeletedAccountsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DeletedAccountsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armstorage.DeletedAccountsClientListOptions) (resp azfake.PagerResponder[armstorage.DeletedAccountsClientListResponse]) +} + +// NewDeletedAccountsServerTransport creates a new instance of DeletedAccountsServerTransport with the provided implementation. +// The returned DeletedAccountsServerTransport instance is connected to an instance of armstorage.DeletedAccountsClient by way of the +// undefined.Transporter field. +func NewDeletedAccountsServerTransport(srv *DeletedAccountsServer) *DeletedAccountsServerTransport { + return &DeletedAccountsServerTransport{srv: srv} +} + +// DeletedAccountsServerTransport connects instances of armstorage.DeletedAccountsClient to instances of DeletedAccountsServer. +// Don't use this type directly, use NewDeletedAccountsServerTransport instead. +type DeletedAccountsServerTransport struct { + srv *DeletedAccountsServer + newListPager *azfake.PagerResponder[armstorage.DeletedAccountsClientListResponse] +} + +// Do implements the policy.Transporter interface for DeletedAccountsServerTransport. +func (d *DeletedAccountsServerTransport) 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 "DeletedAccountsClient.Get": + resp, err = d.dispatchGet(req) + case "DeletedAccountsClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DeletedAccountsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/locations/(?P[a-zA-Z0-9-_]+)/deletedAccounts/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := d.srv.Get(req.Context(), matches[regex.SubexpIndex("deletedAccountName")], matches[regex.SubexpIndex("location")], 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).DeletedAccount, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DeletedAccountsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if d.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/deletedAccounts" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := d.srv.NewListPager(nil) + d.newListPager = &resp + server.PagerResponderInjectNextLinks(d.newListPager, req, func(page *armstorage.DeletedAccountsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(d.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(d.newListPager) { + d.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go b/sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go new file mode 100644 index 000000000000..31094b262512 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go @@ -0,0 +1,221 @@ +//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/storage/armstorage" + "net/http" + "regexp" + "strconv" +) + +// EncryptionScopesServer is a fake server for instances of the armstorage.EncryptionScopesClient type. +type EncryptionScopesServer struct { + // Get is the fake for method EncryptionScopesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *armstorage.EncryptionScopesClientGetOptions) (resp azfake.Responder[armstorage.EncryptionScopesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method EncryptionScopesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.EncryptionScopesClientListOptions) (resp azfake.PagerResponder[armstorage.EncryptionScopesClientListResponse]) + + // Patch is the fake for method EncryptionScopesClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope armstorage.EncryptionScope, options *armstorage.EncryptionScopesClientPatchOptions) (resp azfake.Responder[armstorage.EncryptionScopesClientPatchResponse], errResp azfake.ErrorResponder) + + // Put is the fake for method EncryptionScopesClient.Put + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Put func(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope armstorage.EncryptionScope, options *armstorage.EncryptionScopesClientPutOptions) (resp azfake.Responder[armstorage.EncryptionScopesClientPutResponse], errResp azfake.ErrorResponder) +} + +// NewEncryptionScopesServerTransport creates a new instance of EncryptionScopesServerTransport with the provided implementation. +// The returned EncryptionScopesServerTransport instance is connected to an instance of armstorage.EncryptionScopesClient by way of the +// undefined.Transporter field. +func NewEncryptionScopesServerTransport(srv *EncryptionScopesServer) *EncryptionScopesServerTransport { + return &EncryptionScopesServerTransport{srv: srv} +} + +// EncryptionScopesServerTransport connects instances of armstorage.EncryptionScopesClient to instances of EncryptionScopesServer. +// Don't use this type directly, use NewEncryptionScopesServerTransport instead. +type EncryptionScopesServerTransport struct { + srv *EncryptionScopesServer + newListPager *azfake.PagerResponder[armstorage.EncryptionScopesClientListResponse] +} + +// Do implements the policy.Transporter interface for EncryptionScopesServerTransport. +func (e *EncryptionScopesServerTransport) 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 "EncryptionScopesClient.Get": + resp, err = e.dispatchGet(req) + case "EncryptionScopesClient.NewListPager": + resp, err = e.dispatchNewListPager(req) + case "EncryptionScopesClient.Patch": + resp, err = e.dispatchPatch(req) + case "EncryptionScopesClient.Put": + resp, err = e.dispatchPut(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := e.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("encryptionScopeName")], 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).EncryptionScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if e.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + maxpagesizeParam, err := parseOptional(qp.Get("$maxpagesize"), func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterParam := getOptional(qp.Get("$filter")) + includeParam := getOptional(armstorage.ListEncryptionScopesInclude(qp.Get("$include"))) + var options *armstorage.EncryptionScopesClientListOptions + if maxpagesizeParam != nil || filterParam != nil || includeParam != nil { + options = &armstorage.EncryptionScopesClientListOptions{ + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Include: includeParam, + } + } + resp := e.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + e.newListPager = &resp + server.PagerResponderInjectNextLinks(e.newListPager, req, func(page *armstorage.EncryptionScopesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(e.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(e.newListPager) { + e.newListPager = nil + } + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if e.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("method Patch not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.EncryptionScope](req) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Patch(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("encryptionScopeName")], 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).EncryptionScope, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *EncryptionScopesServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { + if e.srv.Put == nil { + return nil, &nonRetriableError{errors.New("method Put not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.EncryptionScope](req) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Put(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("encryptionScopeName")], 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).EncryptionScope, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go new file mode 100644 index 000000000000..7b156b957fd6 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go @@ -0,0 +1,157 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// FileServicesServer is a fake server for instances of the armstorage.FileServicesClient type. +type FileServicesServer struct { + // GetServiceProperties is the fake for method FileServicesClient.GetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + GetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.FileServicesClientGetServicePropertiesOptions) (resp azfake.Responder[armstorage.FileServicesClientGetServicePropertiesResponse], errResp azfake.ErrorResponder) + + // List is the fake for method FileServicesClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.FileServicesClientListOptions) (resp azfake.Responder[armstorage.FileServicesClientListResponse], errResp azfake.ErrorResponder) + + // SetServiceProperties is the fake for method FileServicesClient.SetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + SetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.FileServiceProperties, options *armstorage.FileServicesClientSetServicePropertiesOptions) (resp azfake.Responder[armstorage.FileServicesClientSetServicePropertiesResponse], errResp azfake.ErrorResponder) +} + +// NewFileServicesServerTransport creates a new instance of FileServicesServerTransport with the provided implementation. +// The returned FileServicesServerTransport instance is connected to an instance of armstorage.FileServicesClient by way of the +// undefined.Transporter field. +func NewFileServicesServerTransport(srv *FileServicesServer) *FileServicesServerTransport { + return &FileServicesServerTransport{srv: srv} +} + +// FileServicesServerTransport connects instances of armstorage.FileServicesClient to instances of FileServicesServer. +// Don't use this type directly, use NewFileServicesServerTransport instead. +type FileServicesServerTransport struct { + srv *FileServicesServer +} + +// Do implements the policy.Transporter interface for FileServicesServerTransport. +func (f *FileServicesServerTransport) 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 "FileServicesClient.GetServiceProperties": + resp, err = f.dispatchGetServiceProperties(req) + case "FileServicesClient.List": + resp, err = f.dispatchList(req) + case "FileServicesClient.SetServiceProperties": + resp, err = f.dispatchSetServiceProperties(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (f *FileServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { + if f.srv.GetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := f.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).FileServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileServicesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if f.srv.List == nil { + return nil, &nonRetriableError{errors.New("method List not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := f.srv.List(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).FileServiceItems, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { + if f.srv.SetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.FileServiceProperties](req) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).FileServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go b/sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go new file mode 100644 index 000000000000..1033baaec916 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go @@ -0,0 +1,352 @@ +//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/storage/armstorage" + "net/http" + "reflect" + "regexp" +) + +// FileSharesServer is a fake server for instances of the armstorage.FileSharesClient type. +type FileSharesServer struct { + // Create is the fake for method FileSharesClient.Create + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Create func(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare armstorage.FileShare, options *armstorage.FileSharesClientCreateOptions) (resp azfake.Responder[armstorage.FileSharesClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method FileSharesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *armstorage.FileSharesClientDeleteOptions) (resp azfake.Responder[armstorage.FileSharesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method FileSharesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *armstorage.FileSharesClientGetOptions) (resp azfake.Responder[armstorage.FileSharesClientGetResponse], errResp azfake.ErrorResponder) + + // Lease is the fake for method FileSharesClient.Lease + // HTTP status codes to indicate success: http.StatusOK + Lease func(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *armstorage.FileSharesClientLeaseOptions) (resp azfake.Responder[armstorage.FileSharesClientLeaseResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method FileSharesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.FileSharesClientListOptions) (resp azfake.PagerResponder[armstorage.FileSharesClientListResponse]) + + // Restore is the fake for method FileSharesClient.Restore + // HTTP status codes to indicate success: http.StatusOK + Restore func(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare armstorage.DeletedShare, options *armstorage.FileSharesClientRestoreOptions) (resp azfake.Responder[armstorage.FileSharesClientRestoreResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method FileSharesClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare armstorage.FileShare, options *armstorage.FileSharesClientUpdateOptions) (resp azfake.Responder[armstorage.FileSharesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewFileSharesServerTransport creates a new instance of FileSharesServerTransport with the provided implementation. +// The returned FileSharesServerTransport instance is connected to an instance of armstorage.FileSharesClient by way of the +// undefined.Transporter field. +func NewFileSharesServerTransport(srv *FileSharesServer) *FileSharesServerTransport { + return &FileSharesServerTransport{srv: srv} +} + +// FileSharesServerTransport connects instances of armstorage.FileSharesClient to instances of FileSharesServer. +// Don't use this type directly, use NewFileSharesServerTransport instead. +type FileSharesServerTransport struct { + srv *FileSharesServer + newListPager *azfake.PagerResponder[armstorage.FileSharesClientListResponse] +} + +// Do implements the policy.Transporter interface for FileSharesServerTransport. +func (f *FileSharesServerTransport) 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 "FileSharesClient.Create": + resp, err = f.dispatchCreate(req) + case "FileSharesClient.Delete": + resp, err = f.dispatchDelete(req) + case "FileSharesClient.Get": + resp, err = f.dispatchGet(req) + case "FileSharesClient.Lease": + resp, err = f.dispatchLease(req) + case "FileSharesClient.NewListPager": + resp, err = f.dispatchNewListPager(req) + case "FileSharesClient.Restore": + resp, err = f.dispatchRestore(req) + case "FileSharesClient.Update": + resp, err = f.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if f.srv.Create == nil { + return nil, &nonRetriableError{errors.New("method Create not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + body, err := server.UnmarshalRequestAsJSON[armstorage.FileShare](req) + if err != nil { + return nil, err + } + expandParam := getOptional(qp.Get("$expand")) + var options *armstorage.FileSharesClientCreateOptions + if expandParam != nil { + options = &armstorage.FileSharesClientCreateOptions{ + Expand: expandParam, + } + } + respr, errRespr := f.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], body, options) + 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).FileShare, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if f.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + xMSSnapshotParam := getOptional(getHeaderValue(req.Header, "x-ms-snapshot")) + includeParam := getOptional(qp.Get("$include")) + var options *armstorage.FileSharesClientDeleteOptions + if xMSSnapshotParam != nil || includeParam != nil { + options = &armstorage.FileSharesClientDeleteOptions{ + XMSSnapshot: xMSSnapshotParam, + Include: includeParam, + } + } + respr, errRespr := f.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], options) + 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 (f *FileSharesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if f.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + expandParam := getOptional(qp.Get("$expand")) + xMSSnapshotParam := getOptional(getHeaderValue(req.Header, "x-ms-snapshot")) + var options *armstorage.FileSharesClientGetOptions + if expandParam != nil || xMSSnapshotParam != nil { + options = &armstorage.FileSharesClientGetOptions{ + Expand: expandParam, + XMSSnapshot: xMSSnapshotParam, + } + } + respr, errRespr := f.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], options) + 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).FileShare, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchLease(req *http.Request) (*http.Response, error) { + if f.srv.Lease == nil { + return nil, &nonRetriableError{errors.New("method Lease not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)/lease" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.LeaseShareRequest](req) + if err != nil { + return nil, err + } + xMSSnapshotParam := getOptional(getHeaderValue(req.Header, "x-ms-snapshot")) + var options *armstorage.FileSharesClientLeaseOptions + if xMSSnapshotParam != nil || !reflect.ValueOf(body).IsZero() { + options = &armstorage.FileSharesClientLeaseOptions{ + XMSSnapshot: xMSSnapshotParam, + Parameters: &body, + } + } + respr, errRespr := f.srv.Lease(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], options) + 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).LeaseShareResponse, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).ETag; val != nil { + resp.Header.Set("ETag", *val) + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if f.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if f.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + maxpagesizeParam := getOptional(qp.Get("$maxpagesize")) + filterParam := getOptional(qp.Get("$filter")) + expandParam := getOptional(qp.Get("$expand")) + var options *armstorage.FileSharesClientListOptions + if maxpagesizeParam != nil || filterParam != nil || expandParam != nil { + options = &armstorage.FileSharesClientListOptions{ + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Expand: expandParam, + } + } + resp := f.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + f.newListPager = &resp + server.PagerResponderInjectNextLinks(f.newListPager, req, func(page *armstorage.FileSharesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(f.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(f.newListPager) { + f.newListPager = nil + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchRestore(req *http.Request) (*http.Response, error) { + if f.srv.Restore == nil { + return nil, &nonRetriableError{errors.New("method Restore not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)/restore" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.DeletedShare](req) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Restore(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSharesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if f.srv.Update == nil { + return nil, &nonRetriableError{errors.New("method Update not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.FileShare](req) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], 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).FileShare, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/internal.go b/sdk/resourcemanager/storage/armstorage/fake/internal.go new file mode 100644 index 000000000000..e9c8222f2199 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/internal.go @@ -0,0 +1,78 @@ +//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 ( + "io" + "net/http" + "reflect" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func getHeaderValue(h http.Header, k string) string { + v := h[k] + if len(v) == 0 { + return "" + } + return v[0] +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func parseWithCast[T any](v string, parse func(v string) (T, error)) (T, error) { + t, err := parse(v) + if err != nil { + return *new(T), err + } + return t, err +} + +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 contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/localusers_server.go b/sdk/resourcemanager/storage/armstorage/fake/localusers_server.go new file mode 100644 index 000000000000..82514d9e9ecd --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/localusers_server.go @@ -0,0 +1,253 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// LocalUsersServer is a fake server for instances of the armstorage.LocalUsersClient type. +type LocalUsersServer struct { + // CreateOrUpdate is the fake for method LocalUsersClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, username string, properties armstorage.LocalUser, options *armstorage.LocalUsersClientCreateOrUpdateOptions) (resp azfake.Responder[armstorage.LocalUsersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method LocalUsersClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, username string, options *armstorage.LocalUsersClientDeleteOptions) (resp azfake.Responder[armstorage.LocalUsersClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method LocalUsersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, username string, options *armstorage.LocalUsersClientGetOptions) (resp azfake.Responder[armstorage.LocalUsersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method LocalUsersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.LocalUsersClientListOptions) (resp azfake.PagerResponder[armstorage.LocalUsersClientListResponse]) + + // ListKeys is the fake for method LocalUsersClient.ListKeys + // HTTP status codes to indicate success: http.StatusOK + ListKeys func(ctx context.Context, resourceGroupName string, accountName string, username string, options *armstorage.LocalUsersClientListKeysOptions) (resp azfake.Responder[armstorage.LocalUsersClientListKeysResponse], errResp azfake.ErrorResponder) + + // RegeneratePassword is the fake for method LocalUsersClient.RegeneratePassword + // HTTP status codes to indicate success: http.StatusOK + RegeneratePassword func(ctx context.Context, resourceGroupName string, accountName string, username string, options *armstorage.LocalUsersClientRegeneratePasswordOptions) (resp azfake.Responder[armstorage.LocalUsersClientRegeneratePasswordResponse], errResp azfake.ErrorResponder) +} + +// NewLocalUsersServerTransport creates a new instance of LocalUsersServerTransport with the provided implementation. +// The returned LocalUsersServerTransport instance is connected to an instance of armstorage.LocalUsersClient by way of the +// undefined.Transporter field. +func NewLocalUsersServerTransport(srv *LocalUsersServer) *LocalUsersServerTransport { + return &LocalUsersServerTransport{srv: srv} +} + +// LocalUsersServerTransport connects instances of armstorage.LocalUsersClient to instances of LocalUsersServer. +// Don't use this type directly, use NewLocalUsersServerTransport instead. +type LocalUsersServerTransport struct { + srv *LocalUsersServer + newListPager *azfake.PagerResponder[armstorage.LocalUsersClientListResponse] +} + +// Do implements the policy.Transporter interface for LocalUsersServerTransport. +func (l *LocalUsersServerTransport) 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 "LocalUsersClient.CreateOrUpdate": + resp, err = l.dispatchCreateOrUpdate(req) + case "LocalUsersClient.Delete": + resp, err = l.dispatchDelete(req) + case "LocalUsersClient.Get": + resp, err = l.dispatchGet(req) + case "LocalUsersClient.NewListPager": + resp, err = l.dispatchNewListPager(req) + case "LocalUsersClient.ListKeys": + resp, err = l.dispatchListKeys(req) + case "LocalUsersClient.RegeneratePassword": + resp, err = l.dispatchRegeneratePassword(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (l *LocalUsersServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if l.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.LocalUser](req) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], 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).LocalUser, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LocalUsersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if l.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := l.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], 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 (l *LocalUsersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if l.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := l.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], 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).LocalUser, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LocalUsersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if l.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := l.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + l.newListPager = &resp + } + resp, err := server.PagerResponderNext(l.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(l.newListPager) { + l.newListPager = nil + } + return resp, nil +} + +func (l *LocalUsersServerTransport) dispatchListKeys(req *http.Request) (*http.Response, error) { + if l.srv.ListKeys == nil { + return nil, &nonRetriableError{errors.New("method ListKeys not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)/listKeys" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := l.srv.ListKeys(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], 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).LocalUserKeys, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LocalUsersServerTransport) dispatchRegeneratePassword(req *http.Request) (*http.Response, error) { + if l.srv.RegeneratePassword == nil { + return nil, &nonRetriableError{errors.New("method RegeneratePassword not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)/regeneratePassword" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := l.srv.RegeneratePassword(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], 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).LocalUserRegeneratePasswordResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go b/sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go new file mode 100644 index 000000000000..0eb23a4099cb --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go @@ -0,0 +1,157 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// ManagementPoliciesServer is a fake server for instances of the armstorage.ManagementPoliciesClient type. +type ManagementPoliciesServer struct { + // CreateOrUpdate is the fake for method ManagementPoliciesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName armstorage.ManagementPolicyName, properties armstorage.ManagementPolicy, options *armstorage.ManagementPoliciesClientCreateOrUpdateOptions) (resp azfake.Responder[armstorage.ManagementPoliciesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ManagementPoliciesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName armstorage.ManagementPolicyName, options *armstorage.ManagementPoliciesClientDeleteOptions) (resp azfake.Responder[armstorage.ManagementPoliciesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ManagementPoliciesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName armstorage.ManagementPolicyName, options *armstorage.ManagementPoliciesClientGetOptions) (resp azfake.Responder[armstorage.ManagementPoliciesClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewManagementPoliciesServerTransport creates a new instance of ManagementPoliciesServerTransport with the provided implementation. +// The returned ManagementPoliciesServerTransport instance is connected to an instance of armstorage.ManagementPoliciesClient by way of the +// undefined.Transporter field. +func NewManagementPoliciesServerTransport(srv *ManagementPoliciesServer) *ManagementPoliciesServerTransport { + return &ManagementPoliciesServerTransport{srv: srv} +} + +// ManagementPoliciesServerTransport connects instances of armstorage.ManagementPoliciesClient to instances of ManagementPoliciesServer. +// Don't use this type directly, use NewManagementPoliciesServerTransport instead. +type ManagementPoliciesServerTransport struct { + srv *ManagementPoliciesServer +} + +// Do implements the policy.Transporter interface for ManagementPoliciesServerTransport. +func (m *ManagementPoliciesServerTransport) 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 "ManagementPoliciesClient.CreateOrUpdate": + resp, err = m.dispatchCreateOrUpdate(req) + case "ManagementPoliciesClient.Delete": + resp, err = m.dispatchDelete(req) + case "ManagementPoliciesClient.Get": + resp, err = m.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ManagementPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if m.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/managementPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.ManagementPolicy](req) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.ManagementPolicyName(matches[regex.SubexpIndex("managementPolicyName")]), 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).ManagementPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagementPoliciesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if m.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/managementPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := m.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.ManagementPolicyName(matches[regex.SubexpIndex("managementPolicyName")]), 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 (m *ManagementPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/managementPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := m.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.ManagementPolicyName(matches[regex.SubexpIndex("managementPolicyName")]), 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).ManagementPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go b/sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go new file mode 100644 index 000000000000..206a7cd03e09 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go @@ -0,0 +1,191 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// ObjectReplicationPoliciesServer is a fake server for instances of the armstorage.ObjectReplicationPoliciesClient type. +type ObjectReplicationPoliciesServer struct { + // CreateOrUpdate is the fake for method ObjectReplicationPoliciesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, properties armstorage.ObjectReplicationPolicy, options *armstorage.ObjectReplicationPoliciesClientCreateOrUpdateOptions) (resp azfake.Responder[armstorage.ObjectReplicationPoliciesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ObjectReplicationPoliciesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *armstorage.ObjectReplicationPoliciesClientDeleteOptions) (resp azfake.Responder[armstorage.ObjectReplicationPoliciesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ObjectReplicationPoliciesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *armstorage.ObjectReplicationPoliciesClientGetOptions) (resp azfake.Responder[armstorage.ObjectReplicationPoliciesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ObjectReplicationPoliciesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.ObjectReplicationPoliciesClientListOptions) (resp azfake.PagerResponder[armstorage.ObjectReplicationPoliciesClientListResponse]) +} + +// NewObjectReplicationPoliciesServerTransport creates a new instance of ObjectReplicationPoliciesServerTransport with the provided implementation. +// The returned ObjectReplicationPoliciesServerTransport instance is connected to an instance of armstorage.ObjectReplicationPoliciesClient by way of the +// undefined.Transporter field. +func NewObjectReplicationPoliciesServerTransport(srv *ObjectReplicationPoliciesServer) *ObjectReplicationPoliciesServerTransport { + return &ObjectReplicationPoliciesServerTransport{srv: srv} +} + +// ObjectReplicationPoliciesServerTransport connects instances of armstorage.ObjectReplicationPoliciesClient to instances of ObjectReplicationPoliciesServer. +// Don't use this type directly, use NewObjectReplicationPoliciesServerTransport instead. +type ObjectReplicationPoliciesServerTransport struct { + srv *ObjectReplicationPoliciesServer + newListPager *azfake.PagerResponder[armstorage.ObjectReplicationPoliciesClientListResponse] +} + +// Do implements the policy.Transporter interface for ObjectReplicationPoliciesServerTransport. +func (o *ObjectReplicationPoliciesServerTransport) 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 "ObjectReplicationPoliciesClient.CreateOrUpdate": + resp, err = o.dispatchCreateOrUpdate(req) + case "ObjectReplicationPoliciesClient.Delete": + resp, err = o.dispatchDelete(req) + case "ObjectReplicationPoliciesClient.Get": + resp, err = o.dispatchGet(req) + case "ObjectReplicationPoliciesClient.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 *ObjectReplicationPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if o.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.ObjectReplicationPolicy](req) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("objectReplicationPolicyId")], 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).ObjectReplicationPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *ObjectReplicationPoliciesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if o.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := o.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("objectReplicationPolicyId")], 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 (o *ObjectReplicationPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := o.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("objectReplicationPolicyId")], 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).ObjectReplicationPolicy, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *ObjectReplicationPoliciesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if o.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := o.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + o.newListPager = &resp + } + resp, err := server.PagerResponderNext(o.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(o.newListPager) { + o.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/operations_server.go b/sdk/resourcemanager/storage/armstorage/fake/operations_server.go new file mode 100644 index 000000000000..749e9f6bf54d --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/operations_server.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 ( + "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/storage/armstorage" + "net/http" +) + +// OperationsServer is a fake server for instances of the armstorage.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armstorage.OperationsClientListOptions) (resp azfake.PagerResponder[armstorage.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armstorage.OperationsClient by way of the +// undefined.Transporter field. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{srv: srv} +} + +// OperationsServerTransport connects instances of armstorage.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *azfake.PagerResponder[armstorage.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("method NewListPager not implemented")} + } + if o.newListPager == nil { + resp := o.srv.NewListPager(nil) + o.newListPager = &resp + } + resp, err := server.PagerResponderNext(o.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(o.newListPager) { + o.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go b/sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go new file mode 100644 index 000000000000..c01dd2527e63 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go @@ -0,0 +1,191 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// PrivateEndpointConnectionsServer is a fake server for instances of the armstorage.PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsServer struct { + // Delete is the fake for method PrivateEndpointConnectionsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *armstorage.PrivateEndpointConnectionsClientDeleteOptions) (resp azfake.Responder[armstorage.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrivateEndpointConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *armstorage.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armstorage.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method PrivateEndpointConnectionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.PrivateEndpointConnectionsClientListOptions) (resp azfake.PagerResponder[armstorage.PrivateEndpointConnectionsClientListResponse]) + + // Put is the fake for method PrivateEndpointConnectionsClient.Put + // HTTP status codes to indicate success: http.StatusOK + Put func(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties armstorage.PrivateEndpointConnection, options *armstorage.PrivateEndpointConnectionsClientPutOptions) (resp azfake.Responder[armstorage.PrivateEndpointConnectionsClientPutResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned PrivateEndpointConnectionsServerTransport instance is connected to an instance of armstorage.PrivateEndpointConnectionsClient by way of the +// undefined.Transporter field. +func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { + return &PrivateEndpointConnectionsServerTransport{srv: srv} +} + +// PrivateEndpointConnectionsServerTransport connects instances of armstorage.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. +// Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. +type PrivateEndpointConnectionsServerTransport struct { + srv *PrivateEndpointConnectionsServer + newListPager *azfake.PagerResponder[armstorage.PrivateEndpointConnectionsClientListResponse] +} + +// Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. +func (p *PrivateEndpointConnectionsServerTransport) 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 "PrivateEndpointConnectionsClient.Delete": + resp, err = p.dispatchDelete(req) + case "PrivateEndpointConnectionsClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.NewListPager": + resp, err = p.dispatchNewListPager(req) + case "PrivateEndpointConnectionsClient.Put": + resp, err = p.dispatchPut(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if p.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := p.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], 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 (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := p.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], 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).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if p.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := p.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + p.newListPager = &resp + } + resp, err := server.PagerResponderNext(p.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(p.newListPager) { + p.newListPager = nil + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { + if p.srv.Put == nil { + return nil, &nonRetriableError{errors.New("method Put not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.PrivateEndpointConnection](req) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Put(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], 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).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go b/sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go new file mode 100644 index 000000000000..164d1ca5f197 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go @@ -0,0 +1,91 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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/storage/armstorage" + "net/http" + "regexp" +) + +// PrivateLinkResourcesServer is a fake server for instances of the armstorage.PrivateLinkResourcesClient type. +type PrivateLinkResourcesServer struct { + // ListByStorageAccount is the fake for method PrivateLinkResourcesClient.ListByStorageAccount + // HTTP status codes to indicate success: http.StatusOK + ListByStorageAccount func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.PrivateLinkResourcesClientListByStorageAccountOptions) (resp azfake.Responder[armstorage.PrivateLinkResourcesClientListByStorageAccountResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. +// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armstorage.PrivateLinkResourcesClient by way of the +// undefined.Transporter field. +func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { + return &PrivateLinkResourcesServerTransport{srv: srv} +} + +// PrivateLinkResourcesServerTransport connects instances of armstorage.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. +// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. +type PrivateLinkResourcesServerTransport struct { + srv *PrivateLinkResourcesServer +} + +// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. +func (p *PrivateLinkResourcesServerTransport) 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 "PrivateLinkResourcesClient.ListByStorageAccount": + resp, err = p.dispatchListByStorageAccount(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchListByStorageAccount(req *http.Request) (*http.Response, error) { + if p.srv.ListByStorageAccount == nil { + return nil, &nonRetriableError{errors.New("method ListByStorageAccount not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateLinkResources" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := p.srv.ListByStorageAccount(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).PrivateLinkResourceListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/queue_server.go b/sdk/resourcemanager/storage/armstorage/fake/queue_server.go new file mode 100644 index 000000000000..f5bcfc87da77 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/queue_server.go @@ -0,0 +1,240 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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/storage/armstorage" + "net/http" + "regexp" +) + +// QueueServer is a fake server for instances of the armstorage.QueueClient type. +type QueueServer struct { + // Create is the fake for method QueueClient.Create + // HTTP status codes to indicate success: http.StatusOK + Create func(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue armstorage.Queue, options *armstorage.QueueClientCreateOptions) (resp azfake.Responder[armstorage.QueueClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method QueueClient.Delete + // HTTP status codes to indicate success: http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *armstorage.QueueClientDeleteOptions) (resp azfake.Responder[armstorage.QueueClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method QueueClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *armstorage.QueueClientGetOptions) (resp azfake.Responder[armstorage.QueueClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method QueueClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.QueueClientListOptions) (resp azfake.PagerResponder[armstorage.QueueClientListResponse]) + + // Update is the fake for method QueueClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue armstorage.Queue, options *armstorage.QueueClientUpdateOptions) (resp azfake.Responder[armstorage.QueueClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewQueueServerTransport creates a new instance of QueueServerTransport with the provided implementation. +// The returned QueueServerTransport instance is connected to an instance of armstorage.QueueClient by way of the +// undefined.Transporter field. +func NewQueueServerTransport(srv *QueueServer) *QueueServerTransport { + return &QueueServerTransport{srv: srv} +} + +// QueueServerTransport connects instances of armstorage.QueueClient to instances of QueueServer. +// Don't use this type directly, use NewQueueServerTransport instead. +type QueueServerTransport struct { + srv *QueueServer + newListPager *azfake.PagerResponder[armstorage.QueueClientListResponse] +} + +// Do implements the policy.Transporter interface for QueueServerTransport. +func (q *QueueServerTransport) 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 "QueueClient.Create": + resp, err = q.dispatchCreate(req) + case "QueueClient.Delete": + resp, err = q.dispatchDelete(req) + case "QueueClient.Get": + resp, err = q.dispatchGet(req) + case "QueueClient.NewListPager": + resp, err = q.dispatchNewListPager(req) + case "QueueClient.Update": + resp, err = q.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (q *QueueServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if q.srv.Create == nil { + return nil, &nonRetriableError{errors.New("method Create not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.Queue](req) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], 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).Queue, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueueServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if q.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := q.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueueServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if q.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := q.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], 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).Queue, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueueServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if q.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if q.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + maxpagesizeParam := getOptional(qp.Get("$maxpagesize")) + filterParam := getOptional(qp.Get("$filter")) + var options *armstorage.QueueClientListOptions + if maxpagesizeParam != nil || filterParam != nil { + options = &armstorage.QueueClientListOptions{ + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + } + } + resp := q.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + q.newListPager = &resp + server.PagerResponderInjectNextLinks(q.newListPager, req, func(page *armstorage.QueueClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(q.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(q.newListPager) { + q.newListPager = nil + } + return resp, nil +} + +func (q *QueueServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if q.srv.Update == nil { + return nil, &nonRetriableError{errors.New("method Update not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.Queue](req) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], 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).Queue, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go new file mode 100644 index 000000000000..af71467f5af1 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go @@ -0,0 +1,157 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// QueueServicesServer is a fake server for instances of the armstorage.QueueServicesClient type. +type QueueServicesServer struct { + // GetServiceProperties is the fake for method QueueServicesClient.GetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + GetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.QueueServicesClientGetServicePropertiesOptions) (resp azfake.Responder[armstorage.QueueServicesClientGetServicePropertiesResponse], errResp azfake.ErrorResponder) + + // List is the fake for method QueueServicesClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.QueueServicesClientListOptions) (resp azfake.Responder[armstorage.QueueServicesClientListResponse], errResp azfake.ErrorResponder) + + // SetServiceProperties is the fake for method QueueServicesClient.SetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + SetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.QueueServiceProperties, options *armstorage.QueueServicesClientSetServicePropertiesOptions) (resp azfake.Responder[armstorage.QueueServicesClientSetServicePropertiesResponse], errResp azfake.ErrorResponder) +} + +// NewQueueServicesServerTransport creates a new instance of QueueServicesServerTransport with the provided implementation. +// The returned QueueServicesServerTransport instance is connected to an instance of armstorage.QueueServicesClient by way of the +// undefined.Transporter field. +func NewQueueServicesServerTransport(srv *QueueServicesServer) *QueueServicesServerTransport { + return &QueueServicesServerTransport{srv: srv} +} + +// QueueServicesServerTransport connects instances of armstorage.QueueServicesClient to instances of QueueServicesServer. +// Don't use this type directly, use NewQueueServicesServerTransport instead. +type QueueServicesServerTransport struct { + srv *QueueServicesServer +} + +// Do implements the policy.Transporter interface for QueueServicesServerTransport. +func (q *QueueServicesServerTransport) 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 "QueueServicesClient.GetServiceProperties": + resp, err = q.dispatchGetServiceProperties(req) + case "QueueServicesClient.List": + resp, err = q.dispatchList(req) + case "QueueServicesClient.SetServiceProperties": + resp, err = q.dispatchSetServiceProperties(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (q *QueueServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { + if q.srv.GetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := q.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).QueueServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueueServicesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if q.srv.List == nil { + return nil, &nonRetriableError{errors.New("method List not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := q.srv.List(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).ListQueueServices, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (q *QueueServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { + if q.srv.SetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.QueueServiceProperties](req) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).QueueServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/skus_server.go b/sdk/resourcemanager/storage/armstorage/fake/skus_server.go new file mode 100644 index 000000000000..c5c49e152d49 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/skus_server.go @@ -0,0 +1,93 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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/resourcemanager/storage/armstorage" + "net/http" + "regexp" +) + +// SKUsServer is a fake server for instances of the armstorage.SKUsClient type. +type SKUsServer struct { + // NewListPager is the fake for method SKUsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armstorage.SKUsClientListOptions) (resp azfake.PagerResponder[armstorage.SKUsClientListResponse]) +} + +// NewSKUsServerTransport creates a new instance of SKUsServerTransport with the provided implementation. +// The returned SKUsServerTransport instance is connected to an instance of armstorage.SKUsClient by way of the +// undefined.Transporter field. +func NewSKUsServerTransport(srv *SKUsServer) *SKUsServerTransport { + return &SKUsServerTransport{srv: srv} +} + +// SKUsServerTransport connects instances of armstorage.SKUsClient to instances of SKUsServer. +// Don't use this type directly, use NewSKUsServerTransport instead. +type SKUsServerTransport struct { + srv *SKUsServer + newListPager *azfake.PagerResponder[armstorage.SKUsClientListResponse] +} + +// Do implements the policy.Transporter interface for SKUsServerTransport. +func (s *SKUsServerTransport) 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 "SKUsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SKUsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if s.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/skus" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListPager(nil) + s.newListPager = &resp + } + resp, err := server.PagerResponderNext(s.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(s.newListPager) { + s.newListPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/table_server.go b/sdk/resourcemanager/storage/armstorage/fake/table_server.go new file mode 100644 index 000000000000..7df61d3f5711 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/table_server.go @@ -0,0 +1,243 @@ +//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/storage/armstorage" + "net/http" + "reflect" + "regexp" +) + +// TableServer is a fake server for instances of the armstorage.TableClient type. +type TableServer struct { + // Create is the fake for method TableClient.Create + // HTTP status codes to indicate success: http.StatusOK + Create func(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *armstorage.TableClientCreateOptions) (resp azfake.Responder[armstorage.TableClientCreateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TableClient.Delete + // HTTP status codes to indicate success: http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *armstorage.TableClientDeleteOptions) (resp azfake.Responder[armstorage.TableClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TableClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *armstorage.TableClientGetOptions) (resp azfake.Responder[armstorage.TableClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TableClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, accountName string, options *armstorage.TableClientListOptions) (resp azfake.PagerResponder[armstorage.TableClientListResponse]) + + // Update is the fake for method TableClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *armstorage.TableClientUpdateOptions) (resp azfake.Responder[armstorage.TableClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewTableServerTransport creates a new instance of TableServerTransport with the provided implementation. +// The returned TableServerTransport instance is connected to an instance of armstorage.TableClient by way of the +// undefined.Transporter field. +func NewTableServerTransport(srv *TableServer) *TableServerTransport { + return &TableServerTransport{srv: srv} +} + +// TableServerTransport connects instances of armstorage.TableClient to instances of TableServer. +// Don't use this type directly, use NewTableServerTransport instead. +type TableServerTransport struct { + srv *TableServer + newListPager *azfake.PagerResponder[armstorage.TableClientListResponse] +} + +// Do implements the policy.Transporter interface for TableServerTransport. +func (t *TableServerTransport) 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 "TableClient.Create": + resp, err = t.dispatchCreate(req) + case "TableClient.Delete": + resp, err = t.dispatchDelete(req) + case "TableClient.Get": + resp, err = t.dispatchGet(req) + case "TableClient.NewListPager": + resp, err = t.dispatchNewListPager(req) + case "TableClient.Update": + resp, err = t.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TableServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { + if t.srv.Create == nil { + return nil, &nonRetriableError{errors.New("method Create not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.Table](req) + if err != nil { + return nil, err + } + var options *armstorage.TableClientCreateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armstorage.TableClientCreateOptions{ + Parameters: &body, + } + } + respr, errRespr := t.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], options) + 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).Table, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TableServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("method Delete not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TableServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.srv.Get == nil { + return nil, &nonRetriableError{errors.New("method Get not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], 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).Table, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TableServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + } + if t.newListPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + t.newListPager = &resp + server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armstorage.TableClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(t.newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(t.newListPager) { + t.newListPager = nil + } + return resp, nil +} + +func (t *TableServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if t.srv.Update == nil { + return nil, &nonRetriableError{errors.New("method Update not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.Table](req) + if err != nil { + return nil, err + } + var options *armstorage.TableClientUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armstorage.TableClientUpdateOptions{ + Parameters: &body, + } + } + respr, errRespr := t.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], options) + 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).Table, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go new file mode 100644 index 000000000000..959e7d30fd7e --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go @@ -0,0 +1,157 @@ +//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/storage/armstorage" + "net/http" + "regexp" +) + +// TableServicesServer is a fake server for instances of the armstorage.TableServicesClient type. +type TableServicesServer struct { + // GetServiceProperties is the fake for method TableServicesClient.GetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + GetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.TableServicesClientGetServicePropertiesOptions) (resp azfake.Responder[armstorage.TableServicesClientGetServicePropertiesResponse], errResp azfake.ErrorResponder) + + // List is the fake for method TableServicesClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.TableServicesClientListOptions) (resp azfake.Responder[armstorage.TableServicesClientListResponse], errResp azfake.ErrorResponder) + + // SetServiceProperties is the fake for method TableServicesClient.SetServiceProperties + // HTTP status codes to indicate success: http.StatusOK + SetServiceProperties func(ctx context.Context, resourceGroupName string, accountName string, parameters armstorage.TableServiceProperties, options *armstorage.TableServicesClientSetServicePropertiesOptions) (resp azfake.Responder[armstorage.TableServicesClientSetServicePropertiesResponse], errResp azfake.ErrorResponder) +} + +// NewTableServicesServerTransport creates a new instance of TableServicesServerTransport with the provided implementation. +// The returned TableServicesServerTransport instance is connected to an instance of armstorage.TableServicesClient by way of the +// undefined.Transporter field. +func NewTableServicesServerTransport(srv *TableServicesServer) *TableServicesServerTransport { + return &TableServicesServerTransport{srv: srv} +} + +// TableServicesServerTransport connects instances of armstorage.TableServicesClient to instances of TableServicesServer. +// Don't use this type directly, use NewTableServicesServerTransport instead. +type TableServicesServerTransport struct { + srv *TableServicesServer +} + +// Do implements the policy.Transporter interface for TableServicesServerTransport. +func (t *TableServicesServerTransport) 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 "TableServicesClient.GetServiceProperties": + resp, err = t.dispatchGetServiceProperties(req) + case "TableServicesClient.List": + resp, err = t.dispatchList(req) + case "TableServicesClient.SetServiceProperties": + resp, err = t.dispatchSetServiceProperties(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TableServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { + if t.srv.GetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).TableServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TableServicesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if t.srv.List == nil { + return nil, &nonRetriableError{errors.New("method List not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + respr, errRespr := t.srv.List(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).ListTableServices, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TableServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { + if t.srv.SetServiceProperties == nil { + return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + } + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/(?P[a-zA-Z0-9-_]+)" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armstorage.TableServiceProperties](req) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], 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).TableServiceProperties, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/time_rfc3339.go b/sdk/resourcemanager/storage/armstorage/fake/time_rfc3339.go new file mode 100644 index 000000000000..45fe10cbc6df --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/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" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fake/usages_server.go b/sdk/resourcemanager/storage/armstorage/fake/usages_server.go new file mode 100644 index 000000000000..242ffb7336df --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake/usages_server.go @@ -0,0 +1,93 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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/resourcemanager/storage/armstorage" + "net/http" + "regexp" +) + +// UsagesServer is a fake server for instances of the armstorage.UsagesClient type. +type UsagesServer struct { + // NewListByLocationPager is the fake for method UsagesClient.NewListByLocationPager + // HTTP status codes to indicate success: http.StatusOK + NewListByLocationPager func(location string, options *armstorage.UsagesClientListByLocationOptions) (resp azfake.PagerResponder[armstorage.UsagesClientListByLocationResponse]) +} + +// NewUsagesServerTransport creates a new instance of UsagesServerTransport with the provided implementation. +// The returned UsagesServerTransport instance is connected to an instance of armstorage.UsagesClient by way of the +// undefined.Transporter field. +func NewUsagesServerTransport(srv *UsagesServer) *UsagesServerTransport { + return &UsagesServerTransport{srv: srv} +} + +// UsagesServerTransport connects instances of armstorage.UsagesClient to instances of UsagesServer. +// Don't use this type directly, use NewUsagesServerTransport instead. +type UsagesServerTransport struct { + srv *UsagesServer + newListByLocationPager *azfake.PagerResponder[armstorage.UsagesClientListByLocationResponse] +} + +// Do implements the policy.Transporter interface for UsagesServerTransport. +func (u *UsagesServerTransport) 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 "UsagesClient.NewListByLocationPager": + resp, err = u.dispatchNewListByLocationPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (u *UsagesServerTransport) dispatchNewListByLocationPager(req *http.Request) (*http.Response, error) { + if u.srv.NewListByLocationPager == nil { + return nil, &nonRetriableError{errors.New("method NewListByLocationPager not implemented")} + } + if u.newListByLocationPager == nil { + const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/locations/(?P[a-zA-Z0-9-_]+)/usages" + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.Path) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := u.srv.NewListByLocationPager(matches[regex.SubexpIndex("location")], nil) + u.newListByLocationPager = &resp + } + resp, err := server.PagerResponderNext(u.newListByLocationPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(u.newListByLocationPager) { + u.newListByLocationPager = nil + } + return resp, nil +} diff --git a/sdk/resourcemanager/storage/armstorage/fileservices_client.go b/sdk/resourcemanager/storage/armstorage/fileservices_client.go index b0970cfd35aa..5b7c478f339c 100644 --- a/sdk/resourcemanager/storage/armstorage/fileservices_client.go +++ b/sdk/resourcemanager/storage/armstorage/fileservices_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 armstorage @@ -55,18 +54,25 @@ func NewFileServicesClient(subscriptionID string, credential azcore.TokenCredent // - options - FileServicesClientGetServicePropertiesOptions contains the optional parameters for the FileServicesClient.GetServiceProperties // method. func (client *FileServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesClientGetServicePropertiesOptions) (FileServicesClientGetServicePropertiesResponse, error) { + var err error + const operationName = "FileServicesClient.GetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return FileServicesClientGetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileServicesClientGetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileServicesClientGetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileServicesClientGetServicePropertiesResponse{}, err } - return client.getServicePropertiesHandleResponse(resp) + resp, err := client.getServicePropertiesHandleResponse(httpResp) + return resp, err } // getServicePropertiesCreateRequest creates the GetServiceProperties request. @@ -114,18 +120,25 @@ func (client *FileServicesClient) getServicePropertiesHandleResponse(resp *http. // 3 and 24 characters in length and use numbers and lower-case letters only. // - options - FileServicesClientListOptions contains the optional parameters for the FileServicesClient.List method. func (client *FileServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesClientListOptions) (FileServicesClientListResponse, error) { + var err error + const operationName = "FileServicesClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return FileServicesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileServicesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileServicesClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileServicesClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -175,18 +188,25 @@ func (client *FileServicesClient) listHandleResponse(resp *http.Response) (FileS // - options - FileServicesClientSetServicePropertiesOptions contains the optional parameters for the FileServicesClient.SetServiceProperties // method. func (client *FileServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters FileServiceProperties, options *FileServicesClientSetServicePropertiesOptions) (FileServicesClientSetServicePropertiesResponse, error) { + var err error + const operationName = "FileServicesClient.SetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return FileServicesClientSetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileServicesClientSetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileServicesClientSetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileServicesClientSetServicePropertiesResponse{}, err } - return client.setServicePropertiesHandleResponse(resp) + resp, err := client.setServicePropertiesHandleResponse(httpResp) + return resp, err } // setServicePropertiesCreateRequest creates the SetServiceProperties request. @@ -213,7 +233,10 @@ func (client *FileServicesClient) setServicePropertiesCreateRequest(ctx context. reqQP.Set("api-version", "2022-09-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 } // setServicePropertiesHandleResponse handles the SetServiceProperties response. diff --git a/sdk/resourcemanager/storage/armstorage/fileshares_client.go b/sdk/resourcemanager/storage/armstorage/fileshares_client.go index 1c414dda2be9..a0f568c50f73 100644 --- a/sdk/resourcemanager/storage/armstorage/fileshares_client.go +++ b/sdk/resourcemanager/storage/armstorage/fileshares_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 armstorage @@ -59,18 +58,25 @@ func NewFileSharesClient(subscriptionID string, credential azcore.TokenCredentia // - fileShare - Properties of the file share to create. // - options - FileSharesClientCreateOptions contains the optional parameters for the FileSharesClient.Create method. func (client *FileSharesClient) Create(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesClientCreateOptions) (FileSharesClientCreateResponse, error) { + var err error + const operationName = "FileSharesClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options) if err != nil { return FileSharesClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSharesClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return FileSharesClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -103,7 +109,10 @@ func (client *FileSharesClient) createCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, fileShare) + if err := runtime.MarshalAsJSON(req, fileShare); err != nil { + return nil, err + } + return req, nil } // createHandleResponse handles the Create response. @@ -127,16 +136,22 @@ func (client *FileSharesClient) createHandleResponse(resp *http.Response) (FileS // character must be immediately preceded and followed by a letter or number. // - options - FileSharesClientDeleteOptions contains the optional parameters for the FileSharesClient.Delete method. func (client *FileSharesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientDeleteOptions) (FileSharesClientDeleteResponse, error) { + var err error + const operationName = "FileSharesClient.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, accountName, shareName, options) if err != nil { return FileSharesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSharesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return FileSharesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientDeleteResponse{}, err } return FileSharesClientDeleteResponse{}, nil } @@ -189,18 +204,25 @@ func (client *FileSharesClient) deleteCreateRequest(ctx context.Context, resourc // character must be immediately preceded and followed by a letter or number. // - options - FileSharesClientGetOptions contains the optional parameters for the FileSharesClient.Get method. func (client *FileSharesClient) Get(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientGetOptions) (FileSharesClientGetResponse, error) { + var err error + const operationName = "FileSharesClient.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, accountName, shareName, options) if err != nil { return FileSharesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSharesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSharesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -261,18 +283,25 @@ func (client *FileSharesClient) getHandleResponse(resp *http.Response) (FileShar // character must be immediately preceded and followed by a letter or number. // - options - FileSharesClientLeaseOptions contains the optional parameters for the FileSharesClient.Lease method. func (client *FileSharesClient) Lease(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesClientLeaseOptions) (FileSharesClientLeaseResponse, error) { + var err error + const operationName = "FileSharesClient.Lease" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.leaseCreateRequest(ctx, resourceGroupName, accountName, shareName, options) if err != nil { return FileSharesClientLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSharesClientLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSharesClientLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientLeaseResponse{}, err } - return client.leaseHandleResponse(resp) + resp, err := client.leaseHandleResponse(httpResp) + return resp, err } // leaseCreateRequest creates the Lease request. @@ -306,7 +335,10 @@ func (client *FileSharesClient) leaseCreateRequest(ctx context.Context, resource } req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { - return req, runtime.MarshalAsJSON(req, *options.Parameters) + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -336,6 +368,7 @@ func (client *FileSharesClient) NewListPager(resourceGroupName string, accountNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *FileSharesClientListResponse) (FileSharesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FileSharesClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -355,6 +388,7 @@ func (client *FileSharesClient) NewListPager(resourceGroupName string, accountNa } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -414,16 +448,22 @@ func (client *FileSharesClient) listHandleResponse(resp *http.Response) (FileSha // character must be immediately preceded and followed by a letter or number. // - options - FileSharesClientRestoreOptions contains the optional parameters for the FileSharesClient.Restore method. func (client *FileSharesClient) Restore(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare, options *FileSharesClientRestoreOptions) (FileSharesClientRestoreResponse, error) { + var err error + const operationName = "FileSharesClient.Restore" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.restoreCreateRequest(ctx, resourceGroupName, accountName, shareName, deletedShare, options) if err != nil { return FileSharesClientRestoreResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSharesClientRestoreResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSharesClientRestoreResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientRestoreResponse{}, err } return FileSharesClientRestoreResponse{}, nil } @@ -455,7 +495,10 @@ func (client *FileSharesClient) restoreCreateRequest(ctx context.Context, resour reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, deletedShare) + if err := runtime.MarshalAsJSON(req, deletedShare); err != nil { + return nil, err + } + return req, nil } // Update - Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. @@ -472,18 +515,25 @@ func (client *FileSharesClient) restoreCreateRequest(ctx context.Context, resour // - fileShare - Properties to update for the file share. // - options - FileSharesClientUpdateOptions contains the optional parameters for the FileSharesClient.Update method. func (client *FileSharesClient) Update(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesClientUpdateOptions) (FileSharesClientUpdateResponse, error) { + var err error + const operationName = "FileSharesClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options) if err != nil { return FileSharesClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSharesClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSharesClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSharesClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -513,7 +563,10 @@ func (client *FileSharesClient) updateCreateRequest(ctx context.Context, resourc reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, fileShare) + if err := runtime.MarshalAsJSON(req, fileShare); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/storage/armstorage/go.mod b/sdk/resourcemanager/storage/armstorage/go.mod index b3d8cb57201b..60b6326c5579 100644 --- a/sdk/resourcemanager/storage/armstorage/go.mod +++ b/sdk/resourcemanager/storage/armstorage/go.mod @@ -3,7 +3,7 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0-beta.2 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 @@ -11,7 +11,7 @@ require ( ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnaeon/go-vcr v1.1.0 // indirect @@ -21,9 +21,9 @@ require ( github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text 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 gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/storage/armstorage/go.sum b/sdk/resourcemanager/storage/armstorage/go.sum index 8cb8bbc6fe9d..7c4ceb8d14fa 100644 --- a/sdk/resourcemanager/storage/armstorage/go.sum +++ b/sdk/resourcemanager/storage/armstorage/go.sum @@ -1,9 +1,9 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0-beta.2 h1:C3zKsGguxcLd8a2uEytB8+TFtBGd75bXRxEs0QBwsv0= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0-beta.2/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 h1:T8quHYlUGyb/oqtSTwqlCr1ilJHrDv+ZtpSfo+hm1BU= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1/go.mod h1:gLa1CL2RNE4s7M3yopJ/p0iq5DdY6Yv5ZUt9MTRZOQM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +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/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= @@ -35,12 +35,12 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +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.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/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/sdk/resourcemanager/storage/armstorage/localusers_client.go b/sdk/resourcemanager/storage/armstorage/localusers_client.go index 1855e77aef62..a89d9b42b134 100644 --- a/sdk/resourcemanager/storage/armstorage/localusers_client.go +++ b/sdk/resourcemanager/storage/armstorage/localusers_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 armstorage @@ -57,18 +56,25 @@ func NewLocalUsersClient(subscriptionID string, credential azcore.TokenCredentia // - options - LocalUsersClientCreateOrUpdateOptions contains the optional parameters for the LocalUsersClient.CreateOrUpdate // method. func (client *LocalUsersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, username string, properties LocalUser, options *LocalUsersClientCreateOrUpdateOptions) (LocalUsersClientCreateOrUpdateResponse, error) { + var err error + const operationName = "LocalUsersClient.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, accountName, username, properties, options) if err != nil { return LocalUsersClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LocalUsersClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LocalUsersClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LocalUsersClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -98,7 +104,10 @@ func (client *LocalUsersClient) createOrUpdateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, properties) + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -121,16 +130,22 @@ func (client *LocalUsersClient) createOrUpdateHandleResponse(resp *http.Response // within the storage account. // - options - LocalUsersClientDeleteOptions contains the optional parameters for the LocalUsersClient.Delete method. func (client *LocalUsersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, username string, options *LocalUsersClientDeleteOptions) (LocalUsersClientDeleteResponse, error) { + var err error + const operationName = "LocalUsersClient.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, accountName, username, options) if err != nil { return LocalUsersClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LocalUsersClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return LocalUsersClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return LocalUsersClientDeleteResponse{}, err } return LocalUsersClientDeleteResponse{}, nil } @@ -176,18 +191,25 @@ func (client *LocalUsersClient) deleteCreateRequest(ctx context.Context, resourc // within the storage account. // - options - LocalUsersClientGetOptions contains the optional parameters for the LocalUsersClient.Get method. func (client *LocalUsersClient) Get(ctx context.Context, resourceGroupName string, accountName string, username string, options *LocalUsersClientGetOptions) (LocalUsersClientGetResponse, error) { + var err error + const operationName = "LocalUsersClient.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, accountName, username, options) if err != nil { return LocalUsersClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LocalUsersClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LocalUsersClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LocalUsersClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -242,6 +264,7 @@ func (client *LocalUsersClient) NewListPager(resourceGroupName string, accountNa return false }, Fetcher: func(ctx context.Context, page *LocalUsersClientListResponse) (LocalUsersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LocalUsersClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return LocalUsersClientListResponse{}, err @@ -255,6 +278,7 @@ func (client *LocalUsersClient) NewListPager(resourceGroupName string, accountNa } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -304,18 +328,25 @@ func (client *LocalUsersClient) listHandleResponse(resp *http.Response) (LocalUs // within the storage account. // - options - LocalUsersClientListKeysOptions contains the optional parameters for the LocalUsersClient.ListKeys method. func (client *LocalUsersClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, username string, options *LocalUsersClientListKeysOptions) (LocalUsersClientListKeysResponse, error) { + var err error + const operationName = "LocalUsersClient.ListKeys" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, username, options) if err != nil { return LocalUsersClientListKeysResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LocalUsersClientListKeysResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LocalUsersClientListKeysResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LocalUsersClientListKeysResponse{}, err } - return client.listKeysHandleResponse(resp) + resp, err := client.listKeysHandleResponse(httpResp) + return resp, err } // listKeysCreateRequest creates the ListKeys request. @@ -369,18 +400,25 @@ func (client *LocalUsersClient) listKeysHandleResponse(resp *http.Response) (Loc // - options - LocalUsersClientRegeneratePasswordOptions contains the optional parameters for the LocalUsersClient.RegeneratePassword // method. func (client *LocalUsersClient) RegeneratePassword(ctx context.Context, resourceGroupName string, accountName string, username string, options *LocalUsersClientRegeneratePasswordOptions) (LocalUsersClientRegeneratePasswordResponse, error) { + var err error + const operationName = "LocalUsersClient.RegeneratePassword" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.regeneratePasswordCreateRequest(ctx, resourceGroupName, accountName, username, options) if err != nil { return LocalUsersClientRegeneratePasswordResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LocalUsersClientRegeneratePasswordResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LocalUsersClientRegeneratePasswordResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LocalUsersClientRegeneratePasswordResponse{}, err } - return client.regeneratePasswordHandleResponse(resp) + resp, err := client.regeneratePasswordHandleResponse(httpResp) + return resp, err } // regeneratePasswordCreateRequest creates the RegeneratePassword request. diff --git a/sdk/resourcemanager/storage/armstorage/managementpolicies_client.go b/sdk/resourcemanager/storage/armstorage/managementpolicies_client.go index 5ef921e9678c..e91b7ca98707 100644 --- a/sdk/resourcemanager/storage/armstorage/managementpolicies_client.go +++ b/sdk/resourcemanager/storage/armstorage/managementpolicies_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 armstorage @@ -56,18 +55,25 @@ func NewManagementPoliciesClient(subscriptionID string, credential azcore.TokenC // - options - ManagementPoliciesClientCreateOrUpdateOptions contains the optional parameters for the ManagementPoliciesClient.CreateOrUpdate // method. func (client *ManagementPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, properties ManagementPolicy, options *ManagementPoliciesClientCreateOrUpdateOptions) (ManagementPoliciesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ManagementPoliciesClient.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, accountName, managementPolicyName, properties, options) if err != nil { return ManagementPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementPoliciesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ManagementPoliciesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ManagementPoliciesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -97,7 +103,10 @@ func (client *ManagementPoliciesClient) createOrUpdateCreateRequest(ctx context. reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, properties) + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -120,16 +129,22 @@ func (client *ManagementPoliciesClient) createOrUpdateHandleResponse(resp *http. // - options - ManagementPoliciesClientDeleteOptions contains the optional parameters for the ManagementPoliciesClient.Delete // method. func (client *ManagementPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesClientDeleteOptions) (ManagementPoliciesClientDeleteResponse, error) { + var err error + const operationName = "ManagementPoliciesClient.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, accountName, managementPolicyName, options) if err != nil { return ManagementPoliciesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementPoliciesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ManagementPoliciesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ManagementPoliciesClientDeleteResponse{}, err } return ManagementPoliciesClientDeleteResponse{}, nil } @@ -173,18 +188,25 @@ func (client *ManagementPoliciesClient) deleteCreateRequest(ctx context.Context, // - managementPolicyName - The name of the Storage Account Management Policy. It should always be 'default' // - options - ManagementPoliciesClientGetOptions contains the optional parameters for the ManagementPoliciesClient.Get method. func (client *ManagementPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesClientGetOptions) (ManagementPoliciesClientGetResponse, error) { + var err error + const operationName = "ManagementPoliciesClient.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, accountName, managementPolicyName, options) if err != nil { return ManagementPoliciesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ManagementPoliciesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ManagementPoliciesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ManagementPoliciesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. diff --git a/sdk/resourcemanager/storage/armstorage/models.go b/sdk/resourcemanager/storage/armstorage/models.go index 681e79dc7632..d75f42df02c3 100644 --- a/sdk/resourcemanager/storage/armstorage/models.go +++ b/sdk/resourcemanager/storage/armstorage/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 armstorage @@ -13,86 +12,86 @@ import "time" type AccessPolicy struct { // Expiry time of the access policy - ExpiryTime *time.Time `json:"expiryTime,omitempty"` + ExpiryTime *time.Time // List of abbreviated permissions. - Permission *string `json:"permission,omitempty"` + Permission *string // Start time of the access policy - StartTime *time.Time `json:"startTime,omitempty"` + StartTime *time.Time } // Account - The storage account. type Account struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The extendedLocation of the resource. - ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + ExtendedLocation *ExtendedLocation // The identity of the resource. - Identity *Identity `json:"identity,omitempty"` + Identity *Identity // Properties of the storage account. - Properties *AccountProperties `json:"properties,omitempty"` + Properties *AccountProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; Gets the Kind. - Kind *Kind `json:"kind,omitempty" azure:"ro"` + Kind *Kind // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Gets the SKU. - SKU *SKU `json:"sku,omitempty" azure:"ro"` + SKU *SKU // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // AccountCheckNameAvailabilityParameters - The parameters used to check the availability of the storage account name. type AccountCheckNameAvailabilityParameters struct { // REQUIRED; The storage account name. - Name *string `json:"name,omitempty"` + Name *string // CONSTANT; The type of resource, Microsoft.Storage/storageAccounts // Field has constant value "Microsoft.Storage/storageAccounts", any specified value is ignored. - Type *string `json:"type,omitempty"` + Type *string } // AccountCreateParameters - The parameters used when creating a storage account. type AccountCreateParameters struct { // REQUIRED; Required. Indicates the type of storage account. - Kind *Kind `json:"kind,omitempty"` + Kind *Kind // REQUIRED; Required. Gets or sets the location of the resource. This will be one of the supported and registered Azure Geo // Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource // cannot be changed once it is created, but if an identical geo region is specified on update, the request will succeed. - Location *string `json:"location,omitempty"` + Location *string // REQUIRED; Required. Gets or sets the SKU name. - SKU *SKU `json:"sku,omitempty"` + SKU *SKU // Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. // Otherwise it will be created in the specified extended location - ExtendedLocation *ExtendedLocation `json:"extendedLocation,omitempty"` + ExtendedLocation *ExtendedLocation // The identity of the resource. - Identity *Identity `json:"identity,omitempty"` + Identity *Identity // The parameters used to create the storage account. - Properties *AccountPropertiesCreateParameters `json:"properties,omitempty"` + Properties *AccountPropertiesCreateParameters // Gets or sets a list of key value pairs that describe the resource. These tags can be used for viewing and grouping this // resource (across resource groups). A maximum of 15 tags can be provided for a // resource. Each tag must have a key with a length no greater than 128 characters and a value with a length no greater than // 256 characters. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // AccountImmutabilityPolicyProperties - This defines account-level immutability policy properties. @@ -100,218 +99,218 @@ type AccountImmutabilityPolicyProperties struct { // This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can // be written to an append blob while maintaining immutability protection and // compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. - AllowProtectedAppendWrites *bool `json:"allowProtectedAppendWrites,omitempty"` + AllowProtectedAppendWrites *bool // The immutability period for the blobs in the container since the policy creation, in days. - ImmutabilityPeriodSinceCreationInDays *int32 `json:"immutabilityPeriodSinceCreationInDays,omitempty"` + ImmutabilityPeriodSinceCreationInDays *int32 // The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows // increase and decrease of immutability retention time and also allows toggling // allowProtectedAppendWrites property, Locked state only allows the increase of the immutability retention time. A policy // can only be created in a Disabled or Unlocked state and can be toggled between // the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. - State *AccountImmutabilityPolicyState `json:"state,omitempty"` + State *AccountImmutabilityPolicyState } // AccountInternetEndpoints - The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via // a internet routing endpoint. type AccountInternetEndpoints struct { // READ-ONLY; Gets the blob endpoint. - Blob *string `json:"blob,omitempty" azure:"ro"` + Blob *string // READ-ONLY; Gets the dfs endpoint. - Dfs *string `json:"dfs,omitempty" azure:"ro"` + Dfs *string // READ-ONLY; Gets the file endpoint. - File *string `json:"file,omitempty" azure:"ro"` + File *string // READ-ONLY; Gets the web endpoint. - Web *string `json:"web,omitempty" azure:"ro"` + Web *string } // AccountKey - An access key for the storage account. type AccountKey struct { // READ-ONLY; Creation time of the key, in round trip date format. - CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` + CreationTime *time.Time // READ-ONLY; Name of the key. - KeyName *string `json:"keyName,omitempty" azure:"ro"` + KeyName *string // READ-ONLY; Permissions for the key -- read-only or full permissions. - Permissions *KeyPermission `json:"permissions,omitempty" azure:"ro"` + Permissions *KeyPermission // READ-ONLY; Base 64-encoded value of the key. - Value *string `json:"value,omitempty" azure:"ro"` + Value *string } // AccountListKeysResult - The response from the ListKeys operation. type AccountListKeysResult struct { // READ-ONLY; Gets the list of storage account keys and their properties for the specified storage account. - Keys []*AccountKey `json:"keys,omitempty" azure:"ro"` + Keys []*AccountKey } // AccountListResult - The response from the List Storage Accounts operation. type AccountListResult struct { // READ-ONLY; Request URL that can be used to query next page of storage accounts. Returned when total number of requested // storage accounts exceed maximum page size. - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; Gets the list of storage accounts and their properties. - Value []*Account `json:"value,omitempty" azure:"ro"` + Value []*Account } // AccountMicrosoftEndpoints - The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object // via a microsoft routing endpoint. type AccountMicrosoftEndpoints struct { // READ-ONLY; Gets the blob endpoint. - Blob *string `json:"blob,omitempty" azure:"ro"` + Blob *string // READ-ONLY; Gets the dfs endpoint. - Dfs *string `json:"dfs,omitempty" azure:"ro"` + Dfs *string // READ-ONLY; Gets the file endpoint. - File *string `json:"file,omitempty" azure:"ro"` + File *string // READ-ONLY; Gets the queue endpoint. - Queue *string `json:"queue,omitempty" azure:"ro"` + Queue *string // READ-ONLY; Gets the table endpoint. - Table *string `json:"table,omitempty" azure:"ro"` + Table *string // READ-ONLY; Gets the web endpoint. - Web *string `json:"web,omitempty" azure:"ro"` + Web *string } // AccountProperties - Properties of the storage account. type AccountProperties struct { // Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for // this property. - AllowBlobPublicAccess *bool `json:"allowBlobPublicAccess,omitempty"` + AllowBlobPublicAccess *bool // Allow or disallow cross AAD tenant object replication. The default interpretation is true for this property. - AllowCrossTenantReplication *bool `json:"allowCrossTenantReplication,omitempty"` + AllowCrossTenantReplication *bool // Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If // false, then all requests, including shared access signatures, must be authorized // with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. - AllowSharedKeyAccess *bool `json:"allowSharedKeyAccess,omitempty"` + AllowSharedKeyAccess *bool // Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. - AllowedCopyScope *AllowedCopyScope `json:"allowedCopyScope,omitempty"` + AllowedCopyScope *AllowedCopyScope // Provides the identity based authentication settings for Azure Files. - AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication `json:"azureFilesIdentityBasedAuthentication,omitempty"` + AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication // Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, // which creates accounts in an Azure DNS Zone and the endpoint URL // will have an alphanumeric DNS Zone identifier. - DNSEndpointType *DNSEndpointType `json:"dnsEndpointType,omitempty"` + DNSEndpointType *DNSEndpointType // A boolean flag which indicates whether the default authentication is OAuth or not. The default interpretation is false // for this property. - DefaultToOAuthAuthentication *bool `json:"defaultToOAuthAuthentication,omitempty"` + DefaultToOAuthAuthentication *bool // Allows https traffic only to storage service if sets to true. - EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` + EnableHTTPSTrafficOnly *bool // NFS 3.0 protocol support enabled if set to true. - EnableNfsV3 *bool `json:"isNfsV3Enabled,omitempty"` + EnableNfsV3 *bool // The property is immutable and can only be set to true at the account creation time. When set to true, it enables object // level immutability for all the containers in the account by default. - ImmutableStorageWithVersioning *ImmutableStorageAccount `json:"immutableStorageWithVersioning,omitempty"` + ImmutableStorageWithVersioning *ImmutableStorageAccount // Account HierarchicalNamespace enabled if sets to true. - IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"` + IsHnsEnabled *bool // Enables local users feature, if set to true - IsLocalUserEnabled *bool `json:"isLocalUserEnabled,omitempty"` + IsLocalUserEnabled *bool // Enables Secure File Transfer Protocol, if set to true - IsSftpEnabled *bool `json:"isSftpEnabled,omitempty"` + IsSftpEnabled *bool // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` + LargeFileSharesState *LargeFileSharesState // Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. - MinimumTLSVersion *MinimumTLSVersion `json:"minimumTlsVersion,omitempty"` + MinimumTLSVersion *MinimumTLSVersion // Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + PublicNetworkAccess *PublicNetworkAccess // Maintains information about the network routing choice opted by the user for data transfer - RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` + RoutingPreference *RoutingPreference // This property is readOnly and is set by server during asynchronous storage account sku conversion operations. - StorageAccountSKUConversionStatus *AccountSKUConversionStatus `json:"storageAccountSkuConversionStatus,omitempty"` + StorageAccountSKUConversionStatus *AccountSKUConversionStatus // READ-ONLY; Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access // tier is the default value for premium block blobs storage account type and it cannot // be changed for the premium block blobs storage account type. - AccessTier *AccessTier `json:"accessTier,omitempty" azure:"ro"` + AccessTier *AccessTier // READ-ONLY; Blob restore status - BlobRestoreStatus *BlobRestoreStatus `json:"blobRestoreStatus,omitempty" azure:"ro"` + BlobRestoreStatus *BlobRestoreStatus // READ-ONLY; Gets the creation date and time of the storage account in UTC. - CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` + CreationTime *time.Time // READ-ONLY; Gets the custom domain the user assigned to this storage account. - CustomDomain *CustomDomain `json:"customDomain,omitempty" azure:"ro"` + CustomDomain *CustomDomain // READ-ONLY; Encryption settings to be used for server-side encryption for the storage account. - Encryption *Encryption `json:"encryption,omitempty" azure:"ro"` + Encryption *Encryption // READ-ONLY; If the failover is in progress, the value will be true, otherwise, it will be null. - FailoverInProgress *bool `json:"failoverInProgress,omitempty" azure:"ro"` + FailoverInProgress *bool // READ-ONLY; Geo Replication Stats - GeoReplicationStats *GeoReplicationStats `json:"geoReplicationStats,omitempty" azure:"ro"` + GeoReplicationStats *GeoReplicationStats // READ-ONLY; Storage account keys creation time. - KeyCreationTime *KeyCreationTime `json:"keyCreationTime,omitempty" azure:"ro"` + KeyCreationTime *KeyCreationTime // READ-ONLY; KeyPolicy assigned to the storage account. - KeyPolicy *KeyPolicy `json:"keyPolicy,omitempty" azure:"ro"` + KeyPolicy *KeyPolicy // READ-ONLY; Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent // timestamp is retained. This element is not returned if there has never been a failover // instance. Only available if the accountType is StandardGRS or StandardRAGRS. - LastGeoFailoverTime *time.Time `json:"lastGeoFailoverTime,omitempty" azure:"ro"` + LastGeoFailoverTime *time.Time // READ-ONLY; Network rule set - NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty" azure:"ro"` + NetworkRuleSet *NetworkRuleSet // READ-ONLY; Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that StandardZRS // and PremiumLRS accounts only return the blob endpoint. - PrimaryEndpoints *Endpoints `json:"primaryEndpoints,omitempty" azure:"ro"` + PrimaryEndpoints *Endpoints // READ-ONLY; Gets the location of the primary data center for the storage account. - PrimaryLocation *string `json:"primaryLocation,omitempty" azure:"ro"` + PrimaryLocation *string // READ-ONLY; List of private endpoint connection associated with the specified storage account - PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + PrivateEndpointConnections []*PrivateEndpointConnection // READ-ONLY; Gets the status of the storage account at the time the operation was called. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ProvisioningState // READ-ONLY; SasPolicy assigned to the storage account. - SasPolicy *SasPolicy `json:"sasPolicy,omitempty" azure:"ro"` + SasPolicy *SasPolicy // READ-ONLY; Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object from the secondary // location of the storage account. Only available if the SKU name is Standard_RAGRS. - SecondaryEndpoints *Endpoints `json:"secondaryEndpoints,omitempty" azure:"ro"` + SecondaryEndpoints *Endpoints // READ-ONLY; Gets the location of the geo-replicated secondary for the storage account. Only available if the accountType // is StandardGRS or StandardRAGRS. - SecondaryLocation *string `json:"secondaryLocation,omitempty" azure:"ro"` + SecondaryLocation *string // READ-ONLY; Gets the status indicating whether the primary location of the storage account is available or unavailable. - StatusOfPrimary *AccountStatus `json:"statusOfPrimary,omitempty" azure:"ro"` + StatusOfPrimary *AccountStatus // READ-ONLY; Gets the status indicating whether the secondary location of the storage account is available or unavailable. // Only available if the SKU name is StandardGRS or StandardRAGRS. - StatusOfSecondary *AccountStatus `json:"statusOfSecondary,omitempty" azure:"ro"` + StatusOfSecondary *AccountStatus } // AccountPropertiesCreateParameters - The parameters used to create the storage account. @@ -319,82 +318,82 @@ type AccountPropertiesCreateParameters struct { // Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier // is the default value for premium block blobs storage account type and it cannot // be changed for the premium block blobs storage account type. - AccessTier *AccessTier `json:"accessTier,omitempty"` + AccessTier *AccessTier // Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for // this property. - AllowBlobPublicAccess *bool `json:"allowBlobPublicAccess,omitempty"` + AllowBlobPublicAccess *bool // Allow or disallow cross AAD tenant object replication. The default interpretation is true for this property. - AllowCrossTenantReplication *bool `json:"allowCrossTenantReplication,omitempty"` + AllowCrossTenantReplication *bool // Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If // false, then all requests, including shared access signatures, must be authorized // with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. - AllowSharedKeyAccess *bool `json:"allowSharedKeyAccess,omitempty"` + AllowSharedKeyAccess *bool // Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. - AllowedCopyScope *AllowedCopyScope `json:"allowedCopyScope,omitempty"` + AllowedCopyScope *AllowedCopyScope // Provides the identity based authentication settings for Azure Files. - AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication `json:"azureFilesIdentityBasedAuthentication,omitempty"` + AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication // User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage // account at this time. To clear the existing custom domain, use an empty string // for the custom domain name property. - CustomDomain *CustomDomain `json:"customDomain,omitempty"` + CustomDomain *CustomDomain // Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, // which creates accounts in an Azure DNS Zone and the endpoint URL // will have an alphanumeric DNS Zone identifier. - DNSEndpointType *DNSEndpointType `json:"dnsEndpointType,omitempty"` + DNSEndpointType *DNSEndpointType // A boolean flag which indicates whether the default authentication is OAuth or not. The default interpretation is false // for this property. - DefaultToOAuthAuthentication *bool `json:"defaultToOAuthAuthentication,omitempty"` + DefaultToOAuthAuthentication *bool // Allows https traffic only to storage service if sets to true. The default value is true since API version 2019-04-01. - EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` + EnableHTTPSTrafficOnly *bool // NFS 3.0 protocol support enabled if set to true. - EnableNfsV3 *bool `json:"isNfsV3Enabled,omitempty"` + EnableNfsV3 *bool // Encryption settings to be used for server-side encryption for the storage account. - Encryption *Encryption `json:"encryption,omitempty"` + Encryption *Encryption // The property is immutable and can only be set to true at the account creation time. When set to true, it enables object // level immutability for all the new containers in the account by default. - ImmutableStorageWithVersioning *ImmutableStorageAccount `json:"immutableStorageWithVersioning,omitempty"` + ImmutableStorageWithVersioning *ImmutableStorageAccount // Account HierarchicalNamespace enabled if sets to true. - IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"` + IsHnsEnabled *bool // Enables local users feature, if set to true - IsLocalUserEnabled *bool `json:"isLocalUserEnabled,omitempty"` + IsLocalUserEnabled *bool // Enables Secure File Transfer Protocol, if set to true - IsSftpEnabled *bool `json:"isSftpEnabled,omitempty"` + IsSftpEnabled *bool // KeyPolicy assigned to the storage account. - KeyPolicy *KeyPolicy `json:"keyPolicy,omitempty"` + KeyPolicy *KeyPolicy // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` + LargeFileSharesState *LargeFileSharesState // Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. - MinimumTLSVersion *MinimumTLSVersion `json:"minimumTlsVersion,omitempty"` + MinimumTLSVersion *MinimumTLSVersion // Network rule set - NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty"` + NetworkRuleSet *NetworkRuleSet // Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + PublicNetworkAccess *PublicNetworkAccess // Maintains information about the network routing choice opted by the user for data transfer - RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` + RoutingPreference *RoutingPreference // SasPolicy assigned to the storage account. - SasPolicy *SasPolicy `json:"sasPolicy,omitempty"` + SasPolicy *SasPolicy } // AccountPropertiesUpdateParameters - The parameters used when updating a storage account. @@ -402,149 +401,149 @@ type AccountPropertiesUpdateParameters struct { // Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier // is the default value for premium block blobs storage account type and it cannot // be changed for the premium block blobs storage account type. - AccessTier *AccessTier `json:"accessTier,omitempty"` + AccessTier *AccessTier // Allow or disallow public access to all blobs or containers in the storage account. The default interpretation is true for // this property. - AllowBlobPublicAccess *bool `json:"allowBlobPublicAccess,omitempty"` + AllowBlobPublicAccess *bool // Allow or disallow cross AAD tenant object replication. The default interpretation is true for this property. - AllowCrossTenantReplication *bool `json:"allowCrossTenantReplication,omitempty"` + AllowCrossTenantReplication *bool // Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If // false, then all requests, including shared access signatures, must be authorized // with Azure Active Directory (Azure AD). The default value is null, which is equivalent to true. - AllowSharedKeyAccess *bool `json:"allowSharedKeyAccess,omitempty"` + AllowSharedKeyAccess *bool // Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. - AllowedCopyScope *AllowedCopyScope `json:"allowedCopyScope,omitempty"` + AllowedCopyScope *AllowedCopyScope // Provides the identity based authentication settings for Azure Files. - AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication `json:"azureFilesIdentityBasedAuthentication,omitempty"` + AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication // Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported // per storage account at this time. To clear the existing custom domain, use an // empty string for the custom domain name property. - CustomDomain *CustomDomain `json:"customDomain,omitempty"` + CustomDomain *CustomDomain // Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, // which creates accounts in an Azure DNS Zone and the endpoint URL // will have an alphanumeric DNS Zone identifier. - DNSEndpointType *DNSEndpointType `json:"dnsEndpointType,omitempty"` + DNSEndpointType *DNSEndpointType // A boolean flag which indicates whether the default authentication is OAuth or not. The default interpretation is false // for this property. - DefaultToOAuthAuthentication *bool `json:"defaultToOAuthAuthentication,omitempty"` + DefaultToOAuthAuthentication *bool // Allows https traffic only to storage service if sets to true. - EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` + EnableHTTPSTrafficOnly *bool // Not applicable. Azure Storage encryption at rest is enabled by default for all storage accounts and cannot be disabled. - Encryption *Encryption `json:"encryption,omitempty"` + Encryption *Encryption // The property is immutable and can only be set to true at the account creation time. When set to true, it enables object // level immutability for all the containers in the account by default. - ImmutableStorageWithVersioning *ImmutableStorageAccount `json:"immutableStorageWithVersioning,omitempty"` + ImmutableStorageWithVersioning *ImmutableStorageAccount // Enables local users feature, if set to true - IsLocalUserEnabled *bool `json:"isLocalUserEnabled,omitempty"` + IsLocalUserEnabled *bool // Enables Secure File Transfer Protocol, if set to true - IsSftpEnabled *bool `json:"isSftpEnabled,omitempty"` + IsSftpEnabled *bool // KeyPolicy assigned to the storage account. - KeyPolicy *KeyPolicy `json:"keyPolicy,omitempty"` + KeyPolicy *KeyPolicy // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` + LargeFileSharesState *LargeFileSharesState // Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. - MinimumTLSVersion *MinimumTLSVersion `json:"minimumTlsVersion,omitempty"` + MinimumTLSVersion *MinimumTLSVersion // Network rule set - NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty"` + NetworkRuleSet *NetworkRuleSet // Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. - PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + PublicNetworkAccess *PublicNetworkAccess // Maintains information about the network routing choice opted by the user for data transfer - RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` + RoutingPreference *RoutingPreference // SasPolicy assigned to the storage account. - SasPolicy *SasPolicy `json:"sasPolicy,omitempty"` + SasPolicy *SasPolicy } // AccountRegenerateKeyParameters - The parameters used to regenerate the storage account key. type AccountRegenerateKeyParameters struct { // REQUIRED; The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. - KeyName *string `json:"keyName,omitempty"` + KeyName *string } // AccountSKUConversionStatus - This defines the sku conversion status object for asynchronous sku conversions. type AccountSKUConversionStatus struct { // This property represents the target sku name to which the account sku is being converted asynchronously. - TargetSKUName *SKUName `json:"targetSkuName,omitempty"` + TargetSKUName *SKUName // READ-ONLY; This property represents the sku conversion end time. - EndTime *string `json:"endTime,omitempty" azure:"ro"` + EndTime *string // READ-ONLY; This property indicates the current sku conversion status. - SKUConversionStatus *SKUConversionStatus `json:"skuConversionStatus,omitempty" azure:"ro"` + SKUConversionStatus *SKUConversionStatus // READ-ONLY; This property represents the sku conversion start time. - StartTime *string `json:"startTime,omitempty" azure:"ro"` + StartTime *string } // AccountSasParameters - The parameters to list SAS credentials of a storage account. type AccountSasParameters struct { // REQUIRED; The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), // Add (a), Create (c), Update (u) and Process (p). - Permissions *Permissions `json:"signedPermission,omitempty"` + Permissions *Permissions // REQUIRED; The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; // Container (c): Access to container-level APIs; Object (o): Access to object-level APIs // for blobs, queue messages, table entities, and files. - ResourceTypes *SignedResourceTypes `json:"signedResourceTypes,omitempty"` + ResourceTypes *SignedResourceTypes // REQUIRED; The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), // File (f). - Services *Services `json:"signedServices,omitempty"` + Services *Services // REQUIRED; The time at which the shared access signature becomes invalid. - SharedAccessExpiryTime *time.Time `json:"signedExpiry,omitempty"` + SharedAccessExpiryTime *time.Time // An IP address or a range of IP addresses from which to accept requests. - IPAddressOrRange *string `json:"signedIp,omitempty"` + IPAddressOrRange *string // The key to sign the account SAS token with. - KeyToSign *string `json:"keyToSign,omitempty"` + KeyToSign *string // The protocol permitted for a request made with the account SAS. - Protocols *HTTPProtocol `json:"signedProtocol,omitempty"` + Protocols *HTTPProtocol // The time at which the SAS becomes valid. - SharedAccessStartTime *time.Time `json:"signedStart,omitempty"` + SharedAccessStartTime *time.Time } // AccountUpdateParameters - The parameters that can be provided when updating the storage account properties. type AccountUpdateParameters struct { // The identity of the resource. - Identity *Identity `json:"identity,omitempty"` + Identity *Identity // Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. - Kind *Kind `json:"kind,omitempty"` + Kind *Kind // The parameters used when updating a storage account. - Properties *AccountPropertiesUpdateParameters `json:"properties,omitempty"` + Properties *AccountPropertiesUpdateParameters // Gets or sets the SKU name. Note that the SKU name cannot be updated to StandardZRS, PremiumLRS or Premium_ZRS, nor can // accounts of those SKU names be updated to any other value. - SKU *SKU `json:"sku,omitempty"` + SKU *SKU // Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this // resource (across resource groups). A maximum of 15 tags can be provided for a // resource. Each tag must have a key no greater in length than 128 characters and a value no greater in length than 256 characters. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // AccountsClientBeginAbortHierarchicalNamespaceMigrationOptions contains the optional parameters for the AccountsClient.BeginAbortHierarchicalNamespaceMigration @@ -647,73 +646,73 @@ type AccountsClientUpdateOptions struct { // ActiveDirectoryProperties - Settings properties for Active Directory (AD). type ActiveDirectoryProperties struct { // REQUIRED; Specifies the domain GUID. - DomainGUID *string `json:"domainGuid,omitempty"` + DomainGUID *string // REQUIRED; Specifies the primary domain that the AD DNS server is authoritative for. - DomainName *string `json:"domainName,omitempty"` + DomainName *string // Specifies the Active Directory account type for Azure Storage. - AccountType *ActiveDirectoryPropertiesAccountType `json:"accountType,omitempty"` + AccountType *ActiveDirectoryPropertiesAccountType // Specifies the security identifier (SID) for Azure Storage. - AzureStorageSid *string `json:"azureStorageSid,omitempty"` + AzureStorageSid *string // Specifies the security identifier (SID). - DomainSid *string `json:"domainSid,omitempty"` + DomainSid *string // Specifies the Active Directory forest to get. - ForestName *string `json:"forestName,omitempty"` + ForestName *string // Specifies the NetBIOS domain name. - NetBiosDomainName *string `json:"netBiosDomainName,omitempty"` + NetBiosDomainName *string // Specifies the Active Directory SAMAccountName for Azure Storage. - SamAccountName *string `json:"samAccountName,omitempty"` + SamAccountName *string } // AzureEntityResource - The resource model definition for an Azure Resource Manager resource with an etag. type AzureEntityResource struct { // READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` + Etag *string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // AzureFilesIdentityBasedAuthentication - Settings for Azure Files identity based authentication. type AzureFilesIdentityBasedAuthentication struct { // REQUIRED; Indicates the directory service used. Note that this enum may be extended in the future. - DirectoryServiceOptions *DirectoryServiceOptions `json:"directoryServiceOptions,omitempty"` + DirectoryServiceOptions *DirectoryServiceOptions // Required if directoryServiceOptions are AD, optional if they are AADKERB. - ActiveDirectoryProperties *ActiveDirectoryProperties `json:"activeDirectoryProperties,omitempty"` + ActiveDirectoryProperties *ActiveDirectoryProperties // Default share permission for users using Kerberos authentication if RBAC role is not assigned. - DefaultSharePermission *DefaultSharePermission `json:"defaultSharePermission,omitempty"` + DefaultSharePermission *DefaultSharePermission } // BlobContainer - Properties of the blob container, including Id, resource name, resource type, Etag. type BlobContainer struct { // Properties of the blob container. - ContainerProperties *ContainerProperties `json:"properties,omitempty"` + ContainerProperties *ContainerProperties // READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` + Etag *string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // BlobContainersClientBeginObjectLevelWormOptions contains the optional parameters for the BlobContainersClient.BeginObjectLevelWorm @@ -834,32 +833,32 @@ type BlobInventoryPoliciesClientListOptions struct { // BlobInventoryPolicy - The storage account blob inventory policy. type BlobInventoryPolicy struct { // Returns the storage account blob inventory policy rules. - Properties *BlobInventoryPolicyProperties `json:"properties,omitempty"` + Properties *BlobInventoryPolicyProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // BlobInventoryPolicyDefinition - An object that defines the blob inventory rule. type BlobInventoryPolicyDefinition struct { // REQUIRED; This is a required field, it specifies the format for the inventory files. - Format *Format `json:"format,omitempty"` + Format *Format // REQUIRED; This is a required field. This field specifies the scope of the inventory created either at the blob or container // level. - ObjectType *ObjectType `json:"objectType,omitempty"` + ObjectType *ObjectType // REQUIRED; This is a required field. This field is used to schedule an inventory formation. - Schedule *Schedule `json:"schedule,omitempty"` + Schedule *Schedule // REQUIRED; This is a required field. This field specifies the fields and properties of the object to be included in the // inventory. The Schema field value 'Name' is always required. The valid values for this @@ -878,10 +877,10 @@ type BlobInventoryPolicyDefinition struct { // ImmutableStorageWithVersioningEnabled, Deleted, Version, DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, // hdiisfolder, Owner, Group, Permissions, Acl, DeletionId' are valid only // for Hns enabled accounts.Schema field values 'Tags, TagCount' are only valid for Non-Hns accounts. - SchemaFields []*string `json:"schemaFields,omitempty"` + SchemaFields []*string // An object that defines the filter set. - Filters *BlobInventoryPolicyFilter `json:"filters,omitempty"` + Filters *BlobInventoryPolicyFilter } // BlobInventoryPolicyFilter - An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType @@ -891,162 +890,162 @@ type BlobInventoryPolicyFilter struct { // An array of predefined enum values. Valid values include blockBlob, appendBlob, pageBlob. Hns accounts does not support // pageBlobs. This field is required when definition.objectType property is set to // 'Blob'. - BlobTypes []*string `json:"blobTypes,omitempty"` + BlobTypes []*string // An array of strings with maximum 10 blob prefixes to be excluded from the inventory. - ExcludePrefix []*string `json:"excludePrefix,omitempty"` + ExcludePrefix []*string // Includes blob versions in blob inventory when value is set to true. The definition.schemaFields values 'VersionId and IsCurrentVersion' // are required if this property is set to true, else they must be // excluded. - IncludeBlobVersions *bool `json:"includeBlobVersions,omitempty"` + IncludeBlobVersions *bool // For 'Container' definition.objectType the definition.schemaFields must include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. // For 'Blob' definition.objectType and HNS enabled storage // accounts the definition.schemaFields must include 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for // Hns disabled accounts the definition.schemaFields must include 'Deleted and // RemainingRetentionDays', else it must be excluded. - IncludeDeleted *bool `json:"includeDeleted,omitempty"` + IncludeDeleted *bool // Includes blob snapshots in blob inventory when value is set to true. The definition.schemaFields value 'Snapshot' is required // if this property is set to true, else it must be excluded. - IncludeSnapshots *bool `json:"includeSnapshots,omitempty"` + IncludeSnapshots *bool // An array of strings with maximum 10 blob prefixes to be included in the inventory. - PrefixMatch []*string `json:"prefixMatch,omitempty"` + PrefixMatch []*string } // BlobInventoryPolicyProperties - The storage account blob inventory policy properties. type BlobInventoryPolicyProperties struct { // REQUIRED; The storage account blob inventory policy object. It is composed of policy rules. - Policy *BlobInventoryPolicySchema `json:"policy,omitempty"` + Policy *BlobInventoryPolicySchema // READ-ONLY; Returns the last modified date and time of the blob inventory policy. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` + LastModifiedTime *time.Time } // BlobInventoryPolicyRule - An object that wraps the blob inventory rule. Each rule is uniquely defined by name. type BlobInventoryPolicyRule struct { // REQUIRED; An object that defines the blob inventory policy rule. - Definition *BlobInventoryPolicyDefinition `json:"definition,omitempty"` + Definition *BlobInventoryPolicyDefinition // REQUIRED; Container name where blob inventory files are stored. Must be pre-created. - Destination *string `json:"destination,omitempty"` + Destination *string // REQUIRED; Rule is enabled when set to true. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool // REQUIRED; A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be // unique within a policy. - Name *string `json:"name,omitempty"` + Name *string } // BlobInventoryPolicySchema - The storage account blob inventory policy rules. type BlobInventoryPolicySchema struct { // REQUIRED; Policy is enabled if set to true. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool // REQUIRED; The storage account blob inventory policy rules. The rule is applied when it is enabled. - Rules []*BlobInventoryPolicyRule `json:"rules,omitempty"` + Rules []*BlobInventoryPolicyRule // REQUIRED; The valid value is Inventory - Type *InventoryRuleType `json:"type,omitempty"` + Type *InventoryRuleType // READ-ONLY; Deprecated Property from API version 2021-04-01 onwards, the required destination container name must be specified // at the rule level 'policy.rule.destination' - Destination *string `json:"destination,omitempty" azure:"ro"` + Destination *string } // BlobRestoreParameters - Blob restore parameters type BlobRestoreParameters struct { // REQUIRED; Blob ranges to restore. - BlobRanges []*BlobRestoreRange `json:"blobRanges,omitempty"` + BlobRanges []*BlobRestoreRange // REQUIRED; Restore blob to the specified time. - TimeToRestore *time.Time `json:"timeToRestore,omitempty"` + TimeToRestore *time.Time } // BlobRestoreRange - Blob range type BlobRestoreRange struct { // REQUIRED; Blob end range. This is exclusive. Empty means account end. - EndRange *string `json:"endRange,omitempty"` + EndRange *string // REQUIRED; Blob start range. This is inclusive. Empty means account start. - StartRange *string `json:"startRange,omitempty"` + StartRange *string } // BlobRestoreStatus - Blob restore status. type BlobRestoreStatus struct { // READ-ONLY; Failure reason when blob restore is failed. - FailureReason *string `json:"failureReason,omitempty" azure:"ro"` + FailureReason *string // READ-ONLY; Blob restore request parameters. - Parameters *BlobRestoreParameters `json:"parameters,omitempty" azure:"ro"` + Parameters *BlobRestoreParameters // READ-ONLY; Id for tracking blob restore request. - RestoreID *string `json:"restoreId,omitempty" azure:"ro"` + RestoreID *string // READ-ONLY; The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. // - Complete: Indicates that blob restore has been completed successfully. - Failed: // Indicates that blob restore is failed. - Status *BlobRestoreProgressStatus `json:"status,omitempty" azure:"ro"` + Status *BlobRestoreProgressStatus } type BlobServiceItems struct { // READ-ONLY; List of blob services returned. - Value []*BlobServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*BlobServiceProperties } // BlobServiceProperties - The properties of a storage account’s Blob service. type BlobServiceProperties struct { // The properties of a storage account’s Blob service. - BlobServiceProperties *BlobServicePropertiesProperties `json:"properties,omitempty"` + BlobServiceProperties *BlobServicePropertiesProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Sku name and tier. - SKU *SKU `json:"sku,omitempty" azure:"ro"` + SKU *SKU // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // BlobServicePropertiesProperties - The properties of a storage account’s Blob service. type BlobServicePropertiesProperties struct { // Deprecated in favor of isVersioningEnabled property. - AutomaticSnapshotPolicyEnabled *bool `json:"automaticSnapshotPolicyEnabled,omitempty"` + AutomaticSnapshotPolicyEnabled *bool // The blob service properties for change feed events. - ChangeFeed *ChangeFeed `json:"changeFeed,omitempty"` + ChangeFeed *ChangeFeed // The blob service properties for container soft delete. - ContainerDeleteRetentionPolicy *DeleteRetentionPolicy `json:"containerDeleteRetentionPolicy,omitempty"` + ContainerDeleteRetentionPolicy *DeleteRetentionPolicy // Specifies CORS rules for the Blob service. You can include up to five CorsRule elements in the request. If no CorsRule // elements are included in the request body, all CORS rules will be deleted, and // CORS will be disabled for the Blob service. - Cors *CorsRules `json:"cors,omitempty"` + Cors *CorsRules // DefaultServiceVersion indicates the default version to use for requests to the Blob service if an incoming request’s version // is not specified. Possible values include version 2008-10-27 and all more // recent versions. - DefaultServiceVersion *string `json:"defaultServiceVersion,omitempty"` + DefaultServiceVersion *string // The blob service properties for blob soft delete. - DeleteRetentionPolicy *DeleteRetentionPolicy `json:"deleteRetentionPolicy,omitempty"` + DeleteRetentionPolicy *DeleteRetentionPolicy // Versioning is enabled if set to true. - IsVersioningEnabled *bool `json:"isVersioningEnabled,omitempty"` + IsVersioningEnabled *bool // The blob service property to configure last access time based tracking policy. - LastAccessTimeTrackingPolicy *LastAccessTimeTrackingPolicy `json:"lastAccessTimeTrackingPolicy,omitempty"` + LastAccessTimeTrackingPolicy *LastAccessTimeTrackingPolicy // The blob service properties for blob restore policy. - RestorePolicy *RestorePolicyProperties `json:"restorePolicy,omitempty"` + RestorePolicy *RestorePolicyProperties } // BlobServicesClientGetServicePropertiesOptions contains the optional parameters for the BlobServicesClient.GetServiceProperties @@ -1069,136 +1068,136 @@ type BlobServicesClientSetServicePropertiesOptions struct { // ChangeFeed - The blob service properties for change feed events. type ChangeFeed struct { // Indicates whether change feed event logging is enabled for the Blob service. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool // Indicates the duration of changeFeed retention in days. Minimum value is 1 day and maximum value is 146000 days (400 years). // A null value indicates an infinite retention of the change feed. - RetentionInDays *int32 `json:"retentionInDays,omitempty"` + RetentionInDays *int32 } // CheckNameAvailabilityResult - The CheckNameAvailability operation response. type CheckNameAvailabilityResult struct { // READ-ONLY; Gets an error message explaining the Reason value in more detail. - Message *string `json:"message,omitempty" azure:"ro"` + Message *string // READ-ONLY; Gets a boolean value that indicates whether the name is available for you to use. If true, the name is available. // If false, the name has already been taken or is invalid and cannot be used. - NameAvailable *bool `json:"nameAvailable,omitempty" azure:"ro"` + NameAvailable *bool // READ-ONLY; Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable // is false. - Reason *Reason `json:"reason,omitempty" azure:"ro"` + Reason *Reason } // ContainerProperties - The properties of a container. type ContainerProperties struct { // Default the container to use specified encryption scope for all writes. - DefaultEncryptionScope *string `json:"defaultEncryptionScope,omitempty"` + DefaultEncryptionScope *string // Block override of encryption scope from the container default. - DenyEncryptionScopeOverride *bool `json:"denyEncryptionScopeOverride,omitempty"` + DenyEncryptionScopeOverride *bool // Enable NFSv3 all squash on blob container. - EnableNfsV3AllSquash *bool `json:"enableNfsV3AllSquash,omitempty"` + EnableNfsV3AllSquash *bool // Enable NFSv3 root squash on blob container. - EnableNfsV3RootSquash *bool `json:"enableNfsV3RootSquash,omitempty"` + EnableNfsV3RootSquash *bool // The object level immutability property of the container. The property is immutable and can only be set to true at the container // creation time. Existing containers must undergo a migration process. - ImmutableStorageWithVersioning *ImmutableStorageWithVersioning `json:"immutableStorageWithVersioning,omitempty"` + ImmutableStorageWithVersioning *ImmutableStorageWithVersioning // A name-value pair to associate with the container as metadata. - Metadata map[string]*string `json:"metadata,omitempty"` + Metadata map[string]*string // Specifies whether data in the container may be accessed publicly and the level of access. - PublicAccess *PublicAccess `json:"publicAccess,omitempty"` + PublicAccess *PublicAccess // READ-ONLY; Indicates whether the blob container was deleted. - Deleted *bool `json:"deleted,omitempty" azure:"ro"` + Deleted *bool // READ-ONLY; Blob container deletion time. - DeletedTime *time.Time `json:"deletedTime,omitempty" azure:"ro"` + DeletedTime *time.Time // READ-ONLY; The hasImmutabilityPolicy public property is set to true by SRP if ImmutabilityPolicy has been created for this // container. The hasImmutabilityPolicy public property is set to false by SRP if // ImmutabilityPolicy has not been created for this container. - HasImmutabilityPolicy *bool `json:"hasImmutabilityPolicy,omitempty" azure:"ro"` + HasImmutabilityPolicy *bool // READ-ONLY; The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold // public property is set to false by SRP if all existing legal hold tags are cleared out. // There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. - HasLegalHold *bool `json:"hasLegalHold,omitempty" azure:"ro"` + HasLegalHold *bool // READ-ONLY; The ImmutabilityPolicy property of the container. - ImmutabilityPolicy *ImmutabilityPolicyProperties `json:"immutabilityPolicy,omitempty" azure:"ro"` + ImmutabilityPolicy *ImmutabilityPolicyProperties // READ-ONLY; Returns the date and time the container was last modified. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` + LastModifiedTime *time.Time // READ-ONLY; Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. - LeaseDuration *LeaseDuration `json:"leaseDuration,omitempty" azure:"ro"` + LeaseDuration *LeaseDuration // READ-ONLY; Lease state of the container. - LeaseState *LeaseState `json:"leaseState,omitempty" azure:"ro"` + LeaseState *LeaseState // READ-ONLY; The lease status of the container. - LeaseStatus *LeaseStatus `json:"leaseStatus,omitempty" azure:"ro"` + LeaseStatus *LeaseStatus // READ-ONLY; The LegalHold property of the container. - LegalHold *LegalHoldProperties `json:"legalHold,omitempty" azure:"ro"` + LegalHold *LegalHoldProperties // READ-ONLY; Remaining retention days for soft deleted blob container. - RemainingRetentionDays *int32 `json:"remainingRetentionDays,omitempty" azure:"ro"` + RemainingRetentionDays *int32 // READ-ONLY; The version of the deleted blob container. - Version *string `json:"version,omitempty" azure:"ro"` + Version *string } // CorsRule - Specifies a CORS rule for the Blob service. type CorsRule struct { // REQUIRED; Required if CorsRule element is present. A list of headers allowed to be part of the cross-origin request. - AllowedHeaders []*string `json:"allowedHeaders,omitempty"` + AllowedHeaders []*string // REQUIRED; Required if CorsRule element is present. A list of HTTP methods that are allowed to be executed by the origin. - AllowedMethods []*CorsRuleAllowedMethodsItem `json:"allowedMethods,omitempty"` + AllowedMethods []*CorsRuleAllowedMethodsItem // REQUIRED; Required if CorsRule element is present. A list of origin domains that will be allowed via CORS, or "*" to allow // all domains - AllowedOrigins []*string `json:"allowedOrigins,omitempty"` + AllowedOrigins []*string // REQUIRED; Required if CorsRule element is present. A list of response headers to expose to CORS clients. - ExposedHeaders []*string `json:"exposedHeaders,omitempty"` + ExposedHeaders []*string // REQUIRED; Required if CorsRule element is present. The number of seconds that the client/browser should cache a preflight // response. - MaxAgeInSeconds *int32 `json:"maxAgeInSeconds,omitempty"` + MaxAgeInSeconds *int32 } // CorsRules - Sets the CORS rules. You can include up to five CorsRule elements in the request. type CorsRules struct { // The List of CORS rules. You can include up to five CorsRule elements in the request. - CorsRules []*CorsRule `json:"corsRules,omitempty"` + CorsRules []*CorsRule } // CustomDomain - The custom domain assigned to this storage account. This can be set via Update. type CustomDomain struct { // REQUIRED; Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. - Name *string `json:"name,omitempty"` + Name *string // Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. - UseSubDomainName *bool `json:"useSubDomainName,omitempty"` + UseSubDomainName *bool } // DateAfterCreation - Object to define snapshot and version action conditions. type DateAfterCreation struct { // REQUIRED; Value indicating the age in days after creation - DaysAfterCreationGreaterThan *float32 `json:"daysAfterCreationGreaterThan,omitempty"` + DaysAfterCreationGreaterThan *float32 // Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions // and requires daysAfterCreationGreaterThan to be set for snapshots and blob // version based actions. The blob will be archived if both the conditions are satisfied. - DaysAfterLastTierChangeGreaterThan *float32 `json:"daysAfterLastTierChangeGreaterThan,omitempty"` + DaysAfterLastTierChangeGreaterThan *float32 } // DateAfterModification - Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan, @@ -1208,19 +1207,19 @@ type DateAfterCreation struct { // daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan. type DateAfterModification struct { // Value indicating the age in days after blob creation. - DaysAfterCreationGreaterThan *float32 `json:"daysAfterCreationGreaterThan,omitempty"` + DaysAfterCreationGreaterThan *float32 // Value indicating the age in days after last blob access. This property can only be used in conjunction with last access // time tracking policy - DaysAfterLastAccessTimeGreaterThan *float32 `json:"daysAfterLastAccessTimeGreaterThan,omitempty"` + DaysAfterLastAccessTimeGreaterThan *float32 // Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions // and requires daysAfterModificationGreaterThan to be set for baseBlobs // based actions. The blob will be archived if both the conditions are satisfied. - DaysAfterLastTierChangeGreaterThan *float32 `json:"daysAfterLastTierChangeGreaterThan,omitempty"` + DaysAfterLastTierChangeGreaterThan *float32 // Value indicating the age in days after last modification - DaysAfterModificationGreaterThan *float32 `json:"daysAfterModificationGreaterThan,omitempty"` + DaysAfterModificationGreaterThan *float32 } // DeleteRetentionPolicy - The service properties for soft delete. @@ -1228,57 +1227,57 @@ type DeleteRetentionPolicy struct { // This property when set to true allows deletion of the soft deleted blob versions and snapshots. This property cannot be // used blob restore policy. This property only applies to blob service and does // not apply to containers or file share. - AllowPermanentDelete *bool `json:"allowPermanentDelete,omitempty"` + AllowPermanentDelete *bool // Indicates the number of days that the deleted item should be retained. The minimum specified value can be 1 and the maximum // value can be 365. - Days *int32 `json:"days,omitempty"` + Days *int32 // Indicates whether DeleteRetentionPolicy is enabled. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool } // DeletedAccount - Deleted storage account type DeletedAccount struct { // Properties of the deleted account. - Properties *DeletedAccountProperties `json:"properties,omitempty"` + Properties *DeletedAccountProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // DeletedAccountListResult - The response from the List Deleted Accounts operation. type DeletedAccountListResult struct { // READ-ONLY; Request URL that can be used to query next page of deleted accounts. Returned when total number of requested // deleted accounts exceed maximum page size. - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; Gets the list of deleted accounts and their properties. - Value []*DeletedAccount `json:"value,omitempty" azure:"ro"` + Value []*DeletedAccount } // DeletedAccountProperties - Attributes of a deleted storage account. type DeletedAccountProperties struct { // READ-ONLY; Creation time of the deleted account. - CreationTime *string `json:"creationTime,omitempty" azure:"ro"` + CreationTime *string // READ-ONLY; Deletion time of the deleted account. - DeletionTime *string `json:"deletionTime,omitempty" azure:"ro"` + DeletionTime *string // READ-ONLY; Location of the deleted account. - Location *string `json:"location,omitempty" azure:"ro"` + Location *string // READ-ONLY; Can be used to attempt recovering this deleted account via PutStorageAccount API. - RestoreReference *string `json:"restoreReference,omitempty" azure:"ro"` + RestoreReference *string // READ-ONLY; Full resource id of the original storage account. - StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty" azure:"ro"` + StorageAccountResourceID *string } // DeletedAccountsClientGetOptions contains the optional parameters for the DeletedAccountsClient.Get method. @@ -1294,63 +1293,63 @@ type DeletedAccountsClientListOptions struct { // DeletedShare - The deleted share to be restored. type DeletedShare struct { // REQUIRED; Required. Identify the name of the deleted share that will be restored. - DeletedShareName *string `json:"deletedShareName,omitempty"` + DeletedShareName *string // REQUIRED; Required. Identify the version of the deleted share that will be restored. - DeletedShareVersion *string `json:"deletedShareVersion,omitempty"` + DeletedShareVersion *string } // Dimension of blobs, possibly be blob type or access tier. type Dimension struct { // Display name of dimension. - DisplayName *string `json:"displayName,omitempty"` + DisplayName *string // Display name of dimension. - Name *string `json:"name,omitempty"` + Name *string } // Encryption - The encryption settings on the storage account. type Encryption struct { // The identity to be used with service-side encryption at rest. - EncryptionIdentity *EncryptionIdentity `json:"identity,omitempty"` + EncryptionIdentity *EncryptionIdentity // The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault - KeySource *KeySource `json:"keySource,omitempty"` + KeySource *KeySource // Properties provided by key vault. - KeyVaultProperties *KeyVaultProperties `json:"keyvaultproperties,omitempty"` + KeyVaultProperties *KeyVaultProperties // A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for // data at rest. - RequireInfrastructureEncryption *bool `json:"requireInfrastructureEncryption,omitempty"` + RequireInfrastructureEncryption *bool // List of services which support encryption. - Services *EncryptionServices `json:"services,omitempty"` + Services *EncryptionServices } // EncryptionIdentity - Encryption identity for the storage account. type EncryptionIdentity struct { // ClientId of the multi-tenant application to be used in conjunction with the user-assigned identity for cross-tenant customer-managed-keys // server-side encryption on the storage account. - EncryptionFederatedIdentityClientID *string `json:"federatedIdentityClientId,omitempty"` + EncryptionFederatedIdentityClientID *string // Resource identifier of the UserAssigned identity to be associated with server-side encryption on the storage account. - EncryptionUserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` + EncryptionUserAssignedIdentity *string } // EncryptionScope - The Encryption Scope resource. type EncryptionScope struct { // Properties of the encryption scope. - EncryptionScopeProperties *EncryptionScopeProperties `json:"properties,omitempty"` + EncryptionScopeProperties *EncryptionScopeProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // EncryptionScopeKeyVaultProperties - The key vault properties for the encryption scope. This is a required field if encryption @@ -1358,13 +1357,13 @@ type EncryptionScope struct { type EncryptionScopeKeyVaultProperties struct { // The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the // identifier to enable customer-managed key support on this encryption scope. - KeyURI *string `json:"keyUri,omitempty"` + KeyURI *string // READ-ONLY; The object identifier of the current versioned Key Vault Key in use. - CurrentVersionedKeyIdentifier *string `json:"currentVersionedKeyIdentifier,omitempty" azure:"ro"` + CurrentVersionedKeyIdentifier *string // READ-ONLY; Timestamp of last rotation of the Key Vault Key. - LastKeyRotationTimestamp *time.Time `json:"lastKeyRotationTimestamp,omitempty" azure:"ro"` + LastKeyRotationTimestamp *time.Time } // EncryptionScopeListResult - List of encryption scopes requested, and if paging is required, a URL to the next page of encryption @@ -1372,33 +1371,33 @@ type EncryptionScopeKeyVaultProperties struct { type EncryptionScopeListResult struct { // READ-ONLY; Request URL that can be used to query next page of encryption scopes. Returned when total number of requested // encryption scopes exceeds the maximum page size. - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of encryption scopes requested. - Value []*EncryptionScope `json:"value,omitempty" azure:"ro"` + Value []*EncryptionScope } // EncryptionScopeProperties - Properties of the encryption scope. type EncryptionScopeProperties struct { // The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set // to 'Microsoft.KeyVault'. - KeyVaultProperties *EncryptionScopeKeyVaultProperties `json:"keyVaultProperties,omitempty"` + KeyVaultProperties *EncryptionScopeKeyVaultProperties // A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for // data at rest. - RequireInfrastructureEncryption *bool `json:"requireInfrastructureEncryption,omitempty"` + RequireInfrastructureEncryption *bool // The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. - Source *EncryptionScopeSource `json:"source,omitempty"` + Source *EncryptionScopeSource // The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - State *EncryptionScopeState `json:"state,omitempty"` + State *EncryptionScopeState // READ-ONLY; Gets the creation date and time of the encryption scope in UTC. - CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` + CreationTime *time.Time // READ-ONLY; Gets the last modification date and time of the encryption scope in UTC. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` + LastModifiedTime *time.Time } // EncryptionScopesClientGetOptions contains the optional parameters for the EncryptionScopesClient.Get method. @@ -1430,104 +1429,104 @@ type EncryptionScopesClientPutOptions struct { type EncryptionService struct { // A boolean indicating whether or not the service encrypts the data as it is stored. Encryption at rest is enabled by default // today and cannot be disabled. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool // Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption // key will be used. 'Service' key type implies that a default service key is used. - KeyType *KeyType `json:"keyType,omitempty"` + KeyType *KeyType // READ-ONLY; Gets a rough estimate of the date/time when the encryption was last enabled by the user. Data is encrypted at // rest by default today and cannot be disabled. - LastEnabledTime *time.Time `json:"lastEnabledTime,omitempty" azure:"ro"` + LastEnabledTime *time.Time } // EncryptionServices - A list of services that support encryption. type EncryptionServices struct { // The encryption function of the blob storage service. - Blob *EncryptionService `json:"blob,omitempty"` + Blob *EncryptionService // The encryption function of the file storage service. - File *EncryptionService `json:"file,omitempty"` + File *EncryptionService // The encryption function of the queue storage service. - Queue *EncryptionService `json:"queue,omitempty"` + Queue *EncryptionService // The encryption function of the table storage service. - Table *EncryptionService `json:"table,omitempty"` + Table *EncryptionService } // Endpoints - The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. type Endpoints struct { // Gets the internet routing storage endpoints - InternetEndpoints *AccountInternetEndpoints `json:"internetEndpoints,omitempty"` + InternetEndpoints *AccountInternetEndpoints // Gets the microsoft routing storage endpoints. - MicrosoftEndpoints *AccountMicrosoftEndpoints `json:"microsoftEndpoints,omitempty"` + MicrosoftEndpoints *AccountMicrosoftEndpoints // READ-ONLY; Gets the blob endpoint. - Blob *string `json:"blob,omitempty" azure:"ro"` + Blob *string // READ-ONLY; Gets the dfs endpoint. - Dfs *string `json:"dfs,omitempty" azure:"ro"` + Dfs *string // READ-ONLY; Gets the file endpoint. - File *string `json:"file,omitempty" azure:"ro"` + File *string // READ-ONLY; Gets the queue endpoint. - Queue *string `json:"queue,omitempty" azure:"ro"` + Queue *string // READ-ONLY; Gets the table endpoint. - Table *string `json:"table,omitempty" azure:"ro"` + Table *string // READ-ONLY; Gets the web endpoint. - Web *string `json:"web,omitempty" azure:"ro"` + Web *string } // ErrorResponse - An error response from the storage resource provider. type ErrorResponse struct { // Azure Storage Resource Provider error response body. - Error *ErrorResponseBody `json:"error,omitempty"` + Error *ErrorResponseBody } // ErrorResponseBody - Error response body contract. type ErrorResponseBody struct { // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` + Code *string // A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` + Message *string } // ExtendedLocation - The complex type of the extended location. type ExtendedLocation struct { // The name of the extended location. - Name *string `json:"name,omitempty"` + Name *string // The type of the extended location. - Type *ExtendedLocationTypes `json:"type,omitempty"` + Type *ExtendedLocationTypes } type FileServiceItems struct { // READ-ONLY; List of file services returned. - Value []*FileServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*FileServiceProperties } // FileServiceProperties - The properties of File services in storage account. type FileServiceProperties struct { // The properties of File services in storage account. - FileServiceProperties *FileServicePropertiesProperties `json:"properties,omitempty"` + FileServiceProperties *FileServicePropertiesProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Sku name and tier. - SKU *SKU `json:"sku,omitempty" azure:"ro"` + SKU *SKU // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // FileServicePropertiesProperties - The properties of File services in storage account. @@ -1535,13 +1534,13 @@ type FileServicePropertiesProperties struct { // Specifies CORS rules for the File service. You can include up to five CorsRule elements in the request. If no CorsRule // elements are included in the request body, all CORS rules will be deleted, and // CORS will be disabled for the File service. - Cors *CorsRules `json:"cors,omitempty"` + Cors *CorsRules // Protocol settings for file service - ProtocolSettings *ProtocolSettings `json:"protocolSettings,omitempty"` + ProtocolSettings *ProtocolSettings // The file service properties for share soft delete. - ShareDeleteRetentionPolicy *DeleteRetentionPolicy `json:"shareDeleteRetentionPolicy,omitempty"` + ShareDeleteRetentionPolicy *DeleteRetentionPolicy } // FileServicesClientGetServicePropertiesOptions contains the optional parameters for the FileServicesClient.GetServiceProperties @@ -1564,37 +1563,37 @@ type FileServicesClientSetServicePropertiesOptions struct { // FileShare - Properties of the file share, including Id, resource name, resource type, Etag. type FileShare struct { // Properties of the file share. - FileShareProperties *FileShareProperties `json:"properties,omitempty"` + FileShareProperties *FileShareProperties // READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` + Etag *string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // FileShareItem - The file share properties be listed out. type FileShareItem struct { // The file share properties be listed out. - Properties *FileShareProperties `json:"properties,omitempty"` + Properties *FileShareProperties // READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` + Etag *string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // FileShareItems - Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next @@ -1602,70 +1601,70 @@ type FileShareItem struct { type FileShareItems struct { // READ-ONLY; Request URL that can be used to query next page of shares. Returned when total number of requested shares exceed // maximum page size. - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of file shares returned. - Value []*FileShareItem `json:"value,omitempty" azure:"ro"` + Value []*FileShareItem } // FileShareProperties - The properties of the file share. type FileShareProperties struct { // Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage // account can choose Premium. - AccessTier *ShareAccessTier `json:"accessTier,omitempty"` + AccessTier *ShareAccessTier // The authentication protocol that is used for the file share. Can only be specified when creating a share. - EnabledProtocols *EnabledProtocols `json:"enabledProtocols,omitempty"` + EnabledProtocols *EnabledProtocols // A name-value pair to associate with the share as metadata. - Metadata map[string]*string `json:"metadata,omitempty"` + Metadata map[string]*string // The property is for NFS share only. The default is NoRootSquash. - RootSquash *RootSquashType `json:"rootSquash,omitempty"` + RootSquash *RootSquashType // The maximum size of the share, in gigabytes. Must be greater than 0, and less than or equal to 5TB (5120). For Large File // Shares, the maximum size is 102400. - ShareQuota *int32 `json:"shareQuota,omitempty"` + ShareQuota *int32 // List of stored access policies specified on the share. - SignedIdentifiers []*SignedIdentifier `json:"signedIdentifiers,omitempty"` + SignedIdentifiers []*SignedIdentifier // READ-ONLY; Indicates the last modification time for share access tier. - AccessTierChangeTime *time.Time `json:"accessTierChangeTime,omitempty" azure:"ro"` + AccessTierChangeTime *time.Time // READ-ONLY; Indicates if there is a pending transition for access tier. - AccessTierStatus *string `json:"accessTierStatus,omitempty" azure:"ro"` + AccessTierStatus *string // READ-ONLY; Indicates whether the share was deleted. - Deleted *bool `json:"deleted,omitempty" azure:"ro"` + Deleted *bool // READ-ONLY; The deleted time if the share was deleted. - DeletedTime *time.Time `json:"deletedTime,omitempty" azure:"ro"` + DeletedTime *time.Time // READ-ONLY; Returns the date and time the share was last modified. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` + LastModifiedTime *time.Time // READ-ONLY; Specifies whether the lease on a share is of infinite or fixed duration, only when the share is leased. - LeaseDuration *LeaseDuration `json:"leaseDuration,omitempty" azure:"ro"` + LeaseDuration *LeaseDuration // READ-ONLY; Lease state of the share. - LeaseState *LeaseState `json:"leaseState,omitempty" azure:"ro"` + LeaseState *LeaseState // READ-ONLY; The lease status of the share. - LeaseStatus *LeaseStatus `json:"leaseStatus,omitempty" azure:"ro"` + LeaseStatus *LeaseStatus // READ-ONLY; Remaining retention days for share that was soft deleted. - RemainingRetentionDays *int32 `json:"remainingRetentionDays,omitempty" azure:"ro"` + RemainingRetentionDays *int32 // READ-ONLY; The approximate size of the data stored on the share. Note that this value may not include all recently created // or recently resized files. - ShareUsageBytes *int64 `json:"shareUsageBytes,omitempty" azure:"ro"` + ShareUsageBytes *int64 // READ-ONLY; Creation time of share snapshot returned in the response of list shares with expand param "snapshots". - SnapshotTime *time.Time `json:"snapshotTime,omitempty" azure:"ro"` + SnapshotTime *time.Time // READ-ONLY; The version of the share. - Version *string `json:"version,omitempty" azure:"ro"` + Version *string } // FileSharesClientCreateOptions contains the optional parameters for the FileSharesClient.Create method. @@ -1729,74 +1728,74 @@ type FileSharesClientUpdateOptions struct { // is only available when geo-redundant replication is enabled for the storage account. type GeoReplicationStats struct { // READ-ONLY; A boolean flag which indicates whether or not account failover is supported for the account. - CanFailover *bool `json:"canFailover,omitempty" azure:"ro"` + CanFailover *bool // READ-ONLY; All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary // writes following this point in time may or may not be available for reads. Element may // be default value if value of LastSyncTime is not available, this can happen if secondary is offline or we are in bootstrap. - LastSyncTime *time.Time `json:"lastSyncTime,omitempty" azure:"ro"` + LastSyncTime *time.Time // READ-ONLY; The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is // active and operational. - Bootstrap: Indicates initial synchronization from the primary // location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: // Indicates that the secondary location is temporarily unavailable. - Status *GeoReplicationStatus `json:"status,omitempty" azure:"ro"` + Status *GeoReplicationStatus } // IPRule - IP rule with specific IP or IP range in CIDR format. type IPRule struct { // REQUIRED; Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. - IPAddressOrRange *string `json:"value,omitempty"` + IPAddressOrRange *string // The action of IP ACL rule. - Action *string `json:"action,omitempty"` + Action *string } // Identity for the resource. type Identity struct { // REQUIRED; The identity type. - Type *IdentityType `json:"type,omitempty"` + Type *IdentityType // Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage // account. The key is the ARM resource identifier of the identity. Only 1 // User Assigned identity is permitted here. - UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + UserAssignedIdentities map[string]*UserAssignedIdentity // READ-ONLY; The principal ID of resource identity. - PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + PrincipalID *string // READ-ONLY; The tenant ID of resource. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` + TenantID *string } // ImmutabilityPolicy - The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. type ImmutabilityPolicy struct { // REQUIRED; The properties of an ImmutabilityPolicy of a blob container. - Properties *ImmutabilityPolicyProperty `json:"properties,omitempty"` + Properties *ImmutabilityPolicyProperty // READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` + Etag *string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ImmutabilityPolicyProperties - The properties of an ImmutabilityPolicy of a blob container. type ImmutabilityPolicyProperties struct { // The properties of an ImmutabilityPolicy of a blob container. - Properties *ImmutabilityPolicyProperty `json:"properties,omitempty"` + Properties *ImmutabilityPolicyProperty // READ-ONLY; ImmutabilityPolicy Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` + Etag *string // READ-ONLY; The ImmutabilityPolicy update history of the blob container. - UpdateHistory []*UpdateHistoryProperty `json:"updateHistory,omitempty" azure:"ro"` + UpdateHistory []*UpdateHistoryProperty } // ImmutabilityPolicyProperty - The properties of an ImmutabilityPolicy of a blob container. @@ -1805,20 +1804,20 @@ type ImmutabilityPolicyProperty struct { // an append blob while maintaining immutability protection and compliance. Only // new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy // API. - AllowProtectedAppendWrites *bool `json:"allowProtectedAppendWrites,omitempty"` + AllowProtectedAppendWrites *bool // This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to // both 'Append and Bock Blobs' while maintaining immutability protection and // compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be // changed with ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and // 'allowProtectedAppendWritesAll' properties are mutually exclusive. - AllowProtectedAppendWritesAll *bool `json:"allowProtectedAppendWritesAll,omitempty"` + AllowProtectedAppendWritesAll *bool // The immutability period for the blobs in the container since the policy creation, in days. - ImmutabilityPeriodSinceCreationInDays *int32 `json:"immutabilityPeriodSinceCreationInDays,omitempty"` + ImmutabilityPeriodSinceCreationInDays *int32 // READ-ONLY; The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - State *ImmutabilityPolicyState `json:"state,omitempty" azure:"ro"` + State *ImmutabilityPolicyState } // ImmutableStorageAccount - This property enables and defines account-level immutability. Enabling the feature auto-enables @@ -1826,193 +1825,193 @@ type ImmutabilityPolicyProperty struct { type ImmutableStorageAccount struct { // A boolean flag which enables account-level immutability. All the containers under such an account have object-level immutability // enabled by default. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool // Specifies the default account-level immutability policy which is inherited and applied to objects that do not possess an // explicit immutability policy at the object level. The object-level immutability // policy has higher precedence than the container-level immutability policy, which has a higher precedence than the account-level // immutability policy. - ImmutabilityPolicy *AccountImmutabilityPolicyProperties `json:"immutabilityPolicy,omitempty"` + ImmutabilityPolicy *AccountImmutabilityPolicyProperties } // ImmutableStorageWithVersioning - Object level immutability properties of the container. type ImmutableStorageWithVersioning struct { // This is an immutable property, when set to true it enables object level immutability at the container level. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool // READ-ONLY; This property denotes the container level immutability to object level immutability migration state. - MigrationState *MigrationState `json:"migrationState,omitempty" azure:"ro"` + MigrationState *MigrationState // READ-ONLY; Returns the date and time the object level immutability was enabled. - TimeStamp *time.Time `json:"timeStamp,omitempty" azure:"ro"` + TimeStamp *time.Time } // KeyCreationTime - Storage account keys creation time. type KeyCreationTime struct { - Key1 *time.Time `json:"key1,omitempty"` - Key2 *time.Time `json:"key2,omitempty"` + Key1 *time.Time + Key2 *time.Time } // KeyPolicy assigned to the storage account. type KeyPolicy struct { // REQUIRED; The key expiration period in days. - KeyExpirationPeriodInDays *int32 `json:"keyExpirationPeriodInDays,omitempty"` + KeyExpirationPeriodInDays *int32 } // KeyVaultProperties - Properties of key vault. type KeyVaultProperties struct { // The name of KeyVault key. - KeyName *string `json:"keyname,omitempty"` + KeyName *string // The Uri of KeyVault. - KeyVaultURI *string `json:"keyvaulturi,omitempty"` + KeyVaultURI *string // The version of KeyVault key. - KeyVersion *string `json:"keyversion,omitempty"` + KeyVersion *string // READ-ONLY; This is a read only property that represents the expiration time of the current version of the customer managed // key used for encryption. - CurrentVersionedKeyExpirationTimestamp *time.Time `json:"currentVersionedKeyExpirationTimestamp,omitempty" azure:"ro"` + CurrentVersionedKeyExpirationTimestamp *time.Time // READ-ONLY; The object identifier of the current versioned Key Vault Key in use. - CurrentVersionedKeyIdentifier *string `json:"currentVersionedKeyIdentifier,omitempty" azure:"ro"` + CurrentVersionedKeyIdentifier *string // READ-ONLY; Timestamp of last rotation of the Key Vault Key. - LastKeyRotationTimestamp *time.Time `json:"lastKeyRotationTimestamp,omitempty" azure:"ro"` + LastKeyRotationTimestamp *time.Time } // LastAccessTimeTrackingPolicy - The blob service properties for Last access time based tracking policy. type LastAccessTimeTrackingPolicy struct { // REQUIRED; When set to true last access time based tracking is enabled. - Enable *bool `json:"enable,omitempty"` + Enable *bool // An array of predefined supported blob types. Only blockBlob is the supported value. This field is currently read only - BlobType []*string `json:"blobType,omitempty"` + BlobType []*string // Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - Name *Name `json:"name,omitempty"` + Name *Name // The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This // field is currently read only with value as 1 - TrackingGranularityInDays *int32 `json:"trackingGranularityInDays,omitempty"` + TrackingGranularityInDays *int32 } // LeaseContainerRequest - Lease Container request schema. type LeaseContainerRequest struct { // REQUIRED; Specifies the lease action. Can be one of the available actions. - Action *LeaseContainerRequestAction `json:"action,omitempty"` + Action *LeaseContainerRequestAction // Optional. For a break action, proposed duration the lease should continue before it is broken, in seconds, between 0 and // 60. - BreakPeriod *int32 `json:"breakPeriod,omitempty"` + BreakPeriod *int32 // Required for acquire. Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. - LeaseDuration *int32 `json:"leaseDuration,omitempty"` + LeaseDuration *int32 // Identifies the lease. Can be specified in any valid GUID string format. - LeaseID *string `json:"leaseId,omitempty"` + LeaseID *string // Optional for acquire, required for change. Proposed lease ID, in a GUID string format. - ProposedLeaseID *string `json:"proposedLeaseId,omitempty"` + ProposedLeaseID *string } // LeaseContainerResponse - Lease Container response schema. type LeaseContainerResponse struct { // Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release // the lease. - LeaseID *string `json:"leaseId,omitempty"` + LeaseID *string // Approximate time remaining in the lease period, in seconds. - LeaseTimeSeconds *string `json:"leaseTimeSeconds,omitempty"` + LeaseTimeSeconds *string } // LeaseShareRequest - Lease Share request schema. type LeaseShareRequest struct { // REQUIRED; Specifies the lease action. Can be one of the available actions. - Action *LeaseShareAction `json:"action,omitempty"` + Action *LeaseShareAction // Optional. For a break action, proposed duration the lease should continue before it is broken, in seconds, between 0 and // 60. - BreakPeriod *int32 `json:"breakPeriod,omitempty"` + BreakPeriod *int32 // Required for acquire. Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. - LeaseDuration *int32 `json:"leaseDuration,omitempty"` + LeaseDuration *int32 // Identifies the lease. Can be specified in any valid GUID string format. - LeaseID *string `json:"leaseId,omitempty"` + LeaseID *string // Optional for acquire, required for change. Proposed lease ID, in a GUID string format. - ProposedLeaseID *string `json:"proposedLeaseId,omitempty"` + ProposedLeaseID *string } // LeaseShareResponse - Lease Share response schema. type LeaseShareResponse struct { // Returned unique lease ID that must be included with any request to delete the share, or to renew, change, or release the // lease. - LeaseID *string `json:"leaseId,omitempty"` + LeaseID *string // Approximate time remaining in the lease period, in seconds. - LeaseTimeSeconds *string `json:"leaseTimeSeconds,omitempty"` + LeaseTimeSeconds *string } // LegalHold - The LegalHold property of a blob container. type LegalHold struct { // REQUIRED; Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case at SRP. - Tags []*string `json:"tags,omitempty"` + Tags []*string // When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. // Only new blocks can be added and any existing blocks cannot be modified // or deleted. - AllowProtectedAppendWritesAll *bool `json:"allowProtectedAppendWritesAll,omitempty"` + AllowProtectedAppendWritesAll *bool // READ-ONLY; The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold // public property is set to false by SRP if all existing legal hold tags are cleared out. // There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. - HasLegalHold *bool `json:"hasLegalHold,omitempty" azure:"ro"` + HasLegalHold *bool } // LegalHoldProperties - The LegalHold property of a blob container. type LegalHoldProperties struct { // Protected append blob writes history. - ProtectedAppendWritesHistory *ProtectedAppendWritesHistory `json:"protectedAppendWritesHistory,omitempty"` + ProtectedAppendWritesHistory *ProtectedAppendWritesHistory // The list of LegalHold tags of a blob container. - Tags []*TagProperty `json:"tags,omitempty"` + Tags []*TagProperty // READ-ONLY; The hasLegalHold public property is set to true by SRP if there are at least one existing tag. The hasLegalHold // public property is set to false by SRP if all existing legal hold tags are cleared out. // There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. - HasLegalHold *bool `json:"hasLegalHold,omitempty" azure:"ro"` + HasLegalHold *bool } // ListAccountSasResponse - The List SAS credentials operation response. type ListAccountSasResponse struct { // READ-ONLY; List SAS credentials of storage account. - AccountSasToken *string `json:"accountSasToken,omitempty" azure:"ro"` + AccountSasToken *string } // ListBlobInventoryPolicy - List of blob inventory policies returned. type ListBlobInventoryPolicy struct { // READ-ONLY; List of blob inventory policies. - Value []*BlobInventoryPolicy `json:"value,omitempty" azure:"ro"` + Value []*BlobInventoryPolicy } // ListContainerItem - The blob container properties be listed out. type ListContainerItem struct { // The blob container properties be listed out. - Properties *ContainerProperties `json:"properties,omitempty"` + Properties *ContainerProperties // READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` + Etag *string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ListContainerItems - Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to @@ -2020,127 +2019,127 @@ type ListContainerItem struct { type ListContainerItems struct { // READ-ONLY; Request URL that can be used to query next page of containers. Returned when total number of requested containers // exceed maximum page size. - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of blobs containers returned. - Value []*ListContainerItem `json:"value,omitempty" azure:"ro"` + Value []*ListContainerItem } type ListQueue struct { // List Queue resource properties. - QueueProperties *ListQueueProperties `json:"properties,omitempty"` + QueueProperties *ListQueueProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } type ListQueueProperties struct { // A name-value pair that represents queue metadata. - Metadata map[string]*string `json:"metadata,omitempty"` + Metadata map[string]*string } // ListQueueResource - Response schema. Contains list of queues returned type ListQueueResource struct { // READ-ONLY; Request URL that can be used to list next page of queues - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of queues returned. - Value []*ListQueue `json:"value,omitempty" azure:"ro"` + Value []*ListQueue } type ListQueueServices struct { // READ-ONLY; List of queue services returned. - Value []*QueueServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*QueueServiceProperties } // ListServiceSasResponse - The List service SAS credentials operation response. type ListServiceSasResponse struct { // READ-ONLY; List service SAS credentials of specific resource. - ServiceSasToken *string `json:"serviceSasToken,omitempty" azure:"ro"` + ServiceSasToken *string } // ListTableResource - Response schema. Contains list of tables returned type ListTableResource struct { // READ-ONLY; Request URL that can be used to query next page of tables - NextLink *string `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of tables returned. - Value []*Table `json:"value,omitempty" azure:"ro"` + Value []*Table } type ListTableServices struct { // READ-ONLY; List of table services returned. - Value []*TableServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*TableServiceProperties } // LocalUser - The local user associated with the storage accounts. type LocalUser struct { // Storage account local user properties. - Properties *LocalUserProperties `json:"properties,omitempty"` + Properties *LocalUserProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Metadata pertaining to creation and last modification of the resource. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // LocalUserKeys - The Storage Account Local User keys. type LocalUserKeys struct { // Optional, local user ssh authorized keys for SFTP. - SSHAuthorizedKeys []*SSHPublicKey `json:"sshAuthorizedKeys,omitempty"` + SSHAuthorizedKeys []*SSHPublicKey // READ-ONLY; Auto generated by the server for SMB authentication. - SharedKey *string `json:"sharedKey,omitempty" azure:"ro"` + SharedKey *string } // LocalUserProperties - The Storage Account Local User properties. type LocalUserProperties struct { // Indicates whether ssh key exists. Set it to false to remove existing SSH key. - HasSSHKey *bool `json:"hasSshKey,omitempty"` + HasSSHKey *bool // Indicates whether ssh password exists. Set it to false to remove existing SSH password. - HasSSHPassword *bool `json:"hasSshPassword,omitempty"` + HasSSHPassword *bool // Indicates whether shared key exists. Set it to false to remove existing shared key. - HasSharedKey *bool `json:"hasSharedKey,omitempty"` + HasSharedKey *bool // Optional, local user home directory. - HomeDirectory *string `json:"homeDirectory,omitempty"` + HomeDirectory *string // The permission scopes of the local user. - PermissionScopes []*PermissionScope `json:"permissionScopes,omitempty"` + PermissionScopes []*PermissionScope // Optional, local user ssh authorized keys for SFTP. - SSHAuthorizedKeys []*SSHPublicKey `json:"sshAuthorizedKeys,omitempty"` + SSHAuthorizedKeys []*SSHPublicKey // READ-ONLY; A unique Security Identifier that is generated by the server. - Sid *string `json:"sid,omitempty" azure:"ro"` + Sid *string } // LocalUserRegeneratePasswordResult - The secrets of Storage Account Local User. type LocalUserRegeneratePasswordResult struct { // READ-ONLY; Auto generated password by the server for SSH authentication if hasSshPassword is set to true on the creation // of local user. - SSHPassword *string `json:"sshPassword,omitempty" azure:"ro"` + SSHPassword *string } // LocalUsers - List storage account local users. type LocalUsers struct { // The local users associated with the storage account. - Value []*LocalUser `json:"value,omitempty"` + Value []*LocalUser } // LocalUsersClientCreateOrUpdateOptions contains the optional parameters for the LocalUsersClient.CreateOrUpdate method. @@ -2193,59 +2192,59 @@ type ManagementPoliciesClientGetOptions struct { // ManagementPolicy - The Get Storage Account ManagementPolicies operation response. type ManagementPolicy struct { // Returns the Storage Account Data Policies Rules. - Properties *ManagementPolicyProperties `json:"properties,omitempty"` + Properties *ManagementPolicyProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ManagementPolicyAction - Actions are applied to the filtered blobs when the execution condition is met. type ManagementPolicyAction struct { // The management policy action for base blob - BaseBlob *ManagementPolicyBaseBlob `json:"baseBlob,omitempty"` + BaseBlob *ManagementPolicyBaseBlob // The management policy action for snapshot - Snapshot *ManagementPolicySnapShot `json:"snapshot,omitempty"` + Snapshot *ManagementPolicySnapShot // The management policy action for version - Version *ManagementPolicyVersion `json:"version,omitempty"` + Version *ManagementPolicyVersion } // ManagementPolicyBaseBlob - Management policy action for base blob. type ManagementPolicyBaseBlob struct { // The function to delete the blob - Delete *DateAfterModification `json:"delete,omitempty"` + Delete *DateAfterModification // This property enables auto tiering of a blob from cool to hot on a blob access. This property requires tierToCool.daysAfterLastAccessTimeGreaterThan. - EnableAutoTierToHotFromCool *bool `json:"enableAutoTierToHotFromCool,omitempty"` + EnableAutoTierToHotFromCool *bool // The function to tier blobs to archive storage. - TierToArchive *DateAfterModification `json:"tierToArchive,omitempty"` + TierToArchive *DateAfterModification // The function to tier blobs to cold storage. - TierToCold *DateAfterModification `json:"tierToCold,omitempty"` + TierToCold *DateAfterModification // The function to tier blobs to cool storage. - TierToCool *DateAfterModification `json:"tierToCool,omitempty"` + TierToCool *DateAfterModification // The function to tier blobs to hot storage. This action can only be used with Premium Block Blob Storage Accounts - TierToHot *DateAfterModification `json:"tierToHot,omitempty"` + TierToHot *DateAfterModification } // ManagementPolicyDefinition - An object that defines the Lifecycle rule. Each definition is made up with a filters set and // an actions set. type ManagementPolicyDefinition struct { // REQUIRED; An object that defines the action set. - Actions *ManagementPolicyAction `json:"actions,omitempty"` + Actions *ManagementPolicyAction // An object that defines the filter set. - Filters *ManagementPolicyFilter `json:"filters,omitempty"` + Filters *ManagementPolicyFilter } // ManagementPolicyFilter - Filters limit rule actions to a subset of blobs within the storage account. If multiple filters @@ -2253,142 +2252,142 @@ type ManagementPolicyDefinition struct { type ManagementPolicyFilter struct { // REQUIRED; An array of predefined enum values. Currently blockBlob supports all tiering and delete actions. Only delete // actions are supported for appendBlob. - BlobTypes []*string `json:"blobTypes,omitempty"` + BlobTypes []*string // An array of blob index tag based filters, there can be at most 10 tag filters - BlobIndexMatch []*TagFilter `json:"blobIndexMatch,omitempty"` + BlobIndexMatch []*TagFilter // An array of strings for prefixes to be match. - PrefixMatch []*string `json:"prefixMatch,omitempty"` + PrefixMatch []*string } // ManagementPolicyProperties - The Storage Account ManagementPolicy properties. type ManagementPolicyProperties struct { // REQUIRED; The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - Policy *ManagementPolicySchema `json:"policy,omitempty"` + Policy *ManagementPolicySchema // READ-ONLY; Returns the date and time the ManagementPolicies was last modified. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` + LastModifiedTime *time.Time } // ManagementPolicyRule - An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. type ManagementPolicyRule struct { // REQUIRED; An object that defines the Lifecycle rule. - Definition *ManagementPolicyDefinition `json:"definition,omitempty"` + Definition *ManagementPolicyDefinition // REQUIRED; A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be // unique within a policy. - Name *string `json:"name,omitempty"` + Name *string // REQUIRED; The valid value is Lifecycle - Type *RuleType `json:"type,omitempty"` + Type *RuleType // Rule is enabled if set to true. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool } // ManagementPolicySchema - The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. type ManagementPolicySchema struct { // REQUIRED; The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - Rules []*ManagementPolicyRule `json:"rules,omitempty"` + Rules []*ManagementPolicyRule } // ManagementPolicySnapShot - Management policy action for snapshot. type ManagementPolicySnapShot struct { // The function to delete the blob snapshot - Delete *DateAfterCreation `json:"delete,omitempty"` + Delete *DateAfterCreation // The function to tier blob snapshot to archive storage. - TierToArchive *DateAfterCreation `json:"tierToArchive,omitempty"` + TierToArchive *DateAfterCreation // The function to tier blobs to cold storage. - TierToCold *DateAfterCreation `json:"tierToCold,omitempty"` + TierToCold *DateAfterCreation // The function to tier blob snapshot to cool storage. - TierToCool *DateAfterCreation `json:"tierToCool,omitempty"` + TierToCool *DateAfterCreation // The function to tier blobs to hot storage. This action can only be used with Premium Block Blob Storage Accounts - TierToHot *DateAfterCreation `json:"tierToHot,omitempty"` + TierToHot *DateAfterCreation } // ManagementPolicyVersion - Management policy action for blob version. type ManagementPolicyVersion struct { // The function to delete the blob version - Delete *DateAfterCreation `json:"delete,omitempty"` + Delete *DateAfterCreation // The function to tier blob version to archive storage. - TierToArchive *DateAfterCreation `json:"tierToArchive,omitempty"` + TierToArchive *DateAfterCreation // The function to tier blobs to cold storage. - TierToCold *DateAfterCreation `json:"tierToCold,omitempty"` + TierToCold *DateAfterCreation // The function to tier blob version to cool storage. - TierToCool *DateAfterCreation `json:"tierToCool,omitempty"` + TierToCool *DateAfterCreation // The function to tier blobs to hot storage. This action can only be used with Premium Block Blob Storage Accounts - TierToHot *DateAfterCreation `json:"tierToHot,omitempty"` + TierToHot *DateAfterCreation } // MetricSpecification - Metric specification of operation. type MetricSpecification struct { // Aggregation type could be Average. - AggregationType *string `json:"aggregationType,omitempty"` + AggregationType *string // The category this metric specification belong to, could be Capacity. - Category *string `json:"category,omitempty"` + Category *string // Dimensions of blobs, including blob type and access tier. - Dimensions []*Dimension `json:"dimensions,omitempty"` + Dimensions []*Dimension // Display description of metric specification. - DisplayDescription *string `json:"displayDescription,omitempty"` + DisplayDescription *string // Display name of metric specification. - DisplayName *string `json:"displayName,omitempty"` + DisplayName *string // The property to decide fill gap with zero or not. - FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` + FillGapWithZero *bool // Name of metric specification. - Name *string `json:"name,omitempty"` + Name *string // Account Resource Id. - ResourceIDDimensionNameOverride *string `json:"resourceIdDimensionNameOverride,omitempty"` + ResourceIDDimensionNameOverride *string // Unit could be Bytes or Count. - Unit *string `json:"unit,omitempty"` + Unit *string } // Multichannel setting. Applies to Premium FileStorage only. type Multichannel struct { // Indicates whether multichannel is enabled - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool } // NetworkRuleSet - Network rule set type NetworkRuleSet struct { // REQUIRED; Specifies the default action of allow or deny when no other rules match. - DefaultAction *DefaultAction `json:"defaultAction,omitempty"` + DefaultAction *DefaultAction // Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices // (For example, "Logging, Metrics"), or None to bypass none // of those traffics. - Bypass *Bypass `json:"bypass,omitempty"` + Bypass *Bypass // Sets the IP ACL rules - IPRules []*IPRule `json:"ipRules,omitempty"` + IPRules []*IPRule // Sets the resource access rules - ResourceAccessRules []*ResourceAccessRule `json:"resourceAccessRules,omitempty"` + ResourceAccessRules []*ResourceAccessRule // Sets the virtual network rules - VirtualNetworkRules []*VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + VirtualNetworkRules []*VirtualNetworkRule } // ObjectReplicationPolicies - List storage account object replication policies. type ObjectReplicationPolicies struct { // The replication policy between two storage accounts. - Value []*ObjectReplicationPolicy `json:"value,omitempty"` + Value []*ObjectReplicationPolicy } // ObjectReplicationPoliciesClientCreateOrUpdateOptions contains the optional parameters for the ObjectReplicationPoliciesClient.CreateOrUpdate @@ -2418,16 +2417,16 @@ type ObjectReplicationPoliciesClientListOptions struct { // ObjectReplicationPolicy - The replication policy between two storage accounts. Multiple rules can be defined in one policy. type ObjectReplicationPolicy struct { // Returns the Storage Account Object Replication Policy. - Properties *ObjectReplicationPolicyProperties `json:"properties,omitempty"` + Properties *ObjectReplicationPolicyProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ObjectReplicationPolicyFilter - Filters limit replication to a subset of blobs within the storage account. A logical OR @@ -2436,86 +2435,86 @@ type ObjectReplicationPolicy struct { type ObjectReplicationPolicyFilter struct { // Blobs created after the time will be replicated to the destination. It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. // Example: 2020-02-19T16:05:00Z - MinCreationTime *string `json:"minCreationTime,omitempty"` + MinCreationTime *string // Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. - PrefixMatch []*string `json:"prefixMatch,omitempty"` + PrefixMatch []*string } // ObjectReplicationPolicyProperties - The Storage Account ObjectReplicationPolicy properties. type ObjectReplicationPolicyProperties struct { // REQUIRED; Required. Destination account name. It should be full resource id if allowCrossTenantReplication set to false. - DestinationAccount *string `json:"destinationAccount,omitempty"` + DestinationAccount *string // REQUIRED; Required. Source account name. It should be full resource id if allowCrossTenantReplication set to false. - SourceAccount *string `json:"sourceAccount,omitempty"` + SourceAccount *string // The storage account object replication rules. - Rules []*ObjectReplicationPolicyRule `json:"rules,omitempty"` + Rules []*ObjectReplicationPolicyRule // READ-ONLY; Indicates when the policy is enabled on the source account. - EnabledTime *time.Time `json:"enabledTime,omitempty" azure:"ro"` + EnabledTime *time.Time // READ-ONLY; A unique id for object replication policy. - PolicyID *string `json:"policyId,omitempty" azure:"ro"` + PolicyID *string } // ObjectReplicationPolicyRule - The replication policy rule between two containers. type ObjectReplicationPolicyRule struct { // REQUIRED; Required. Destination container name. - DestinationContainer *string `json:"destinationContainer,omitempty"` + DestinationContainer *string // REQUIRED; Required. Source container name. - SourceContainer *string `json:"sourceContainer,omitempty"` + SourceContainer *string // Optional. An object that defines the filter set. - Filters *ObjectReplicationPolicyFilter `json:"filters,omitempty"` + Filters *ObjectReplicationPolicyFilter // Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. - RuleID *string `json:"ruleId,omitempty"` + RuleID *string } // Operation - Storage REST API operation definition. type Operation struct { // Display metadata associated with the operation. - Display *OperationDisplay `json:"display,omitempty"` + Display *OperationDisplay // Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` + Name *string // Properties of operation, include metric specifications. - OperationProperties *OperationProperties `json:"properties,omitempty"` + OperationProperties *OperationProperties // The origin of operations. - Origin *string `json:"origin,omitempty"` + Origin *string } // OperationDisplay - Display metadata associated with the operation. type OperationDisplay struct { // Description of the operation. - Description *string `json:"description,omitempty"` + Description *string // Type of operation: get, read, delete, etc. - Operation *string `json:"operation,omitempty"` + Operation *string // Service provider: Microsoft Storage. - Provider *string `json:"provider,omitempty"` + Provider *string // Resource on which the operation is performed etc. - Resource *string `json:"resource,omitempty"` + Resource *string } // OperationListResult - Result of the request to list Storage operations. It contains a list of operations and a URL link // to get the next set of results. type OperationListResult struct { // List of Storage operations supported by the Storage resource provider. - Value []*Operation `json:"value,omitempty"` + Value []*Operation } // OperationProperties - Properties of operation, include metric specifications. type OperationProperties struct { // One property of operation, include metric specifications. - ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` + ServiceSpecification *ServiceSpecification } // OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. @@ -2526,52 +2525,52 @@ type OperationsClientListOptions struct { type PermissionScope struct { // REQUIRED; The permissions for the local user. Possible values include: Read (r), Write (w), Delete (d), List (l), and Create // (c). - Permissions *string `json:"permissions,omitempty"` + Permissions *string // REQUIRED; The name of resource, normally the container name or the file share name, used by the local user. - ResourceName *string `json:"resourceName,omitempty"` + ResourceName *string // REQUIRED; The service used by the local user, e.g. blob, file. - Service *string `json:"service,omitempty"` + Service *string } // PrivateEndpoint - The Private Endpoint resource. type PrivateEndpoint struct { // READ-ONLY; The ARM identifier for Private Endpoint - ID *string `json:"id,omitempty" azure:"ro"` + ID *string } // PrivateEndpointConnection - The Private Endpoint Connection resource. type PrivateEndpointConnection struct { // Resource properties. - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Properties *PrivateEndpointConnectionProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // PrivateEndpointConnectionListResult - List of private endpoint connection associated with the specified storage account type PrivateEndpointConnectionListResult struct { // Array of private endpoint connections - Value []*PrivateEndpointConnection `json:"value,omitempty"` + Value []*PrivateEndpointConnection } // PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnectProperties. type PrivateEndpointConnectionProperties struct { // REQUIRED; A collection of information about the state of the connection between service consumer and provider. - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState // The resource of private end point. - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateEndpoint *PrivateEndpoint // READ-ONLY; The provisioning state of the private endpoint connection resource. - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *PrivateEndpointConnectionProvisioningState } // PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete @@ -2601,34 +2600,34 @@ type PrivateEndpointConnectionsClientPutOptions struct { // PrivateLinkResource - A private link resource type PrivateLinkResource struct { // Resource properties. - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Properties *PrivateLinkResourceProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // PrivateLinkResourceListResult - A list of private link resources type PrivateLinkResourceListResult struct { // Array of private link resources - Value []*PrivateLinkResource `json:"value,omitempty"` + Value []*PrivateLinkResource } // PrivateLinkResourceProperties - Properties of a private link resource. type PrivateLinkResourceProperties struct { // The private link resource Private link DNS zone name. - RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` + RequiredZoneNames []*string // READ-ONLY; The private link resource group id. - GroupID *string `json:"groupId,omitempty" azure:"ro"` + GroupID *string // READ-ONLY; The private link resource required member names. - RequiredMembers []*string `json:"requiredMembers,omitempty" azure:"ro"` + RequiredMembers []*string } // PrivateLinkResourcesClientListByStorageAccountOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByStorageAccount @@ -2641,13 +2640,13 @@ type PrivateLinkResourcesClientListByStorageAccountOptions struct { // and provider. type PrivateLinkServiceConnectionState struct { // A message indicating if changes on the service provider require any updates on the consumer. - ActionRequired *string `json:"actionRequired,omitempty"` + ActionRequired *string // The reason for approval/rejection of the connection. - Description *string `json:"description,omitempty"` + Description *string // Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` + Status *PrivateEndpointServiceConnectionStatus } // ProtectedAppendWritesHistory - Protected append writes history setting for the blob container with Legal holds. @@ -2655,43 +2654,43 @@ type ProtectedAppendWritesHistory struct { // When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. // Only new blocks can be added and any existing blocks cannot be modified // or deleted. - AllowProtectedAppendWritesAll *bool `json:"allowProtectedAppendWritesAll,omitempty"` + AllowProtectedAppendWritesAll *bool // READ-ONLY; Returns the date and time the tag was added. - Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` + Timestamp *time.Time } // ProtocolSettings - Protocol settings for file service type ProtocolSettings struct { // Setting for SMB protocol - Smb *SmbSetting `json:"smb,omitempty"` + Smb *SmbSetting } // ProxyResource - The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a // location type ProxyResource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } type Queue struct { // Queue resource properties. - QueueProperties *QueueProperties `json:"properties,omitempty"` + QueueProperties *QueueProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // QueueClientCreateOptions contains the optional parameters for the QueueClient.Create method. @@ -2724,26 +2723,26 @@ type QueueClientUpdateOptions struct { type QueueProperties struct { // A name-value pair that represents queue metadata. - Metadata map[string]*string `json:"metadata,omitempty"` + Metadata map[string]*string // READ-ONLY; Integer indicating an approximate number of messages in the queue. This number is not lower than the actual // number of messages in the queue, but could be higher. - ApproximateMessageCount *int32 `json:"approximateMessageCount,omitempty" azure:"ro"` + ApproximateMessageCount *int32 } // QueueServiceProperties - The properties of a storage account’s Queue service. type QueueServiceProperties struct { // The properties of a storage account’s Queue service. - QueueServiceProperties *QueueServicePropertiesProperties `json:"properties,omitempty"` + QueueServiceProperties *QueueServicePropertiesProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // QueueServicePropertiesProperties - The properties of a storage account’s Queue service. @@ -2751,7 +2750,7 @@ type QueueServicePropertiesProperties struct { // Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule // elements are included in the request body, all CORS rules will be deleted, and // CORS will be disabled for the Queue service. - Cors *CorsRules `json:"cors,omitempty"` + Cors *CorsRules } // QueueServicesClientGetServicePropertiesOptions contains the optional parameters for the QueueServicesClient.GetServiceProperties @@ -2774,37 +2773,37 @@ type QueueServicesClientSetServicePropertiesOptions struct { // Resource - Common fields that are returned in the response for all Azure Resource Manager resources type Resource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // ResourceAccessRule - Resource Access Rule. type ResourceAccessRule struct { // Resource Id - ResourceID *string `json:"resourceId,omitempty"` + ResourceID *string // Tenant Id - TenantID *string `json:"tenantId,omitempty"` + TenantID *string } // RestorePolicyProperties - The blob service properties for blob restore policy type RestorePolicyProperties struct { // REQUIRED; Blob restore is enabled if set to true. - Enabled *bool `json:"enabled,omitempty"` + Enabled *bool // how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. - Days *int32 `json:"days,omitempty"` + Days *int32 // READ-ONLY; Deprecated in favor of minRestoreTime property. - LastEnabledTime *time.Time `json:"lastEnabledTime,omitempty" azure:"ro"` + LastEnabledTime *time.Time // READ-ONLY; Returns the minimum date and time that the restore can be started. - MinRestoreTime *time.Time `json:"minRestoreTime,omitempty" azure:"ro"` + MinRestoreTime *time.Time } // Restriction - The restriction because of which SKU cannot be used. @@ -2812,37 +2811,37 @@ type Restriction struct { // The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when // the SKU has requiredQuotas parameter as the subscription does not belong to that // quota. The "NotAvailableForSubscription" is related to capacity at DC. - ReasonCode *ReasonCode `json:"reasonCode,omitempty"` + ReasonCode *ReasonCode // READ-ONLY; The type of restrictions. As of now only possible value for this is location. - Type *string `json:"type,omitempty" azure:"ro"` + Type *string // READ-ONLY; The value of restrictions. If the restriction type is set to location. This would be different locations where // the SKU is restricted. - Values []*string `json:"values,omitempty" azure:"ro"` + Values []*string } // RoutingPreference - Routing preference defines the type of network, either microsoft or internet routing to be used to // deliver the user data, the default option is microsoft routing type RoutingPreference struct { // A boolean flag which indicates whether internet routing storage endpoints are to be published - PublishInternetEndpoints *bool `json:"publishInternetEndpoints,omitempty"` + PublishInternetEndpoints *bool // A boolean flag which indicates whether microsoft routing storage endpoints are to be published - PublishMicrosoftEndpoints *bool `json:"publishMicrosoftEndpoints,omitempty"` + PublishMicrosoftEndpoints *bool // Routing Choice defines the kind of network routing opted by the user. - RoutingChoice *RoutingChoice `json:"routingChoice,omitempty"` + RoutingChoice *RoutingChoice } // SKU - The SKU of the storage account. type SKU struct { // REQUIRED; The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called // accountType. - Name *SKUName `json:"name,omitempty"` + Name *SKUName // READ-ONLY; The SKU tier. This is based on the SKU name. - Tier *SKUTier `json:"tier,omitempty" azure:"ro"` + Tier *SKUTier } // SKUCapability - The capability information in the specified SKU, including file encryption, network ACLs, change notification, @@ -2850,43 +2849,43 @@ type SKU struct { type SKUCapability struct { // READ-ONLY; The name of capability, The capability information in the specified SKU, including file encryption, network // ACLs, change notification, etc. - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; A string value to indicate states of given capability. Possibly 'true' or 'false'. - Value *string `json:"value,omitempty" azure:"ro"` + Value *string } // SKUInformation - Storage SKU and its properties type SKUInformation struct { // REQUIRED; The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called // accountType. - Name *SKUName `json:"name,omitempty"` + Name *SKUName // The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. - Restrictions []*Restriction `json:"restrictions,omitempty"` + Restrictions []*Restriction // READ-ONLY; The capability information in the specified SKU, including file encryption, network ACLs, change notification, // etc. - Capabilities []*SKUCapability `json:"capabilities,omitempty" azure:"ro"` + Capabilities []*SKUCapability // READ-ONLY; Indicates the type of storage account. - Kind *Kind `json:"kind,omitempty" azure:"ro"` + Kind *Kind // READ-ONLY; The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. // West US, East US, Southeast Asia, etc.). - Locations []*string `json:"locations,omitempty" azure:"ro"` + Locations []*string // READ-ONLY; The type of the resource, usually it is 'storageAccounts'. - ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + ResourceType *string // READ-ONLY; The SKU tier. This is based on the SKU name. - Tier *SKUTier `json:"tier,omitempty" azure:"ro"` + Tier *SKUTier } // SKUListResult - The response from the List Storage SKUs operation. type SKUListResult struct { // READ-ONLY; Get the list result of storage SKUs and their properties. - Value []*SKUInformation `json:"value,omitempty" azure:"ro"` + Value []*SKUInformation } // SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. @@ -2896,163 +2895,163 @@ type SKUsClientListOptions struct { type SSHPublicKey struct { // Optional. It is used to store the function/usage of the key - Description *string `json:"description,omitempty"` + Description *string // Ssh public key base64 encoded. The format should be: ' ', e.g. ssh-rsa AAAABBBB - Key *string `json:"key,omitempty"` + Key *string } // SasPolicy assigned to the storage account. type SasPolicy struct { // REQUIRED; The SAS expiration action. Can only be Log. - ExpirationAction *ExpirationAction `json:"expirationAction,omitempty"` + ExpirationAction *ExpirationAction // REQUIRED; The SAS expiration period, DD.HH:MM:SS. - SasExpirationPeriod *string `json:"sasExpirationPeriod,omitempty"` + SasExpirationPeriod *string } // ServiceSasParameters - The parameters to list service SAS credentials of a specific resource. type ServiceSasParameters struct { // REQUIRED; The canonical path to the signed resource. - CanonicalizedResource *string `json:"canonicalizedResource,omitempty"` + CanonicalizedResource *string // The response header override for cache control. - CacheControl *string `json:"rscc,omitempty"` + CacheControl *string // The response header override for content disposition. - ContentDisposition *string `json:"rscd,omitempty"` + ContentDisposition *string // The response header override for content encoding. - ContentEncoding *string `json:"rsce,omitempty"` + ContentEncoding *string // The response header override for content language. - ContentLanguage *string `json:"rscl,omitempty"` + ContentLanguage *string // The response header override for content type. - ContentType *string `json:"rsct,omitempty"` + ContentType *string // An IP address or a range of IP addresses from which to accept requests. - IPAddressOrRange *string `json:"signedIp,omitempty"` + IPAddressOrRange *string // A unique value up to 64 characters in length that correlates to an access policy specified for the container, queue, or // table. - Identifier *string `json:"signedIdentifier,omitempty"` + Identifier *string // The key to sign the account SAS token with. - KeyToSign *string `json:"keyToSign,omitempty"` + KeyToSign *string // The end of partition key. - PartitionKeyEnd *string `json:"endPk,omitempty"` + PartitionKeyEnd *string // The start of partition key. - PartitionKeyStart *string `json:"startPk,omitempty"` + PartitionKeyStart *string // The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), // Create (c), Update (u) and Process (p). - Permissions *Permissions `json:"signedPermission,omitempty"` + Permissions *Permissions // The protocol permitted for a request made with the account SAS. - Protocols *HTTPProtocol `json:"signedProtocol,omitempty"` + Protocols *HTTPProtocol // The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share // (s). - Resource *SignedResource `json:"signedResource,omitempty"` + Resource *SignedResource // The end of row key. - RowKeyEnd *string `json:"endRk,omitempty"` + RowKeyEnd *string // The start of row key. - RowKeyStart *string `json:"startRk,omitempty"` + RowKeyStart *string // The time at which the shared access signature becomes invalid. - SharedAccessExpiryTime *time.Time `json:"signedExpiry,omitempty"` + SharedAccessExpiryTime *time.Time // The time at which the SAS becomes valid. - SharedAccessStartTime *time.Time `json:"signedStart,omitempty"` + SharedAccessStartTime *time.Time } // ServiceSpecification - One property of operation, include metric specifications. type ServiceSpecification struct { // Metric specifications of operation. - MetricSpecifications []*MetricSpecification `json:"metricSpecifications,omitempty"` + MetricSpecifications []*MetricSpecification } type SignedIdentifier struct { // Access policy - AccessPolicy *AccessPolicy `json:"accessPolicy,omitempty"` + AccessPolicy *AccessPolicy // An unique identifier of the stored access policy. - ID *string `json:"id,omitempty"` + ID *string } // SmbSetting - Setting for SMB protocol type SmbSetting struct { // SMB authentication methods supported by server. Valid values are NTLMv2, Kerberos. Should be passed as a string with delimiter // ';'. - AuthenticationMethods *string `json:"authenticationMethods,omitempty"` + AuthenticationMethods *string // SMB channel encryption supported by server. Valid values are AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as // a string with delimiter ';'. - ChannelEncryption *string `json:"channelEncryption,omitempty"` + ChannelEncryption *string // Kerberos ticket encryption supported by server. Valid values are RC4-HMAC, AES-256. Should be passed as a string with delimiter // ';' - KerberosTicketEncryption *string `json:"kerberosTicketEncryption,omitempty"` + KerberosTicketEncryption *string // Multichannel setting. Applies to Premium FileStorage only. - Multichannel *Multichannel `json:"multichannel,omitempty"` + Multichannel *Multichannel // SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, SMB3.1.1. Should be passed as a string with // delimiter ';'. - Versions *string `json:"versions,omitempty"` + Versions *string } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAt *time.Time // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` + CreatedBy *string // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAt *time.Time // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedBy *string // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *CreatedByType } // Table - Properties of the table, including Id, resource name, resource type. type Table struct { // Table resource properties. - TableProperties *TableProperties `json:"properties,omitempty"` + TableProperties *TableProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // TableAccessPolicy - Table Access Policy Properties Object. type TableAccessPolicy struct { // REQUIRED; Required. List of abbreviated permissions. Supported permission values include 'r','a','u','d' - Permission *string `json:"permission,omitempty"` + Permission *string // Expiry time of the access policy - ExpiryTime *time.Time `json:"expiryTime,omitempty"` + ExpiryTime *time.Time // Start time of the access policy - StartTime *time.Time `json:"startTime,omitempty"` + StartTime *time.Time } // TableClientCreateOptions contains the optional parameters for the TableClient.Create method. @@ -3084,25 +3083,25 @@ type TableClientUpdateOptions struct { type TableProperties struct { // List of stored access policies specified on the table. - SignedIdentifiers []*TableSignedIdentifier `json:"signedIdentifiers,omitempty"` + SignedIdentifiers []*TableSignedIdentifier // READ-ONLY; Table name under the specified account - TableName *string `json:"tableName,omitempty" azure:"ro"` + TableName *string } // TableServiceProperties - The properties of a storage account’s Table service. type TableServiceProperties struct { // The properties of a storage account’s Table service. - TableServiceProperties *TableServicePropertiesProperties `json:"properties,omitempty"` + TableServiceProperties *TableServicePropertiesProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // TableServicePropertiesProperties - The properties of a storage account’s Table service. @@ -3110,7 +3109,7 @@ type TableServicePropertiesProperties struct { // Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule // elements are included in the request body, all CORS rules will be deleted, and // CORS will be disabled for the Table service. - Cors *CorsRules `json:"cors,omitempty"` + Cors *CorsRules } // TableServicesClientGetServicePropertiesOptions contains the optional parameters for the TableServicesClient.GetServiceProperties @@ -3133,60 +3132,60 @@ type TableServicesClientSetServicePropertiesOptions struct { // TableSignedIdentifier - Object to set Table Access Policy. type TableSignedIdentifier struct { // REQUIRED; unique-64-character-value of the stored access policy. - ID *string `json:"id,omitempty"` + ID *string // Access policy - AccessPolicy *TableAccessPolicy `json:"accessPolicy,omitempty"` + AccessPolicy *TableAccessPolicy } // TagFilter - Blob index tag based filtering for blob objects type TagFilter struct { // REQUIRED; This is the filter tag name, it can have 1 - 128 characters - Name *string `json:"name,omitempty"` + Name *string // REQUIRED; This is the comparison operator which is used for object comparison and filtering. Only == (equality operator) // is currently supported - Op *string `json:"op,omitempty"` + Op *string // REQUIRED; This is the filter tag value field used for tag based filtering, it can have 0 - 256 characters - Value *string `json:"value,omitempty"` + Value *string } // TagProperty - A tag of the LegalHold of a blob container. type TagProperty struct { // READ-ONLY; Returns the Object ID of the user who added the tag. - ObjectIdentifier *string `json:"objectIdentifier,omitempty" azure:"ro"` + ObjectIdentifier *string // READ-ONLY; The tag value. - Tag *string `json:"tag,omitempty" azure:"ro"` + Tag *string // READ-ONLY; Returns the Tenant ID that issued the token for the user who added the tag. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` + TenantID *string // READ-ONLY; Returns the date and time the tag was added. - Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` + Timestamp *time.Time // READ-ONLY; Returns the User Principal Name of the user who added the tag. - Upn *string `json:"upn,omitempty" azure:"ro"` + Upn *string } // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' // and a 'location' type TrackedResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // UpdateHistoryProperty - An update history of the ImmutabilityPolicy of a blob container. @@ -3195,62 +3194,62 @@ type UpdateHistoryProperty struct { // an append blob while maintaining immutability protection and compliance. Only // new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy // API. - AllowProtectedAppendWrites *bool `json:"allowProtectedAppendWrites,omitempty"` + AllowProtectedAppendWrites *bool // This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to // both 'Append and Bock Blobs' while maintaining immutability protection and // compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. This property cannot be // changed with ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and // 'allowProtectedAppendWritesAll' properties are mutually exclusive. - AllowProtectedAppendWritesAll *bool `json:"allowProtectedAppendWritesAll,omitempty"` + AllowProtectedAppendWritesAll *bool // READ-ONLY; The immutability period for the blobs in the container since the policy creation, in days. - ImmutabilityPeriodSinceCreationInDays *int32 `json:"immutabilityPeriodSinceCreationInDays,omitempty" azure:"ro"` + ImmutabilityPeriodSinceCreationInDays *int32 // READ-ONLY; Returns the Object ID of the user who updated the ImmutabilityPolicy. - ObjectIdentifier *string `json:"objectIdentifier,omitempty" azure:"ro"` + ObjectIdentifier *string // READ-ONLY; Returns the Tenant ID that issued the token for the user who updated the ImmutabilityPolicy. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` + TenantID *string // READ-ONLY; Returns the date and time the ImmutabilityPolicy was updated. - Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` + Timestamp *time.Time // READ-ONLY; The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. - Update *ImmutabilityPolicyUpdateType `json:"update,omitempty" azure:"ro"` + Update *ImmutabilityPolicyUpdateType // READ-ONLY; Returns the User Principal Name of the user who updated the ImmutabilityPolicy. - Upn *string `json:"upn,omitempty" azure:"ro"` + Upn *string } // Usage - Describes Storage Resource Usage. type Usage struct { // READ-ONLY; Gets the current count of the allocated resources in the subscription. - CurrentValue *int32 `json:"currentValue,omitempty" azure:"ro"` + CurrentValue *int32 // READ-ONLY; Gets the maximum count of the resources that can be allocated in the subscription. - Limit *int32 `json:"limit,omitempty" azure:"ro"` + Limit *int32 // READ-ONLY; Gets the name of the type of usage. - Name *UsageName `json:"name,omitempty" azure:"ro"` + Name *UsageName // READ-ONLY; Gets the unit of measurement. - Unit *UsageUnit `json:"unit,omitempty" azure:"ro"` + Unit *UsageUnit } // UsageListResult - The response from the List Usages operation. type UsageListResult struct { // Gets or sets the list of Storage Resource Usages. - Value []*Usage `json:"value,omitempty"` + Value []*Usage } // UsageName - The usage names that can be used; currently limited to StorageAccount. type UsageName struct { // READ-ONLY; Gets a localized string describing the resource name. - LocalizedValue *string `json:"localizedValue,omitempty" azure:"ro"` + LocalizedValue *string // READ-ONLY; Gets a string describing the resource name. - Value *string `json:"value,omitempty" azure:"ro"` + Value *string } // UsagesClientListByLocationOptions contains the optional parameters for the UsagesClient.NewListByLocationPager method. @@ -3261,20 +3260,20 @@ type UsagesClientListByLocationOptions struct { // UserAssignedIdentity for the resource. type UserAssignedIdentity struct { // READ-ONLY; The client ID of the identity. - ClientID *string `json:"clientId,omitempty" azure:"ro"` + ClientID *string // READ-ONLY; The principal ID of the identity. - PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + PrincipalID *string } // VirtualNetworkRule - Virtual Network rule. type VirtualNetworkRule struct { // REQUIRED; Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. - VirtualNetworkResourceID *string `json:"id,omitempty"` + VirtualNetworkResourceID *string // The action of virtual network rule. - Action *string `json:"action,omitempty"` + Action *string // Gets the state of virtual network rule. - State *State `json:"state,omitempty"` + State *State } diff --git a/sdk/resourcemanager/storage/armstorage/models_serde.go b/sdk/resourcemanager/storage/armstorage/models_serde.go index da77c61a385b..e48c343882e4 100644 --- a/sdk/resourcemanager/storage/armstorage/models_serde.go +++ b/sdk/resourcemanager/storage/armstorage/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 armstorage diff --git a/sdk/resourcemanager/storage/armstorage/objectreplicationpolicies_client.go b/sdk/resourcemanager/storage/armstorage/objectreplicationpolicies_client.go index ed7334c151b5..42783e84b59b 100644 --- a/sdk/resourcemanager/storage/armstorage/objectreplicationpolicies_client.go +++ b/sdk/resourcemanager/storage/armstorage/objectreplicationpolicies_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 armstorage @@ -58,18 +57,25 @@ func NewObjectReplicationPoliciesClient(subscriptionID string, credential azcore // - options - ObjectReplicationPoliciesClientCreateOrUpdateOptions contains the optional parameters for the ObjectReplicationPoliciesClient.CreateOrUpdate // method. func (client *ObjectReplicationPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, properties ObjectReplicationPolicy, options *ObjectReplicationPoliciesClientCreateOrUpdateOptions) (ObjectReplicationPoliciesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ObjectReplicationPoliciesClient.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, accountName, objectReplicationPolicyID, properties, options) if err != nil { return ObjectReplicationPoliciesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectReplicationPoliciesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ObjectReplicationPoliciesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ObjectReplicationPoliciesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -99,7 +105,10 @@ func (client *ObjectReplicationPoliciesClient) createOrUpdateCreateRequest(ctx c reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, properties) + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -124,16 +133,22 @@ func (client *ObjectReplicationPoliciesClient) createOrUpdateHandleResponse(resp // - options - ObjectReplicationPoliciesClientDeleteOptions contains the optional parameters for the ObjectReplicationPoliciesClient.Delete // method. func (client *ObjectReplicationPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesClientDeleteOptions) (ObjectReplicationPoliciesClientDeleteResponse, error) { + var err error + const operationName = "ObjectReplicationPoliciesClient.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, accountName, objectReplicationPolicyID, options) if err != nil { return ObjectReplicationPoliciesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectReplicationPoliciesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ObjectReplicationPoliciesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ObjectReplicationPoliciesClientDeleteResponse{}, err } return ObjectReplicationPoliciesClientDeleteResponse{}, nil } @@ -181,18 +196,25 @@ func (client *ObjectReplicationPoliciesClient) deleteCreateRequest(ctx context.C // - options - ObjectReplicationPoliciesClientGetOptions contains the optional parameters for the ObjectReplicationPoliciesClient.Get // method. func (client *ObjectReplicationPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesClientGetOptions) (ObjectReplicationPoliciesClientGetResponse, error) { + var err error + const operationName = "ObjectReplicationPoliciesClient.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, accountName, objectReplicationPolicyID, options) if err != nil { return ObjectReplicationPoliciesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ObjectReplicationPoliciesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ObjectReplicationPoliciesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ObjectReplicationPoliciesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -248,6 +270,7 @@ func (client *ObjectReplicationPoliciesClient) NewListPager(resourceGroupName st return false }, Fetcher: func(ctx context.Context, page *ObjectReplicationPoliciesClientListResponse) (ObjectReplicationPoliciesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ObjectReplicationPoliciesClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return ObjectReplicationPoliciesClientListResponse{}, err @@ -261,6 +284,7 @@ func (client *ObjectReplicationPoliciesClient) NewListPager(resourceGroupName st } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/storage/armstorage/operations_client.go b/sdk/resourcemanager/storage/armstorage/operations_client.go index 4fa2e7783c2e..24ea8449a8c5 100644 --- a/sdk/resourcemanager/storage/armstorage/operations_client.go +++ b/sdk/resourcemanager/storage/armstorage/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 armstorage @@ -48,6 +47,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return false }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") req, err := client.listCreateRequest(ctx, options) if err != nil { return OperationsClientListResponse{}, err @@ -61,6 +61,7 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/storage/armstorage/privateendpointconnections_client.go b/sdk/resourcemanager/storage/armstorage/privateendpointconnections_client.go index 654992cc98a3..7fa15e1dbae7 100644 --- a/sdk/resourcemanager/storage/armstorage/privateendpointconnections_client.go +++ b/sdk/resourcemanager/storage/armstorage/privateendpointconnections_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 armstorage @@ -55,16 +54,22 @@ func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcor // - options - PrivateEndpointConnectionsClientDeleteOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Delete // method. func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientDeleteOptions) (PrivateEndpointConnectionsClientDeleteResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.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, accountName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return PrivateEndpointConnectionsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientDeleteResponse{}, err } return PrivateEndpointConnectionsClientDeleteResponse{}, nil } @@ -110,18 +115,25 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // - options - PrivateEndpointConnectionsClientGetOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Get // method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.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, accountName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -177,6 +189,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s return false }, Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListResponse) (PrivateEndpointConnectionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err @@ -190,6 +203,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -240,18 +254,25 @@ func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *http.Re // - options - PrivateEndpointConnectionsClientPutOptions contains the optional parameters for the PrivateEndpointConnectionsClient.Put // method. func (client *PrivateEndpointConnectionsClient) Put(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientPutOptions) (PrivateEndpointConnectionsClientPutResponse, error) { + var err error + const operationName = "PrivateEndpointConnectionsClient.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, accountName, privateEndpointConnectionName, properties, options) if err != nil { return PrivateEndpointConnectionsClientPutResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateEndpointConnectionsClientPutResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientPutResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateEndpointConnectionsClientPutResponse{}, err } - return client.putHandleResponse(resp) + resp, err := client.putHandleResponse(httpResp) + return resp, err } // putCreateRequest creates the Put request. @@ -281,7 +302,10 @@ func (client *PrivateEndpointConnectionsClient) putCreateRequest(ctx context.Con reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, properties) + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil } // putHandleResponse handles the Put response. diff --git a/sdk/resourcemanager/storage/armstorage/privatelinkresources_client.go b/sdk/resourcemanager/storage/armstorage/privatelinkresources_client.go index fd52b4345e08..c02c8331a822 100644 --- a/sdk/resourcemanager/storage/armstorage/privatelinkresources_client.go +++ b/sdk/resourcemanager/storage/armstorage/privatelinkresources_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 armstorage @@ -54,18 +53,25 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // - options - PrivateLinkResourcesClientListByStorageAccountOptions contains the optional parameters for the PrivateLinkResourcesClient.ListByStorageAccount // method. func (client *PrivateLinkResourcesClient) ListByStorageAccount(ctx context.Context, resourceGroupName string, accountName string, options *PrivateLinkResourcesClientListByStorageAccountOptions) (PrivateLinkResourcesClientListByStorageAccountResponse, error) { + var err error + const operationName = "PrivateLinkResourcesClient.ListByStorageAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listByStorageAccountCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return PrivateLinkResourcesClientListByStorageAccountResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return PrivateLinkResourcesClientListByStorageAccountResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateLinkResourcesClientListByStorageAccountResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PrivateLinkResourcesClientListByStorageAccountResponse{}, err } - return client.listByStorageAccountHandleResponse(resp) + resp, err := client.listByStorageAccountHandleResponse(httpResp) + return resp, err } // listByStorageAccountCreateRequest creates the ListByStorageAccount request. diff --git a/sdk/resourcemanager/storage/armstorage/queue_client.go b/sdk/resourcemanager/storage/armstorage/queue_client.go index 9cf5ea914adb..c3b0a0befb50 100644 --- a/sdk/resourcemanager/storage/armstorage/queue_client.go +++ b/sdk/resourcemanager/storage/armstorage/queue_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 armstorage @@ -57,18 +56,25 @@ func NewQueueClient(subscriptionID string, credential azcore.TokenCredential, op // - queue - Queue properties and metadata to be created with // - options - QueueClientCreateOptions contains the optional parameters for the QueueClient.Create method. func (client *QueueClient) Create(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue Queue, options *QueueClientCreateOptions) (QueueClientCreateResponse, error) { + var err error + const operationName = "QueueClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, queueName, queue, options) if err != nil { return QueueClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueueClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QueueClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueueClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -98,7 +104,10 @@ func (client *QueueClient) createCreateRequest(ctx context.Context, resourceGrou reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, queue) + if err := runtime.MarshalAsJSON(req, queue); err != nil { + return nil, err + } + return req, nil } // createHandleResponse handles the Create response. @@ -122,16 +131,22 @@ func (client *QueueClient) createHandleResponse(resp *http.Response) (QueueClien // an alphanumeric character and it cannot have two consecutive dash(-) characters. // - options - QueueClientDeleteOptions contains the optional parameters for the QueueClient.Delete method. func (client *QueueClient) Delete(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueClientDeleteOptions) (QueueClientDeleteResponse, error) { + var err error + const operationName = "QueueClient.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, accountName, queueName, options) if err != nil { return QueueClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueueClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return QueueClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return QueueClientDeleteResponse{}, err } return QueueClientDeleteResponse{}, nil } @@ -178,18 +193,25 @@ func (client *QueueClient) deleteCreateRequest(ctx context.Context, resourceGrou // an alphanumeric character and it cannot have two consecutive dash(-) characters. // - options - QueueClientGetOptions contains the optional parameters for the QueueClient.Get method. func (client *QueueClient) Get(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueClientGetOptions) (QueueClientGetResponse, error) { + var err error + const operationName = "QueueClient.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, accountName, queueName, options) if err != nil { return QueueClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueueClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QueueClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueueClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -244,6 +266,7 @@ func (client *QueueClient) NewListPager(resourceGroupName string, accountName st return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *QueueClientListResponse) (QueueClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "QueueClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -263,6 +286,7 @@ func (client *QueueClient) NewListPager(resourceGroupName string, accountName st } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -320,18 +344,25 @@ func (client *QueueClient) listHandleResponse(resp *http.Response) (QueueClientL // - queue - Queue properties and metadata to be created with // - options - QueueClientUpdateOptions contains the optional parameters for the QueueClient.Update method. func (client *QueueClient) Update(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue Queue, options *QueueClientUpdateOptions) (QueueClientUpdateResponse, error) { + var err error + const operationName = "QueueClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, queueName, queue, options) if err != nil { return QueueClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueueClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QueueClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueueClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -361,7 +392,10 @@ func (client *QueueClient) updateCreateRequest(ctx context.Context, resourceGrou reqQP.Set("api-version", "2022-09-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, queue) + if err := runtime.MarshalAsJSON(req, queue); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/storage/armstorage/queueservices_client.go b/sdk/resourcemanager/storage/armstorage/queueservices_client.go index 4947d327e07e..21e2f89e3ac5 100644 --- a/sdk/resourcemanager/storage/armstorage/queueservices_client.go +++ b/sdk/resourcemanager/storage/armstorage/queueservices_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 armstorage @@ -55,18 +54,25 @@ func NewQueueServicesClient(subscriptionID string, credential azcore.TokenCreden // - options - QueueServicesClientGetServicePropertiesOptions contains the optional parameters for the QueueServicesClient.GetServiceProperties // method. func (client *QueueServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesClientGetServicePropertiesOptions) (QueueServicesClientGetServicePropertiesResponse, error) { + var err error + const operationName = "QueueServicesClient.GetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return QueueServicesClientGetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueueServicesClientGetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QueueServicesClientGetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueueServicesClientGetServicePropertiesResponse{}, err } - return client.getServicePropertiesHandleResponse(resp) + resp, err := client.getServicePropertiesHandleResponse(httpResp) + return resp, err } // getServicePropertiesCreateRequest creates the GetServiceProperties request. @@ -114,18 +120,25 @@ func (client *QueueServicesClient) getServicePropertiesHandleResponse(resp *http // 3 and 24 characters in length and use numbers and lower-case letters only. // - options - QueueServicesClientListOptions contains the optional parameters for the QueueServicesClient.List method. func (client *QueueServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesClientListOptions) (QueueServicesClientListResponse, error) { + var err error + const operationName = "QueueServicesClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return QueueServicesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueueServicesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QueueServicesClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueueServicesClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -176,18 +189,25 @@ func (client *QueueServicesClient) listHandleResponse(resp *http.Response) (Queu // - options - QueueServicesClientSetServicePropertiesOptions contains the optional parameters for the QueueServicesClient.SetServiceProperties // method. func (client *QueueServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters QueueServiceProperties, options *QueueServicesClientSetServicePropertiesOptions) (QueueServicesClientSetServicePropertiesResponse, error) { + var err error + const operationName = "QueueServicesClient.SetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return QueueServicesClientSetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueueServicesClientSetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QueueServicesClientSetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueueServicesClientSetServicePropertiesResponse{}, err } - return client.setServicePropertiesHandleResponse(resp) + resp, err := client.setServicePropertiesHandleResponse(httpResp) + return resp, err } // setServicePropertiesCreateRequest creates the SetServiceProperties request. @@ -214,7 +234,10 @@ func (client *QueueServicesClient) setServicePropertiesCreateRequest(ctx context reqQP.Set("api-version", "2022-09-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 } // setServicePropertiesHandleResponse handles the SetServiceProperties response. diff --git a/sdk/resourcemanager/storage/armstorage/response_types.go b/sdk/resourcemanager/storage/armstorage/response_types.go index 6b1f3f1ddbe9..ab83d9fbbf2f 100644 --- a/sdk/resourcemanager/storage/armstorage/response_types.go +++ b/sdk/resourcemanager/storage/armstorage/response_types.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 armstorage diff --git a/sdk/resourcemanager/storage/armstorage/skus_client.go b/sdk/resourcemanager/storage/armstorage/skus_client.go index 378c35b986ec..36433821a32b 100644 --- a/sdk/resourcemanager/storage/armstorage/skus_client.go +++ b/sdk/resourcemanager/storage/armstorage/skus_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 armstorage @@ -54,6 +53,7 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. return false }, Fetcher: func(ctx context.Context, page *SKUsClientListResponse) (SKUsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SKUsClient.NewListPager") req, err := client.listCreateRequest(ctx, options) if err != nil { return SKUsClientListResponse{}, err @@ -67,6 +67,7 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/storage/armstorage/table_client.go b/sdk/resourcemanager/storage/armstorage/table_client.go index 808746d509b1..8dd973a7cb7d 100644 --- a/sdk/resourcemanager/storage/armstorage/table_client.go +++ b/sdk/resourcemanager/storage/armstorage/table_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 armstorage @@ -55,18 +54,25 @@ func NewTableClient(subscriptionID string, credential azcore.TokenCredential, op // comprise of only alphanumeric characters and it cannot begin with a numeric character. // - options - TableClientCreateOptions contains the optional parameters for the TableClient.Create method. func (client *TableClient) Create(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableClientCreateOptions) (TableClientCreateResponse, error) { + var err error + const operationName = "TableClient.Create" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, tableName, options) if err != nil { return TableClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TableClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TableClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -97,7 +103,10 @@ func (client *TableClient) createCreateRequest(ctx context.Context, resourceGrou req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { - return req, runtime.MarshalAsJSON(req, *options.Parameters) + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -122,16 +131,22 @@ func (client *TableClient) createHandleResponse(resp *http.Response) (TableClien // comprise of only alphanumeric characters and it cannot begin with a numeric character. // - options - TableClientDeleteOptions contains the optional parameters for the TableClient.Delete method. func (client *TableClient) Delete(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableClientDeleteOptions) (TableClientDeleteResponse, error) { + var err error + const operationName = "TableClient.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, accountName, tableName, options) if err != nil { return TableClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TableClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return TableClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TableClientDeleteResponse{}, err } return TableClientDeleteResponse{}, nil } @@ -177,18 +192,25 @@ func (client *TableClient) deleteCreateRequest(ctx context.Context, resourceGrou // comprise of only alphanumeric characters and it cannot begin with a numeric character. // - options - TableClientGetOptions contains the optional parameters for the TableClient.Get method. func (client *TableClient) Get(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableClientGetOptions) (TableClientGetResponse, error) { + var err error + const operationName = "TableClient.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, accountName, tableName, options) if err != nil { return TableClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TableClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TableClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -243,6 +265,7 @@ func (client *TableClient) NewListPager(resourceGroupName string, accountName st return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *TableClientListResponse) (TableClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TableClient.NewListPager") var req *policy.Request var err error if page == nil { @@ -262,6 +285,7 @@ func (client *TableClient) NewListPager(resourceGroupName string, accountName st } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -311,18 +335,25 @@ func (client *TableClient) listHandleResponse(resp *http.Response) (TableClientL // comprise of only alphanumeric characters and it cannot begin with a numeric character. // - options - TableClientUpdateOptions contains the optional parameters for the TableClient.Update method. func (client *TableClient) Update(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableClientUpdateOptions) (TableClientUpdateResponse, error) { + var err error + const operationName = "TableClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, tableName, options) if err != nil { return TableClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TableClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TableClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -353,7 +384,10 @@ func (client *TableClient) updateCreateRequest(ctx context.Context, resourceGrou req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { - return req, runtime.MarshalAsJSON(req, *options.Parameters) + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/storage/armstorage/tableservices_client.go b/sdk/resourcemanager/storage/armstorage/tableservices_client.go index 2cc731656d3c..010189120092 100644 --- a/sdk/resourcemanager/storage/armstorage/tableservices_client.go +++ b/sdk/resourcemanager/storage/armstorage/tableservices_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 armstorage @@ -55,18 +54,25 @@ func NewTableServicesClient(subscriptionID string, credential azcore.TokenCreden // - options - TableServicesClientGetServicePropertiesOptions contains the optional parameters for the TableServicesClient.GetServiceProperties // method. func (client *TableServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesClientGetServicePropertiesOptions) (TableServicesClientGetServicePropertiesResponse, error) { + var err error + const operationName = "TableServicesClient.GetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return TableServicesClientGetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TableServicesClientGetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableServicesClientGetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TableServicesClientGetServicePropertiesResponse{}, err } - return client.getServicePropertiesHandleResponse(resp) + resp, err := client.getServicePropertiesHandleResponse(httpResp) + return resp, err } // getServicePropertiesCreateRequest creates the GetServiceProperties request. @@ -114,18 +120,25 @@ func (client *TableServicesClient) getServicePropertiesHandleResponse(resp *http // 3 and 24 characters in length and use numbers and lower-case letters only. // - options - TableServicesClientListOptions contains the optional parameters for the TableServicesClient.List method. func (client *TableServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesClientListOptions) (TableServicesClientListResponse, error) { + var err error + const operationName = "TableServicesClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { return TableServicesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TableServicesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableServicesClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TableServicesClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -176,18 +189,25 @@ func (client *TableServicesClient) listHandleResponse(resp *http.Response) (Tabl // - options - TableServicesClientSetServicePropertiesOptions contains the optional parameters for the TableServicesClient.SetServiceProperties // method. func (client *TableServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters TableServiceProperties, options *TableServicesClientSetServicePropertiesOptions) (TableServicesClientSetServicePropertiesResponse, error) { + var err error + const operationName = "TableServicesClient.SetServiceProperties" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { return TableServicesClientSetServicePropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TableServicesClientSetServicePropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TableServicesClientSetServicePropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TableServicesClientSetServicePropertiesResponse{}, err } - return client.setServicePropertiesHandleResponse(resp) + resp, err := client.setServicePropertiesHandleResponse(httpResp) + return resp, err } // setServicePropertiesCreateRequest creates the SetServiceProperties request. @@ -214,7 +234,10 @@ func (client *TableServicesClient) setServicePropertiesCreateRequest(ctx context reqQP.Set("api-version", "2022-09-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 } // setServicePropertiesHandleResponse handles the SetServiceProperties response. diff --git a/sdk/resourcemanager/storage/armstorage/time_rfc3339.go b/sdk/resourcemanager/storage/armstorage/time_rfc3339.go index 625ecd137ae8..f4a3a336cf69 100644 --- a/sdk/resourcemanager/storage/armstorage/time_rfc3339.go +++ b/sdk/resourcemanager/storage/armstorage/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 armstorage diff --git a/sdk/resourcemanager/storage/armstorage/usages_client.go b/sdk/resourcemanager/storage/armstorage/usages_client.go index 2c66fa4c0199..43b4c6808002 100644 --- a/sdk/resourcemanager/storage/armstorage/usages_client.go +++ b/sdk/resourcemanager/storage/armstorage/usages_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 armstorage @@ -56,6 +55,7 @@ func (client *UsagesClient) NewListByLocationPager(location string, options *Usa return false }, Fetcher: func(ctx context.Context, page *UsagesClientListByLocationResponse) (UsagesClientListByLocationResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "UsagesClient.NewListByLocationPager") req, err := client.listByLocationCreateRequest(ctx, location, options) if err != nil { return UsagesClientListByLocationResponse{}, err @@ -69,6 +69,7 @@ func (client *UsagesClient) NewListByLocationPager(location string, options *Usa } return client.listByLocationHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } From 72c43a6b8c6ca23c74a80e6216f0eb1974209c52 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Fri, 9 Jun 2023 16:06:21 -0700 Subject: [PATCH 2/2] update to latest code generator added fake testable example bump release date --- .../storage/armstorage/CHANGELOG.md | 2 +- .../storage/armstorage/build.go | 2 +- .../armstorage/fake/accounts_server.go | 255 +++++++++++---- .../armstorage/fake/blobcontainers_server.go | 295 ++++++++++++++---- .../fake/blobinventorypolicies_server.go | 77 ++++- .../armstorage/fake/blobservices_server.go | 49 ++- .../armstorage/fake/deletedaccounts_server.go | 23 +- .../fake/encryptionscopes_server.go | 95 ++++-- .../armstorage/fake/fileservices_server.go | 49 ++- .../armstorage/fake/fileshares_server.go | 173 ++++++++-- .../armstorage/fake/localusers_server.go | 117 +++++-- .../fake/managementpolicies_server.go | 61 +++- .../fake/objectreplicationpolicies_server.go | 77 ++++- .../armstorage/fake/operations_server.go | 2 +- .../fake/privateendpointconnections_server.go | 77 ++++- .../fake/privatelinkresources_server.go | 17 +- .../storage/armstorage/fake/queue_server.go | 109 +++++-- .../armstorage/fake/queueservices_server.go | 49 ++- .../storage/armstorage/fake/skus_server.go | 6 +- .../storage/armstorage/fake/table_server.go | 97 ++++-- .../armstorage/fake/tableservices_server.go | 49 ++- .../storage/armstorage/fake/usages_server.go | 13 +- .../storage/armstorage/fake_example_test.go | 79 +++++ 23 files changed, 1401 insertions(+), 372 deletions(-) create mode 100644 sdk/resourcemanager/storage/armstorage/fake_example_test.go diff --git a/sdk/resourcemanager/storage/armstorage/CHANGELOG.md b/sdk/resourcemanager/storage/armstorage/CHANGELOG.md index 0f3a865aafc3..f6bfb1fcb5f3 100644 --- a/sdk/resourcemanager/storage/armstorage/CHANGELOG.md +++ b/sdk/resourcemanager/storage/armstorage/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.4.0-beta.1 (2023-06-08) +## 1.4.0-beta.1 (2023-06-12) ### Features Added diff --git a/sdk/resourcemanager/storage/armstorage/build.go b/sdk/resourcemanager/storage/armstorage/build.go index 93257c9e9c50..783f5618d9b4 100644 --- a/sdk/resourcemanager/storage/armstorage/build.go +++ b/sdk/resourcemanager/storage/armstorage/build.go @@ -2,6 +2,6 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -goExtension "@autorest/go@4.0.0-preview.50" -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/storage/armstorage +//go:generate pwsh ../../../../eng/scripts/build.ps1 -goExtension "@autorest/go@4.0.0-preview.51" -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/storage/armstorage package armstorage diff --git a/sdk/resourcemanager/storage/armstorage/fake/accounts_server.go b/sdk/resourcemanager/storage/armstorage/fake/accounts_server.go index eab8268d3b3c..0acb06d10e22 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/accounts_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/accounts_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -165,16 +166,24 @@ func (a *AccountsServerTransport) Do(req *http.Request) (*http.Response, error) func (a *AccountsServerTransport) dispatchBeginAbortHierarchicalNamespaceMigration(req *http.Request) (*http.Response, error) { if a.srv.BeginAbortHierarchicalNamespaceMigration == nil { - return nil, &nonRetriableError{errors.New("method BeginAbortHierarchicalNamespaceMigration not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginAbortHierarchicalNamespaceMigration not implemented")} } if a.beginAbortHierarchicalNamespaceMigration == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourcegroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/aborthnsonmigration" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/aborthnsonmigration` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := a.srv.BeginAbortHierarchicalNamespaceMigration(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginAbortHierarchicalNamespaceMigration(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -198,11 +207,11 @@ func (a *AccountsServerTransport) dispatchBeginAbortHierarchicalNamespaceMigrati func (a *AccountsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { if a.srv.CheckNameAvailability == nil { - return nil, &nonRetriableError{errors.New("method CheckNameAvailability not implemented")} + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/checkNameAvailability" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/checkNameAvailability` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -227,12 +236,12 @@ func (a *AccountsServerTransport) dispatchCheckNameAvailability(req *http.Reques func (a *AccountsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { if a.srv.BeginCreate == nil { - return nil, &nonRetriableError{errors.New("method BeginCreate not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} } if a.beginCreate == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -240,7 +249,15 @@ func (a *AccountsServerTransport) dispatchBeginCreate(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := a.srv.BeginCreate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreate(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -264,15 +281,23 @@ func (a *AccountsServerTransport) dispatchBeginCreate(req *http.Request) (*http. func (a *AccountsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if a.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := a.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -289,24 +314,36 @@ func (a *AccountsServerTransport) dispatchDelete(req *http.Request) (*http.Respo func (a *AccountsServerTransport) dispatchBeginFailover(req *http.Request) (*http.Response, error) { if a.srv.BeginFailover == nil { - return nil, &nonRetriableError{errors.New("method BeginFailover not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginFailover not implemented")} } if a.beginFailover == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/failover" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/failover` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - failoverTypeParam := getOptional(qp.Get("failoverType")) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + failoverTypeUnescaped, err := url.QueryUnescape(qp.Get("failoverType")) + if err != nil { + return nil, err + } + failoverTypeParam := getOptional(failoverTypeUnescaped) var options *armstorage.AccountsClientBeginFailoverOptions if failoverTypeParam != nil { options = &armstorage.AccountsClientBeginFailoverOptions{ FailoverType: failoverTypeParam, } } - respr, errRespr := a.srv.BeginFailover(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + respr, errRespr := a.srv.BeginFailover(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -330,23 +367,35 @@ func (a *AccountsServerTransport) dispatchBeginFailover(req *http.Request) (*htt func (a *AccountsServerTransport) dispatchGetProperties(req *http.Request) (*http.Response, error) { if a.srv.GetProperties == nil { - return nil, &nonRetriableError{errors.New("method GetProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - expandParam := getOptional(armstorage.StorageAccountExpand(qp.Get("$expand"))) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(armstorage.StorageAccountExpand(expandUnescaped)) var options *armstorage.AccountsClientGetPropertiesOptions if expandParam != nil { options = &armstorage.AccountsClientGetPropertiesOptions{ Expand: expandParam, } } - respr, errRespr := a.srv.GetProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + respr, errRespr := a.srv.GetProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -363,17 +412,29 @@ func (a *AccountsServerTransport) dispatchGetProperties(req *http.Request) (*htt func (a *AccountsServerTransport) dispatchBeginHierarchicalNamespaceMigration(req *http.Request) (*http.Response, error) { if a.srv.BeginHierarchicalNamespaceMigration == nil { - return nil, &nonRetriableError{errors.New("method BeginHierarchicalNamespaceMigration not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginHierarchicalNamespaceMigration not implemented")} } if a.beginHierarchicalNamespaceMigration == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourcegroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/hnsonmigration" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/hnsonmigration` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - respr, errRespr := a.srv.BeginHierarchicalNamespaceMigration(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], qp.Get("requestType"), nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + requestTypeUnescaped, err := url.QueryUnescape(qp.Get("requestType")) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginHierarchicalNamespaceMigration(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, requestTypeUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -397,12 +458,12 @@ func (a *AccountsServerTransport) dispatchBeginHierarchicalNamespaceMigration(re func (a *AccountsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if a.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if a.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -427,11 +488,11 @@ func (a *AccountsServerTransport) dispatchNewListPager(req *http.Request) (*http func (a *AccountsServerTransport) dispatchListAccountSAS(req *http.Request) (*http.Response, error) { if a.srv.ListAccountSAS == nil { - return nil, &nonRetriableError{errors.New("method ListAccountSAS not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ListAccountSAS not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/ListAccountSas" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ListAccountSas` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -439,7 +500,15 @@ func (a *AccountsServerTransport) dispatchListAccountSAS(req *http.Request) (*ht if err != nil { return nil, err } - respr, errRespr := a.srv.ListAccountSAS(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListAccountSAS(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -456,16 +525,20 @@ func (a *AccountsServerTransport) dispatchListAccountSAS(req *http.Request) (*ht func (a *AccountsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { if a.srv.NewListByResourceGroupPager == nil { - return nil, &nonRetriableError{errors.New("method NewListByResourceGroupPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} } if a.newListByResourceGroupPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := a.srv.NewListByResourceGroupPager(matches[regex.SubexpIndex("resourceGroupName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByResourceGroupPager(resourceGroupNameUnescaped, nil) a.newListByResourceGroupPager = &resp server.PagerResponderInjectNextLinks(a.newListByResourceGroupPager, req, func(page *armstorage.AccountsClientListByResourceGroupResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -486,23 +559,35 @@ func (a *AccountsServerTransport) dispatchNewListByResourceGroupPager(req *http. func (a *AccountsServerTransport) dispatchListKeys(req *http.Request) (*http.Response, error) { if a.srv.ListKeys == nil { - return nil, &nonRetriableError{errors.New("method ListKeys not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ListKeys not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/listKeys" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listKeys` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - expandParam := getOptional(qp.Get("$expand")) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) var options *armstorage.AccountsClientListKeysOptions if expandParam != nil { options = &armstorage.AccountsClientListKeysOptions{ Expand: expandParam, } } - respr, errRespr := a.srv.ListKeys(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + respr, errRespr := a.srv.ListKeys(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -519,11 +604,11 @@ func (a *AccountsServerTransport) dispatchListKeys(req *http.Request) (*http.Res func (a *AccountsServerTransport) dispatchListServiceSAS(req *http.Request) (*http.Response, error) { if a.srv.ListServiceSAS == nil { - return nil, &nonRetriableError{errors.New("method ListServiceSAS not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ListServiceSAS not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/ListServiceSas" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ListServiceSas` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -531,7 +616,15 @@ func (a *AccountsServerTransport) dispatchListServiceSAS(req *http.Request) (*ht if err != nil { return nil, err } - respr, errRespr := a.srv.ListServiceSAS(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListServiceSAS(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -548,11 +641,11 @@ func (a *AccountsServerTransport) dispatchListServiceSAS(req *http.Request) (*ht func (a *AccountsServerTransport) dispatchRegenerateKey(req *http.Request) (*http.Response, error) { if a.srv.RegenerateKey == nil { - return nil, &nonRetriableError{errors.New("method RegenerateKey not implemented")} + return nil, &nonRetriableError{errors.New("fake for method RegenerateKey not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/regenerateKey" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regenerateKey` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -560,7 +653,15 @@ func (a *AccountsServerTransport) dispatchRegenerateKey(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := a.srv.RegenerateKey(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.RegenerateKey(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -577,12 +678,12 @@ func (a *AccountsServerTransport) dispatchRegenerateKey(req *http.Request) (*htt func (a *AccountsServerTransport) dispatchBeginRestoreBlobRanges(req *http.Request) (*http.Response, error) { if a.srv.BeginRestoreBlobRanges == nil { - return nil, &nonRetriableError{errors.New("method BeginRestoreBlobRanges not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginRestoreBlobRanges not implemented")} } if a.beginRestoreBlobRanges == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/restoreBlobRanges" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/restoreBlobRanges` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -590,7 +691,15 @@ func (a *AccountsServerTransport) dispatchBeginRestoreBlobRanges(req *http.Reque if err != nil { return nil, err } - respr, errRespr := a.srv.BeginRestoreBlobRanges(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginRestoreBlobRanges(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -614,15 +723,23 @@ func (a *AccountsServerTransport) dispatchBeginRestoreBlobRanges(req *http.Reque func (a *AccountsServerTransport) dispatchRevokeUserDelegationKeys(req *http.Request) (*http.Response, error) { if a.srv.RevokeUserDelegationKeys == nil { - return nil, &nonRetriableError{errors.New("method RevokeUserDelegationKeys not implemented")} + return nil, &nonRetriableError{errors.New("fake for method RevokeUserDelegationKeys not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/revokeUserDelegationKeys" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/revokeUserDelegationKeys` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := a.srv.RevokeUserDelegationKeys(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.RevokeUserDelegationKeys(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -639,11 +756,11 @@ func (a *AccountsServerTransport) dispatchRevokeUserDelegationKeys(req *http.Req func (a *AccountsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { if a.srv.Update == nil { - return nil, &nonRetriableError{errors.New("method Update not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -651,7 +768,15 @@ func (a *AccountsServerTransport) dispatchUpdate(req *http.Request) (*http.Respo if err != nil { return nil, err } - respr, errRespr := a.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Update(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go b/sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go index cabe0299c7bd..7e70c154ac61 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/blobcontainers_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "reflect" "regexp" ) @@ -149,11 +150,11 @@ func (b *BlobContainersServerTransport) Do(req *http.Request) (*http.Response, e func (b *BlobContainersServerTransport) dispatchClearLegalHold(req *http.Request) (*http.Response, error) { if b.srv.ClearLegalHold == nil { - return nil, &nonRetriableError{errors.New("method ClearLegalHold not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ClearLegalHold not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/clearLegalHold" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/clearLegalHold` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -161,7 +162,19 @@ func (b *BlobContainersServerTransport) dispatchClearLegalHold(req *http.Request if err != nil { return nil, err } - respr, errRespr := b.srv.ClearLegalHold(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.ClearLegalHold(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -178,11 +191,11 @@ func (b *BlobContainersServerTransport) dispatchClearLegalHold(req *http.Request func (b *BlobContainersServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { if b.srv.Create == nil { - return nil, &nonRetriableError{errors.New("method Create not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -190,7 +203,19 @@ func (b *BlobContainersServerTransport) dispatchCreate(req *http.Request) (*http if err != nil { return nil, err } - respr, errRespr := b.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Create(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -207,11 +232,11 @@ func (b *BlobContainersServerTransport) dispatchCreate(req *http.Request) (*http func (b *BlobContainersServerTransport) dispatchCreateOrUpdateImmutabilityPolicy(req *http.Request) (*http.Response, error) { if b.srv.CreateOrUpdateImmutabilityPolicy == nil { - return nil, &nonRetriableError{errors.New("method CreateOrUpdateImmutabilityPolicy not implemented")} + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateImmutabilityPolicy not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/immutabilityPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -219,6 +244,18 @@ func (b *BlobContainersServerTransport) dispatchCreateOrUpdateImmutabilityPolicy if err != nil { return nil, err } + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) var options *armstorage.BlobContainersClientCreateOrUpdateImmutabilityPolicyOptions if ifMatchParam != nil || !reflect.ValueOf(body).IsZero() { @@ -227,7 +264,7 @@ func (b *BlobContainersServerTransport) dispatchCreateOrUpdateImmutabilityPolicy Parameters: &body, } } - respr, errRespr := b.srv.CreateOrUpdateImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], options) + respr, errRespr := b.srv.CreateOrUpdateImmutabilityPolicy(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -247,15 +284,27 @@ func (b *BlobContainersServerTransport) dispatchCreateOrUpdateImmutabilityPolicy func (b *BlobContainersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if b.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -272,15 +321,27 @@ func (b *BlobContainersServerTransport) dispatchDelete(req *http.Request) (*http func (b *BlobContainersServerTransport) dispatchDeleteImmutabilityPolicy(req *http.Request) (*http.Response, error) { if b.srv.DeleteImmutabilityPolicy == nil { - return nil, &nonRetriableError{errors.New("method DeleteImmutabilityPolicy not implemented")} + return nil, &nonRetriableError{errors.New("fake for method DeleteImmutabilityPolicy not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/immutabilityPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.DeleteImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], getHeaderValue(req.Header, "If-Match"), nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.DeleteImmutabilityPolicy(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, getHeaderValue(req.Header, "If-Match"), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -300,11 +361,11 @@ func (b *BlobContainersServerTransport) dispatchDeleteImmutabilityPolicy(req *ht func (b *BlobContainersServerTransport) dispatchExtendImmutabilityPolicy(req *http.Request) (*http.Response, error) { if b.srv.ExtendImmutabilityPolicy == nil { - return nil, &nonRetriableError{errors.New("method ExtendImmutabilityPolicy not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ExtendImmutabilityPolicy not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/default/extend" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/immutabilityPolicies/default/extend` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -312,13 +373,25 @@ func (b *BlobContainersServerTransport) dispatchExtendImmutabilityPolicy(req *ht if err != nil { return nil, err } + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } var options *armstorage.BlobContainersClientExtendImmutabilityPolicyOptions if !reflect.ValueOf(body).IsZero() { options = &armstorage.BlobContainersClientExtendImmutabilityPolicyOptions{ Parameters: &body, } } - respr, errRespr := b.srv.ExtendImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], getHeaderValue(req.Header, "If-Match"), options) + respr, errRespr := b.srv.ExtendImmutabilityPolicy(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, getHeaderValue(req.Header, "If-Match"), options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -338,15 +411,27 @@ func (b *BlobContainersServerTransport) dispatchExtendImmutabilityPolicy(req *ht func (b *BlobContainersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if b.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -363,14 +448,26 @@ func (b *BlobContainersServerTransport) dispatchGet(req *http.Request) (*http.Re func (b *BlobContainersServerTransport) dispatchGetImmutabilityPolicy(req *http.Request) (*http.Response, error) { if b.srv.GetImmutabilityPolicy == nil { - return nil, &nonRetriableError{errors.New("method GetImmutabilityPolicy not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetImmutabilityPolicy not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/immutabilityPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 5 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) var options *armstorage.BlobContainersClientGetImmutabilityPolicyOptions if ifMatchParam != nil { @@ -378,7 +475,7 @@ func (b *BlobContainersServerTransport) dispatchGetImmutabilityPolicy(req *http. IfMatch: ifMatchParam, } } - respr, errRespr := b.srv.GetImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], options) + respr, errRespr := b.srv.GetImmutabilityPolicy(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -398,11 +495,11 @@ func (b *BlobContainersServerTransport) dispatchGetImmutabilityPolicy(req *http. func (b *BlobContainersServerTransport) dispatchLease(req *http.Request) (*http.Response, error) { if b.srv.Lease == nil { - return nil, &nonRetriableError{errors.New("method Lease not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Lease not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/lease" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/lease` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -410,13 +507,25 @@ func (b *BlobContainersServerTransport) dispatchLease(req *http.Request) (*http. if err != nil { return nil, err } + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } var options *armstorage.BlobContainersClientLeaseOptions if !reflect.ValueOf(body).IsZero() { options = &armstorage.BlobContainersClientLeaseOptions{ Parameters: &body, } } - respr, errRespr := b.srv.Lease(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], options) + respr, errRespr := b.srv.Lease(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -433,19 +542,39 @@ func (b *BlobContainersServerTransport) dispatchLease(req *http.Request) (*http. func (b *BlobContainersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if b.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if b.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - maxpagesizeParam := getOptional(qp.Get("$maxpagesize")) - filterParam := getOptional(qp.Get("$filter")) - includeParam := getOptional(armstorage.ListContainersInclude(qp.Get("$include"))) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("$maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam := getOptional(maxpagesizeUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + includeUnescaped, err := url.QueryUnescape(qp.Get("$include")) + if err != nil { + return nil, err + } + includeParam := getOptional(armstorage.ListContainersInclude(includeUnescaped)) var options *armstorage.BlobContainersClientListOptions if maxpagesizeParam != nil || filterParam != nil || includeParam != nil { options = &armstorage.BlobContainersClientListOptions{ @@ -454,7 +583,7 @@ func (b *BlobContainersServerTransport) dispatchNewListPager(req *http.Request) Include: includeParam, } } - resp := b.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + resp := b.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, options) b.newListPager = &resp server.PagerResponderInjectNextLinks(b.newListPager, req, func(page *armstorage.BlobContainersClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -475,15 +604,27 @@ func (b *BlobContainersServerTransport) dispatchNewListPager(req *http.Request) func (b *BlobContainersServerTransport) dispatchLockImmutabilityPolicy(req *http.Request) (*http.Response, error) { if b.srv.LockImmutabilityPolicy == nil { - return nil, &nonRetriableError{errors.New("method LockImmutabilityPolicy not implemented")} + return nil, &nonRetriableError{errors.New("fake for method LockImmutabilityPolicy not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/immutabilityPolicies/default/lock" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/immutabilityPolicies/default/lock` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.LockImmutabilityPolicy(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], getHeaderValue(req.Header, "If-Match"), nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.LockImmutabilityPolicy(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, getHeaderValue(req.Header, "If-Match"), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -503,16 +644,28 @@ func (b *BlobContainersServerTransport) dispatchLockImmutabilityPolicy(req *http func (b *BlobContainersServerTransport) dispatchBeginObjectLevelWorm(req *http.Request) (*http.Response, error) { if b.srv.BeginObjectLevelWorm == nil { - return nil, &nonRetriableError{errors.New("method BeginObjectLevelWorm not implemented")} + return nil, &nonRetriableError{errors.New("fake for method BeginObjectLevelWorm not implemented")} } if b.beginObjectLevelWorm == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/migrate" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/migrate` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.BeginObjectLevelWorm(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.BeginObjectLevelWorm(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -536,11 +689,11 @@ func (b *BlobContainersServerTransport) dispatchBeginObjectLevelWorm(req *http.R func (b *BlobContainersServerTransport) dispatchSetLegalHold(req *http.Request) (*http.Response, error) { if b.srv.SetLegalHold == nil { - return nil, &nonRetriableError{errors.New("method SetLegalHold not implemented")} + return nil, &nonRetriableError{errors.New("fake for method SetLegalHold not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)/setLegalHold" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/setLegalHold` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -548,7 +701,19 @@ func (b *BlobContainersServerTransport) dispatchSetLegalHold(req *http.Request) if err != nil { return nil, err } - respr, errRespr := b.srv.SetLegalHold(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.SetLegalHold(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -565,11 +730,11 @@ func (b *BlobContainersServerTransport) dispatchSetLegalHold(req *http.Request) func (b *BlobContainersServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { if b.srv.Update == nil { - return nil, &nonRetriableError{errors.New("method Update not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/default/containers/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/default/containers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -577,7 +742,19 @@ func (b *BlobContainersServerTransport) dispatchUpdate(req *http.Request) (*http if err != nil { return nil, err } - respr, errRespr := b.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("containerName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + containerNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("containerName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Update(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, containerNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go b/sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go index 370ec9c48da8..9cf662468441 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/blobinventorypolicies_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -86,11 +87,11 @@ func (b *BlobInventoryPoliciesServerTransport) Do(req *http.Request) (*http.Resp func (b *BlobInventoryPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { if b.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -98,7 +99,19 @@ func (b *BlobInventoryPoliciesServerTransport) dispatchCreateOrUpdate(req *http. if err != nil { return nil, err } - respr, errRespr := b.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.BlobInventoryPolicyName(matches[regex.SubexpIndex("blobInventoryPolicyName")]), body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + blobInventoryPolicyNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("blobInventoryPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.CreateOrUpdate(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, armstorage.BlobInventoryPolicyName(blobInventoryPolicyNameUnescaped), body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -115,15 +128,27 @@ func (b *BlobInventoryPoliciesServerTransport) dispatchCreateOrUpdate(req *http. func (b *BlobInventoryPoliciesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if b.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.BlobInventoryPolicyName(matches[regex.SubexpIndex("blobInventoryPolicyName")]), nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + blobInventoryPolicyNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("blobInventoryPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, armstorage.BlobInventoryPolicyName(blobInventoryPolicyNameUnescaped), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -140,15 +165,27 @@ func (b *BlobInventoryPoliciesServerTransport) dispatchDelete(req *http.Request) func (b *BlobInventoryPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if b.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.BlobInventoryPolicyName(matches[regex.SubexpIndex("blobInventoryPolicyName")]), nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + blobInventoryPolicyNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("blobInventoryPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, armstorage.BlobInventoryPolicyName(blobInventoryPolicyNameUnescaped), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -165,16 +202,24 @@ func (b *BlobInventoryPoliciesServerTransport) dispatchGet(req *http.Request) (* func (b *BlobInventoryPoliciesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if b.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if b.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/inventoryPolicies" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inventoryPolicies` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := b.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := b.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, nil) b.newListPager = &resp } resp, err := server.PagerResponderNext(b.newListPager, req) diff --git a/sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go index 5f74cac8ec85..62969a414208 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/blobservices_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -80,15 +81,23 @@ func (b *BlobServicesServerTransport) Do(req *http.Request) (*http.Response, err func (b *BlobServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { if b.srv.GetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := b.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.GetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -105,16 +114,24 @@ func (b *BlobServicesServerTransport) dispatchGetServiceProperties(req *http.Req func (b *BlobServicesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if b.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if b.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := b.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := b.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, nil) b.newListPager = &resp } resp, err := server.PagerResponderNext(b.newListPager, req) @@ -132,11 +149,11 @@ func (b *BlobServicesServerTransport) dispatchNewListPager(req *http.Request) (* func (b *BlobServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { if b.srv.SetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method SetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/blobServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/blobServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -144,7 +161,15 @@ func (b *BlobServicesServerTransport) dispatchSetServiceProperties(req *http.Req if err != nil { return nil, err } - respr, errRespr := b.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.SetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go b/sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go index bcf2aeed5337..06cb1a702afb 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/deletedaccounts_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -75,15 +76,23 @@ func (d *DeletedAccountsServerTransport) Do(req *http.Request) (*http.Response, func (d *DeletedAccountsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if d.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/locations/(?P[a-zA-Z0-9-_]+)/deletedAccounts/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := d.srv.Get(req.Context(), matches[regex.SubexpIndex("deletedAccountName")], matches[regex.SubexpIndex("location")], nil) + deletedAccountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("deletedAccountName")]) + if err != nil { + return nil, err + } + locationUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), deletedAccountNameUnescaped, locationUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -100,12 +109,12 @@ func (d *DeletedAccountsServerTransport) dispatchGet(req *http.Request) (*http.R func (d *DeletedAccountsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if d.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if d.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/deletedAccounts" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/deletedAccounts` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } diff --git a/sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go b/sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go index 31094b262512..1a14dd34d83b 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/encryptionscopes_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" "strconv" ) @@ -88,15 +89,27 @@ func (e *EncryptionScopesServerTransport) Do(req *http.Request) (*http.Response, func (e *EncryptionScopesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if e.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := e.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("encryptionScopeName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + encryptionScopeNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("encryptionScopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, encryptionScopeNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -113,17 +126,29 @@ func (e *EncryptionScopesServerTransport) dispatchGet(req *http.Request) (*http. func (e *EncryptionScopesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if e.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if e.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - maxpagesizeParam, err := parseOptional(qp.Get("$maxpagesize"), func(v string) (int32, error) { + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("$maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam, err := parseOptional(maxpagesizeUnescaped, func(v string) (int32, error) { p, parseErr := strconv.ParseInt(v, 10, 32) if parseErr != nil { return 0, parseErr @@ -133,8 +158,16 @@ func (e *EncryptionScopesServerTransport) dispatchNewListPager(req *http.Request if err != nil { return nil, err } - filterParam := getOptional(qp.Get("$filter")) - includeParam := getOptional(armstorage.ListEncryptionScopesInclude(qp.Get("$include"))) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + includeUnescaped, err := url.QueryUnescape(qp.Get("$include")) + if err != nil { + return nil, err + } + includeParam := getOptional(armstorage.ListEncryptionScopesInclude(includeUnescaped)) var options *armstorage.EncryptionScopesClientListOptions if maxpagesizeParam != nil || filterParam != nil || includeParam != nil { options = &armstorage.EncryptionScopesClientListOptions{ @@ -143,7 +176,7 @@ func (e *EncryptionScopesServerTransport) dispatchNewListPager(req *http.Request Include: includeParam, } } - resp := e.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + resp := e.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, options) e.newListPager = &resp server.PagerResponderInjectNextLinks(e.newListPager, req, func(page *armstorage.EncryptionScopesClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -164,11 +197,11 @@ func (e *EncryptionScopesServerTransport) dispatchNewListPager(req *http.Request func (e *EncryptionScopesServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { if e.srv.Patch == nil { - return nil, &nonRetriableError{errors.New("method Patch not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -176,7 +209,19 @@ func (e *EncryptionScopesServerTransport) dispatchPatch(req *http.Request) (*htt if err != nil { return nil, err } - respr, errRespr := e.srv.Patch(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("encryptionScopeName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + encryptionScopeNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("encryptionScopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Patch(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, encryptionScopeNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -193,11 +238,11 @@ func (e *EncryptionScopesServerTransport) dispatchPatch(req *http.Request) (*htt func (e *EncryptionScopesServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { if e.srv.Put == nil { - return nil, &nonRetriableError{errors.New("method Put not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/encryptionScopes/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/encryptionScopes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -205,7 +250,19 @@ func (e *EncryptionScopesServerTransport) dispatchPut(req *http.Request) (*http. if err != nil { return nil, err } - respr, errRespr := e.srv.Put(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("encryptionScopeName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + encryptionScopeNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("encryptionScopeName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Put(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, encryptionScopeNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go index 7b156b957fd6..c6412297aa99 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/fileservices_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -79,15 +80,23 @@ func (f *FileServicesServerTransport) Do(req *http.Request) (*http.Response, err func (f *FileServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { if f.srv.GetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := f.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.GetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -104,15 +113,23 @@ func (f *FileServicesServerTransport) dispatchGetServiceProperties(req *http.Req func (f *FileServicesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { if f.srv.List == nil { - return nil, &nonRetriableError{errors.New("method List not implemented")} + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := f.srv.List(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.List(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -129,11 +146,11 @@ func (f *FileServicesServerTransport) dispatchList(req *http.Request) (*http.Res func (f *FileServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { if f.srv.SetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method SetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -141,7 +158,15 @@ func (f *FileServicesServerTransport) dispatchSetServiceProperties(req *http.Req if err != nil { return nil, err } - respr, errRespr := f.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.SetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go b/sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go index 1033baaec916..3a1b63c5fd6f 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/fileshares_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "reflect" "regexp" ) @@ -106,11 +107,11 @@ func (f *FileSharesServerTransport) Do(req *http.Request) (*http.Response, error func (f *FileSharesServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { if f.srv.Create == nil { - return nil, &nonRetriableError{errors.New("method Create not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/default/shares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -119,14 +120,30 @@ func (f *FileSharesServerTransport) dispatchCreate(req *http.Request) (*http.Res if err != nil { return nil, err } - expandParam := getOptional(qp.Get("$expand")) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + shareNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("shareName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) var options *armstorage.FileSharesClientCreateOptions if expandParam != nil { options = &armstorage.FileSharesClientCreateOptions{ Expand: expandParam, } } - respr, errRespr := f.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], body, options) + respr, errRespr := f.srv.Create(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, shareNameUnescaped, body, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -143,17 +160,33 @@ func (f *FileSharesServerTransport) dispatchCreate(req *http.Request) (*http.Res func (f *FileSharesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if f.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/default/shares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + shareNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("shareName")]) + if err != nil { + return nil, err + } xMSSnapshotParam := getOptional(getHeaderValue(req.Header, "x-ms-snapshot")) - includeParam := getOptional(qp.Get("$include")) + includeUnescaped, err := url.QueryUnescape(qp.Get("$include")) + if err != nil { + return nil, err + } + includeParam := getOptional(includeUnescaped) var options *armstorage.FileSharesClientDeleteOptions if xMSSnapshotParam != nil || includeParam != nil { options = &armstorage.FileSharesClientDeleteOptions{ @@ -161,7 +194,7 @@ func (f *FileSharesServerTransport) dispatchDelete(req *http.Request) (*http.Res Include: includeParam, } } - respr, errRespr := f.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], options) + respr, errRespr := f.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, shareNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -178,16 +211,32 @@ func (f *FileSharesServerTransport) dispatchDelete(req *http.Request) (*http.Res func (f *FileSharesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if f.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/default/shares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - expandParam := getOptional(qp.Get("$expand")) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + shareNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("shareName")]) + if err != nil { + return nil, err + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) xMSSnapshotParam := getOptional(getHeaderValue(req.Header, "x-ms-snapshot")) var options *armstorage.FileSharesClientGetOptions if expandParam != nil || xMSSnapshotParam != nil { @@ -196,7 +245,7 @@ func (f *FileSharesServerTransport) dispatchGet(req *http.Request) (*http.Respon XMSSnapshot: xMSSnapshotParam, } } - respr, errRespr := f.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], options) + respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, shareNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -213,11 +262,11 @@ func (f *FileSharesServerTransport) dispatchGet(req *http.Request) (*http.Respon func (f *FileSharesServerTransport) dispatchLease(req *http.Request) (*http.Response, error) { if f.srv.Lease == nil { - return nil, &nonRetriableError{errors.New("method Lease not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Lease not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)/lease" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/default/shares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/lease` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -225,6 +274,18 @@ func (f *FileSharesServerTransport) dispatchLease(req *http.Request) (*http.Resp if err != nil { return nil, err } + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + shareNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("shareName")]) + if err != nil { + return nil, err + } xMSSnapshotParam := getOptional(getHeaderValue(req.Header, "x-ms-snapshot")) var options *armstorage.FileSharesClientLeaseOptions if xMSSnapshotParam != nil || !reflect.ValueOf(body).IsZero() { @@ -233,7 +294,7 @@ func (f *FileSharesServerTransport) dispatchLease(req *http.Request) (*http.Resp Parameters: &body, } } - respr, errRespr := f.srv.Lease(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], options) + respr, errRespr := f.srv.Lease(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, shareNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -253,19 +314,39 @@ func (f *FileSharesServerTransport) dispatchLease(req *http.Request) (*http.Resp func (f *FileSharesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if f.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if f.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/default/shares` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - maxpagesizeParam := getOptional(qp.Get("$maxpagesize")) - filterParam := getOptional(qp.Get("$filter")) - expandParam := getOptional(qp.Get("$expand")) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("$maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam := getOptional(maxpagesizeUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) var options *armstorage.FileSharesClientListOptions if maxpagesizeParam != nil || filterParam != nil || expandParam != nil { options = &armstorage.FileSharesClientListOptions{ @@ -274,7 +355,7 @@ func (f *FileSharesServerTransport) dispatchNewListPager(req *http.Request) (*ht Expand: expandParam, } } - resp := f.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + resp := f.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, options) f.newListPager = &resp server.PagerResponderInjectNextLinks(f.newListPager, req, func(page *armstorage.FileSharesClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -295,11 +376,11 @@ func (f *FileSharesServerTransport) dispatchNewListPager(req *http.Request) (*ht func (f *FileSharesServerTransport) dispatchRestore(req *http.Request) (*http.Response, error) { if f.srv.Restore == nil { - return nil, &nonRetriableError{errors.New("method Restore not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Restore not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)/restore" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/default/shares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/restore` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -307,7 +388,19 @@ func (f *FileSharesServerTransport) dispatchRestore(req *http.Request) (*http.Re if err != nil { return nil, err } - respr, errRespr := f.srv.Restore(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + shareNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("shareName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Restore(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, shareNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -324,11 +417,11 @@ func (f *FileSharesServerTransport) dispatchRestore(req *http.Request) (*http.Re func (f *FileSharesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { if f.srv.Update == nil { - return nil, &nonRetriableError{errors.New("method Update not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/fileServices/default/shares/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/fileServices/default/shares/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -336,7 +429,19 @@ func (f *FileSharesServerTransport) dispatchUpdate(req *http.Request) (*http.Res if err != nil { return nil, err } - respr, errRespr := f.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("shareName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + shareNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("shareName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Update(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, shareNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/localusers_server.go b/sdk/resourcemanager/storage/armstorage/fake/localusers_server.go index 82514d9e9ecd..e4003238c2ff 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/localusers_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/localusers_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -98,11 +99,11 @@ func (l *LocalUsersServerTransport) Do(req *http.Request) (*http.Response, error func (l *LocalUsersServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { if l.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/localUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -110,7 +111,19 @@ func (l *LocalUsersServerTransport) dispatchCreateOrUpdate(req *http.Request) (* if err != nil { return nil, err } - respr, errRespr := l.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + usernameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("username")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.CreateOrUpdate(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, usernameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -127,15 +140,27 @@ func (l *LocalUsersServerTransport) dispatchCreateOrUpdate(req *http.Request) (* func (l *LocalUsersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if l.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/localUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := l.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + usernameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("username")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, usernameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -152,15 +177,27 @@ func (l *LocalUsersServerTransport) dispatchDelete(req *http.Request) (*http.Res func (l *LocalUsersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if l.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/localUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := l.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + usernameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("username")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, usernameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -177,16 +214,24 @@ func (l *LocalUsersServerTransport) dispatchGet(req *http.Request) (*http.Respon func (l *LocalUsersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if l.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if l.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/localUsers` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := l.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := l.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, nil) l.newListPager = &resp } resp, err := server.PagerResponderNext(l.newListPager, req) @@ -204,15 +249,27 @@ func (l *LocalUsersServerTransport) dispatchNewListPager(req *http.Request) (*ht func (l *LocalUsersServerTransport) dispatchListKeys(req *http.Request) (*http.Response, error) { if l.srv.ListKeys == nil { - return nil, &nonRetriableError{errors.New("method ListKeys not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ListKeys not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)/listKeys" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/localUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listKeys` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := l.srv.ListKeys(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + usernameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("username")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.ListKeys(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, usernameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -229,15 +286,27 @@ func (l *LocalUsersServerTransport) dispatchListKeys(req *http.Request) (*http.R func (l *LocalUsersServerTransport) dispatchRegeneratePassword(req *http.Request) (*http.Response, error) { if l.srv.RegeneratePassword == nil { - return nil, &nonRetriableError{errors.New("method RegeneratePassword not implemented")} + return nil, &nonRetriableError{errors.New("fake for method RegeneratePassword not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/localUsers/(?P[a-zA-Z0-9-_]+)/regeneratePassword" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/localUsers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regeneratePassword` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := l.srv.RegeneratePassword(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("username")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + usernameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("username")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.RegeneratePassword(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, usernameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go b/sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go index 0eb23a4099cb..e8001a9e71e8 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/managementpolicies_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -79,11 +80,11 @@ func (m *ManagementPoliciesServerTransport) Do(req *http.Request) (*http.Respons func (m *ManagementPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { if m.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/managementPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managementPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -91,7 +92,19 @@ func (m *ManagementPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Req if err != nil { return nil, err } - respr, errRespr := m.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.ManagementPolicyName(matches[regex.SubexpIndex("managementPolicyName")]), body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + managementPolicyNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("managementPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.CreateOrUpdate(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, armstorage.ManagementPolicyName(managementPolicyNameUnescaped), body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -108,15 +121,27 @@ func (m *ManagementPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Req func (m *ManagementPoliciesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if m.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/managementPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managementPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := m.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.ManagementPolicyName(matches[regex.SubexpIndex("managementPolicyName")]), nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + managementPolicyNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("managementPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, armstorage.ManagementPolicyName(managementPolicyNameUnescaped), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -133,15 +158,27 @@ func (m *ManagementPoliciesServerTransport) dispatchDelete(req *http.Request) (* func (m *ManagementPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if m.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/managementPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managementPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := m.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], armstorage.ManagementPolicyName(matches[regex.SubexpIndex("managementPolicyName")]), nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + managementPolicyNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("managementPolicyName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, armstorage.ManagementPolicyName(managementPolicyNameUnescaped), nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go b/sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go index 206a7cd03e09..ba22a2278204 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/objectreplicationpolicies_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -86,11 +87,11 @@ func (o *ObjectReplicationPoliciesServerTransport) Do(req *http.Request) (*http. func (o *ObjectReplicationPoliciesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { if o.srv.CreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("method CreateOrUpdate not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/objectReplicationPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -98,7 +99,19 @@ func (o *ObjectReplicationPoliciesServerTransport) dispatchCreateOrUpdate(req *h if err != nil { return nil, err } - respr, errRespr := o.srv.CreateOrUpdate(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("objectReplicationPolicyId")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + objectReplicationPolicyIDUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("objectReplicationPolicyId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.CreateOrUpdate(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, objectReplicationPolicyIDUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -115,15 +128,27 @@ func (o *ObjectReplicationPoliciesServerTransport) dispatchCreateOrUpdate(req *h func (o *ObjectReplicationPoliciesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if o.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/objectReplicationPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := o.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("objectReplicationPolicyId")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + objectReplicationPolicyIDUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("objectReplicationPolicyId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, objectReplicationPolicyIDUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -140,15 +165,27 @@ func (o *ObjectReplicationPoliciesServerTransport) dispatchDelete(req *http.Requ func (o *ObjectReplicationPoliciesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if o.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/objectReplicationPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := o.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("objectReplicationPolicyId")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + objectReplicationPolicyIDUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("objectReplicationPolicyId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, objectReplicationPolicyIDUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -165,16 +202,24 @@ func (o *ObjectReplicationPoliciesServerTransport) dispatchGet(req *http.Request func (o *ObjectReplicationPoliciesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if o.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if o.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/objectReplicationPolicies" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/objectReplicationPolicies` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := o.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := o.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, nil) o.newListPager = &resp } resp, err := server.PagerResponderNext(o.newListPager, req) diff --git a/sdk/resourcemanager/storage/armstorage/fake/operations_server.go b/sdk/resourcemanager/storage/armstorage/fake/operations_server.go index 749e9f6bf54d..8455f7c9e986 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/operations_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/operations_server.go @@ -66,7 +66,7 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if o.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if o.newListPager == nil { resp := o.srv.NewListPager(nil) diff --git a/sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go b/sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go index c01dd2527e63..0eb0be9c14a8 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/privateendpointconnections_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -86,15 +87,27 @@ func (p *PrivateEndpointConnectionsServerTransport) Do(req *http.Request) (*http func (p *PrivateEndpointConnectionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if p.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, privateEndpointConnectionNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -111,15 +124,27 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchDelete(req *http.Req func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if p.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, privateEndpointConnectionNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -136,16 +161,24 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Reques func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if p.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if p.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := p.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, nil) p.newListPager = &resp } resp, err := server.PagerResponderNext(p.newListPager, req) @@ -163,11 +196,11 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *ht func (p *PrivateEndpointConnectionsServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { if p.srv.Put == nil { - return nil, &nonRetriableError{errors.New("method Put not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateEndpointConnections/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -175,7 +208,19 @@ func (p *PrivateEndpointConnectionsServerTransport) dispatchPut(req *http.Reques if err != nil { return nil, err } - respr, errRespr := p.srv.Put(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("privateEndpointConnectionName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Put(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, privateEndpointConnectionNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go b/sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go index 164d1ca5f197..2982b970fc39 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/privatelinkresources_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -67,15 +68,23 @@ func (p *PrivateLinkResourcesServerTransport) Do(req *http.Request) (*http.Respo func (p *PrivateLinkResourcesServerTransport) dispatchListByStorageAccount(req *http.Request) (*http.Response, error) { if p.srv.ListByStorageAccount == nil { - return nil, &nonRetriableError{errors.New("method ListByStorageAccount not implemented")} + return nil, &nonRetriableError{errors.New("fake for method ListByStorageAccount not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/privateLinkResources" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := p.srv.ListByStorageAccount(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ListByStorageAccount(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/queue_server.go b/sdk/resourcemanager/storage/armstorage/fake/queue_server.go index f5bcfc87da77..b3e56a9a3865 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/queue_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/queue_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -93,11 +94,11 @@ func (q *QueueServerTransport) Do(req *http.Request) (*http.Response, error) { func (q *QueueServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { if q.srv.Create == nil { - return nil, &nonRetriableError{errors.New("method Create not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices/default/queues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -105,7 +106,19 @@ func (q *QueueServerTransport) dispatchCreate(req *http.Request) (*http.Response if err != nil { return nil, err } - respr, errRespr := q.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + queueNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("queueName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Create(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, queueNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -122,15 +135,27 @@ func (q *QueueServerTransport) dispatchCreate(req *http.Request) (*http.Response func (q *QueueServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if q.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices/default/queues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := q.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + queueNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("queueName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, queueNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -147,15 +172,27 @@ func (q *QueueServerTransport) dispatchDelete(req *http.Request) (*http.Response func (q *QueueServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if q.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices/default/queues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := q.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + queueNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("queueName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, queueNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -172,18 +209,34 @@ func (q *QueueServerTransport) dispatchGet(req *http.Request) (*http.Response, e func (q *QueueServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if q.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if q.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices/default/queues` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + 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() - maxpagesizeParam := getOptional(qp.Get("$maxpagesize")) - filterParam := getOptional(qp.Get("$filter")) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("$maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam := getOptional(maxpagesizeUnescaped) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) var options *armstorage.QueueClientListOptions if maxpagesizeParam != nil || filterParam != nil { options = &armstorage.QueueClientListOptions{ @@ -191,7 +244,7 @@ func (q *QueueServerTransport) dispatchNewListPager(req *http.Request) (*http.Re Filter: filterParam, } } - resp := q.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], options) + resp := q.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, options) q.newListPager = &resp server.PagerResponderInjectNextLinks(q.newListPager, req, func(page *armstorage.QueueClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -212,11 +265,11 @@ func (q *QueueServerTransport) dispatchNewListPager(req *http.Request) (*http.Re func (q *QueueServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { if q.srv.Update == nil { - return nil, &nonRetriableError{errors.New("method Update not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/default/queues/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices/default/queues/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -224,7 +277,19 @@ func (q *QueueServerTransport) dispatchUpdate(req *http.Request) (*http.Response if err != nil { return nil, err } - respr, errRespr := q.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("queueName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + queueNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("queueName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.Update(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, queueNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go index af71467f5af1..9a2decdb676a 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/queueservices_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -79,15 +80,23 @@ func (q *QueueServicesServerTransport) Do(req *http.Request) (*http.Response, er func (q *QueueServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { if q.srv.GetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := q.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.GetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -104,15 +113,23 @@ func (q *QueueServicesServerTransport) dispatchGetServiceProperties(req *http.Re func (q *QueueServicesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { if q.srv.List == nil { - return nil, &nonRetriableError{errors.New("method List not implemented")} + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := q.srv.List(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.List(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -129,11 +146,11 @@ func (q *QueueServicesServerTransport) dispatchList(req *http.Request) (*http.Re func (q *QueueServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { if q.srv.SetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method SetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/queueServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/queueServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -141,7 +158,15 @@ func (q *QueueServicesServerTransport) dispatchSetServiceProperties(req *http.Re if err != nil { return nil, err } - respr, errRespr := q.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := q.srv.SetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/skus_server.go b/sdk/resourcemanager/storage/armstorage/fake/skus_server.go index c5c49e152d49..788f53517098 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/skus_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/skus_server.go @@ -67,12 +67,12 @@ func (s *SKUsServerTransport) Do(req *http.Request) (*http.Response, error) { func (s *SKUsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if s.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if s.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/skus" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/skus` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 1 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } diff --git a/sdk/resourcemanager/storage/armstorage/fake/table_server.go b/sdk/resourcemanager/storage/armstorage/fake/table_server.go index 7df61d3f5711..045146945ce8 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/table_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/table_server.go @@ -18,6 +18,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "reflect" "regexp" ) @@ -94,11 +95,11 @@ func (t *TableServerTransport) Do(req *http.Request) (*http.Response, error) { func (t *TableServerTransport) dispatchCreate(req *http.Request) (*http.Response, error) { if t.srv.Create == nil { - return nil, &nonRetriableError{errors.New("method Create not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Create not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices/default/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -106,13 +107,25 @@ func (t *TableServerTransport) dispatchCreate(req *http.Request) (*http.Response if err != nil { return nil, err } + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + tableNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tableName")]) + if err != nil { + return nil, err + } var options *armstorage.TableClientCreateOptions if !reflect.ValueOf(body).IsZero() { options = &armstorage.TableClientCreateOptions{ Parameters: &body, } } - respr, errRespr := t.srv.Create(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], options) + respr, errRespr := t.srv.Create(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, tableNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -129,15 +142,27 @@ func (t *TableServerTransport) dispatchCreate(req *http.Request) (*http.Response func (t *TableServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { if t.srv.Delete == nil { - return nil, &nonRetriableError{errors.New("method Delete not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices/default/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.Delete(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + tableNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tableName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, tableNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -154,15 +179,27 @@ func (t *TableServerTransport) dispatchDelete(req *http.Request) (*http.Response func (t *TableServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if t.srv.Get == nil { - return nil, &nonRetriableError{errors.New("method Get not implemented")} + 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.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices/default/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.Get(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + tableNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tableName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, tableNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -179,16 +216,24 @@ func (t *TableServerTransport) dispatchGet(req *http.Request) (*http.Response, e func (t *TableServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { if t.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("method NewListPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } if t.newListPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices/default/tables` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := t.srv.NewListPager(matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameUnescaped, accountNameUnescaped, nil) t.newListPager = &resp server.PagerResponderInjectNextLinks(t.newListPager, req, func(page *armstorage.TableClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) @@ -209,11 +254,11 @@ func (t *TableServerTransport) dispatchNewListPager(req *http.Request) (*http.Re func (t *TableServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { if t.srv.Update == nil { - return nil, &nonRetriableError{errors.New("method Update not implemented")} + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/default/tables/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices/default/tables/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -221,13 +266,25 @@ func (t *TableServerTransport) dispatchUpdate(req *http.Request) (*http.Response if err != nil { return nil, err } + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + tableNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("tableName")]) + if err != nil { + return nil, err + } var options *armstorage.TableClientUpdateOptions if !reflect.ValueOf(body).IsZero() { options = &armstorage.TableClientUpdateOptions{ Parameters: &body, } } - respr, errRespr := t.srv.Update(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], matches[regex.SubexpIndex("tableName")], options) + respr, errRespr := t.srv.Update(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, tableNameUnescaped, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go b/sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go index 959e7d30fd7e..c12f333e7b7b 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/tableservices_server.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -79,15 +80,23 @@ func (t *TableServicesServerTransport) Do(req *http.Request) (*http.Response, er func (t *TableServicesServerTransport) dispatchGetServiceProperties(req *http.Request) (*http.Response, error) { if t.srv.GetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method GetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method GetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.GetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.GetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -104,15 +113,23 @@ func (t *TableServicesServerTransport) dispatchGetServiceProperties(req *http.Re func (t *TableServicesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { if t.srv.List == nil { - return nil, &nonRetriableError{errors.New("method List not implemented")} + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - respr, errRespr := t.srv.List(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.List(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -129,11 +146,11 @@ func (t *TableServicesServerTransport) dispatchList(req *http.Request) (*http.Re func (t *TableServicesServerTransport) dispatchSetServiceProperties(req *http.Request) (*http.Response, error) { if t.srv.SetServiceProperties == nil { - return nil, &nonRetriableError{errors.New("method SetServiceProperties not implemented")} + return nil, &nonRetriableError{errors.New("fake for method SetServiceProperties not implemented")} } - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/resourceGroups/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/storageAccounts/(?P[a-zA-Z0-9-_]+)/tableServices/(?P[a-zA-Z0-9-_]+)" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/storageAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tableServices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 4 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } @@ -141,7 +158,15 @@ func (t *TableServicesServerTransport) dispatchSetServiceProperties(req *http.Re if err != nil { return nil, err } - respr, errRespr := t.srv.SetServiceProperties(req.Context(), matches[regex.SubexpIndex("resourceGroupName")], matches[regex.SubexpIndex("accountName")], body, nil) + resourceGroupNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + accountNameUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("accountName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.SetServiceProperties(req.Context(), resourceGroupNameUnescaped, accountNameUnescaped, body, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } diff --git a/sdk/resourcemanager/storage/armstorage/fake/usages_server.go b/sdk/resourcemanager/storage/armstorage/fake/usages_server.go index 242ffb7336df..e046d3bf62c2 100644 --- a/sdk/resourcemanager/storage/armstorage/fake/usages_server.go +++ b/sdk/resourcemanager/storage/armstorage/fake/usages_server.go @@ -16,6 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" "net/http" + "net/url" "regexp" ) @@ -67,16 +68,20 @@ func (u *UsagesServerTransport) Do(req *http.Request) (*http.Response, error) { func (u *UsagesServerTransport) dispatchNewListByLocationPager(req *http.Request) (*http.Response, error) { if u.srv.NewListByLocationPager == nil { - return nil, &nonRetriableError{errors.New("method NewListByLocationPager not implemented")} + return nil, &nonRetriableError{errors.New("fake for method NewListByLocationPager not implemented")} } if u.newListByLocationPager == nil { - const regexStr = "/subscriptions/(?P[a-zA-Z0-9-_]+)/providers/Microsoft.Storage/locations/(?P[a-zA-Z0-9-_]+)/usages" + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft.Storage/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/usages` regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.Path) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - resp := u.srv.NewListByLocationPager(matches[regex.SubexpIndex("location")], nil) + locationUnescaped, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + resp := u.srv.NewListByLocationPager(locationUnescaped, nil) u.newListByLocationPager = &resp } resp, err := server.PagerResponderNext(u.newListByLocationPager, req) diff --git a/sdk/resourcemanager/storage/armstorage/fake_example_test.go b/sdk/resourcemanager/storage/armstorage/fake_example_test.go new file mode 100644 index 000000000000..055958399b09 --- /dev/null +++ b/sdk/resourcemanager/storage/armstorage/fake_example_test.go @@ -0,0 +1,79 @@ +//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. + +package armstorage_test + +import ( + "context" + "fmt" + "log" + "net/http" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage/fake" +) + +func ExampleAccountsServer() { + // first, create an instance of the fake server for the client you wish to test. + // the type name of the server will be similar to the corresponding client, with + // the suffix "Server" instead of "Client". + fakeAccountsServer := fake.AccountsServer{ + + // next, provide implementations for the APIs you wish to fake. + // this fake corresponds to the AccountsClient.GetProperties() API. + GetProperties: func(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientGetPropertiesOptions) (resp azfake.Responder[armstorage.AccountsClientGetPropertiesResponse], errResp azfake.ErrorResponder) { + // the values of ctx, resourceGroupName, accountName, and options come from the API call. + + // the named return values resp and errResp are used to construct the response + // and are meant to be mutually exclusive. if both responses have been constructed, + // the error response is selected. + + // construct the response type, populating fields as required + accountResp := armstorage.AccountsClientGetPropertiesResponse{} + accountResp.ID = to.Ptr("/fake/resource/id") + + // use resp to set the desired response + resp.SetResponse(http.StatusOK, accountResp, nil) + + // to simulate the failure case, use errResp + //errResp.SetResponseError(http.StatusBadRequest, "ThisIsASimulatedError") + + return + }, + } + + // now create the corresponding client, connecting the fake server via the client options + client, err := armstorage.NewAccountsClient("subscriptionID", azfake.NewTokenCredential(), &arm.ClientOptions{ + ClientOptions: azcore.ClientOptions{ + Transport: fake.NewAccountsServerTransport(&fakeAccountsServer), + }, + }) + if err != nil { + log.Fatal(err) + } + + // call the API. the provided values will be passed to the fake's implementation. + // the response or error values returned by the API call are from the fake. + resp, err := client.GetProperties(context.TODO(), "fakeResourceGroup", "fakeVM", nil) + if err != nil { + log.Fatal(err) + } + + fmt.Println(*resp.ID) + + // APIs that haven't been faked will return an error + _, err = client.CheckNameAvailability(context.TODO(), armstorage.AccountCheckNameAvailabilityParameters{}, nil) + + fmt.Println(err.Error()) + + // Output: + // /fake/resource/id + // fake for method CheckNameAvailability not implemented +}