diff --git a/sdk/arm/storage/2019-06-01/armstorage/CHANGELOG.md b/sdk/arm/storage/2019-06-01/armstorage/CHANGELOG.md deleted file mode 100644 index c7196df9ed8b..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -# Release History - -## v0.1.0 (released) diff --git a/sdk/arm/storage/2019-06-01/armstorage/_meta.json b/sdk/arm/storage/2019-06-01/armstorage/_meta.json deleted file mode 100644 index 0b99b07042ad..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", - "readme": "/_/azure-rest-api-specs/specification/storage/resource-manager/readme.md", - "tag": "package-2019-06", - "use": "@autorest/go@4.0.0-preview.19", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@autorest/go@4.0.0-preview.19 --version:3.2.1 --tag=\"package-2019-06\" --output-folder=/_/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage --file-prefix=\"zz_generated_\" --credential-scope=\"https://management.azure.com//.default\" --azure-arm=true --go.clear-output-folder=false --modelerfour.lenient-model-deduplication --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/storage/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--version:3.2.1 --file-prefix=\"zz_generated_\" --credential-scope=\"https://management.azure.com//.default\" --azure-arm=true --go.clear-output-folder=false --modelerfour.lenient-model-deduplication --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/sdk/arm/storage/2019-06-01/armstorage/example_blobcontainers_test.go b/sdk/arm/storage/2019-06-01/armstorage/example_blobcontainers_test.go deleted file mode 100644 index ec2b64190011..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/example_blobcontainers_test.go +++ /dev/null @@ -1,87 +0,0 @@ -// +build go1.13 - -// 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" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" -) - -func ExampleBlobContainersClient_Create() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewBlobContainersClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.Create( - context.Background(), - "", - "", - "", - armstorage.BlobContainer{}, nil) - if err != nil { - log.Fatalf("failed to obtain a response: %v", err) - } - log.Printf("blob container ID: %v\n", *resp.BlobContainer.ID) -} - -func ExampleBlobContainersClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewBlobContainersClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.Get( - context.Background(), - "", - "", - "", nil) - if err != nil { - log.Fatalf("failed to obtain a response: %v", err) - } - log.Printf("blob container ID: %v\n", *resp.BlobContainer.ID) -} - -func ExampleBlobContainersClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewBlobContainersClient(armcore.NewDefaultConnection(cred, nil), "") - pager := client.List("", "", nil) - for pager.NextPage(context.Background()) { - resp := pager.PageResponse() - if len(*resp.ListContainerItems.Value) == 0 { - log.Fatal("missing payload") - } - for _, val := range *resp.ListContainerItems.Value { - log.Printf("container item: %v", *val.ID) - } - } - if err := pager.Err(); err != nil { - log.Fatal(err) - } -} - -func ExampleBlobContainersClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewBlobContainersClient(armcore.NewDefaultConnection(cred, nil), "") - _, err = client.Delete( - context.Background(), - "", - "", - "", nil) - if err != nil { - log.Fatalf("failed to obtain a response: %v", err) - } -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/example_storageaccounts_test.go b/sdk/arm/storage/2019-06-01/armstorage/example_storageaccounts_test.go deleted file mode 100644 index 01bc5b8ca12e..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/example_storageaccounts_test.go +++ /dev/null @@ -1,177 +0,0 @@ -// +build go1.13 - -// 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" - "log" - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/to" -) - -func ExampleStorageAccountsClient_BeginCreate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - poller, err := client.BeginCreate( - context.Background(), - "", - "", - armstorage.StorageAccountCreateParameters{ - SKU: &armstorage.SKU{ - Name: armstorage.SKUNameStandardLRS.ToPtr(), - Tier: armstorage.SKUTierStandard.ToPtr(), - }, - Kind: armstorage.KindBlobStorage.ToPtr(), - Location: to.StringPtr(""), - Properties: &armstorage.StorageAccountPropertiesCreateParameters{ - AccessTier: armstorage.AccessTierCool.ToPtr(), - }, - }, nil) - if err != nil { - log.Fatalf("failed to obtain a response: %v", err) - } - resp, err := poller.PollUntilDone(context.Background(), 30*time.Second) - if err != nil { - log.Fatalf("failed to create storage account: %v", err) - } - log.Printf("storage account ID: %v\n", *resp.StorageAccount.ID) -} - -func ExampleStorageAccountsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - pager := client.List(nil) - for pager.NextPage(context.Background()) { - resp := pager.PageResponse() - if len(*resp.StorageAccountListResult.Value) == 0 { - log.Fatal("missing payload") - } - for _, val := range *resp.StorageAccountListResult.Value { - log.Printf("storage account: %v", *val.ID) - } - } - if err := pager.Err(); err != nil { - log.Fatal(err) - } -} - -func ExampleStorageAccountsClient_ListByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.ListByResourceGroup(context.Background(), "", nil) - if err != nil { - log.Fatalf("failed to obtain a response: %v", err) - } - for _, sa := range *resp.StorageAccountListResult.Value { - log.Printf("storage account ID: %v", *sa.ID) - } -} - -func ExampleStorageAccountsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.CheckNameAvailability( - context.Background(), - armstorage.StorageAccountCheckNameAvailabilityParameters{ - Name: to.StringPtr(""), - Type: to.StringPtr("Microsoft.Storage/storageAccounts"), - }, - nil) - if err != nil { - log.Fatalf("failed to delete account: %v", err) - } - log.Printf("name availability: %v", *resp.CheckNameAvailabilityResult.NameAvailable) -} - -func ExampleStorageAccountsClient_ListKeys() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.ListKeys(context.Background(), "", "", nil) - if err != nil { - log.Fatalf("failed to delete account: %v", err) - } - for _, k := range *resp.StorageAccountListKeysResult.Keys { - log.Printf("account key: %v", *k.KeyName) - } -} - -func ExampleStorageAccountsClient_GetProperties() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.GetProperties(context.Background(), "", "", nil) - if err != nil { - log.Fatalf("failed to delete account: %v", err) - } - log.Printf("storage account properties Access Tier: %v", *resp.StorageAccount.Properties.AccessTier) -} - -func ExampleStorageAccountsClient_RegenerateKey() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.RegenerateKey(context.Background(), "", "", armstorage.StorageAccountRegenerateKeyParameters{KeyName: to.StringPtr("")}, nil) - if err != nil { - log.Fatalf("failed to delete account: %v", err) - } - for _, k := range *resp.StorageAccountListKeysResult.Keys { - log.Printf("key: %v, value: %v", *k.KeyName, *k.Value) - } -} - -func ExampleStorageAccountsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.Update( - context.Background(), - "", - "", - armstorage.StorageAccountUpdateParameters{ - Tags: &map[string]*string{ - "who rocks": to.StringPtr("golang"), - "where": to.StringPtr("on azure")}}, nil) - if err != nil { - log.Fatalf("failed to delete account: %v", err) - } - log.Printf("storage account ID: %v", *resp.StorageAccount.ID) -} -func ExampleStorageAccountsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - _, err = client.Delete(context.Background(), "", "", nil) - if err != nil { - log.Fatalf("failed to delete account: %v", err) - } -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_connection.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_connection.go deleted file mode 100644 index 2be89266359e..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_connection.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import "github.com/Azure/azure-sdk-for-go/sdk/arm/storage" - -const telemetryInfo = "azsdk-go-armstorage/2019-06-01/" + storage.Version diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_constants.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_constants.go deleted file mode 100644 index 1857fed701cf..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_constants.go +++ /dev/null @@ -1,1063 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -// AccessTier - Required for storage accounts where kind = BlobStorage. The access tier used for billing. -type AccessTier string - -const ( - AccessTierHot AccessTier = "Hot" - AccessTierCool AccessTier = "Cool" -) - -// PossibleAccessTierValues returns the possible values for the AccessTier const type. -func PossibleAccessTierValues() []AccessTier { - return []AccessTier{ - AccessTierHot, - AccessTierCool, - } -} - -// ToPtr returns a *AccessTier pointing to the current value. -func (c AccessTier) ToPtr() *AccessTier { - return &c -} - -// AccountStatus - Gets the status indicating whether the primary location of the storage account is available or unavailable. -type AccountStatus string - -const ( - AccountStatusAvailable AccountStatus = "available" - AccountStatusUnavailable AccountStatus = "unavailable" -) - -// PossibleAccountStatusValues returns the possible values for the AccountStatus const type. -func PossibleAccountStatusValues() []AccountStatus { - return []AccountStatus{ - AccountStatusAvailable, - AccountStatusUnavailable, - } -} - -// ToPtr returns a *AccountStatus pointing to the current value. -func (c AccountStatus) ToPtr() *AccountStatus { - return &c -} - -// BlobRestoreProgressStatus - 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. -type BlobRestoreProgressStatus string - -const ( - BlobRestoreProgressStatusComplete BlobRestoreProgressStatus = "Complete" - BlobRestoreProgressStatusFailed BlobRestoreProgressStatus = "Failed" - BlobRestoreProgressStatusInProgress BlobRestoreProgressStatus = "InProgress" -) - -// PossibleBlobRestoreProgressStatusValues returns the possible values for the BlobRestoreProgressStatus const type. -func PossibleBlobRestoreProgressStatusValues() []BlobRestoreProgressStatus { - return []BlobRestoreProgressStatus{ - BlobRestoreProgressStatusComplete, - BlobRestoreProgressStatusFailed, - BlobRestoreProgressStatusInProgress, - } -} - -// ToPtr returns a *BlobRestoreProgressStatus pointing to the current value. -func (c BlobRestoreProgressStatus) ToPtr() *BlobRestoreProgressStatus { - return &c -} - -// Bypass - 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. -type Bypass string - -const ( - BypassAzureServices Bypass = "AzureServices" - BypassLogging Bypass = "Logging" - BypassMetrics Bypass = "Metrics" - BypassNone Bypass = "None" -) - -// PossibleBypassValues returns the possible values for the Bypass const type. -func PossibleBypassValues() []Bypass { - return []Bypass{ - BypassAzureServices, - BypassLogging, - BypassMetrics, - BypassNone, - } -} - -// ToPtr returns a *Bypass pointing to the current value. -func (c Bypass) ToPtr() *Bypass { - return &c -} - -type CorsRuleAllowedMethodsItem string - -const ( - CorsRuleAllowedMethodsItemDELETE CorsRuleAllowedMethodsItem = "DELETE" - CorsRuleAllowedMethodsItemGET CorsRuleAllowedMethodsItem = "GET" - CorsRuleAllowedMethodsItemHEAD CorsRuleAllowedMethodsItem = "HEAD" - CorsRuleAllowedMethodsItemMERGE CorsRuleAllowedMethodsItem = "MERGE" - CorsRuleAllowedMethodsItemOPTIONS CorsRuleAllowedMethodsItem = "OPTIONS" - CorsRuleAllowedMethodsItemPOST CorsRuleAllowedMethodsItem = "POST" - CorsRuleAllowedMethodsItemPUT CorsRuleAllowedMethodsItem = "PUT" -) - -// PossibleCorsRuleAllowedMethodsItemValues returns the possible values for the CorsRuleAllowedMethodsItem const type. -func PossibleCorsRuleAllowedMethodsItemValues() []CorsRuleAllowedMethodsItem { - return []CorsRuleAllowedMethodsItem{ - CorsRuleAllowedMethodsItemDELETE, - CorsRuleAllowedMethodsItemGET, - CorsRuleAllowedMethodsItemHEAD, - CorsRuleAllowedMethodsItemMERGE, - CorsRuleAllowedMethodsItemOPTIONS, - CorsRuleAllowedMethodsItemPOST, - CorsRuleAllowedMethodsItemPUT, - } -} - -// ToPtr returns a *CorsRuleAllowedMethodsItem pointing to the current value. -func (c CorsRuleAllowedMethodsItem) ToPtr() *CorsRuleAllowedMethodsItem { - return &c -} - -// DefaultAction - Specifies the default action of allow or deny when no other rules match. -type DefaultAction string - -const ( - DefaultActionAllow DefaultAction = "Allow" - DefaultActionDeny DefaultAction = "Deny" -) - -// PossibleDefaultActionValues returns the possible values for the DefaultAction const type. -func PossibleDefaultActionValues() []DefaultAction { - return []DefaultAction{ - DefaultActionAllow, - DefaultActionDeny, - } -} - -// ToPtr returns a *DefaultAction pointing to the current value. -func (c DefaultAction) ToPtr() *DefaultAction { - return &c -} - -// DirectoryServiceOptions - Indicates the directory service used. -type DirectoryServiceOptions string - -const ( - DirectoryServiceOptionsAADDS DirectoryServiceOptions = "AADDS" - DirectoryServiceOptionsAD DirectoryServiceOptions = "AD" - DirectoryServiceOptionsNone DirectoryServiceOptions = "None" -) - -// PossibleDirectoryServiceOptionsValues returns the possible values for the DirectoryServiceOptions const type. -func PossibleDirectoryServiceOptionsValues() []DirectoryServiceOptions { - return []DirectoryServiceOptions{ - DirectoryServiceOptionsAADDS, - DirectoryServiceOptionsAD, - DirectoryServiceOptionsNone, - } -} - -// ToPtr returns a *DirectoryServiceOptions pointing to the current value. -func (c DirectoryServiceOptions) ToPtr() *DirectoryServiceOptions { - return &c -} - -// EnabledProtocols - The authentication protocol that is used for the file share. Can only be specified when creating a share. -type EnabledProtocols string - -const ( - EnabledProtocolsNFS EnabledProtocols = "NFS" - EnabledProtocolsSMB EnabledProtocols = "SMB" -) - -// PossibleEnabledProtocolsValues returns the possible values for the EnabledProtocols const type. -func PossibleEnabledProtocolsValues() []EnabledProtocols { - return []EnabledProtocols{ - EnabledProtocolsNFS, - EnabledProtocolsSMB, - } -} - -// ToPtr returns a *EnabledProtocols pointing to the current value. -func (c EnabledProtocols) ToPtr() *EnabledProtocols { - return &c -} - -// EncryptionScopeSource - The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. -type EncryptionScopeSource string - -const ( - EncryptionScopeSourceMicrosoftKeyVault EncryptionScopeSource = "Microsoft.KeyVault" - EncryptionScopeSourceMicrosoftStorage EncryptionScopeSource = "Microsoft.Storage" -) - -// PossibleEncryptionScopeSourceValues returns the possible values for the EncryptionScopeSource const type. -func PossibleEncryptionScopeSourceValues() []EncryptionScopeSource { - return []EncryptionScopeSource{ - EncryptionScopeSourceMicrosoftKeyVault, - EncryptionScopeSourceMicrosoftStorage, - } -} - -// ToPtr returns a *EncryptionScopeSource pointing to the current value. -func (c EncryptionScopeSource) ToPtr() *EncryptionScopeSource { - return &c -} - -// EncryptionScopeState - The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. -type EncryptionScopeState string - -const ( - EncryptionScopeStateDisabled EncryptionScopeState = "Disabled" - EncryptionScopeStateEnabled EncryptionScopeState = "Enabled" -) - -// PossibleEncryptionScopeStateValues returns the possible values for the EncryptionScopeState const type. -func PossibleEncryptionScopeStateValues() []EncryptionScopeState { - return []EncryptionScopeState{ - EncryptionScopeStateDisabled, - EncryptionScopeStateEnabled, - } -} - -// ToPtr returns a *EncryptionScopeState pointing to the current value. -func (c EncryptionScopeState) ToPtr() *EncryptionScopeState { - return &c -} - -// GeoReplicationStatus - 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. -type GeoReplicationStatus string - -const ( - GeoReplicationStatusBootstrap GeoReplicationStatus = "Bootstrap" - GeoReplicationStatusLive GeoReplicationStatus = "Live" - GeoReplicationStatusUnavailable GeoReplicationStatus = "Unavailable" -) - -// PossibleGeoReplicationStatusValues returns the possible values for the GeoReplicationStatus const type. -func PossibleGeoReplicationStatusValues() []GeoReplicationStatus { - return []GeoReplicationStatus{ - GeoReplicationStatusBootstrap, - GeoReplicationStatusLive, - GeoReplicationStatusUnavailable, - } -} - -// ToPtr returns a *GeoReplicationStatus pointing to the current value. -func (c GeoReplicationStatus) ToPtr() *GeoReplicationStatus { - return &c -} - -// HTTPProtocol - The protocol permitted for a request made with the account SAS. -type HTTPProtocol string - -const ( - HTTPProtocolHTTPSHTTP HTTPProtocol = "https,http" - HTTPProtocolHTTPS HTTPProtocol = "https" -) - -// PossibleHTTPProtocolValues returns the possible values for the HTTPProtocol const type. -func PossibleHTTPProtocolValues() []HTTPProtocol { - return []HTTPProtocol{ - HTTPProtocolHTTPSHTTP, - HTTPProtocolHTTPS, - } -} - -// ToPtr returns a *HTTPProtocol pointing to the current value. -func (c HTTPProtocol) ToPtr() *HTTPProtocol { - return &c -} - -// ImmutabilityPolicyState - The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. -type ImmutabilityPolicyState string - -const ( - ImmutabilityPolicyStateLocked ImmutabilityPolicyState = "Locked" - ImmutabilityPolicyStateUnlocked ImmutabilityPolicyState = "Unlocked" -) - -// PossibleImmutabilityPolicyStateValues returns the possible values for the ImmutabilityPolicyState const type. -func PossibleImmutabilityPolicyStateValues() []ImmutabilityPolicyState { - return []ImmutabilityPolicyState{ - ImmutabilityPolicyStateLocked, - ImmutabilityPolicyStateUnlocked, - } -} - -// ToPtr returns a *ImmutabilityPolicyState pointing to the current value. -func (c ImmutabilityPolicyState) ToPtr() *ImmutabilityPolicyState { - return &c -} - -// ImmutabilityPolicyUpdateType - The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. -type ImmutabilityPolicyUpdateType string - -const ( - ImmutabilityPolicyUpdateTypeExtend ImmutabilityPolicyUpdateType = "extend" - ImmutabilityPolicyUpdateTypeLock ImmutabilityPolicyUpdateType = "lock" - ImmutabilityPolicyUpdateTypePut ImmutabilityPolicyUpdateType = "put" -) - -// PossibleImmutabilityPolicyUpdateTypeValues returns the possible values for the ImmutabilityPolicyUpdateType const type. -func PossibleImmutabilityPolicyUpdateTypeValues() []ImmutabilityPolicyUpdateType { - return []ImmutabilityPolicyUpdateType{ - ImmutabilityPolicyUpdateTypeExtend, - ImmutabilityPolicyUpdateTypeLock, - ImmutabilityPolicyUpdateTypePut, - } -} - -// ToPtr returns a *ImmutabilityPolicyUpdateType pointing to the current value. -func (c ImmutabilityPolicyUpdateType) ToPtr() *ImmutabilityPolicyUpdateType { - return &c -} - -// KeyPermission - Permissions for the key -- read-only or full permissions. -type KeyPermission string - -const ( - KeyPermissionRead KeyPermission = "Read" - KeyPermissionFull KeyPermission = "Full" -) - -// PossibleKeyPermissionValues returns the possible values for the KeyPermission const type. -func PossibleKeyPermissionValues() []KeyPermission { - return []KeyPermission{ - KeyPermissionRead, - KeyPermissionFull, - } -} - -// ToPtr returns a *KeyPermission pointing to the current value. -func (c KeyPermission) ToPtr() *KeyPermission { - return &c -} - -// KeySource - The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault -type KeySource string - -const ( - KeySourceMicrosoftKeyvault KeySource = "Microsoft.Keyvault" - KeySourceMicrosoftStorage KeySource = "Microsoft.Storage" -) - -// PossibleKeySourceValues returns the possible values for the KeySource const type. -func PossibleKeySourceValues() []KeySource { - return []KeySource{ - KeySourceMicrosoftKeyvault, - KeySourceMicrosoftStorage, - } -} - -// ToPtr returns a *KeySource pointing to the current value. -func (c KeySource) ToPtr() *KeySource { - return &c -} - -// KeyType - 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. -type KeyType string - -const ( - KeyTypeAccount KeyType = "Account" - KeyTypeService KeyType = "Service" -) - -// PossibleKeyTypeValues returns the possible values for the KeyType const type. -func PossibleKeyTypeValues() []KeyType { - return []KeyType{ - KeyTypeAccount, - KeyTypeService, - } -} - -// ToPtr returns a *KeyType pointing to the current value. -func (c KeyType) ToPtr() *KeyType { - return &c -} - -// Kind - Indicates the type of storage account. -type Kind string - -const ( - KindBlobStorage Kind = "BlobStorage" - KindBlockBlobStorage Kind = "BlockBlobStorage" - KindFileStorage Kind = "FileStorage" - KindStorage Kind = "Storage" - KindStorageV2 Kind = "StorageV2" -) - -// PossibleKindValues returns the possible values for the Kind const type. -func PossibleKindValues() []Kind { - return []Kind{ - KindBlobStorage, - KindBlockBlobStorage, - KindFileStorage, - KindStorage, - KindStorageV2, - } -} - -// ToPtr returns a *Kind pointing to the current value. -func (c Kind) ToPtr() *Kind { - return &c -} - -// LargeFileSharesState - Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. -type LargeFileSharesState string - -const ( - LargeFileSharesStateDisabled LargeFileSharesState = "Disabled" - LargeFileSharesStateEnabled LargeFileSharesState = "Enabled" -) - -// PossibleLargeFileSharesStateValues returns the possible values for the LargeFileSharesState const type. -func PossibleLargeFileSharesStateValues() []LargeFileSharesState { - return []LargeFileSharesState{ - LargeFileSharesStateDisabled, - LargeFileSharesStateEnabled, - } -} - -// ToPtr returns a *LargeFileSharesState pointing to the current value. -func (c LargeFileSharesState) ToPtr() *LargeFileSharesState { - return &c -} - -// LeaseContainerRequestAction - Specifies the lease action. Can be one of the available actions. -type LeaseContainerRequestAction string - -const ( - LeaseContainerRequestActionAcquire LeaseContainerRequestAction = "Acquire" - LeaseContainerRequestActionBreak LeaseContainerRequestAction = "Break" - LeaseContainerRequestActionChange LeaseContainerRequestAction = "Change" - LeaseContainerRequestActionRelease LeaseContainerRequestAction = "Release" - LeaseContainerRequestActionRenew LeaseContainerRequestAction = "Renew" -) - -// PossibleLeaseContainerRequestActionValues returns the possible values for the LeaseContainerRequestAction const type. -func PossibleLeaseContainerRequestActionValues() []LeaseContainerRequestAction { - return []LeaseContainerRequestAction{ - LeaseContainerRequestActionAcquire, - LeaseContainerRequestActionBreak, - LeaseContainerRequestActionChange, - LeaseContainerRequestActionRelease, - LeaseContainerRequestActionRenew, - } -} - -// ToPtr returns a *LeaseContainerRequestAction pointing to the current value. -func (c LeaseContainerRequestAction) ToPtr() *LeaseContainerRequestAction { - return &c -} - -// LeaseDuration - Specifies whether the lease on a container is of infinite or fixed duration, only when the container is leased. -type LeaseDuration string - -const ( - LeaseDurationFixed LeaseDuration = "Fixed" - LeaseDurationInfinite LeaseDuration = "Infinite" -) - -// PossibleLeaseDurationValues returns the possible values for the LeaseDuration const type. -func PossibleLeaseDurationValues() []LeaseDuration { - return []LeaseDuration{ - LeaseDurationFixed, - LeaseDurationInfinite, - } -} - -// ToPtr returns a *LeaseDuration pointing to the current value. -func (c LeaseDuration) ToPtr() *LeaseDuration { - return &c -} - -// LeaseState - Lease state of the container. -type LeaseState string - -const ( - LeaseStateAvailable LeaseState = "Available" - LeaseStateBreaking LeaseState = "Breaking" - LeaseStateBroken LeaseState = "Broken" - LeaseStateExpired LeaseState = "Expired" - LeaseStateLeased LeaseState = "Leased" -) - -// PossibleLeaseStateValues returns the possible values for the LeaseState const type. -func PossibleLeaseStateValues() []LeaseState { - return []LeaseState{ - LeaseStateAvailable, - LeaseStateBreaking, - LeaseStateBroken, - LeaseStateExpired, - LeaseStateLeased, - } -} - -// ToPtr returns a *LeaseState pointing to the current value. -func (c LeaseState) ToPtr() *LeaseState { - return &c -} - -// LeaseStatus - The lease status of the container. -type LeaseStatus string - -const ( - LeaseStatusLocked LeaseStatus = "Locked" - LeaseStatusUnlocked LeaseStatus = "Unlocked" -) - -// PossibleLeaseStatusValues returns the possible values for the LeaseStatus const type. -func PossibleLeaseStatusValues() []LeaseStatus { - return []LeaseStatus{ - LeaseStatusLocked, - LeaseStatusUnlocked, - } -} - -// ToPtr returns a *LeaseStatus pointing to the current value. -func (c LeaseStatus) ToPtr() *LeaseStatus { - return &c -} - -type ListContainersInclude string - -const ( - ListContainersIncludeDeleted ListContainersInclude = "deleted" -) - -// PossibleListContainersIncludeValues returns the possible values for the ListContainersInclude const type. -func PossibleListContainersIncludeValues() []ListContainersInclude { - return []ListContainersInclude{ - ListContainersIncludeDeleted, - } -} - -// ToPtr returns a *ListContainersInclude pointing to the current value. -func (c ListContainersInclude) ToPtr() *ListContainersInclude { - return &c -} - -type ManagementPolicyName string - -const ( - ManagementPolicyNameDefault ManagementPolicyName = "default" -) - -// PossibleManagementPolicyNameValues returns the possible values for the ManagementPolicyName const type. -func PossibleManagementPolicyNameValues() []ManagementPolicyName { - return []ManagementPolicyName{ - ManagementPolicyNameDefault, - } -} - -// ToPtr returns a *ManagementPolicyName pointing to the current value. -func (c ManagementPolicyName) ToPtr() *ManagementPolicyName { - return &c -} - -// MinimumTLSVersion - Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. -type MinimumTLSVersion string - -const ( - MinimumTLSVersionTLS10 MinimumTLSVersion = "TLS1_0" - MinimumTLSVersionTLS11 MinimumTLSVersion = "TLS1_1" - MinimumTLSVersionTLS12 MinimumTLSVersion = "TLS1_2" -) - -// PossibleMinimumTLSVersionValues returns the possible values for the MinimumTLSVersion const type. -func PossibleMinimumTLSVersionValues() []MinimumTLSVersion { - return []MinimumTLSVersion{ - MinimumTLSVersionTLS10, - MinimumTLSVersionTLS11, - MinimumTLSVersionTLS12, - } -} - -// ToPtr returns a *MinimumTLSVersion pointing to the current value. -func (c MinimumTLSVersion) ToPtr() *MinimumTLSVersion { - return &c -} - -// Permissions - 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). -type Permissions string - -const ( - PermissionsA Permissions = "a" - PermissionsC Permissions = "c" - PermissionsD Permissions = "d" - PermissionsL Permissions = "l" - PermissionsP Permissions = "p" - PermissionsR Permissions = "r" - PermissionsU Permissions = "u" - PermissionsW Permissions = "w" -) - -// PossiblePermissionsValues returns the possible values for the Permissions const type. -func PossiblePermissionsValues() []Permissions { - return []Permissions{ - PermissionsA, - PermissionsC, - PermissionsD, - PermissionsL, - PermissionsP, - PermissionsR, - PermissionsU, - PermissionsW, - } -} - -// ToPtr returns a *Permissions pointing to the current value. -func (c Permissions) ToPtr() *Permissions { - return &c -} - -// PrivateEndpointConnectionProvisioningState - The current provisioning state. -type PrivateEndpointConnectionProvisioningState string - -const ( - PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" - PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" - PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" - PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" -) - -// PossiblePrivateEndpointConnectionProvisioningStateValues returns the possible values for the PrivateEndpointConnectionProvisioningState const type. -func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { - return []PrivateEndpointConnectionProvisioningState{ - PrivateEndpointConnectionProvisioningStateCreating, - PrivateEndpointConnectionProvisioningStateDeleting, - PrivateEndpointConnectionProvisioningStateFailed, - PrivateEndpointConnectionProvisioningStateSucceeded, - } -} - -// ToPtr returns a *PrivateEndpointConnectionProvisioningState pointing to the current value. -func (c PrivateEndpointConnectionProvisioningState) ToPtr() *PrivateEndpointConnectionProvisioningState { - return &c -} - -// PrivateEndpointServiceConnectionStatus - The private endpoint connection status. -type PrivateEndpointServiceConnectionStatus string - -const ( - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -// PossiblePrivateEndpointServiceConnectionStatusValues returns the possible values for the PrivateEndpointServiceConnectionStatus const type. -func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { - return []PrivateEndpointServiceConnectionStatus{ - PrivateEndpointServiceConnectionStatusApproved, - PrivateEndpointServiceConnectionStatusPending, - PrivateEndpointServiceConnectionStatusRejected, - } -} - -// ToPtr returns a *PrivateEndpointServiceConnectionStatus pointing to the current value. -func (c PrivateEndpointServiceConnectionStatus) ToPtr() *PrivateEndpointServiceConnectionStatus { - return &c -} - -// ProvisioningState - Gets the status of the storage account at the time the operation was called. -type ProvisioningState string - -const ( - ProvisioningStateCreating ProvisioningState = "Creating" - ProvisioningStateResolvingDNS ProvisioningState = "ResolvingDNS" - ProvisioningStateSucceeded ProvisioningState = "Succeeded" -) - -// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. -func PossibleProvisioningStateValues() []ProvisioningState { - return []ProvisioningState{ - ProvisioningStateCreating, - ProvisioningStateResolvingDNS, - ProvisioningStateSucceeded, - } -} - -// ToPtr returns a *ProvisioningState pointing to the current value. -func (c ProvisioningState) ToPtr() *ProvisioningState { - return &c -} - -// PublicAccess - Specifies whether data in the container may be accessed publicly and the level of access. -type PublicAccess string - -const ( - PublicAccessContainer PublicAccess = "Container" - PublicAccessBlob PublicAccess = "Blob" - PublicAccessNone PublicAccess = "None" -) - -// PossiblePublicAccessValues returns the possible values for the PublicAccess const type. -func PossiblePublicAccessValues() []PublicAccess { - return []PublicAccess{ - PublicAccessContainer, - PublicAccessBlob, - PublicAccessNone, - } -} - -// ToPtr returns a *PublicAccess pointing to the current value. -func (c PublicAccess) ToPtr() *PublicAccess { - return &c -} - -// Reason - Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. -type Reason string - -const ( - ReasonAccountNameInvalid Reason = "AccountNameInvalid" - ReasonAlreadyExists Reason = "AlreadyExists" -) - -// PossibleReasonValues returns the possible values for the Reason const type. -func PossibleReasonValues() []Reason { - return []Reason{ - ReasonAccountNameInvalid, - ReasonAlreadyExists, - } -} - -// ToPtr returns a *Reason pointing to the current value. -func (c Reason) ToPtr() *Reason { - return &c -} - -// ReasonCode - 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. -type ReasonCode string - -const ( - ReasonCodeNotAvailableForSubscription ReasonCode = "NotAvailableForSubscription" - ReasonCodeQuotaID ReasonCode = "QuotaId" -) - -// PossibleReasonCodeValues returns the possible values for the ReasonCode const type. -func PossibleReasonCodeValues() []ReasonCode { - return []ReasonCode{ - ReasonCodeNotAvailableForSubscription, - ReasonCodeQuotaID, - } -} - -// ToPtr returns a *ReasonCode pointing to the current value. -func (c ReasonCode) ToPtr() *ReasonCode { - return &c -} - -// RootSquashType - The property is for NFS share only. The default is NoRootSquash. -type RootSquashType string - -const ( - RootSquashTypeAllSquash RootSquashType = "AllSquash" - RootSquashTypeNoRootSquash RootSquashType = "NoRootSquash" - RootSquashTypeRootSquash RootSquashType = "RootSquash" -) - -// PossibleRootSquashTypeValues returns the possible values for the RootSquashType const type. -func PossibleRootSquashTypeValues() []RootSquashType { - return []RootSquashType{ - RootSquashTypeAllSquash, - RootSquashTypeNoRootSquash, - RootSquashTypeRootSquash, - } -} - -// ToPtr returns a *RootSquashType pointing to the current value. -func (c RootSquashType) ToPtr() *RootSquashType { - return &c -} - -// RoutingChoice - Routing Choice defines the kind of network routing opted by the user. -type RoutingChoice string - -const ( - RoutingChoiceInternetRouting RoutingChoice = "InternetRouting" - RoutingChoiceMicrosoftRouting RoutingChoice = "MicrosoftRouting" -) - -// PossibleRoutingChoiceValues returns the possible values for the RoutingChoice const type. -func PossibleRoutingChoiceValues() []RoutingChoice { - return []RoutingChoice{ - RoutingChoiceInternetRouting, - RoutingChoiceMicrosoftRouting, - } -} - -// ToPtr returns a *RoutingChoice pointing to the current value. -func (c RoutingChoice) ToPtr() *RoutingChoice { - return &c -} - -// RuleType - The valid value is Lifecycle -type RuleType string - -const ( - RuleTypeLifecycle RuleType = "Lifecycle" -) - -// PossibleRuleTypeValues returns the possible values for the RuleType const type. -func PossibleRuleTypeValues() []RuleType { - return []RuleType{ - RuleTypeLifecycle, - } -} - -// ToPtr returns a *RuleType pointing to the current value. -func (c RuleType) ToPtr() *RuleType { - return &c -} - -// SKUName - The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. -type SKUName string - -const ( - SKUNamePremiumLRS SKUName = "Premium_LRS" - SKUNamePremiumZRS SKUName = "Premium_ZRS" - SKUNameStandardGRS SKUName = "Standard_GRS" - SKUNameStandardGZRS SKUName = "Standard_GZRS" - SKUNameStandardLRS SKUName = "Standard_LRS" - SKUNameStandardRAGRS SKUName = "Standard_RAGRS" - SKUNameStandardRAGZRS SKUName = "Standard_RAGZRS" - SKUNameStandardZRS SKUName = "Standard_ZRS" -) - -// PossibleSKUNameValues returns the possible values for the SKUName const type. -func PossibleSKUNameValues() []SKUName { - return []SKUName{ - SKUNamePremiumLRS, - SKUNamePremiumZRS, - SKUNameStandardGRS, - SKUNameStandardGZRS, - SKUNameStandardLRS, - SKUNameStandardRAGRS, - SKUNameStandardRAGZRS, - SKUNameStandardZRS, - } -} - -// ToPtr returns a *SKUName pointing to the current value. -func (c SKUName) ToPtr() *SKUName { - return &c -} - -// SKUTier - The SKU tier. This is based on the SKU name. -type SKUTier string - -const ( - SKUTierStandard SKUTier = "Standard" - SKUTierPremium SKUTier = "Premium" -) - -// PossibleSKUTierValues returns the possible values for the SKUTier const type. -func PossibleSKUTierValues() []SKUTier { - return []SKUTier{ - SKUTierStandard, - SKUTierPremium, - } -} - -// ToPtr returns a *SKUTier pointing to the current value. -func (c SKUTier) ToPtr() *SKUTier { - return &c -} - -// Services - The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). -type Services string - -const ( - ServicesB Services = "b" - ServicesF Services = "f" - ServicesQ Services = "q" - ServicesT Services = "t" -) - -// PossibleServicesValues returns the possible values for the Services const type. -func PossibleServicesValues() []Services { - return []Services{ - ServicesB, - ServicesF, - ServicesQ, - ServicesT, - } -} - -// ToPtr returns a *Services pointing to the current value. -func (c Services) ToPtr() *Services { - return &c -} - -// ShareAccessTier - Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account -// can choose Premium. -type ShareAccessTier string - -const ( - ShareAccessTierCool ShareAccessTier = "Cool" - ShareAccessTierHot ShareAccessTier = "Hot" - ShareAccessTierPremium ShareAccessTier = "Premium" - ShareAccessTierTransactionOptimized ShareAccessTier = "TransactionOptimized" -) - -// PossibleShareAccessTierValues returns the possible values for the ShareAccessTier const type. -func PossibleShareAccessTierValues() []ShareAccessTier { - return []ShareAccessTier{ - ShareAccessTierCool, - ShareAccessTierHot, - ShareAccessTierPremium, - ShareAccessTierTransactionOptimized, - } -} - -// ToPtr returns a *ShareAccessTier pointing to the current value. -func (c ShareAccessTier) ToPtr() *ShareAccessTier { - return &c -} - -// SignedResource - The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). -type SignedResource string - -const ( - SignedResourceB SignedResource = "b" - SignedResourceC SignedResource = "c" - SignedResourceF SignedResource = "f" - SignedResourceS SignedResource = "s" -) - -// PossibleSignedResourceValues returns the possible values for the SignedResource const type. -func PossibleSignedResourceValues() []SignedResource { - return []SignedResource{ - SignedResourceB, - SignedResourceC, - SignedResourceF, - SignedResourceS, - } -} - -// ToPtr returns a *SignedResource pointing to the current value. -func (c SignedResource) ToPtr() *SignedResource { - return &c -} - -// SignedResourceTypes - 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. -type SignedResourceTypes string - -const ( - SignedResourceTypesC SignedResourceTypes = "c" - SignedResourceTypesO SignedResourceTypes = "o" - SignedResourceTypesS SignedResourceTypes = "s" -) - -// PossibleSignedResourceTypesValues returns the possible values for the SignedResourceTypes const type. -func PossibleSignedResourceTypesValues() []SignedResourceTypes { - return []SignedResourceTypes{ - SignedResourceTypesC, - SignedResourceTypesO, - SignedResourceTypesS, - } -} - -// ToPtr returns a *SignedResourceTypes pointing to the current value. -func (c SignedResourceTypes) ToPtr() *SignedResourceTypes { - return &c -} - -// State - Gets the state of virtual network rule. -type State string - -const ( - StateProvisioning State = "provisioning" - StateDeprovisioning State = "deprovisioning" - StateSucceeded State = "succeeded" - StateFailed State = "failed" - StateNetworkSourceDeleted State = "networkSourceDeleted" -) - -// PossibleStateValues returns the possible values for the State const type. -func PossibleStateValues() []State { - return []State{ - StateProvisioning, - StateDeprovisioning, - StateSucceeded, - StateFailed, - StateNetworkSourceDeleted, - } -} - -// ToPtr returns a *State pointing to the current value. -func (c State) ToPtr() *State { - return &c -} - -type StorageAccountExpand string - -const ( - StorageAccountExpandGeoReplicationStats StorageAccountExpand = "geoReplicationStats" - StorageAccountExpandBlobRestoreStatus StorageAccountExpand = "blobRestoreStatus" -) - -// PossibleStorageAccountExpandValues returns the possible values for the StorageAccountExpand const type. -func PossibleStorageAccountExpandValues() []StorageAccountExpand { - return []StorageAccountExpand{ - StorageAccountExpandGeoReplicationStats, - StorageAccountExpandBlobRestoreStatus, - } -} - -// ToPtr returns a *StorageAccountExpand pointing to the current value. -func (c StorageAccountExpand) ToPtr() *StorageAccountExpand { - return &c -} - -// UsageUnit - Gets the unit of measurement. -type UsageUnit string - -const ( - UsageUnitCount UsageUnit = "Count" - UsageUnitBytes UsageUnit = "Bytes" - UsageUnitSeconds UsageUnit = "Seconds" - UsageUnitPercent UsageUnit = "Percent" - UsageUnitCountsPerSecond UsageUnit = "CountsPerSecond" - UsageUnitBytesPerSecond UsageUnit = "BytesPerSecond" -) - -// PossibleUsageUnitValues returns the possible values for the UsageUnit const type. -func PossibleUsageUnitValues() []UsageUnit { - return []UsageUnit{ - UsageUnitCount, - UsageUnitBytes, - UsageUnitSeconds, - UsageUnitPercent, - UsageUnitCountsPerSecond, - UsageUnitBytesPerSecond, - } -} - -// ToPtr returns a *UsageUnit pointing to the current value. -func (c UsageUnit) ToPtr() *UsageUnit { - return &c -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileshares_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileshares_client.go deleted file mode 100644 index 55da1572e8f8..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileshares_client.go +++ /dev/null @@ -1,413 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "net/url" - "strings" -) - -// FileSharesClient contains the methods for the FileShares group. -// Don't use this type directly, use NewFileSharesClient() instead. -type FileSharesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewFileSharesClient creates a new instance of FileSharesClient with the specified values. -func NewFileSharesClient(con *armcore.Connection, subscriptionID string) *FileSharesClient { - return &FileSharesClient{con: con, subscriptionID: subscriptionID} -} - -// Create - Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. -// It does not include a list of the files contained by -// the share. -func (client *FileSharesClient) Create(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesCreateOptions) (FileShareResponse, error) { - req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options) - if err != nil { - return FileShareResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return FileShareResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { - return FileShareResponse{}, client.createHandleError(resp) - } - return client.createHandleResponse(resp) -} - -// createCreateRequest creates the Create request. -func (client *FileSharesClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesCreateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if shareName == "" { - return nil, errors.New("parameter shareName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(fileShare) -} - -// createHandleResponse handles the Create response. -func (client *FileSharesClient) createHandleResponse(resp *azcore.Response) (FileShareResponse, error) { - var val *FileShare - if err := resp.UnmarshalAsJSON(&val); err != nil { - return FileShareResponse{}, err - } - return FileShareResponse{RawResponse: resp.Response, FileShare: val}, nil -} - -// createHandleError handles the Create error response. -func (client *FileSharesClient) createHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Delete - Deletes specified share under its account. -func (client *FileSharesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, shareName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *FileSharesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if shareName == "" { - return nil, errors.New("parameter shareName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *FileSharesClient) deleteHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Get - Gets properties of a specified share. -func (client *FileSharesClient) Get(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesGetOptions) (FileShareResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, shareName, options) - if err != nil { - return FileShareResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return FileShareResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return FileShareResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *FileSharesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if shareName == "" { - return nil, errors.New("parameter shareName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", "stats") - } - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *FileSharesClient) getHandleResponse(resp *azcore.Response) (FileShareResponse, error) { - var val *FileShare - if err := resp.UnmarshalAsJSON(&val); err != nil { - return FileShareResponse{}, err - } - return FileShareResponse{RawResponse: resp.Response, FileShare: val}, nil -} - -// getHandleError handles the Get error response. -func (client *FileSharesClient) getHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - Lists all shares. -func (client *FileSharesClient) List(resourceGroupName string, accountName string, options *FileSharesListOptions) FileShareItemsPager { - return &fileShareItemsPager{ - pipeline: client.con.Pipeline(), - requester: func(ctx context.Context) (*azcore.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, accountName, options) - }, - responder: client.listHandleResponse, - errorer: client.listHandleError, - advancer: func(ctx context.Context, resp FileShareItemsResponse) (*azcore.Request, error) { - return azcore.NewRequest(ctx, http.MethodGet, *resp.FileShareItems.NextLink) - }, - statusCodes: []int{http.StatusOK}, - } -} - -// listCreateRequest creates the List request. -func (client *FileSharesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *FileSharesListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - if options != nil && options.Maxpagesize != nil { - reqQP.Set("$maxpagesize", *options.Maxpagesize) - } - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } - if options != nil && options.Expand != nil { - reqQP.Set("$expand", "deleted") - } - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *FileSharesClient) listHandleResponse(resp *azcore.Response) (FileShareItemsResponse, error) { - var val *FileShareItems - if err := resp.UnmarshalAsJSON(&val); err != nil { - return FileShareItemsResponse{}, err - } - return FileShareItemsResponse{RawResponse: resp.Response, FileShareItems: val}, nil -} - -// listHandleError handles the List error response. -func (client *FileSharesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Restore - Restore a file share within a valid retention days if share soft delete is enabled -func (client *FileSharesClient) Restore(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare, options *FileSharesRestoreOptions) (*http.Response, error) { - req, err := client.restoreCreateRequest(ctx, resourceGroupName, accountName, shareName, deletedShare, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK) { - return nil, client.restoreHandleError(resp) - } - return resp.Response, nil -} - -// restoreCreateRequest creates the Restore request. -func (client *FileSharesClient) restoreCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare, options *FileSharesRestoreOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if shareName == "" { - return nil, errors.New("parameter shareName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(deletedShare) -} - -// restoreHandleError handles the Restore error response. -func (client *FileSharesClient) restoreHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Update - Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified -// share does not already exist. -func (client *FileSharesClient) Update(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesUpdateOptions) (FileShareResponse, error) { - req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options) - if err != nil { - return FileShareResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return FileShareResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return FileShareResponse{}, client.updateHandleError(resp) - } - return client.updateHandleResponse(resp) -} - -// updateCreateRequest creates the Update request. -func (client *FileSharesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesUpdateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if shareName == "" { - return nil, errors.New("parameter shareName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(fileShare) -} - -// updateHandleResponse handles the Update response. -func (client *FileSharesClient) updateHandleResponse(resp *azcore.Response) (FileShareResponse, error) { - var val *FileShare - if err := resp.UnmarshalAsJSON(&val); err != nil { - return FileShareResponse{}, err - } - return FileShareResponse{RawResponse: resp.Response, FileShare: val}, nil -} - -// updateHandleError handles the Update error response. -func (client *FileSharesClient) updateHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_managementpolicies_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_managementpolicies_client.go deleted file mode 100644 index bf7f295c80fb..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_managementpolicies_client.go +++ /dev/null @@ -1,226 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// ManagementPoliciesClient contains the methods for the ManagementPolicies group. -// Don't use this type directly, use NewManagementPoliciesClient() instead. -type ManagementPoliciesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewManagementPoliciesClient creates a new instance of ManagementPoliciesClient with the specified values. -func NewManagementPoliciesClient(con *armcore.Connection, subscriptionID string) *ManagementPoliciesClient { - return &ManagementPoliciesClient{con: con, subscriptionID: subscriptionID} -} - -// CreateOrUpdate - Sets the managementpolicy to the specified storage account. -func (client *ManagementPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, properties ManagementPolicy, options *ManagementPoliciesCreateOrUpdateOptions) (ManagementPolicyResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, managementPolicyName, properties, options) - if err != nil { - return ManagementPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ManagementPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ManagementPolicyResponse{}, client.createOrUpdateHandleError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ManagementPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, properties ManagementPolicy, options *ManagementPoliciesCreateOrUpdateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if managementPolicyName == "" { - return nil, errors.New("parameter managementPolicyName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementPolicyName}", url.PathEscape(string(managementPolicyName))) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(properties) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ManagementPoliciesClient) createOrUpdateHandleResponse(resp *azcore.Response) (ManagementPolicyResponse, error) { - var val *ManagementPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ManagementPolicyResponse{}, err - } - return ManagementPolicyResponse{RawResponse: resp.Response, ManagementPolicy: val}, nil -} - -// createOrUpdateHandleError handles the CreateOrUpdate error response. -func (client *ManagementPoliciesClient) createOrUpdateHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Delete - Deletes the managementpolicy associated with the specified storage account. -func (client *ManagementPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, managementPolicyName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ManagementPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if managementPolicyName == "" { - return nil, errors.New("parameter managementPolicyName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementPolicyName}", url.PathEscape(string(managementPolicyName))) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *ManagementPoliciesClient) deleteHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Get - Gets the managementpolicy associated with the specified storage account. -func (client *ManagementPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesGetOptions) (ManagementPolicyResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, managementPolicyName, options) - if err != nil { - return ManagementPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ManagementPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ManagementPolicyResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *ManagementPoliciesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if managementPolicyName == "" { - return nil, errors.New("parameter managementPolicyName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{managementPolicyName}", url.PathEscape(string(managementPolicyName))) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ManagementPoliciesClient) getHandleResponse(resp *azcore.Response) (ManagementPolicyResponse, error) { - var val *ManagementPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ManagementPolicyResponse{}, err - } - return ManagementPolicyResponse{RawResponse: resp.Response, ManagementPolicy: val}, nil -} - -// getHandleError handles the Get error response. -func (client *ManagementPoliciesClient) getHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_models.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_models.go deleted file mode 100644 index 156caf2f7d0f..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_models.go +++ /dev/null @@ -1,3427 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "reflect" - "time" -) - -// AccountSasParameters - The parameters to list SAS credentials of a storage account. -type AccountSasParameters struct { - // An IP address or a range of IP addresses from which to accept requests. - IPAddressOrRange *string `json:"signedIp,omitempty"` - - // The key to sign the account SAS token with. - KeyToSign *string `json:"keyToSign,omitempty"` - - // 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"` - - // The protocol permitted for a request made with the account SAS. - Protocols *HTTPProtocol `json:"signedProtocol,omitempty"` - - // 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"` - - // The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). - Services *Services `json:"signedServices,omitempty"` - - // The time at which the shared access signature becomes invalid. - SharedAccessExpiryTime *time.Time `json:"signedExpiry,omitempty"` - - // The time at which the SAS becomes valid. - SharedAccessStartTime *time.Time `json:"signedStart,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type AccountSasParameters. -func (a AccountSasParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "signedIp", a.IPAddressOrRange) - populate(objectMap, "keyToSign", a.KeyToSign) - populate(objectMap, "signedPermission", a.Permissions) - populate(objectMap, "signedProtocol", a.Protocols) - populate(objectMap, "signedResourceTypes", a.ResourceTypes) - populate(objectMap, "signedServices", a.Services) - populate(objectMap, "signedExpiry", (*timeRFC3339)(a.SharedAccessExpiryTime)) - populate(objectMap, "signedStart", (*timeRFC3339)(a.SharedAccessStartTime)) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type AccountSasParameters. -func (a *AccountSasParameters) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "signedIp": - err = unpopulate(val, &a.IPAddressOrRange) - delete(rawMsg, key) - case "keyToSign": - err = unpopulate(val, &a.KeyToSign) - delete(rawMsg, key) - case "signedPermission": - err = unpopulate(val, &a.Permissions) - delete(rawMsg, key) - case "signedProtocol": - err = unpopulate(val, &a.Protocols) - delete(rawMsg, key) - case "signedResourceTypes": - err = unpopulate(val, &a.ResourceTypes) - delete(rawMsg, key) - case "signedServices": - err = unpopulate(val, &a.Services) - delete(rawMsg, key) - case "signedExpiry": - var aux timeRFC3339 - err = unpopulate(val, &aux) - a.SharedAccessExpiryTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "signedStart": - var aux timeRFC3339 - err = unpopulate(val, &aux) - a.SharedAccessStartTime = (*time.Time)(&aux) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// ActiveDirectoryProperties - Settings properties for Active Directory (AD). -type ActiveDirectoryProperties struct { - // Specifies the security identifier (SID) for Azure Storage. - AzureStorageSid *string `json:"azureStorageSid,omitempty"` - - // Specifies the domain GUID. - DomainGUID *string `json:"domainGuid,omitempty"` - - // Specifies the primary domain that the AD DNS server is authoritative for. - DomainName *string `json:"domainName,omitempty"` - - // Specifies the security identifier (SID). - DomainSid *string `json:"domainSid,omitempty"` - - // Specifies the Active Directory forest to get. - ForestName *string `json:"forestName,omitempty"` - - // Specifies the NetBIOS domain name. - NetBiosDomainName *string `json:"netBiosDomainName,omitempty"` -} - -// AzureEntityResource - The resource model definition for an Azure Resource Manager resource with an etag. -type AzureEntityResource struct { - Resource - // READ-ONLY; Resource Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type AzureEntityResource. -func (a AzureEntityResource) MarshalJSON() ([]byte, error) { - objectMap := a.marshalInternal() - return json.Marshal(objectMap) -} - -func (a AzureEntityResource) marshalInternal() map[string]interface{} { - objectMap := a.Resource.marshalInternal() - populate(objectMap, "etag", a.Etag) - return objectMap -} - -// AzureFilesIdentityBasedAuthentication - Settings for Azure Files identity based authentication. -type AzureFilesIdentityBasedAuthentication struct { - // Required if choose AD. - ActiveDirectoryProperties *ActiveDirectoryProperties `json:"activeDirectoryProperties,omitempty"` - - // Indicates the directory service used. - DirectoryServiceOptions *DirectoryServiceOptions `json:"directoryServiceOptions,omitempty"` -} - -// BlobContainer - Properties of the blob container, including Id, resource name, resource type, Etag. -type BlobContainer struct { - AzureEntityResource - // Properties of the blob container. - ContainerProperties *ContainerProperties `json:"properties,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type BlobContainer. -func (b BlobContainer) MarshalJSON() ([]byte, error) { - objectMap := b.AzureEntityResource.marshalInternal() - populate(objectMap, "properties", b.ContainerProperties) - return json.Marshal(objectMap) -} - -// BlobContainerResponse is the response envelope for operations that return a BlobContainer type. -type BlobContainerResponse struct { - // Properties of the blob container, including Id, resource name, resource type, Etag. - BlobContainer *BlobContainer - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// BlobContainersClearLegalHoldOptions contains the optional parameters for the BlobContainers.ClearLegalHold method. -type BlobContainersClearLegalHoldOptions struct { - // placeholder for future optional parameters -} - -// BlobContainersCreateOptions contains the optional parameters for the BlobContainers.Create method. -type BlobContainersCreateOptions struct { - // placeholder for future optional parameters -} - -// BlobContainersCreateOrUpdateImmutabilityPolicyOptions contains the optional parameters for the BlobContainers.CreateOrUpdateImmutabilityPolicy method. -type BlobContainersCreateOrUpdateImmutabilityPolicyOptions struct { - // The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy - // already exists. If omitted, this operation will always be applied. - IfMatch *string - // The ImmutabilityPolicy Properties that will be created or updated to a blob container. - Parameters *ImmutabilityPolicy -} - -// BlobContainersDeleteImmutabilityPolicyOptions contains the optional parameters for the BlobContainers.DeleteImmutabilityPolicy method. -type BlobContainersDeleteImmutabilityPolicyOptions struct { - // placeholder for future optional parameters -} - -// BlobContainersDeleteOptions contains the optional parameters for the BlobContainers.Delete method. -type BlobContainersDeleteOptions struct { - // placeholder for future optional parameters -} - -// BlobContainersExtendImmutabilityPolicyOptions contains the optional parameters for the BlobContainers.ExtendImmutabilityPolicy method. -type BlobContainersExtendImmutabilityPolicyOptions struct { - // The ImmutabilityPolicy Properties that will be extended for a blob container. - Parameters *ImmutabilityPolicy -} - -// BlobContainersGetImmutabilityPolicyOptions contains the optional parameters for the BlobContainers.GetImmutabilityPolicy method. -type BlobContainersGetImmutabilityPolicyOptions struct { - // The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy - // already exists. If omitted, this operation will always be applied. - IfMatch *string -} - -// BlobContainersGetOptions contains the optional parameters for the BlobContainers.Get method. -type BlobContainersGetOptions struct { - // placeholder for future optional parameters -} - -// BlobContainersLeaseOptions contains the optional parameters for the BlobContainers.Lease method. -type BlobContainersLeaseOptions struct { - // Lease Container request body. - Parameters *LeaseContainerRequest -} - -// BlobContainersListOptions contains the optional parameters for the BlobContainers.List method. -type BlobContainersListOptions struct { - // Optional. When specified, only container names starting with the filter will be listed. - Filter *string - // Optional, used to include the properties for soft deleted blob containers. - Include *ListContainersInclude - // Optional. Specified maximum number of containers that can be included in the list. - Maxpagesize *string -} - -// BlobContainersLockImmutabilityPolicyOptions contains the optional parameters for the BlobContainers.LockImmutabilityPolicy method. -type BlobContainersLockImmutabilityPolicyOptions struct { - // placeholder for future optional parameters -} - -// BlobContainersSetLegalHoldOptions contains the optional parameters for the BlobContainers.SetLegalHold method. -type BlobContainersSetLegalHoldOptions struct { - // placeholder for future optional parameters -} - -// BlobContainersUpdateOptions contains the optional parameters for the BlobContainers.Update method. -type BlobContainersUpdateOptions struct { - // placeholder for future optional parameters -} - -// BlobRestoreParameters - Blob restore parameters -type BlobRestoreParameters struct { - // Blob ranges to restore. - BlobRanges *[]*BlobRestoreRange `json:"blobRanges,omitempty"` - - // Restore blob to the specified time. - TimeToRestore *time.Time `json:"timeToRestore,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type BlobRestoreParameters. -func (b BlobRestoreParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "blobRanges", b.BlobRanges) - populate(objectMap, "timeToRestore", (*timeRFC3339)(b.TimeToRestore)) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type BlobRestoreParameters. -func (b *BlobRestoreParameters) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "blobRanges": - err = unpopulate(val, &b.BlobRanges) - delete(rawMsg, key) - case "timeToRestore": - var aux timeRFC3339 - err = unpopulate(val, &aux) - b.TimeToRestore = (*time.Time)(&aux) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// BlobRestoreRange - Blob range -type BlobRestoreRange struct { - // Blob end range. This is exclusive. Empty means account end. - EndRange *string `json:"endRange,omitempty"` - - // Blob start range. This is inclusive. Empty means account start. - StartRange *string `json:"startRange,omitempty"` -} - -// BlobRestoreStatus - Blob restore status. -type BlobRestoreStatus struct { - // READ-ONLY; Failure reason when blob restore is failed. - FailureReason *string `json:"failureReason,omitempty" azure:"ro"` - - // READ-ONLY; Blob restore request parameters. - Parameters *BlobRestoreParameters `json:"parameters,omitempty" azure:"ro"` - - // READ-ONLY; Id for tracking blob restore request. - RestoreID *string `json:"restoreId,omitempty" azure:"ro"` - - // 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"` -} - -// BlobRestoreStatusPollerResponse is the response envelope for operations that asynchronously return a BlobRestoreStatus type. -type BlobRestoreStatusPollerResponse struct { - // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received - PollUntilDone func(ctx context.Context, frequency time.Duration) (BlobRestoreStatusResponse, error) - - // Poller contains an initialized poller. - Poller BlobRestoreStatusPoller - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// BlobRestoreStatusResponse is the response envelope for operations that return a BlobRestoreStatus type. -type BlobRestoreStatusResponse struct { - // Blob restore status. - BlobRestoreStatus *BlobRestoreStatus - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -type BlobServiceItems struct { - // READ-ONLY; List of blob services returned. - Value *[]*BlobServiceProperties `json:"value,omitempty" azure:"ro"` -} - -// BlobServiceItemsResponse is the response envelope for operations that return a BlobServiceItems type. -type BlobServiceItemsResponse struct { - BlobServiceItems *BlobServiceItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// BlobServiceProperties - The properties of a storage account’s Blob service. -type BlobServiceProperties struct { - Resource - // The properties of a storage account’s Blob service. - BlobServiceProperties *BlobServicePropertiesAutoGenerated `json:"properties,omitempty"` - - // READ-ONLY; Sku name and tier. - SKU *SKU `json:"sku,omitempty" azure:"ro"` -} - -// BlobServicePropertiesAutoGenerated - The properties of a storage account’s Blob service. -type BlobServicePropertiesAutoGenerated struct { - // Deprecated in favor of isVersioningEnabled property. - AutomaticSnapshotPolicyEnabled *bool `json:"automaticSnapshotPolicyEnabled,omitempty"` - - // The blob service properties for change feed events. - ChangeFeed *ChangeFeed `json:"changeFeed,omitempty"` - - // The blob service properties for container soft delete. - ContainerDeleteRetentionPolicy *DeleteRetentionPolicy `json:"containerDeleteRetentionPolicy,omitempty"` - - // 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"` - - // 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"` - - // The blob service properties for blob soft delete. - DeleteRetentionPolicy *DeleteRetentionPolicy `json:"deleteRetentionPolicy,omitempty"` - - // Versioning is enabled if set to true. - IsVersioningEnabled *bool `json:"isVersioningEnabled,omitempty"` - - // The blob service properties for blob restore policy. - RestorePolicy *RestorePolicyProperties `json:"restorePolicy,omitempty"` -} - -// BlobServicePropertiesResponse is the response envelope for operations that return a BlobServiceProperties type. -type BlobServicePropertiesResponse struct { - // The properties of a storage account’s Blob service. - BlobServiceProperties *BlobServiceProperties - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// BlobServicesGetServicePropertiesOptions contains the optional parameters for the BlobServices.GetServiceProperties method. -type BlobServicesGetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// BlobServicesListOptions contains the optional parameters for the BlobServices.List method. -type BlobServicesListOptions struct { - // placeholder for future optional parameters -} - -// BlobServicesSetServicePropertiesOptions contains the optional parameters for the BlobServices.SetServiceProperties method. -type BlobServicesSetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// 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"` -} - -// 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"` - - // 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"` - - // 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"` -} - -// CheckNameAvailabilityResultResponse is the response envelope for operations that return a CheckNameAvailabilityResult type. -type CheckNameAvailabilityResultResponse struct { - // The CheckNameAvailability operation response. - CheckNameAvailabilityResult *CheckNameAvailabilityResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// CloudError - An error response from the Storage service. -type CloudError struct { - // An error response from the Storage service. - InnerError *CloudErrorBody `json:"error,omitempty"` -} - -// Error implements the error interface for type CloudError. -func (e CloudError) Error() string { - msg := "" - if e.InnerError != nil { - msg += "InnerError: \n" - if e.InnerError.Code != nil { - msg += fmt.Sprintf("\tCode: %v\n", *e.InnerError.Code) - } - if e.InnerError.Message != nil { - msg += fmt.Sprintf("\tMessage: %v\n", *e.InnerError.Message) - } - if e.InnerError.Target != nil { - msg += fmt.Sprintf("\tTarget: %v\n", *e.InnerError.Target) - } - if e.InnerError.Details != nil { - msg += fmt.Sprintf("\tDetails: %v\n", *e.InnerError.Details) - } - } - if msg == "" { - msg = "missing error info" - } - return msg -} - -// CloudErrorBody - An error response from the Storage service. -type CloudErrorBody struct { - // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - - // A list of additional details about the error. - Details *[]*CloudErrorBody `json:"details,omitempty"` - - // A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` - - // The target of the particular error. For example, the name of the property in error. - Target *string `json:"target,omitempty"` -} - -// 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"` - - // READ-ONLY; Indicates whether the blob container was deleted. - Deleted *bool `json:"deleted,omitempty" azure:"ro"` - - // READ-ONLY; Blob container deletion time. - DeletedTime *time.Time `json:"deletedTime,omitempty" azure:"ro"` - - // Block override of encryption scope from the container default. - DenyEncryptionScopeOverride *bool `json:"denyEncryptionScopeOverride,omitempty"` - - // 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"` - - // 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"` - - // READ-ONLY; The ImmutabilityPolicy property of the container. - ImmutabilityPolicy *ImmutabilityPolicyProperties `json:"immutabilityPolicy,omitempty" azure:"ro"` - - // READ-ONLY; Returns the date and time the container was last modified. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - - // 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"` - - // READ-ONLY; Lease state of the container. - LeaseState *LeaseState `json:"leaseState,omitempty" azure:"ro"` - - // READ-ONLY; The lease status of the container. - LeaseStatus *LeaseStatus `json:"leaseStatus,omitempty" azure:"ro"` - - // READ-ONLY; The LegalHold property of the container. - LegalHold *LegalHoldProperties `json:"legalHold,omitempty" azure:"ro"` - - // A name-value pair to associate with the container as metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` - - // Specifies whether data in the container may be accessed publicly and the level of access. - PublicAccess *PublicAccess `json:"publicAccess,omitempty"` - - // READ-ONLY; Remaining retention days for soft deleted blob container. - RemainingRetentionDays *int32 `json:"remainingRetentionDays,omitempty" azure:"ro"` - - // READ-ONLY; The version of the deleted blob container. - Version *string `json:"version,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type ContainerProperties. -func (c ContainerProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "defaultEncryptionScope", c.DefaultEncryptionScope) - populate(objectMap, "deleted", c.Deleted) - populate(objectMap, "deletedTime", (*timeRFC3339)(c.DeletedTime)) - populate(objectMap, "denyEncryptionScopeOverride", c.DenyEncryptionScopeOverride) - populate(objectMap, "hasImmutabilityPolicy", c.HasImmutabilityPolicy) - populate(objectMap, "hasLegalHold", c.HasLegalHold) - populate(objectMap, "immutabilityPolicy", c.ImmutabilityPolicy) - populate(objectMap, "lastModifiedTime", (*timeRFC3339)(c.LastModifiedTime)) - populate(objectMap, "leaseDuration", c.LeaseDuration) - populate(objectMap, "leaseState", c.LeaseState) - populate(objectMap, "leaseStatus", c.LeaseStatus) - populate(objectMap, "legalHold", c.LegalHold) - populate(objectMap, "metadata", c.Metadata) - populate(objectMap, "publicAccess", c.PublicAccess) - populate(objectMap, "remainingRetentionDays", c.RemainingRetentionDays) - populate(objectMap, "version", c.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerProperties. -func (c *ContainerProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "defaultEncryptionScope": - err = unpopulate(val, &c.DefaultEncryptionScope) - delete(rawMsg, key) - case "deleted": - err = unpopulate(val, &c.Deleted) - delete(rawMsg, key) - case "deletedTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - c.DeletedTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "denyEncryptionScopeOverride": - err = unpopulate(val, &c.DenyEncryptionScopeOverride) - delete(rawMsg, key) - case "hasImmutabilityPolicy": - err = unpopulate(val, &c.HasImmutabilityPolicy) - delete(rawMsg, key) - case "hasLegalHold": - err = unpopulate(val, &c.HasLegalHold) - delete(rawMsg, key) - case "immutabilityPolicy": - err = unpopulate(val, &c.ImmutabilityPolicy) - delete(rawMsg, key) - case "lastModifiedTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - c.LastModifiedTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "leaseDuration": - err = unpopulate(val, &c.LeaseDuration) - delete(rawMsg, key) - case "leaseState": - err = unpopulate(val, &c.LeaseState) - delete(rawMsg, key) - case "leaseStatus": - err = unpopulate(val, &c.LeaseStatus) - delete(rawMsg, key) - case "legalHold": - err = unpopulate(val, &c.LegalHold) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, &c.Metadata) - delete(rawMsg, key) - case "publicAccess": - err = unpopulate(val, &c.PublicAccess) - delete(rawMsg, key) - case "remainingRetentionDays": - err = unpopulate(val, &c.RemainingRetentionDays) - delete(rawMsg, key) - case "version": - err = unpopulate(val, &c.Version) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// CorsRule - Specifies a CORS rule for the Blob service. -type CorsRule struct { - // Required if CorsRule element is present. A list of headers allowed to be part of the cross-origin request. - AllowedHeaders *[]*string `json:"allowedHeaders,omitempty"` - - // 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"` - - // 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"` - - // Required if CorsRule element is present. A list of response headers to expose to CORS clients. - ExposedHeaders *[]*string `json:"exposedHeaders,omitempty"` - - // Required if CorsRule element is present. The number of seconds that the client/browser should cache a preflight response. - MaxAgeInSeconds *int32 `json:"maxAgeInSeconds,omitempty"` -} - -// 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"` -} - -// CustomDomain - The custom domain assigned to this storage account. This can be set via Update. -type CustomDomain struct { - // Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. - Name *string `json:"name,omitempty"` - - // Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. - UseSubDomainName *bool `json:"useSubDomainName,omitempty"` -} - -// DateAfterCreation - Object to define the number of days after creation. -type DateAfterCreation struct { - // Value indicating the age in days after creation - DaysAfterCreationGreaterThan *float32 `json:"daysAfterCreationGreaterThan,omitempty"` -} - -// DateAfterModification - Object to define the number of days after last modification. -type DateAfterModification struct { - // Value indicating the age in days after last modification - DaysAfterModificationGreaterThan *float32 `json:"daysAfterModificationGreaterThan,omitempty"` -} - -// DeleteRetentionPolicy - The service properties for soft delete. -type DeleteRetentionPolicy struct { - // 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"` - - // Indicates whether DeleteRetentionPolicy is enabled. - Enabled *bool `json:"enabled,omitempty"` -} - -// DeletedShare - The deleted share to be restored. -type DeletedShare struct { - // Required. Identify the name of the deleted share that will be restored. - DeletedShareName *string `json:"deletedShareName,omitempty"` - - // Required. Identify the version of the deleted share that will be restored. - DeletedShareVersion *string `json:"deletedShareVersion,omitempty"` -} - -// Dimension of blobs, possibly be blob type or access tier. -type Dimension struct { - // Display name of dimension. - DisplayName *string `json:"displayName,omitempty"` - - // Display name of dimension. - Name *string `json:"name,omitempty"` -} - -// Encryption - The encryption settings on the storage account. -type Encryption struct { - // The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault - KeySource *KeySource `json:"keySource,omitempty"` - - // Properties provided by key vault. - KeyVaultProperties *KeyVaultProperties `json:"keyvaultproperties,omitempty"` - - // 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"` - - // List of services which support encryption. - Services *EncryptionServices `json:"services,omitempty"` -} - -// EncryptionScope - The Encryption Scope resource. -type EncryptionScope struct { - Resource - // Properties of the encryption scope. - EncryptionScopeProperties *EncryptionScopeProperties `json:"properties,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type EncryptionScope. -func (e EncryptionScope) MarshalJSON() ([]byte, error) { - objectMap := e.Resource.marshalInternal() - populate(objectMap, "properties", e.EncryptionScopeProperties) - return json.Marshal(objectMap) -} - -// EncryptionScopeKeyVaultProperties - The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute -// is set to 'Microsoft.KeyVault'. -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"` -} - -// EncryptionScopeListResult - List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. -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"` - - // READ-ONLY; List of encryption scopes requested. - Value *[]*EncryptionScope `json:"value,omitempty" azure:"ro"` -} - -// EncryptionScopeListResultResponse is the response envelope for operations that return a EncryptionScopeListResult type. -type EncryptionScopeListResultResponse struct { - // List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. - EncryptionScopeListResult *EncryptionScopeListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// EncryptionScopeProperties - Properties of the encryption scope. -type EncryptionScopeProperties struct { - // READ-ONLY; Gets the creation date and time of the encryption scope in UTC. - CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` - - // 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"` - - // READ-ONLY; Gets the last modification date and time of the encryption scope in UTC. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - - // The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. - Source *EncryptionScopeSource `json:"source,omitempty"` - - // The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - State *EncryptionScopeState `json:"state,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type EncryptionScopeProperties. -func (e EncryptionScopeProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "creationTime", (*timeRFC3339)(e.CreationTime)) - populate(objectMap, "keyVaultProperties", e.KeyVaultProperties) - populate(objectMap, "lastModifiedTime", (*timeRFC3339)(e.LastModifiedTime)) - populate(objectMap, "source", e.Source) - populate(objectMap, "state", e.State) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionScopeProperties. -func (e *EncryptionScopeProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "creationTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - e.CreationTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "keyVaultProperties": - err = unpopulate(val, &e.KeyVaultProperties) - delete(rawMsg, key) - case "lastModifiedTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - e.LastModifiedTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "source": - err = unpopulate(val, &e.Source) - delete(rawMsg, key) - case "state": - err = unpopulate(val, &e.State) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// EncryptionScopeResponse is the response envelope for operations that return a EncryptionScope type. -type EncryptionScopeResponse struct { - // The Encryption Scope resource. - EncryptionScope *EncryptionScope - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// EncryptionScopesGetOptions contains the optional parameters for the EncryptionScopes.Get method. -type EncryptionScopesGetOptions struct { - // placeholder for future optional parameters -} - -// EncryptionScopesListOptions contains the optional parameters for the EncryptionScopes.List method. -type EncryptionScopesListOptions struct { - // placeholder for future optional parameters -} - -// EncryptionScopesPatchOptions contains the optional parameters for the EncryptionScopes.Patch method. -type EncryptionScopesPatchOptions struct { - // placeholder for future optional parameters -} - -// EncryptionScopesPutOptions contains the optional parameters for the EncryptionScopes.Put method. -type EncryptionScopesPutOptions struct { - // placeholder for future optional parameters -} - -// EncryptionService - A service that allows server-side encryption to be used. -type EncryptionService struct { - // A boolean indicating whether or not the service encrypts the data as it is stored. - Enabled *bool `json:"enabled,omitempty"` - - // 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"` - - // READ-ONLY; Gets a rough estimate of the date/time when the encryption was last enabled by the user. Only returned when encryption is enabled. There might - // be some unencrypted blobs which were written after this - // time, as it is just a rough estimate. - LastEnabledTime *time.Time `json:"lastEnabledTime,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type EncryptionService. -func (e EncryptionService) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "enabled", e.Enabled) - populate(objectMap, "keyType", e.KeyType) - populate(objectMap, "lastEnabledTime", (*timeRFC3339)(e.LastEnabledTime)) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionService. -func (e *EncryptionService) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "enabled": - err = unpopulate(val, &e.Enabled) - delete(rawMsg, key) - case "keyType": - err = unpopulate(val, &e.KeyType) - delete(rawMsg, key) - case "lastEnabledTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - e.LastEnabledTime = (*time.Time)(&aux) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// EncryptionServices - A list of services that support encryption. -type EncryptionServices struct { - // The encryption function of the blob storage service. - Blob *EncryptionService `json:"blob,omitempty"` - - // The encryption function of the file storage service. - File *EncryptionService `json:"file,omitempty"` - - // The encryption function of the queue storage service. - Queue *EncryptionService `json:"queue,omitempty"` - - // The encryption function of the table storage service. - Table *EncryptionService `json:"table,omitempty"` -} - -// Endpoints - The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. -type Endpoints struct { - // READ-ONLY; Gets the blob endpoint. - Blob *string `json:"blob,omitempty" azure:"ro"` - - // READ-ONLY; Gets the dfs endpoint. - Dfs *string `json:"dfs,omitempty" azure:"ro"` - - // READ-ONLY; Gets the file endpoint. - File *string `json:"file,omitempty" azure:"ro"` - - // Gets the internet routing storage endpoints - InternetEndpoints *StorageAccountInternetEndpoints `json:"internetEndpoints,omitempty"` - - // Gets the microsoft routing storage endpoints. - MicrosoftEndpoints *StorageAccountMicrosoftEndpoints `json:"microsoftEndpoints,omitempty"` - - // READ-ONLY; Gets the queue endpoint. - Queue *string `json:"queue,omitempty" azure:"ro"` - - // READ-ONLY; Gets the table endpoint. - Table *string `json:"table,omitempty" azure:"ro"` - - // READ-ONLY; Gets the web endpoint. - Web *string `json:"web,omitempty" azure:"ro"` -} - -// ErrorResponse - An error response from the storage resource provider. -type ErrorResponse struct { - // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - - // A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` -} - -// Error implements the error interface for type ErrorResponse. -func (e ErrorResponse) Error() string { - msg := "" - if e.Code != nil { - msg += fmt.Sprintf("Code: %v\n", *e.Code) - } - if e.Message != nil { - msg += fmt.Sprintf("Message: %v\n", *e.Message) - } - if msg == "" { - msg = "missing error info" - } - return msg -} - -type FileServiceItems struct { - // READ-ONLY; List of file services returned. - Value *[]*FileServiceProperties `json:"value,omitempty" azure:"ro"` -} - -// FileServiceItemsResponse is the response envelope for operations that return a FileServiceItems type. -type FileServiceItemsResponse struct { - FileServiceItems *FileServiceItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// FileServiceProperties - The properties of File services in storage account. -type FileServiceProperties struct { - Resource - // The properties of File services in storage account. - FileServiceProperties *FileServicePropertiesAutoGenerated `json:"properties,omitempty"` - - // READ-ONLY; Sku name and tier. - SKU *SKU `json:"sku,omitempty" azure:"ro"` -} - -// FileServicePropertiesAutoGenerated - The properties of File services in storage account. -type FileServicePropertiesAutoGenerated 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"` - - // The file service properties for share soft delete. - ShareDeleteRetentionPolicy *DeleteRetentionPolicy `json:"shareDeleteRetentionPolicy,omitempty"` -} - -// FileServicePropertiesResponse is the response envelope for operations that return a FileServiceProperties type. -type FileServicePropertiesResponse struct { - // The properties of File services in storage account. - FileServiceProperties *FileServiceProperties - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// FileServicesGetServicePropertiesOptions contains the optional parameters for the FileServices.GetServiceProperties method. -type FileServicesGetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// FileServicesListOptions contains the optional parameters for the FileServices.List method. -type FileServicesListOptions struct { - // placeholder for future optional parameters -} - -// FileServicesSetServicePropertiesOptions contains the optional parameters for the FileServices.SetServiceProperties method. -type FileServicesSetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// FileShare - Properties of the file share, including Id, resource name, resource type, Etag. -type FileShare struct { - AzureEntityResource - // Properties of the file share. - FileShareProperties *FileShareProperties `json:"properties,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type FileShare. -func (f FileShare) MarshalJSON() ([]byte, error) { - objectMap := f.AzureEntityResource.marshalInternal() - populate(objectMap, "properties", f.FileShareProperties) - return json.Marshal(objectMap) -} - -// FileShareItem - The file share properties be listed out. -type FileShareItem struct { - AzureEntityResource - // The file share properties be listed out. - Properties *FileShareProperties `json:"properties,omitempty"` -} - -// FileShareItems - Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. -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"` - - // READ-ONLY; List of file shares returned. - Value *[]*FileShareItem `json:"value,omitempty" azure:"ro"` -} - -// FileShareItemsResponse is the response envelope for operations that return a FileShareItems type. -type FileShareItemsResponse struct { - // Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. - FileShareItems *FileShareItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// 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"` - - // READ-ONLY; Indicates the last modification time for share access tier. - AccessTierChangeTime *time.Time `json:"accessTierChangeTime,omitempty" azure:"ro"` - - // READ-ONLY; Indicates if there is a pending transition for access tier. - AccessTierStatus *string `json:"accessTierStatus,omitempty" azure:"ro"` - - // READ-ONLY; Indicates whether the share was deleted. - Deleted *bool `json:"deleted,omitempty" azure:"ro"` - - // READ-ONLY; The deleted time if the share was deleted. - DeletedTime *time.Time `json:"deletedTime,omitempty" azure:"ro"` - - // The authentication protocol that is used for the file share. Can only be specified when creating a share. - EnabledProtocols *EnabledProtocols `json:"enabledProtocols,omitempty"` - - // READ-ONLY; Returns the date and time the share was last modified. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - - // A name-value pair to associate with the share as metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` - - // READ-ONLY; Remaining retention days for share that was soft deleted. - RemainingRetentionDays *int32 `json:"remainingRetentionDays,omitempty" azure:"ro"` - - // The property is for NFS share only. The default is NoRootSquash. - RootSquash *RootSquashType `json:"rootSquash,omitempty"` - - // 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"` - - // 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"` - - // READ-ONLY; The version of the share. - Version *string `json:"version,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type FileShareProperties. -func (f FileShareProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accessTier", f.AccessTier) - populate(objectMap, "accessTierChangeTime", (*timeRFC3339)(f.AccessTierChangeTime)) - populate(objectMap, "accessTierStatus", f.AccessTierStatus) - populate(objectMap, "deleted", f.Deleted) - populate(objectMap, "deletedTime", (*timeRFC3339)(f.DeletedTime)) - populate(objectMap, "enabledProtocols", f.EnabledProtocols) - populate(objectMap, "lastModifiedTime", (*timeRFC3339)(f.LastModifiedTime)) - populate(objectMap, "metadata", f.Metadata) - populate(objectMap, "remainingRetentionDays", f.RemainingRetentionDays) - populate(objectMap, "rootSquash", f.RootSquash) - populate(objectMap, "shareQuota", f.ShareQuota) - populate(objectMap, "shareUsageBytes", f.ShareUsageBytes) - populate(objectMap, "version", f.Version) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type FileShareProperties. -func (f *FileShareProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "accessTier": - err = unpopulate(val, &f.AccessTier) - delete(rawMsg, key) - case "accessTierChangeTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - f.AccessTierChangeTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "accessTierStatus": - err = unpopulate(val, &f.AccessTierStatus) - delete(rawMsg, key) - case "deleted": - err = unpopulate(val, &f.Deleted) - delete(rawMsg, key) - case "deletedTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - f.DeletedTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "enabledProtocols": - err = unpopulate(val, &f.EnabledProtocols) - delete(rawMsg, key) - case "lastModifiedTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - f.LastModifiedTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "metadata": - err = unpopulate(val, &f.Metadata) - delete(rawMsg, key) - case "remainingRetentionDays": - err = unpopulate(val, &f.RemainingRetentionDays) - delete(rawMsg, key) - case "rootSquash": - err = unpopulate(val, &f.RootSquash) - delete(rawMsg, key) - case "shareQuota": - err = unpopulate(val, &f.ShareQuota) - delete(rawMsg, key) - case "shareUsageBytes": - err = unpopulate(val, &f.ShareUsageBytes) - delete(rawMsg, key) - case "version": - err = unpopulate(val, &f.Version) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// FileShareResponse is the response envelope for operations that return a FileShare type. -type FileShareResponse struct { - // Properties of the file share, including Id, resource name, resource type, Etag. - FileShare *FileShare - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// FileSharesCreateOptions contains the optional parameters for the FileShares.Create method. -type FileSharesCreateOptions struct { - // placeholder for future optional parameters -} - -// FileSharesDeleteOptions contains the optional parameters for the FileShares.Delete method. -type FileSharesDeleteOptions struct { - // placeholder for future optional parameters -} - -// FileSharesGetOptions contains the optional parameters for the FileShares.Get method. -type FileSharesGetOptions struct { - // Optional, used to expand the properties within share's properties. - Expand *string -} - -// FileSharesListOptions contains the optional parameters for the FileShares.List method. -type FileSharesListOptions struct { - // Optional, used to expand the properties within share's properties. - Expand *string - // Optional. When specified, only share names starting with the filter will be listed. - Filter *string - // Optional. Specified maximum number of shares that can be included in the list. - Maxpagesize *string -} - -// FileSharesRestoreOptions contains the optional parameters for the FileShares.Restore method. -type FileSharesRestoreOptions struct { - // placeholder for future optional parameters -} - -// FileSharesUpdateOptions contains the optional parameters for the FileShares.Update method. -type FileSharesUpdateOptions struct { - // placeholder for future optional parameters -} - -// GeoReplicationStats - Statistics related to replication for storage account's Blob, Table, Queue and File services. It 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"` - - // 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"` - - // 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"` -} - -// MarshalJSON implements the json.Marshaller interface for type GeoReplicationStats. -func (g GeoReplicationStats) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "canFailover", g.CanFailover) - populate(objectMap, "lastSyncTime", (*timeRFC3339)(g.LastSyncTime)) - populate(objectMap, "status", g.Status) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type GeoReplicationStats. -func (g *GeoReplicationStats) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "canFailover": - err = unpopulate(val, &g.CanFailover) - delete(rawMsg, key) - case "lastSyncTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - g.LastSyncTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "status": - err = unpopulate(val, &g.Status) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// HTTPPollerResponse contains the asynchronous HTTP response from the call to the service endpoint. -type HTTPPollerResponse struct { - // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received - PollUntilDone func(ctx context.Context, frequency time.Duration) (*http.Response, error) - - // Poller contains an initialized poller. - Poller HTTPPoller - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// IPRule - IP rule with specific IP or IP range in CIDR format. -type IPRule struct { - // The action of IP ACL rule. - Action *string `json:"action,omitempty"` - - // Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. - IPAddressOrRange *string `json:"value,omitempty"` -} - -// Identity for the resource. -type Identity struct { - // READ-ONLY; The principal ID of resource identity. - PrincipalID *string `json:"principalId,omitempty" azure:"ro"` - - // READ-ONLY; The tenant ID of resource. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` - - // The identity type. - Type *string `json:"type,omitempty"` -} - -// ImmutabilityPolicy - The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. -type ImmutabilityPolicy struct { - AzureEntityResource - // The properties of an ImmutabilityPolicy of a blob container. - Properties *ImmutabilityPolicyProperty `json:"properties,omitempty"` -} - -// ImmutabilityPolicyProperties - The properties of an ImmutabilityPolicy of a blob container. -type ImmutabilityPolicyProperties struct { - // READ-ONLY; ImmutabilityPolicy Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` - - // The properties of an ImmutabilityPolicy of a blob container. - Properties *ImmutabilityPolicyProperty `json:"properties,omitempty"` - - // READ-ONLY; The ImmutabilityPolicy update history of the blob container. - UpdateHistory *[]*UpdateHistoryProperty `json:"updateHistory,omitempty" azure:"ro"` -} - -// ImmutabilityPolicyProperty - The properties of an ImmutabilityPolicy of a blob container. -type ImmutabilityPolicyProperty struct { - // This property can only be changed for 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. This property cannot be changed with ExtendImmutabilityPolicy API - AllowProtectedAppendWrites *bool `json:"allowProtectedAppendWrites,omitempty"` - - // The immutability period for the blobs in the container since the policy creation, in days. - ImmutabilityPeriodSinceCreationInDays *int32 `json:"immutabilityPeriodSinceCreationInDays,omitempty"` - - // READ-ONLY; The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - State *ImmutabilityPolicyState `json:"state,omitempty" azure:"ro"` -} - -// ImmutabilityPolicyResponse is the response envelope for operations that return a ImmutabilityPolicy type. -type ImmutabilityPolicyResponse struct { - // ETag contains the information returned from the ETag header response. - ETag *string - - // The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. - ImmutabilityPolicy *ImmutabilityPolicy - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// KeyVaultProperties - Properties of key vault. -type KeyVaultProperties struct { - // READ-ONLY; The object identifier of the current versioned Key Vault Key in use. - CurrentVersionedKeyIdentifier *string `json:"currentVersionedKeyIdentifier,omitempty" azure:"ro"` - - // The name of KeyVault key. - KeyName *string `json:"keyname,omitempty"` - - // The Uri of KeyVault. - KeyVaultURI *string `json:"keyvaulturi,omitempty"` - - // The version of KeyVault key. - KeyVersion *string `json:"keyversion,omitempty"` - - // READ-ONLY; Timestamp of last rotation of the Key Vault Key. - LastKeyRotationTimestamp *time.Time `json:"lastKeyRotationTimestamp,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type KeyVaultProperties. -func (k KeyVaultProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "currentVersionedKeyIdentifier", k.CurrentVersionedKeyIdentifier) - populate(objectMap, "keyname", k.KeyName) - populate(objectMap, "keyvaulturi", k.KeyVaultURI) - populate(objectMap, "keyversion", k.KeyVersion) - populate(objectMap, "lastKeyRotationTimestamp", (*timeRFC3339)(k.LastKeyRotationTimestamp)) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultProperties. -func (k *KeyVaultProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "currentVersionedKeyIdentifier": - err = unpopulate(val, &k.CurrentVersionedKeyIdentifier) - delete(rawMsg, key) - case "keyname": - err = unpopulate(val, &k.KeyName) - delete(rawMsg, key) - case "keyvaulturi": - err = unpopulate(val, &k.KeyVaultURI) - delete(rawMsg, key) - case "keyversion": - err = unpopulate(val, &k.KeyVersion) - delete(rawMsg, key) - case "lastKeyRotationTimestamp": - var aux timeRFC3339 - err = unpopulate(val, &aux) - k.LastKeyRotationTimestamp = (*time.Time)(&aux) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// LeaseContainerRequest - Lease Container request schema. -type LeaseContainerRequest struct { - // Specifies the lease action. Can be one of the available actions. - Action *LeaseContainerRequestAction `json:"action,omitempty"` - - // 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"` - - // 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"` - - // Identifies the lease. Can be specified in any valid GUID string format. - LeaseID *string `json:"leaseId,omitempty"` - - // Optional for acquire, required for change. Proposed lease ID, in a GUID string format. - ProposedLeaseID *string `json:"proposedLeaseId,omitempty"` -} - -// 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"` - - // Approximate time remaining in the lease period, in seconds. - LeaseTimeSeconds *string `json:"leaseTimeSeconds,omitempty"` -} - -// LeaseContainerResponseResponse is the response envelope for operations that return a LeaseContainerResponse type. -type LeaseContainerResponseResponse struct { - // Lease Container response schema. - LeaseContainerResponse *LeaseContainerResponse - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// LegalHold - The LegalHold property of a blob container. -type LegalHold struct { - // 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"` - - // Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case at SRP. - Tags *[]*string `json:"tags,omitempty"` -} - -// LegalHoldProperties - The LegalHold property of a blob container. -type LegalHoldProperties struct { - // 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"` - - // The list of LegalHold tags of a blob container. - Tags *[]*TagProperty `json:"tags,omitempty"` -} - -// LegalHoldResponse is the response envelope for operations that return a LegalHold type. -type LegalHoldResponse struct { - // The LegalHold property of a blob container. - LegalHold *LegalHold - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// 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"` -} - -// ListAccountSasResponseResponse is the response envelope for operations that return a ListAccountSasResponse type. -type ListAccountSasResponseResponse struct { - // The List SAS credentials operation response. - ListAccountSasResponse *ListAccountSasResponse - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ListContainerItem - The blob container properties be listed out. -type ListContainerItem struct { - AzureEntityResource - // The blob container properties be listed out. - Properties *ContainerProperties `json:"properties,omitempty"` -} - -// ListContainerItems - Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. -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"` - - // READ-ONLY; List of blobs containers returned. - Value *[]*ListContainerItem `json:"value,omitempty" azure:"ro"` -} - -// ListContainerItemsResponse is the response envelope for operations that return a ListContainerItems type. -type ListContainerItemsResponse struct { - // Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. - ListContainerItems *ListContainerItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -type ListQueue struct { - Resource - // List Queue resource properties. - QueueProperties *ListQueueProperties `json:"properties,omitempty"` -} - -type ListQueueProperties struct { - // A name-value pair that represents queue metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` -} - -// 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"` - - // READ-ONLY; List of queues returned. - Value *[]*ListQueue `json:"value,omitempty" azure:"ro"` -} - -// ListQueueResourceResponse is the response envelope for operations that return a ListQueueResource type. -type ListQueueResourceResponse struct { - // Response schema. Contains list of queues returned - ListQueueResource *ListQueueResource - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -type ListQueueServices struct { - // READ-ONLY; List of queue services returned. - Value *[]*QueueServiceProperties `json:"value,omitempty" azure:"ro"` -} - -// ListQueueServicesResponse is the response envelope for operations that return a ListQueueServices type. -type ListQueueServicesResponse struct { - ListQueueServices *ListQueueServices - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// 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"` -} - -// ListServiceSasResponseResponse is the response envelope for operations that return a ListServiceSasResponse type. -type ListServiceSasResponseResponse struct { - // The List service SAS credentials operation response. - ListServiceSasResponse *ListServiceSasResponse - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// 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"` - - // READ-ONLY; List of tables returned. - Value *[]*Table `json:"value,omitempty" azure:"ro"` -} - -// ListTableResourceResponse is the response envelope for operations that return a ListTableResource type. -type ListTableResourceResponse struct { - // Response schema. Contains list of tables returned - ListTableResource *ListTableResource - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -type ListTableServices struct { - // READ-ONLY; List of table services returned. - Value *[]*TableServiceProperties `json:"value,omitempty" azure:"ro"` -} - -// ListTableServicesResponse is the response envelope for operations that return a ListTableServices type. -type ListTableServicesResponse struct { - ListTableServices *ListTableServices - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ManagementPoliciesCreateOrUpdateOptions contains the optional parameters for the ManagementPolicies.CreateOrUpdate method. -type ManagementPoliciesCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ManagementPoliciesDeleteOptions contains the optional parameters for the ManagementPolicies.Delete method. -type ManagementPoliciesDeleteOptions struct { - // placeholder for future optional parameters -} - -// ManagementPoliciesGetOptions contains the optional parameters for the ManagementPolicies.Get method. -type ManagementPoliciesGetOptions struct { - // placeholder for future optional parameters -} - -// ManagementPolicy - The Get Storage Account ManagementPolicies operation response. -type ManagementPolicy struct { - Resource - // Returns the Storage Account Data Policies Rules. - Properties *ManagementPolicyProperties `json:"properties,omitempty"` -} - -// 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"` - - // The management policy action for snapshot - Snapshot *ManagementPolicySnapShot `json:"snapshot,omitempty"` -} - -// ManagementPolicyBaseBlob - Management policy action for base blob. -type ManagementPolicyBaseBlob struct { - // The function to delete the blob - Delete *DateAfterModification `json:"delete,omitempty"` - - // The function to tier blobs to archive storage. Support blobs currently at Hot or Cool tier - TierToArchive *DateAfterModification `json:"tierToArchive,omitempty"` - - // The function to tier blobs to cool storage. Support blobs currently at Hot tier - TierToCool *DateAfterModification `json:"tierToCool,omitempty"` -} - -// ManagementPolicyDefinition - An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. -type ManagementPolicyDefinition struct { - // An object that defines the action set. - Actions *ManagementPolicyAction `json:"actions,omitempty"` - - // An object that defines the filter set. - Filters *ManagementPolicyFilter `json:"filters,omitempty"` -} - -// ManagementPolicyFilter - Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is -// performed on all filters. -type ManagementPolicyFilter struct { - // An array of blob index tag based filters, there can be at most 10 tag filters - BlobIndexMatch *[]*TagFilter `json:"blobIndexMatch,omitempty"` - - // An array of predefined enum values. Only blockBlob is supported. - BlobTypes *[]*string `json:"blobTypes,omitempty"` - - // An array of strings for prefixes to be match. - PrefixMatch *[]*string `json:"prefixMatch,omitempty"` -} - -// ManagementPolicyProperties - The Storage Account ManagementPolicy properties. -type ManagementPolicyProperties struct { - // READ-ONLY; Returns the date and time the ManagementPolicies was last modified. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - - // 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"` -} - -// MarshalJSON implements the json.Marshaller interface for type ManagementPolicyProperties. -func (m ManagementPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "lastModifiedTime", (*timeRFC3339)(m.LastModifiedTime)) - populate(objectMap, "policy", m.Policy) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ManagementPolicyProperties. -func (m *ManagementPolicyProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "lastModifiedTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - m.LastModifiedTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "policy": - err = unpopulate(val, &m.Policy) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// ManagementPolicyResponse is the response envelope for operations that return a ManagementPolicy type. -type ManagementPolicyResponse struct { - // The Get Storage Account ManagementPolicies operation response. - ManagementPolicy *ManagementPolicy - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ManagementPolicyRule - An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. -type ManagementPolicyRule struct { - // An object that defines the Lifecycle rule. - Definition *ManagementPolicyDefinition `json:"definition,omitempty"` - - // Rule is enabled if set to true. - Enabled *bool `json:"enabled,omitempty"` - - // 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"` - - // The valid value is Lifecycle - Type *RuleType `json:"type,omitempty"` -} - -// 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 { - // 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"` -} - -// ManagementPolicySnapShot - Management policy action for snapshot. -type ManagementPolicySnapShot struct { - // The function to delete the blob snapshot - Delete *DateAfterCreation `json:"delete,omitempty"` -} - -// MetricSpecification - Metric specification of operation. -type MetricSpecification struct { - // Aggregation type could be Average. - AggregationType *string `json:"aggregationType,omitempty"` - - // The category this metric specification belong to, could be Capacity. - Category *string `json:"category,omitempty"` - - // Dimensions of blobs, including blob type and access tier. - Dimensions *[]*Dimension `json:"dimensions,omitempty"` - - // Display description of metric specification. - DisplayDescription *string `json:"displayDescription,omitempty"` - - // Display name of metric specification. - DisplayName *string `json:"displayName,omitempty"` - - // The property to decide fill gap with zero or not. - FillGapWithZero *bool `json:"fillGapWithZero,omitempty"` - - // Name of metric specification. - Name *string `json:"name,omitempty"` - - // Account Resource Id. - ResourceIDDimensionNameOverride *string `json:"resourceIdDimensionNameOverride,omitempty"` - - // Unit could be Bytes or Count. - Unit *string `json:"unit,omitempty"` -} - -// NetworkRuleSet - Network rule set -type NetworkRuleSet struct { - // 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"` - - // Specifies the default action of allow or deny when no other rules match. - DefaultAction *DefaultAction `json:"defaultAction,omitempty"` - - // Sets the IP ACL rules - IPRules *[]*IPRule `json:"ipRules,omitempty"` - - // Sets the virtual network rules - VirtualNetworkRules *[]*VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` -} - -// ObjectReplicationPolicies - List storage account object replication policies. -type ObjectReplicationPolicies struct { - // The replication policy between two storage accounts. - Value *[]*ObjectReplicationPolicy `json:"value,omitempty"` -} - -// ObjectReplicationPoliciesCreateOrUpdateOptions contains the optional parameters for the ObjectReplicationPolicies.CreateOrUpdate method. -type ObjectReplicationPoliciesCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ObjectReplicationPoliciesDeleteOptions contains the optional parameters for the ObjectReplicationPolicies.Delete method. -type ObjectReplicationPoliciesDeleteOptions struct { - // placeholder for future optional parameters -} - -// ObjectReplicationPoliciesGetOptions contains the optional parameters for the ObjectReplicationPolicies.Get method. -type ObjectReplicationPoliciesGetOptions struct { - // placeholder for future optional parameters -} - -// ObjectReplicationPoliciesListOptions contains the optional parameters for the ObjectReplicationPolicies.List method. -type ObjectReplicationPoliciesListOptions struct { - // placeholder for future optional parameters -} - -// ObjectReplicationPoliciesResponse is the response envelope for operations that return a ObjectReplicationPolicies type. -type ObjectReplicationPoliciesResponse struct { - // List storage account object replication policies. - ObjectReplicationPolicies *ObjectReplicationPolicies - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ObjectReplicationPolicy - The replication policy between two storage accounts. Multiple rules can be defined in one policy. -type ObjectReplicationPolicy struct { - Resource - // Returns the Storage Account Object Replication Policy. - Properties *ObjectReplicationPolicyProperties `json:"properties,omitempty"` -} - -// ObjectReplicationPolicyFilter - Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the -// filter. If multiple filters are defined, a logical AND is performed on all -// filters. -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"` - - // Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. - PrefixMatch *[]*string `json:"prefixMatch,omitempty"` -} - -// ObjectReplicationPolicyProperties - The Storage Account ObjectReplicationPolicy properties. -type ObjectReplicationPolicyProperties struct { - // Required. Destination account name. - DestinationAccount *string `json:"destinationAccount,omitempty"` - - // READ-ONLY; Indicates when the policy is enabled on the source account. - EnabledTime *time.Time `json:"enabledTime,omitempty" azure:"ro"` - - // READ-ONLY; A unique id for object replication policy. - PolicyID *string `json:"policyId,omitempty" azure:"ro"` - - // The storage account object replication rules. - Rules *[]*ObjectReplicationPolicyRule `json:"rules,omitempty"` - - // Required. Source account name. - SourceAccount *string `json:"sourceAccount,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type ObjectReplicationPolicyProperties. -func (o ObjectReplicationPolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "destinationAccount", o.DestinationAccount) - populate(objectMap, "enabledTime", (*timeRFC3339)(o.EnabledTime)) - populate(objectMap, "policyId", o.PolicyID) - populate(objectMap, "rules", o.Rules) - populate(objectMap, "sourceAccount", o.SourceAccount) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ObjectReplicationPolicyProperties. -func (o *ObjectReplicationPolicyProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "destinationAccount": - err = unpopulate(val, &o.DestinationAccount) - delete(rawMsg, key) - case "enabledTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - o.EnabledTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "policyId": - err = unpopulate(val, &o.PolicyID) - delete(rawMsg, key) - case "rules": - err = unpopulate(val, &o.Rules) - delete(rawMsg, key) - case "sourceAccount": - err = unpopulate(val, &o.SourceAccount) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// ObjectReplicationPolicyResponse is the response envelope for operations that return a ObjectReplicationPolicy type. -type ObjectReplicationPolicyResponse struct { - // The replication policy between two storage accounts. Multiple rules can be defined in one policy. - ObjectReplicationPolicy *ObjectReplicationPolicy - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// ObjectReplicationPolicyRule - The replication policy rule between two containers. -type ObjectReplicationPolicyRule struct { - // Required. Destination container name. - DestinationContainer *string `json:"destinationContainer,omitempty"` - - // Optional. An object that defines the filter set. - Filters *ObjectReplicationPolicyFilter `json:"filters,omitempty"` - - // 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"` - - // Required. Source container name. - SourceContainer *string `json:"sourceContainer,omitempty"` -} - -// Operation - Storage REST API operation definition. -type Operation struct { - // Display metadata associated with the operation. - Display *OperationDisplay `json:"display,omitempty"` - - // Operation name: {provider}/{resource}/{operation} - Name *string `json:"name,omitempty"` - - // Properties of operation, include metric specifications. - OperationProperties *OperationProperties `json:"properties,omitempty"` - - // The origin of operations. - Origin *string `json:"origin,omitempty"` -} - -// OperationDisplay - Display metadata associated with the operation. -type OperationDisplay struct { - // Description of the operation. - Description *string `json:"description,omitempty"` - - // Type of operation: get, read, delete, etc. - Operation *string `json:"operation,omitempty"` - - // Service provider: Microsoft Storage. - Provider *string `json:"provider,omitempty"` - - // Resource on which the operation is performed etc. - Resource *string `json:"resource,omitempty"` -} - -// 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"` -} - -// OperationListResultResponse is the response envelope for operations that return a OperationListResult type. -type OperationListResultResponse struct { - // 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. - OperationListResult *OperationListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// OperationProperties - Properties of operation, include metric specifications. -type OperationProperties struct { - // One property of operation, include metric specifications. - ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` -} - -// OperationsListOptions contains the optional parameters for the Operations.List method. -type OperationsListOptions struct { - // placeholder for future optional parameters -} - -// PrivateEndpoint - The Private Endpoint resource. -type PrivateEndpoint struct { - // READ-ONLY; The ARM identifier for Private Endpoint - ID *string `json:"id,omitempty" azure:"ro"` -} - -// PrivateEndpointConnection - The Private Endpoint Connection resource. -type PrivateEndpointConnection struct { - Resource - // Resource properties. - Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` -} - -// 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"` -} - -// PrivateEndpointConnectionListResultResponse is the response envelope for operations that return a PrivateEndpointConnectionListResult type. -type PrivateEndpointConnectionListResultResponse struct { - // List of private endpoint connection associated with the specified storage account - PrivateEndpointConnectionListResult *PrivateEndpointConnectionListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// PrivateEndpointConnectionProperties - Properties of the PrivateEndpointConnectProperties. -type PrivateEndpointConnectionProperties struct { - // The resource of private end point. - PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - - // A collection of information about the state of the connection between service consumer and provider. - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - - // READ-ONLY; The provisioning state of the private endpoint connection resource. - ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` -} - -// PrivateEndpointConnectionResponse is the response envelope for operations that return a PrivateEndpointConnection type. -type PrivateEndpointConnectionResponse struct { - // The Private Endpoint Connection resource. - PrivateEndpointConnection *PrivateEndpointConnection - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// PrivateEndpointConnectionsDeleteOptions contains the optional parameters for the PrivateEndpointConnections.Delete method. -type PrivateEndpointConnectionsDeleteOptions struct { - // placeholder for future optional parameters -} - -// PrivateEndpointConnectionsGetOptions contains the optional parameters for the PrivateEndpointConnections.Get method. -type PrivateEndpointConnectionsGetOptions struct { - // placeholder for future optional parameters -} - -// PrivateEndpointConnectionsListOptions contains the optional parameters for the PrivateEndpointConnections.List method. -type PrivateEndpointConnectionsListOptions struct { - // placeholder for future optional parameters -} - -// PrivateEndpointConnectionsPutOptions contains the optional parameters for the PrivateEndpointConnections.Put method. -type PrivateEndpointConnectionsPutOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkResource - A private link resource -type PrivateLinkResource struct { - Resource - // Resource properties. - Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` -} - -// PrivateLinkResourceListResult - A list of private link resources -type PrivateLinkResourceListResult struct { - // Array of private link resources - Value *[]*PrivateLinkResource `json:"value,omitempty"` -} - -// PrivateLinkResourceListResultResponse is the response envelope for operations that return a PrivateLinkResourceListResult type. -type PrivateLinkResourceListResultResponse struct { - // A list of private link resources - PrivateLinkResourceListResult *PrivateLinkResourceListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// PrivateLinkResourceProperties - Properties of a private link resource. -type PrivateLinkResourceProperties struct { - // READ-ONLY; The private link resource group id. - GroupID *string `json:"groupId,omitempty" azure:"ro"` - - // READ-ONLY; The private link resource required member names. - RequiredMembers *[]*string `json:"requiredMembers,omitempty" azure:"ro"` - - // The private link resource Private link DNS zone name. - RequiredZoneNames *[]*string `json:"requiredZoneNames,omitempty"` -} - -// PrivateLinkResourcesListByStorageAccountOptions contains the optional parameters for the PrivateLinkResources.ListByStorageAccount method. -type PrivateLinkResourcesListByStorageAccountOptions struct { - // placeholder for future optional parameters -} - -// PrivateLinkServiceConnectionState - A collection of information about the state of the connection between service consumer 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"` - - // The reason for approval/rejection of the connection. - Description *string `json:"description,omitempty"` - - // Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. - Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` -} - -// QueueCreateOptions contains the optional parameters for the Queue.Create method. -type QueueCreateOptions struct { - // placeholder for future optional parameters -} - -// QueueDeleteOptions contains the optional parameters for the Queue.Delete method. -type QueueDeleteOptions struct { - // placeholder for future optional parameters -} - -// QueueGetOptions contains the optional parameters for the Queue.Get method. -type QueueGetOptions struct { - // placeholder for future optional parameters -} - -// QueueListOptions contains the optional parameters for the Queue.List method. -type QueueListOptions struct { - // Optional, When specified, only the queues with a name starting with the given filter will be listed. - Filter *string - // Optional, a maximum number of queues that should be included in a list queue response - Maxpagesize *string -} - -type QueueProperties struct { - // 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"` - - // A name-value pair that represents queue metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` -} - -// QueueServiceProperties - The properties of a storage account’s Queue service. -type QueueServiceProperties struct { - Resource - // The properties of a storage account’s Queue service. - QueueServiceProperties *QueueServicePropertiesAutoGenerated `json:"properties,omitempty"` -} - -// QueueServicePropertiesAutoGenerated - The properties of a storage account’s Queue service. -type QueueServicePropertiesAutoGenerated 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"` -} - -// QueueServicePropertiesResponse is the response envelope for operations that return a QueueServiceProperties type. -type QueueServicePropertiesResponse struct { - // The properties of a storage account’s Queue service. - QueueServiceProperties *QueueServiceProperties - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// QueueServicesGetServicePropertiesOptions contains the optional parameters for the QueueServices.GetServiceProperties method. -type QueueServicesGetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// QueueServicesListOptions contains the optional parameters for the QueueServices.List method. -type QueueServicesListOptions struct { - // placeholder for future optional parameters -} - -// QueueServicesSetServicePropertiesOptions contains the optional parameters for the QueueServices.SetServiceProperties method. -type QueueServicesSetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// QueueUpdateOptions contains the optional parameters for the Queue.Update method. -type QueueUpdateOptions struct { - // placeholder for future optional parameters -} - -// Resource - Common fields that are returned in the response for all Azure Resource Manager resources -type Resource struct { - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` - - // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` -} - -func (r Resource) marshalInternal() map[string]interface{} { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", r.ID) - populate(objectMap, "name", r.Name) - populate(objectMap, "type", r.Type) - return objectMap -} - -// RestorePolicyProperties - The blob service properties for blob restore policy -type RestorePolicyProperties struct { - // how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. - Days *int32 `json:"days,omitempty"` - - // Blob restore is enabled if set to true. - Enabled *bool `json:"enabled,omitempty"` - - // READ-ONLY; Deprecated in favor of minRestoreTime property. - LastEnabledTime *time.Time `json:"lastEnabledTime,omitempty" azure:"ro"` - - // READ-ONLY; Returns the minimum date and time that the restore can be started. - MinRestoreTime *time.Time `json:"minRestoreTime,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type RestorePolicyProperties. -func (r RestorePolicyProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "days", r.Days) - populate(objectMap, "enabled", r.Enabled) - populate(objectMap, "lastEnabledTime", (*timeRFC3339)(r.LastEnabledTime)) - populate(objectMap, "minRestoreTime", (*timeRFC3339)(r.MinRestoreTime)) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type RestorePolicyProperties. -func (r *RestorePolicyProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "days": - err = unpopulate(val, &r.Days) - delete(rawMsg, key) - case "enabled": - err = unpopulate(val, &r.Enabled) - delete(rawMsg, key) - case "lastEnabledTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - r.LastEnabledTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "minRestoreTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - r.MinRestoreTime = (*time.Time)(&aux) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// Restriction - The restriction because of which SKU cannot be used. -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"` - - // READ-ONLY; The type of restrictions. As of now only possible value for this is location. - Type *string `json:"type,omitempty" azure:"ro"` - - // 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"` -} - -// 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"` - - // A boolean flag which indicates whether microsoft routing storage endpoints are to be published - PublishMicrosoftEndpoints *bool `json:"publishMicrosoftEndpoints,omitempty"` - - // Routing Choice defines the kind of network routing opted by the user. - RoutingChoice *RoutingChoice `json:"routingChoice,omitempty"` -} - -// SKU - The SKU of the storage account. -type SKU struct { - // 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"` - - // READ-ONLY; The SKU tier. This is based on the SKU name. - Tier *SKUTier `json:"tier,omitempty" azure:"ro"` -} - -// SKUCapability - The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. -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"` - - // READ-ONLY; A string value to indicate states of given capability. Possibly 'true' or 'false'. - Value *string `json:"value,omitempty" azure:"ro"` -} - -// SKUInformation - Storage SKU and its properties -type SKUInformation struct { - // READ-ONLY; The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. - Capabilities *[]*SKUCapability `json:"capabilities,omitempty" azure:"ro"` - - // READ-ONLY; Indicates the type of storage account. - Kind *Kind `json:"kind,omitempty" azure:"ro"` - - // 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"` - - // 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"` - - // READ-ONLY; The type of the resource, usually it is 'storageAccounts'. - ResourceType *string `json:"resourceType,omitempty" azure:"ro"` - - // The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. - Restrictions *[]*Restriction `json:"restrictions,omitempty"` - - // READ-ONLY; The SKU tier. This is based on the SKU name. - Tier *SKUTier `json:"tier,omitempty" azure:"ro"` -} - -// SKUsListOptions contains the optional parameters for the SKUs.List method. -type SKUsListOptions struct { - // placeholder for future optional parameters -} - -// ServiceSasParameters - The parameters to list service SAS credentials of a specific resource. -type ServiceSasParameters struct { - // The response header override for cache control. - CacheControl *string `json:"rscc,omitempty"` - - // The canonical path to the signed resource. - CanonicalizedResource *string `json:"canonicalizedResource,omitempty"` - - // The response header override for content disposition. - ContentDisposition *string `json:"rscd,omitempty"` - - // The response header override for content encoding. - ContentEncoding *string `json:"rsce,omitempty"` - - // The response header override for content language. - ContentLanguage *string `json:"rscl,omitempty"` - - // The response header override for content type. - ContentType *string `json:"rsct,omitempty"` - - // An IP address or a range of IP addresses from which to accept requests. - IPAddressOrRange *string `json:"signedIp,omitempty"` - - // 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"` - - // The key to sign the account SAS token with. - KeyToSign *string `json:"keyToSign,omitempty"` - - // The end of partition key. - PartitionKeyEnd *string `json:"endPk,omitempty"` - - // The start of partition key. - PartitionKeyStart *string `json:"startPk,omitempty"` - - // 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"` - - // The protocol permitted for a request made with the account SAS. - Protocols *HTTPProtocol `json:"signedProtocol,omitempty"` - - // The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). - Resource *SignedResource `json:"signedResource,omitempty"` - - // The end of row key. - RowKeyEnd *string `json:"endRk,omitempty"` - - // The start of row key. - RowKeyStart *string `json:"startRk,omitempty"` - - // The time at which the shared access signature becomes invalid. - SharedAccessExpiryTime *time.Time `json:"signedExpiry,omitempty"` - - // The time at which the SAS becomes valid. - SharedAccessStartTime *time.Time `json:"signedStart,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type ServiceSasParameters. -func (s ServiceSasParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "rscc", s.CacheControl) - populate(objectMap, "canonicalizedResource", s.CanonicalizedResource) - populate(objectMap, "rscd", s.ContentDisposition) - populate(objectMap, "rsce", s.ContentEncoding) - populate(objectMap, "rscl", s.ContentLanguage) - populate(objectMap, "rsct", s.ContentType) - populate(objectMap, "signedIp", s.IPAddressOrRange) - populate(objectMap, "signedIdentifier", s.Identifier) - populate(objectMap, "keyToSign", s.KeyToSign) - populate(objectMap, "endPk", s.PartitionKeyEnd) - populate(objectMap, "startPk", s.PartitionKeyStart) - populate(objectMap, "signedPermission", s.Permissions) - populate(objectMap, "signedProtocol", s.Protocols) - populate(objectMap, "signedResource", s.Resource) - populate(objectMap, "endRk", s.RowKeyEnd) - populate(objectMap, "startRk", s.RowKeyStart) - populate(objectMap, "signedExpiry", (*timeRFC3339)(s.SharedAccessExpiryTime)) - populate(objectMap, "signedStart", (*timeRFC3339)(s.SharedAccessStartTime)) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ServiceSasParameters. -func (s *ServiceSasParameters) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "rscc": - err = unpopulate(val, &s.CacheControl) - delete(rawMsg, key) - case "canonicalizedResource": - err = unpopulate(val, &s.CanonicalizedResource) - delete(rawMsg, key) - case "rscd": - err = unpopulate(val, &s.ContentDisposition) - delete(rawMsg, key) - case "rsce": - err = unpopulate(val, &s.ContentEncoding) - delete(rawMsg, key) - case "rscl": - err = unpopulate(val, &s.ContentLanguage) - delete(rawMsg, key) - case "rsct": - err = unpopulate(val, &s.ContentType) - delete(rawMsg, key) - case "signedIp": - err = unpopulate(val, &s.IPAddressOrRange) - delete(rawMsg, key) - case "signedIdentifier": - err = unpopulate(val, &s.Identifier) - delete(rawMsg, key) - case "keyToSign": - err = unpopulate(val, &s.KeyToSign) - delete(rawMsg, key) - case "endPk": - err = unpopulate(val, &s.PartitionKeyEnd) - delete(rawMsg, key) - case "startPk": - err = unpopulate(val, &s.PartitionKeyStart) - delete(rawMsg, key) - case "signedPermission": - err = unpopulate(val, &s.Permissions) - delete(rawMsg, key) - case "signedProtocol": - err = unpopulate(val, &s.Protocols) - delete(rawMsg, key) - case "signedResource": - err = unpopulate(val, &s.Resource) - delete(rawMsg, key) - case "endRk": - err = unpopulate(val, &s.RowKeyEnd) - delete(rawMsg, key) - case "startRk": - err = unpopulate(val, &s.RowKeyStart) - delete(rawMsg, key) - case "signedExpiry": - var aux timeRFC3339 - err = unpopulate(val, &aux) - s.SharedAccessExpiryTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "signedStart": - var aux timeRFC3339 - err = unpopulate(val, &aux) - s.SharedAccessStartTime = (*time.Time)(&aux) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// ServiceSpecification - One property of operation, include metric specifications. -type ServiceSpecification struct { - // Metric specifications of operation. - MetricSpecifications *[]*MetricSpecification `json:"metricSpecifications,omitempty"` -} - -// StorageAccount - The storage account. -type StorageAccount struct { - TrackedResource - // The identity of the resource. - Identity *Identity `json:"identity,omitempty"` - - // READ-ONLY; Gets the Kind. - Kind *Kind `json:"kind,omitempty" azure:"ro"` - - // Properties of the storage account. - Properties *StorageAccountProperties `json:"properties,omitempty"` - - // READ-ONLY; Gets the SKU. - SKU *SKU `json:"sku,omitempty" azure:"ro"` -} - -// StorageAccountCheckNameAvailabilityParameters - The parameters used to check the availability of the storage account name. -type StorageAccountCheckNameAvailabilityParameters struct { - // The storage account name. - Name *string `json:"name,omitempty"` - - // The type of resource, Microsoft.Storage/storageAccounts - Type *string `json:"type,omitempty"` -} - -// StorageAccountCreateParameters - The parameters used when creating a storage account. -type StorageAccountCreateParameters struct { - // The identity of the resource. - Identity *Identity `json:"identity,omitempty"` - - // Required. Indicates the type of storage account. - Kind *Kind `json:"kind,omitempty"` - - // 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"` - - // The parameters used to create the storage account. - Properties *StorageAccountPropertiesCreateParameters `json:"properties,omitempty"` - - // Required. Gets or sets the SKU name. - SKU *SKU `json:"sku,omitempty"` - - // 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"` -} - -// StorageAccountInternetEndpoints - The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. -type StorageAccountInternetEndpoints struct { - // READ-ONLY; Gets the blob endpoint. - Blob *string `json:"blob,omitempty" azure:"ro"` - - // READ-ONLY; Gets the dfs endpoint. - Dfs *string `json:"dfs,omitempty" azure:"ro"` - - // READ-ONLY; Gets the file endpoint. - File *string `json:"file,omitempty" azure:"ro"` - - // READ-ONLY; Gets the web endpoint. - Web *string `json:"web,omitempty" azure:"ro"` -} - -// StorageAccountKey - An access key for the storage account. -type StorageAccountKey struct { - // READ-ONLY; Name of the key. - KeyName *string `json:"keyName,omitempty" azure:"ro"` - - // READ-ONLY; Permissions for the key -- read-only or full permissions. - Permissions *KeyPermission `json:"permissions,omitempty" azure:"ro"` - - // READ-ONLY; Base 64-encoded value of the key. - Value *string `json:"value,omitempty" azure:"ro"` -} - -// StorageAccountListKeysResult - The response from the ListKeys operation. -type StorageAccountListKeysResult struct { - // READ-ONLY; Gets the list of storage account keys and their properties for the specified storage account. - Keys *[]*StorageAccountKey `json:"keys,omitempty" azure:"ro"` -} - -// StorageAccountListKeysResultResponse is the response envelope for operations that return a StorageAccountListKeysResult type. -type StorageAccountListKeysResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the ListKeys operation. - StorageAccountListKeysResult *StorageAccountListKeysResult -} - -// StorageAccountListResult - The response from the List Storage Accounts operation. -type StorageAccountListResult 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"` - - // READ-ONLY; Gets the list of storage accounts and their properties. - Value *[]*StorageAccount `json:"value,omitempty" azure:"ro"` -} - -// StorageAccountListResultResponse is the response envelope for operations that return a StorageAccountListResult type. -type StorageAccountListResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the List Storage Accounts operation. - StorageAccountListResult *StorageAccountListResult -} - -// StorageAccountMicrosoftEndpoints - 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 StorageAccountMicrosoftEndpoints struct { - // READ-ONLY; Gets the blob endpoint. - Blob *string `json:"blob,omitempty" azure:"ro"` - - // READ-ONLY; Gets the dfs endpoint. - Dfs *string `json:"dfs,omitempty" azure:"ro"` - - // READ-ONLY; Gets the file endpoint. - File *string `json:"file,omitempty" azure:"ro"` - - // READ-ONLY; Gets the queue endpoint. - Queue *string `json:"queue,omitempty" azure:"ro"` - - // READ-ONLY; Gets the table endpoint. - Table *string `json:"table,omitempty" azure:"ro"` - - // READ-ONLY; Gets the web endpoint. - Web *string `json:"web,omitempty" azure:"ro"` -} - -// StorageAccountPollerResponse is the response envelope for operations that asynchronously return a StorageAccount type. -type StorageAccountPollerResponse struct { - // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received - PollUntilDone func(ctx context.Context, frequency time.Duration) (StorageAccountResponse, error) - - // Poller contains an initialized poller. - Poller StorageAccountPoller - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// StorageAccountProperties - Properties of the storage account. -type StorageAccountProperties struct { - // READ-ONLY; Required for storage accounts where kind = BlobStorage. The access tier used for billing. - AccessTier *AccessTier `json:"accessTier,omitempty" azure:"ro"` - - // 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"` - - // Provides the identity based authentication settings for Azure Files. - AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication `json:"azureFilesIdentityBasedAuthentication,omitempty"` - - // READ-ONLY; Blob restore status - BlobRestoreStatus *BlobRestoreStatus `json:"blobRestoreStatus,omitempty" azure:"ro"` - - // READ-ONLY; Gets the creation date and time of the storage account in UTC. - CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` - - // READ-ONLY; Gets the custom domain the user assigned to this storage account. - CustomDomain *CustomDomain `json:"customDomain,omitempty" azure:"ro"` - - // Allows https traffic only to storage service if sets to true. - EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` - - // READ-ONLY; Gets the encryption settings on the account. If unspecified, the account is unencrypted. - Encryption *Encryption `json:"encryption,omitempty" azure:"ro"` - - // 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"` - - // READ-ONLY; Geo Replication Stats - GeoReplicationStats *GeoReplicationStats `json:"geoReplicationStats,omitempty" azure:"ro"` - - // Account HierarchicalNamespace enabled if sets to true. - IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"` - - // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` - - // 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"` - - // 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"` - - // READ-ONLY; Network rule set - NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty" azure:"ro"` - - // 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"` - - // READ-ONLY; Gets the location of the primary data center for the storage account. - PrimaryLocation *string `json:"primaryLocation,omitempty" azure:"ro"` - - // READ-ONLY; List of private endpoint connection associated with the specified storage account - PrivateEndpointConnections *[]*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` - - // READ-ONLY; Gets the status of the storage account at the time the operation was called. - ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - - // Maintains information about the network routing choice opted by the user for data transfer - RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` - - // 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"` - - // 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"` - - // 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"` - - // 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"` -} - -// MarshalJSON implements the json.Marshaller interface for type StorageAccountProperties. -func (s StorageAccountProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accessTier", s.AccessTier) - populate(objectMap, "allowBlobPublicAccess", s.AllowBlobPublicAccess) - populate(objectMap, "azureFilesIdentityBasedAuthentication", s.AzureFilesIdentityBasedAuthentication) - populate(objectMap, "blobRestoreStatus", s.BlobRestoreStatus) - populate(objectMap, "creationTime", (*timeRFC3339)(s.CreationTime)) - populate(objectMap, "customDomain", s.CustomDomain) - populate(objectMap, "supportsHttpsTrafficOnly", s.EnableHTTPSTrafficOnly) - populate(objectMap, "encryption", s.Encryption) - populate(objectMap, "failoverInProgress", s.FailoverInProgress) - populate(objectMap, "geoReplicationStats", s.GeoReplicationStats) - populate(objectMap, "isHnsEnabled", s.IsHnsEnabled) - populate(objectMap, "largeFileSharesState", s.LargeFileSharesState) - populate(objectMap, "lastGeoFailoverTime", (*timeRFC3339)(s.LastGeoFailoverTime)) - populate(objectMap, "minimumTlsVersion", s.MinimumTLSVersion) - populate(objectMap, "networkAcls", s.NetworkRuleSet) - populate(objectMap, "primaryEndpoints", s.PrimaryEndpoints) - populate(objectMap, "primaryLocation", s.PrimaryLocation) - populate(objectMap, "privateEndpointConnections", s.PrivateEndpointConnections) - populate(objectMap, "provisioningState", s.ProvisioningState) - populate(objectMap, "routingPreference", s.RoutingPreference) - populate(objectMap, "secondaryEndpoints", s.SecondaryEndpoints) - populate(objectMap, "secondaryLocation", s.SecondaryLocation) - populate(objectMap, "statusOfPrimary", s.StatusOfPrimary) - populate(objectMap, "statusOfSecondary", s.StatusOfSecondary) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type StorageAccountProperties. -func (s *StorageAccountProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "accessTier": - err = unpopulate(val, &s.AccessTier) - delete(rawMsg, key) - case "allowBlobPublicAccess": - err = unpopulate(val, &s.AllowBlobPublicAccess) - delete(rawMsg, key) - case "azureFilesIdentityBasedAuthentication": - err = unpopulate(val, &s.AzureFilesIdentityBasedAuthentication) - delete(rawMsg, key) - case "blobRestoreStatus": - err = unpopulate(val, &s.BlobRestoreStatus) - delete(rawMsg, key) - case "creationTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - s.CreationTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "customDomain": - err = unpopulate(val, &s.CustomDomain) - delete(rawMsg, key) - case "supportsHttpsTrafficOnly": - err = unpopulate(val, &s.EnableHTTPSTrafficOnly) - delete(rawMsg, key) - case "encryption": - err = unpopulate(val, &s.Encryption) - delete(rawMsg, key) - case "failoverInProgress": - err = unpopulate(val, &s.FailoverInProgress) - delete(rawMsg, key) - case "geoReplicationStats": - err = unpopulate(val, &s.GeoReplicationStats) - delete(rawMsg, key) - case "isHnsEnabled": - err = unpopulate(val, &s.IsHnsEnabled) - delete(rawMsg, key) - case "largeFileSharesState": - err = unpopulate(val, &s.LargeFileSharesState) - delete(rawMsg, key) - case "lastGeoFailoverTime": - var aux timeRFC3339 - err = unpopulate(val, &aux) - s.LastGeoFailoverTime = (*time.Time)(&aux) - delete(rawMsg, key) - case "minimumTlsVersion": - err = unpopulate(val, &s.MinimumTLSVersion) - delete(rawMsg, key) - case "networkAcls": - err = unpopulate(val, &s.NetworkRuleSet) - delete(rawMsg, key) - case "primaryEndpoints": - err = unpopulate(val, &s.PrimaryEndpoints) - delete(rawMsg, key) - case "primaryLocation": - err = unpopulate(val, &s.PrimaryLocation) - delete(rawMsg, key) - case "privateEndpointConnections": - err = unpopulate(val, &s.PrivateEndpointConnections) - delete(rawMsg, key) - case "provisioningState": - err = unpopulate(val, &s.ProvisioningState) - delete(rawMsg, key) - case "routingPreference": - err = unpopulate(val, &s.RoutingPreference) - delete(rawMsg, key) - case "secondaryEndpoints": - err = unpopulate(val, &s.SecondaryEndpoints) - delete(rawMsg, key) - case "secondaryLocation": - err = unpopulate(val, &s.SecondaryLocation) - delete(rawMsg, key) - case "statusOfPrimary": - err = unpopulate(val, &s.StatusOfPrimary) - delete(rawMsg, key) - case "statusOfSecondary": - err = unpopulate(val, &s.StatusOfSecondary) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// StorageAccountPropertiesCreateParameters - The parameters used to create the storage account. -type StorageAccountPropertiesCreateParameters struct { - // Required for storage accounts where kind = BlobStorage. The access tier used for billing. - AccessTier *AccessTier `json:"accessTier,omitempty"` - - // 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"` - - // Provides the identity based authentication settings for Azure Files. - AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication `json:"azureFilesIdentityBasedAuthentication,omitempty"` - - // 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"` - - // 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"` - - // Not applicable. Azure Storage encryption is enabled for all storage accounts and cannot be disabled. - Encryption *Encryption `json:"encryption,omitempty"` - - // Account HierarchicalNamespace enabled if sets to true. - IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"` - - // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` - - // 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"` - - // Network rule set - NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty"` - - // Maintains information about the network routing choice opted by the user for data transfer - RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` -} - -// StorageAccountPropertiesUpdateParameters - The parameters used when updating a storage account. -type StorageAccountPropertiesUpdateParameters struct { - // Required for storage accounts where kind = BlobStorage. The access tier used for billing. - AccessTier *AccessTier `json:"accessTier,omitempty"` - - // 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"` - - // Provides the identity based authentication settings for Azure Files. - AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication `json:"azureFilesIdentityBasedAuthentication,omitempty"` - - // 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"` - - // Allows https traffic only to storage service if sets to true. - EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` - - // Provides the encryption settings on the account. The default setting is unencrypted. - Encryption *Encryption `json:"encryption,omitempty"` - - // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` - - // 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"` - - // Network rule set - NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty"` - - // Maintains information about the network routing choice opted by the user for data transfer - RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` -} - -// StorageAccountRegenerateKeyParameters - The parameters used to regenerate the storage account key. -type StorageAccountRegenerateKeyParameters struct { - // The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. - KeyName *string `json:"keyName,omitempty"` -} - -// StorageAccountResponse is the response envelope for operations that return a StorageAccount type. -type StorageAccountResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The storage account. - StorageAccount *StorageAccount -} - -// StorageAccountUpdateParameters - The parameters that can be provided when updating the storage account properties. -type StorageAccountUpdateParameters struct { - // The identity of the resource. - Identity *Identity `json:"identity,omitempty"` - - // Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. - Kind *Kind `json:"kind,omitempty"` - - // The parameters used when updating a storage account. - Properties *StorageAccountPropertiesUpdateParameters `json:"properties,omitempty"` - - // 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"` - - // 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"` -} - -// MarshalJSON implements the json.Marshaller interface for type StorageAccountUpdateParameters. -func (s StorageAccountUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "identity", s.Identity) - populate(objectMap, "kind", s.Kind) - populate(objectMap, "properties", s.Properties) - populate(objectMap, "sku", s.SKU) - populate(objectMap, "tags", s.Tags) - return json.Marshal(objectMap) -} - -// StorageAccountsBeginCreateOptions contains the optional parameters for the StorageAccounts.BeginCreate method. -type StorageAccountsBeginCreateOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsBeginFailoverOptions contains the optional parameters for the StorageAccounts.BeginFailover method. -type StorageAccountsBeginFailoverOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsBeginRestoreBlobRangesOptions contains the optional parameters for the StorageAccounts.BeginRestoreBlobRanges method. -type StorageAccountsBeginRestoreBlobRangesOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsCheckNameAvailabilityOptions contains the optional parameters for the StorageAccounts.CheckNameAvailability method. -type StorageAccountsCheckNameAvailabilityOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsDeleteOptions contains the optional parameters for the StorageAccounts.Delete method. -type StorageAccountsDeleteOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsGetPropertiesOptions contains the optional parameters for the StorageAccounts.GetProperties method. -type StorageAccountsGetPropertiesOptions struct { - // May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support - // geoReplicationStats and blobRestoreStatus. - Expand *StorageAccountExpand -} - -// StorageAccountsListAccountSASOptions contains the optional parameters for the StorageAccounts.ListAccountSAS method. -type StorageAccountsListAccountSASOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsListByResourceGroupOptions contains the optional parameters for the StorageAccounts.ListByResourceGroup method. -type StorageAccountsListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsListKeysOptions contains the optional parameters for the StorageAccounts.ListKeys method. -type StorageAccountsListKeysOptions struct { - // Specifies type of the key to be listed. Possible value is kerb. - Expand *string -} - -// StorageAccountsListOptions contains the optional parameters for the StorageAccounts.List method. -type StorageAccountsListOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsListServiceSASOptions contains the optional parameters for the StorageAccounts.ListServiceSAS method. -type StorageAccountsListServiceSASOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsRegenerateKeyOptions contains the optional parameters for the StorageAccounts.RegenerateKey method. -type StorageAccountsRegenerateKeyOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsRevokeUserDelegationKeysOptions contains the optional parameters for the StorageAccounts.RevokeUserDelegationKeys method. -type StorageAccountsRevokeUserDelegationKeysOptions struct { - // placeholder for future optional parameters -} - -// StorageAccountsUpdateOptions contains the optional parameters for the StorageAccounts.Update method. -type StorageAccountsUpdateOptions struct { - // placeholder for future optional parameters -} - -type StorageQueue struct { - Resource - // Queue resource properties. - QueueProperties *QueueProperties `json:"properties,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type StorageQueue. -func (s StorageQueue) MarshalJSON() ([]byte, error) { - objectMap := s.Resource.marshalInternal() - populate(objectMap, "properties", s.QueueProperties) - return json.Marshal(objectMap) -} - -// StorageQueueResponse is the response envelope for operations that return a StorageQueue type. -type StorageQueueResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - StorageQueue *StorageQueue -} - -// StorageSKUListResult - The response from the List Storage SKUs operation. -type StorageSKUListResult struct { - // READ-ONLY; Get the list result of storage SKUs and their properties. - Value *[]*SKUInformation `json:"value,omitempty" azure:"ro"` -} - -// StorageSKUListResultResponse is the response envelope for operations that return a StorageSKUListResult type. -type StorageSKUListResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the List Storage SKUs operation. - StorageSKUListResult *StorageSKUListResult -} - -// Table - Properties of the table, including Id, resource name, resource type. -type Table struct { - Resource - // Table resource properties. - TableProperties *TableProperties `json:"properties,omitempty"` -} - -// TableCreateOptions contains the optional parameters for the Table.Create method. -type TableCreateOptions struct { - // placeholder for future optional parameters -} - -// TableDeleteOptions contains the optional parameters for the Table.Delete method. -type TableDeleteOptions struct { - // placeholder for future optional parameters -} - -// TableGetOptions contains the optional parameters for the Table.Get method. -type TableGetOptions struct { - // placeholder for future optional parameters -} - -// TableListOptions contains the optional parameters for the Table.List method. -type TableListOptions struct { - // placeholder for future optional parameters -} - -type TableProperties struct { - // READ-ONLY; Table name under the specified account - TableName *string `json:"tableName,omitempty" azure:"ro"` -} - -// TableResponse is the response envelope for operations that return a Table type. -type TableResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // Properties of the table, including Id, resource name, resource type. - Table *Table -} - -// TableServiceProperties - The properties of a storage account’s Table service. -type TableServiceProperties struct { - Resource - // The properties of a storage account’s Table service. - TableServiceProperties *TableServicePropertiesAutoGenerated `json:"properties,omitempty"` -} - -// TableServicePropertiesAutoGenerated - The properties of a storage account’s Table service. -type TableServicePropertiesAutoGenerated 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"` -} - -// TableServicePropertiesResponse is the response envelope for operations that return a TableServiceProperties type. -type TableServicePropertiesResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The properties of a storage account’s Table service. - TableServiceProperties *TableServiceProperties -} - -// TableServicesGetServicePropertiesOptions contains the optional parameters for the TableServices.GetServiceProperties method. -type TableServicesGetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// TableServicesListOptions contains the optional parameters for the TableServices.List method. -type TableServicesListOptions struct { - // placeholder for future optional parameters -} - -// TableServicesSetServicePropertiesOptions contains the optional parameters for the TableServices.SetServiceProperties method. -type TableServicesSetServicePropertiesOptions struct { - // placeholder for future optional parameters -} - -// TableUpdateOptions contains the optional parameters for the Table.Update method. -type TableUpdateOptions struct { - // placeholder for future optional parameters -} - -// TagFilter - Blob index tag based filtering for blob objects -type TagFilter struct { - // This is the filter tag name, it can have 1 - 128 characters - Name *string `json:"name,omitempty"` - - // This is the comparison operator which is used for object comparison and filtering. Only == (equality operator) is currently supported - Op *string `json:"op,omitempty"` - - // This is the filter tag value field used for tag based filtering, it can have 0 - 256 characters - Value *string `json:"value,omitempty"` -} - -// 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"` - - // READ-ONLY; The tag value. - Tag *string `json:"tag,omitempty" azure:"ro"` - - // READ-ONLY; Returns the Tenant ID that issued the token for the user who added the tag. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` - - // READ-ONLY; Returns the date and time the tag was added. - Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` - - // READ-ONLY; Returns the User Principal Name of the user who added the tag. - Upn *string `json:"upn,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type TagProperty. -func (t TagProperty) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "objectIdentifier", t.ObjectIdentifier) - populate(objectMap, "tag", t.Tag) - populate(objectMap, "tenantId", t.TenantID) - populate(objectMap, "timestamp", (*timeRFC3339)(t.Timestamp)) - populate(objectMap, "upn", t.Upn) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type TagProperty. -func (t *TagProperty) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "objectIdentifier": - err = unpopulate(val, &t.ObjectIdentifier) - delete(rawMsg, key) - case "tag": - err = unpopulate(val, &t.Tag) - delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, &t.TenantID) - delete(rawMsg, key) - case "timestamp": - var aux timeRFC3339 - err = unpopulate(val, &aux) - t.Timestamp = (*time.Time)(&aux) - delete(rawMsg, key) - case "upn": - err = unpopulate(val, &t.Upn) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' -type TrackedResource struct { - Resource - // The geo-location where the resource lives - Location *string `json:"location,omitempty"` - - // Resource tags. - Tags *map[string]*string `json:"tags,omitempty"` -} - -// UpdateHistoryProperty - An update history of the ImmutabilityPolicy of a blob container. -type UpdateHistoryProperty struct { - // READ-ONLY; The immutability period for the blobs in the container since the policy creation, in days. - ImmutabilityPeriodSinceCreationInDays *int32 `json:"immutabilityPeriodSinceCreationInDays,omitempty" azure:"ro"` - - // READ-ONLY; Returns the Object ID of the user who updated the ImmutabilityPolicy. - ObjectIdentifier *string `json:"objectIdentifier,omitempty" azure:"ro"` - - // READ-ONLY; Returns the Tenant ID that issued the token for the user who updated the ImmutabilityPolicy. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` - - // READ-ONLY; Returns the date and time the ImmutabilityPolicy was updated. - Timestamp *time.Time `json:"timestamp,omitempty" azure:"ro"` - - // READ-ONLY; The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. - Update *ImmutabilityPolicyUpdateType `json:"update,omitempty" azure:"ro"` - - // READ-ONLY; Returns the User Principal Name of the user who updated the ImmutabilityPolicy. - Upn *string `json:"upn,omitempty" azure:"ro"` -} - -// MarshalJSON implements the json.Marshaller interface for type UpdateHistoryProperty. -func (u UpdateHistoryProperty) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "immutabilityPeriodSinceCreationInDays", u.ImmutabilityPeriodSinceCreationInDays) - populate(objectMap, "objectIdentifier", u.ObjectIdentifier) - populate(objectMap, "tenantId", u.TenantID) - populate(objectMap, "timestamp", (*timeRFC3339)(u.Timestamp)) - populate(objectMap, "update", u.Update) - populate(objectMap, "upn", u.Upn) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type UpdateHistoryProperty. -func (u *UpdateHistoryProperty) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "immutabilityPeriodSinceCreationInDays": - err = unpopulate(val, &u.ImmutabilityPeriodSinceCreationInDays) - delete(rawMsg, key) - case "objectIdentifier": - err = unpopulate(val, &u.ObjectIdentifier) - delete(rawMsg, key) - case "tenantId": - err = unpopulate(val, &u.TenantID) - delete(rawMsg, key) - case "timestamp": - var aux timeRFC3339 - err = unpopulate(val, &aux) - u.Timestamp = (*time.Time)(&aux) - delete(rawMsg, key) - case "update": - err = unpopulate(val, &u.Update) - delete(rawMsg, key) - case "upn": - err = unpopulate(val, &u.Upn) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - -// 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"` - - // READ-ONLY; Gets the maximum count of the resources that can be allocated in the subscription. - Limit *int32 `json:"limit,omitempty" azure:"ro"` - - // READ-ONLY; Gets the name of the type of usage. - Name *UsageName `json:"name,omitempty" azure:"ro"` - - // READ-ONLY; Gets the unit of measurement. - Unit *UsageUnit `json:"unit,omitempty" azure:"ro"` -} - -// 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"` -} - -// UsageListResultResponse is the response envelope for operations that return a UsageListResult type. -type UsageListResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the List Usages operation. - UsageListResult *UsageListResult -} - -// 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"` - - // READ-ONLY; Gets a string describing the resource name. - Value *string `json:"value,omitempty" azure:"ro"` -} - -// UsagesListByLocationOptions contains the optional parameters for the Usages.ListByLocation method. -type UsagesListByLocationOptions struct { - // placeholder for future optional parameters -} - -// VirtualNetworkRule - Virtual Network rule. -type VirtualNetworkRule struct { - // The action of virtual network rule. - Action *string `json:"action,omitempty"` - - // Gets the state of virtual network rule. - State *State `json:"state,omitempty"` - - // Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. - VirtualNetworkResourceID *string `json:"id,omitempty"` -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data *json.RawMessage, v interface{}) error { - if data == nil { - return nil - } - return json.Unmarshal(*data, v) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pagers.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pagers.go deleted file mode 100644 index 88511b0c55bf..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pagers.go +++ /dev/null @@ -1,470 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// EncryptionScopeListResultPager provides iteration over EncryptionScopeListResult pages. -type EncryptionScopeListResultPager interface { - azcore.Pager - - // Page returns the current EncryptionScopeListResultResponse. - PageResponse() EncryptionScopeListResultResponse -} - -type encryptionScopeListResultCreateRequest func(context.Context) (*azcore.Request, error) - -type encryptionScopeListResultHandleError func(*azcore.Response) error - -type encryptionScopeListResultHandleResponse func(*azcore.Response) (EncryptionScopeListResultResponse, error) - -type encryptionScopeListResultAdvancePage func(context.Context, EncryptionScopeListResultResponse) (*azcore.Request, error) - -type encryptionScopeListResultPager struct { - // the pipeline for making the request - pipeline azcore.Pipeline - // creates the initial request (non-LRO case) - requester encryptionScopeListResultCreateRequest - // callback for handling response errors - errorer encryptionScopeListResultHandleError - // callback for handling the HTTP response - responder encryptionScopeListResultHandleResponse - // callback for advancing to the next page - advancer encryptionScopeListResultAdvancePage - // contains the current response - current EncryptionScopeListResultResponse - // status codes for successful retrieval - statusCodes []int - // any error encountered - err error -} - -func (p *encryptionScopeListResultPager) Err() error { - return p.err -} - -func (p *encryptionScopeListResultPager) NextPage(ctx context.Context) bool { - var req *azcore.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.EncryptionScopeListResult.NextLink == nil || len(*p.current.EncryptionScopeListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.pipeline.Do(req) - if err != nil { - p.err = err - return false - } - if !resp.HasStatusCode(p.statusCodes...) { - p.err = p.errorer(resp) - return false - } - result, err := p.responder(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -func (p *encryptionScopeListResultPager) PageResponse() EncryptionScopeListResultResponse { - return p.current -} - -// FileShareItemsPager provides iteration over FileShareItems pages. -type FileShareItemsPager interface { - azcore.Pager - - // Page returns the current FileShareItemsResponse. - PageResponse() FileShareItemsResponse -} - -type fileShareItemsCreateRequest func(context.Context) (*azcore.Request, error) - -type fileShareItemsHandleError func(*azcore.Response) error - -type fileShareItemsHandleResponse func(*azcore.Response) (FileShareItemsResponse, error) - -type fileShareItemsAdvancePage func(context.Context, FileShareItemsResponse) (*azcore.Request, error) - -type fileShareItemsPager struct { - // the pipeline for making the request - pipeline azcore.Pipeline - // creates the initial request (non-LRO case) - requester fileShareItemsCreateRequest - // callback for handling response errors - errorer fileShareItemsHandleError - // callback for handling the HTTP response - responder fileShareItemsHandleResponse - // callback for advancing to the next page - advancer fileShareItemsAdvancePage - // contains the current response - current FileShareItemsResponse - // status codes for successful retrieval - statusCodes []int - // any error encountered - err error -} - -func (p *fileShareItemsPager) Err() error { - return p.err -} - -func (p *fileShareItemsPager) NextPage(ctx context.Context) bool { - var req *azcore.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.FileShareItems.NextLink == nil || len(*p.current.FileShareItems.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.pipeline.Do(req) - if err != nil { - p.err = err - return false - } - if !resp.HasStatusCode(p.statusCodes...) { - p.err = p.errorer(resp) - return false - } - result, err := p.responder(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -func (p *fileShareItemsPager) PageResponse() FileShareItemsResponse { - return p.current -} - -// ListContainerItemsPager provides iteration over ListContainerItems pages. -type ListContainerItemsPager interface { - azcore.Pager - - // Page returns the current ListContainerItemsResponse. - PageResponse() ListContainerItemsResponse -} - -type listContainerItemsCreateRequest func(context.Context) (*azcore.Request, error) - -type listContainerItemsHandleError func(*azcore.Response) error - -type listContainerItemsHandleResponse func(*azcore.Response) (ListContainerItemsResponse, error) - -type listContainerItemsAdvancePage func(context.Context, ListContainerItemsResponse) (*azcore.Request, error) - -type listContainerItemsPager struct { - // the pipeline for making the request - pipeline azcore.Pipeline - // creates the initial request (non-LRO case) - requester listContainerItemsCreateRequest - // callback for handling response errors - errorer listContainerItemsHandleError - // callback for handling the HTTP response - responder listContainerItemsHandleResponse - // callback for advancing to the next page - advancer listContainerItemsAdvancePage - // contains the current response - current ListContainerItemsResponse - // status codes for successful retrieval - statusCodes []int - // any error encountered - err error -} - -func (p *listContainerItemsPager) Err() error { - return p.err -} - -func (p *listContainerItemsPager) NextPage(ctx context.Context) bool { - var req *azcore.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.ListContainerItems.NextLink == nil || len(*p.current.ListContainerItems.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.pipeline.Do(req) - if err != nil { - p.err = err - return false - } - if !resp.HasStatusCode(p.statusCodes...) { - p.err = p.errorer(resp) - return false - } - result, err := p.responder(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -func (p *listContainerItemsPager) PageResponse() ListContainerItemsResponse { - return p.current -} - -// ListQueueResourcePager provides iteration over ListQueueResource pages. -type ListQueueResourcePager interface { - azcore.Pager - - // Page returns the current ListQueueResourceResponse. - PageResponse() ListQueueResourceResponse -} - -type listQueueResourceCreateRequest func(context.Context) (*azcore.Request, error) - -type listQueueResourceHandleError func(*azcore.Response) error - -type listQueueResourceHandleResponse func(*azcore.Response) (ListQueueResourceResponse, error) - -type listQueueResourceAdvancePage func(context.Context, ListQueueResourceResponse) (*azcore.Request, error) - -type listQueueResourcePager struct { - // the pipeline for making the request - pipeline azcore.Pipeline - // creates the initial request (non-LRO case) - requester listQueueResourceCreateRequest - // callback for handling response errors - errorer listQueueResourceHandleError - // callback for handling the HTTP response - responder listQueueResourceHandleResponse - // callback for advancing to the next page - advancer listQueueResourceAdvancePage - // contains the current response - current ListQueueResourceResponse - // status codes for successful retrieval - statusCodes []int - // any error encountered - err error -} - -func (p *listQueueResourcePager) Err() error { - return p.err -} - -func (p *listQueueResourcePager) NextPage(ctx context.Context) bool { - var req *azcore.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.ListQueueResource.NextLink == nil || len(*p.current.ListQueueResource.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.pipeline.Do(req) - if err != nil { - p.err = err - return false - } - if !resp.HasStatusCode(p.statusCodes...) { - p.err = p.errorer(resp) - return false - } - result, err := p.responder(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -func (p *listQueueResourcePager) PageResponse() ListQueueResourceResponse { - return p.current -} - -// ListTableResourcePager provides iteration over ListTableResource pages. -type ListTableResourcePager interface { - azcore.Pager - - // Page returns the current ListTableResourceResponse. - PageResponse() ListTableResourceResponse -} - -type listTableResourceCreateRequest func(context.Context) (*azcore.Request, error) - -type listTableResourceHandleError func(*azcore.Response) error - -type listTableResourceHandleResponse func(*azcore.Response) (ListTableResourceResponse, error) - -type listTableResourceAdvancePage func(context.Context, ListTableResourceResponse) (*azcore.Request, error) - -type listTableResourcePager struct { - // the pipeline for making the request - pipeline azcore.Pipeline - // creates the initial request (non-LRO case) - requester listTableResourceCreateRequest - // callback for handling response errors - errorer listTableResourceHandleError - // callback for handling the HTTP response - responder listTableResourceHandleResponse - // callback for advancing to the next page - advancer listTableResourceAdvancePage - // contains the current response - current ListTableResourceResponse - // status codes for successful retrieval - statusCodes []int - // any error encountered - err error -} - -func (p *listTableResourcePager) Err() error { - return p.err -} - -func (p *listTableResourcePager) NextPage(ctx context.Context) bool { - var req *azcore.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.ListTableResource.NextLink == nil || len(*p.current.ListTableResource.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.pipeline.Do(req) - if err != nil { - p.err = err - return false - } - if !resp.HasStatusCode(p.statusCodes...) { - p.err = p.errorer(resp) - return false - } - result, err := p.responder(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -func (p *listTableResourcePager) PageResponse() ListTableResourceResponse { - return p.current -} - -// StorageAccountListResultPager provides iteration over StorageAccountListResult pages. -type StorageAccountListResultPager interface { - azcore.Pager - - // Page returns the current StorageAccountListResultResponse. - PageResponse() StorageAccountListResultResponse -} - -type storageAccountListResultCreateRequest func(context.Context) (*azcore.Request, error) - -type storageAccountListResultHandleError func(*azcore.Response) error - -type storageAccountListResultHandleResponse func(*azcore.Response) (StorageAccountListResultResponse, error) - -type storageAccountListResultAdvancePage func(context.Context, StorageAccountListResultResponse) (*azcore.Request, error) - -type storageAccountListResultPager struct { - // the pipeline for making the request - pipeline azcore.Pipeline - // creates the initial request (non-LRO case) - requester storageAccountListResultCreateRequest - // callback for handling response errors - errorer storageAccountListResultHandleError - // callback for handling the HTTP response - responder storageAccountListResultHandleResponse - // callback for advancing to the next page - advancer storageAccountListResultAdvancePage - // contains the current response - current StorageAccountListResultResponse - // status codes for successful retrieval - statusCodes []int - // any error encountered - err error -} - -func (p *storageAccountListResultPager) Err() error { - return p.err -} - -func (p *storageAccountListResultPager) NextPage(ctx context.Context) bool { - var req *azcore.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.StorageAccountListResult.NextLink == nil || len(*p.current.StorageAccountListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.pipeline.Do(req) - if err != nil { - p.err = err - return false - } - if !resp.HasStatusCode(p.statusCodes...) { - p.err = p.errorer(resp) - return false - } - result, err := p.responder(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -func (p *storageAccountListResultPager) PageResponse() StorageAccountListResultResponse { - return p.current -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privateendpointconnections_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privateendpointconnections_client.go deleted file mode 100644 index 2c2e49fc41fd..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privateendpointconnections_client.go +++ /dev/null @@ -1,282 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// PrivateEndpointConnectionsClient contains the methods for the PrivateEndpointConnections group. -// Don't use this type directly, use NewPrivateEndpointConnectionsClient() instead. -type PrivateEndpointConnectionsClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient with the specified values. -func NewPrivateEndpointConnectionsClient(con *armcore.Connection, subscriptionID string) *PrivateEndpointConnectionsClient { - return &PrivateEndpointConnectionsClient{con: con, subscriptionID: subscriptionID} -} - -// Delete - Deletes the specified private endpoint connection associated with the storage account. -func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if privateEndpointConnectionName == "" { - return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *PrivateEndpointConnectionsClient) deleteHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Get - Gets the specified private endpoint connection associated with the storage account. -func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionName, options) - if err != nil { - return PrivateEndpointConnectionResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return PrivateEndpointConnectionResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return PrivateEndpointConnectionResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if privateEndpointConnectionName == "" { - return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionResponse, error) { - var val *PrivateEndpointConnection - if err := resp.UnmarshalAsJSON(&val); err != nil { - return PrivateEndpointConnectionResponse{}, err - } - return PrivateEndpointConnectionResponse{RawResponse: resp.Response, PrivateEndpointConnection: val}, nil -} - -// getHandleError handles the Get error response. -func (client *PrivateEndpointConnectionsClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - List all the private endpoint connections associated with the storage account. -func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, accountName string, options *PrivateEndpointConnectionsListOptions) (PrivateEndpointConnectionListResultResponse, error) { - req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return PrivateEndpointConnectionListResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return PrivateEndpointConnectionListResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return PrivateEndpointConnectionListResultResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *PrivateEndpointConnectionsListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionListResultResponse, error) { - var val *PrivateEndpointConnectionListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return PrivateEndpointConnectionListResultResponse{}, err - } - return PrivateEndpointConnectionListResultResponse{RawResponse: resp.Response, PrivateEndpointConnectionListResult: val}, nil -} - -// listHandleError handles the List error response. -func (client *PrivateEndpointConnectionsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Put - Update the state of specified private endpoint connection associated with the storage account. -func (client *PrivateEndpointConnectionsClient) Put(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsPutOptions) (PrivateEndpointConnectionResponse, error) { - req, err := client.putCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionName, properties, options) - if err != nil { - return PrivateEndpointConnectionResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return PrivateEndpointConnectionResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return PrivateEndpointConnectionResponse{}, client.putHandleError(resp) - } - return client.putHandleResponse(resp) -} - -// putCreateRequest creates the Put request. -func (client *PrivateEndpointConnectionsClient) putCreateRequest(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsPutOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if privateEndpointConnectionName == "" { - return nil, errors.New("parameter privateEndpointConnectionName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{privateEndpointConnectionName}", url.PathEscape(privateEndpointConnectionName)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(properties) -} - -// putHandleResponse handles the Put response. -func (client *PrivateEndpointConnectionsClient) putHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionResponse, error) { - var val *PrivateEndpointConnection - if err := resp.UnmarshalAsJSON(&val); err != nil { - return PrivateEndpointConnectionResponse{}, err - } - return PrivateEndpointConnectionResponse{RawResponse: resp.Response, PrivateEndpointConnection: val}, nil -} - -// putHandleError handles the Put error response. -func (client *PrivateEndpointConnectionsClient) putHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privatelinkresources_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privatelinkresources_client.go deleted file mode 100644 index 3953825446eb..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privatelinkresources_client.go +++ /dev/null @@ -1,96 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// PrivateLinkResourcesClient contains the methods for the PrivateLinkResources group. -// Don't use this type directly, use NewPrivateLinkResourcesClient() instead. -type PrivateLinkResourcesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient with the specified values. -func NewPrivateLinkResourcesClient(con *armcore.Connection, subscriptionID string) *PrivateLinkResourcesClient { - return &PrivateLinkResourcesClient{con: con, subscriptionID: subscriptionID} -} - -// ListByStorageAccount - Gets the private link resources that need to be created for a storage account. -func (client *PrivateLinkResourcesClient) ListByStorageAccount(ctx context.Context, resourceGroupName string, accountName string, options *PrivateLinkResourcesListByStorageAccountOptions) (PrivateLinkResourceListResultResponse, error) { - req, err := client.listByStorageAccountCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return PrivateLinkResourceListResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return PrivateLinkResourceListResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return PrivateLinkResourceListResultResponse{}, client.listByStorageAccountHandleError(resp) - } - return client.listByStorageAccountHandleResponse(resp) -} - -// listByStorageAccountCreateRequest creates the ListByStorageAccount request. -func (client *PrivateLinkResourcesClient) listByStorageAccountCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *PrivateLinkResourcesListByStorageAccountOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listByStorageAccountHandleResponse handles the ListByStorageAccount response. -func (client *PrivateLinkResourcesClient) listByStorageAccountHandleResponse(resp *azcore.Response) (PrivateLinkResourceListResultResponse, error) { - var val *PrivateLinkResourceListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return PrivateLinkResourceListResultResponse{}, err - } - return PrivateLinkResourceListResultResponse{RawResponse: resp.Response, PrivateLinkResourceListResult: val}, nil -} - -// listByStorageAccountHandleError handles the ListByStorageAccount error response. -func (client *PrivateLinkResourcesClient) listByStorageAccountHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queueservices_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queueservices_client.go deleted file mode 100644 index 362ead31fdcd..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queueservices_client.go +++ /dev/null @@ -1,217 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "net/url" - "strings" -) - -// QueueServicesClient contains the methods for the QueueServices group. -// Don't use this type directly, use NewQueueServicesClient() instead. -type QueueServicesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewQueueServicesClient creates a new instance of QueueServicesClient with the specified values. -func NewQueueServicesClient(con *armcore.Connection, subscriptionID string) *QueueServicesClient { - return &QueueServicesClient{con: con, subscriptionID: subscriptionID} -} - -// GetServiceProperties - Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource -// Sharing) rules. -func (client *QueueServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesGetServicePropertiesOptions) (QueueServicePropertiesResponse, error) { - req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return QueueServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return QueueServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return QueueServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) - } - return client.getServicePropertiesHandleResponse(resp) -} - -// getServicePropertiesCreateRequest creates the GetServiceProperties request. -func (client *QueueServicesClient) getServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesGetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{queueServiceName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getServicePropertiesHandleResponse handles the GetServiceProperties response. -func (client *QueueServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (QueueServicePropertiesResponse, error) { - var val *QueueServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return QueueServicePropertiesResponse{}, err - } - return QueueServicePropertiesResponse{RawResponse: resp.Response, QueueServiceProperties: val}, nil -} - -// getServicePropertiesHandleError handles the GetServiceProperties error response. -func (client *QueueServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - List all queue services for the storage account -func (client *QueueServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesListOptions) (ListQueueServicesResponse, error) { - req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return ListQueueServicesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ListQueueServicesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ListQueueServicesResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *QueueServicesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *QueueServicesClient) listHandleResponse(resp *azcore.Response) (ListQueueServicesResponse, error) { - var val *ListQueueServices - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ListQueueServicesResponse{}, err - } - return ListQueueServicesResponse{RawResponse: resp.Response, ListQueueServices: val}, nil -} - -// listHandleError handles the List error response. -func (client *QueueServicesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// SetServiceProperties - Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource -// Sharing) rules. -func (client *QueueServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters QueueServiceProperties, options *QueueServicesSetServicePropertiesOptions) (QueueServicePropertiesResponse, error) { - req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return QueueServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return QueueServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return QueueServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) - } - return client.setServicePropertiesHandleResponse(resp) -} - -// setServicePropertiesCreateRequest creates the SetServiceProperties request. -func (client *QueueServicesClient) setServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters QueueServiceProperties, options *QueueServicesSetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{queueServiceName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// setServicePropertiesHandleResponse handles the SetServiceProperties response. -func (client *QueueServicesClient) setServicePropertiesHandleResponse(resp *azcore.Response) (QueueServicePropertiesResponse, error) { - var val *QueueServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return QueueServicePropertiesResponse{}, err - } - return QueueServicePropertiesResponse{RawResponse: resp.Response, QueueServiceProperties: val}, nil -} - -// setServicePropertiesHandleError handles the SetServiceProperties error response. -func (client *QueueServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_skus_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_skus_client.go deleted file mode 100644 index 2ce8debc7f1e..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_skus_client.go +++ /dev/null @@ -1,88 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// SKUsClient contains the methods for the SKUs group. -// Don't use this type directly, use NewSKUsClient() instead. -type SKUsClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewSKUsClient creates a new instance of SKUsClient with the specified values. -func NewSKUsClient(con *armcore.Connection, subscriptionID string) *SKUsClient { - return &SKUsClient{con: con, subscriptionID: subscriptionID} -} - -// List - Lists the available SKUs supported by Microsoft.Storage for given subscription. -func (client *SKUsClient) List(ctx context.Context, options *SKUsListOptions) (StorageSKUListResultResponse, error) { - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return StorageSKUListResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageSKUListResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageSKUListResultResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *SKUsClient) listHandleResponse(resp *azcore.Response) (StorageSKUListResultResponse, error) { - var val *StorageSKUListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageSKUListResultResponse{}, err - } - return StorageSKUListResultResponse{RawResponse: resp.Response, StorageSKUListResult: val}, nil -} - -// listHandleError handles the List error response. -func (client *SKUsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_storageaccounts_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_storageaccounts_client.go deleted file mode 100644 index d4a9c7a60eb2..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_storageaccounts_client.go +++ /dev/null @@ -1,1050 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" - "time" -) - -// StorageAccountsClient contains the methods for the StorageAccounts group. -// Don't use this type directly, use NewStorageAccountsClient() instead. -type StorageAccountsClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewStorageAccountsClient creates a new instance of StorageAccountsClient with the specified values. -func NewStorageAccountsClient(con *armcore.Connection, subscriptionID string) *StorageAccountsClient { - return &StorageAccountsClient{con: con, subscriptionID: subscriptionID} -} - -// CheckNameAvailability - Checks that the storage account name is valid and is not already in use. -func (client *StorageAccountsClient) CheckNameAvailability(ctx context.Context, accountName StorageAccountCheckNameAvailabilityParameters, options *StorageAccountsCheckNameAvailabilityOptions) (CheckNameAvailabilityResultResponse, error) { - req, err := client.checkNameAvailabilityCreateRequest(ctx, accountName, options) - if err != nil { - return CheckNameAvailabilityResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return CheckNameAvailabilityResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return CheckNameAvailabilityResultResponse{}, client.checkNameAvailabilityHandleError(resp) - } - return client.checkNameAvailabilityHandleResponse(resp) -} - -// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. -func (client *StorageAccountsClient) checkNameAvailabilityCreateRequest(ctx context.Context, accountName StorageAccountCheckNameAvailabilityParameters, options *StorageAccountsCheckNameAvailabilityOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(accountName) -} - -// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. -func (client *StorageAccountsClient) checkNameAvailabilityHandleResponse(resp *azcore.Response) (CheckNameAvailabilityResultResponse, error) { - var val *CheckNameAvailabilityResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return CheckNameAvailabilityResultResponse{}, err - } - return CheckNameAvailabilityResultResponse{RawResponse: resp.Response, CheckNameAvailabilityResult: val}, nil -} - -// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. -func (client *StorageAccountsClient) checkNameAvailabilityHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// BeginCreate - Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request -// is issued with different properties, the account properties -// will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request -// will succeed. -func (client *StorageAccountsClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountCreateParameters, options *StorageAccountsBeginCreateOptions) (StorageAccountPollerResponse, error) { - resp, err := client.create(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return StorageAccountPollerResponse{}, err - } - result := StorageAccountPollerResponse{ - RawResponse: resp.Response, - } - pt, err := armcore.NewPoller("StorageAccountsClient.Create", "", resp, client.createHandleError) - if err != nil { - return StorageAccountPollerResponse{}, err - } - poller := &storageAccountPoller{ - pipeline: client.con.Pipeline(), - pt: pt, - } - result.Poller = poller - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (StorageAccountResponse, error) { - return poller.pollUntilDone(ctx, frequency) - } - return result, nil -} - -// ResumeCreate creates a new StorageAccountPoller from the specified resume token. -// token - The value must come from a previous call to StorageAccountPoller.ResumeToken(). -func (client *StorageAccountsClient) ResumeCreate(ctx context.Context, token string) (StorageAccountPollerResponse, error) { - pt, err := armcore.NewPollerFromResumeToken("StorageAccountsClient.Create", token, client.createHandleError) - if err != nil { - return StorageAccountPollerResponse{}, err - } - poller := &storageAccountPoller{ - pipeline: client.con.Pipeline(), - pt: pt, - } - resp, err := poller.Poll(ctx) - if err != nil { - return StorageAccountPollerResponse{}, err - } - result := StorageAccountPollerResponse{ - RawResponse: resp, - } - result.Poller = poller - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (StorageAccountResponse, error) { - return poller.pollUntilDone(ctx, frequency) - } - return result, nil -} - -// Create - Asynchronously creates a new storage account with the specified parameters. If an account is already created and a subsequent create request -// is issued with different properties, the account properties -// will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request -// will succeed. -func (client *StorageAccountsClient) create(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountCreateParameters, options *StorageAccountsBeginCreateOptions) (*azcore.Response, error) { - req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { - return nil, client.createHandleError(resp) - } - return resp, nil -} - -// createCreateRequest creates the Create request. -func (client *StorageAccountsClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountCreateParameters, options *StorageAccountsBeginCreateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// createHandleResponse handles the Create response. -func (client *StorageAccountsClient) createHandleResponse(resp *azcore.Response) (StorageAccountResponse, error) { - var val *StorageAccount - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountResponse{}, err - } - return StorageAccountResponse{RawResponse: resp.Response, StorageAccount: val}, nil -} - -// createHandleError handles the Create error response. -func (client *StorageAccountsClient) createHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Delete - Deletes a storage account in Microsoft Azure. -func (client *StorageAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *StorageAccountsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *StorageAccountsClient) deleteHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// BeginFailover - Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's -// primary cluster to secondary cluster for RA-GRS accounts. The -// secondary cluster will become primary after failover. -func (client *StorageAccountsClient) BeginFailover(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsBeginFailoverOptions) (HTTPPollerResponse, error) { - resp, err := client.failover(ctx, resourceGroupName, accountName, options) - if err != nil { - return HTTPPollerResponse{}, err - } - result := HTTPPollerResponse{ - RawResponse: resp.Response, - } - pt, err := armcore.NewPoller("StorageAccountsClient.Failover", "location", resp, client.failoverHandleError) - if err != nil { - return HTTPPollerResponse{}, err - } - poller := &httpPoller{ - pipeline: client.con.Pipeline(), - pt: pt, - } - result.Poller = poller - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { - return poller.pollUntilDone(ctx, frequency) - } - return result, nil -} - -// ResumeFailover creates a new HTTPPoller from the specified resume token. -// token - The value must come from a previous call to HTTPPoller.ResumeToken(). -func (client *StorageAccountsClient) ResumeFailover(ctx context.Context, token string) (HTTPPollerResponse, error) { - pt, err := armcore.NewPollerFromResumeToken("StorageAccountsClient.Failover", token, client.failoverHandleError) - if err != nil { - return HTTPPollerResponse{}, err - } - poller := &httpPoller{ - pipeline: client.con.Pipeline(), - pt: pt, - } - resp, err := poller.Poll(ctx) - if err != nil { - return HTTPPollerResponse{}, err - } - result := HTTPPollerResponse{ - RawResponse: resp, - } - result.Poller = poller - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { - return poller.pollUntilDone(ctx, frequency) - } - return result, nil -} - -// Failover - Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary -// cluster to secondary cluster for RA-GRS accounts. The -// secondary cluster will become primary after failover. -func (client *StorageAccountsClient) failover(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsBeginFailoverOptions) (*azcore.Response, error) { - req, err := client.failoverCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { - return nil, client.failoverHandleError(resp) - } - return resp, nil -} - -// failoverCreateRequest creates the Failover request. -func (client *StorageAccountsClient) failoverCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsBeginFailoverOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - return req, nil -} - -// failoverHandleError handles the Failover error response. -func (client *StorageAccountsClient) failoverHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// GetProperties - Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The -// ListKeys operation should be used to retrieve storage keys. -func (client *StorageAccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsGetPropertiesOptions) (StorageAccountResponse, error) { - req, err := client.getPropertiesCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return StorageAccountResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageAccountResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageAccountResponse{}, client.getPropertiesHandleError(resp) - } - return client.getPropertiesHandleResponse(resp) -} - -// getPropertiesCreateRequest creates the GetProperties request. -func (client *StorageAccountsClient) getPropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsGetPropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", string(*options.Expand)) - } - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getPropertiesHandleResponse handles the GetProperties response. -func (client *StorageAccountsClient) getPropertiesHandleResponse(resp *azcore.Response) (StorageAccountResponse, error) { - var val *StorageAccount - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountResponse{}, err - } - return StorageAccountResponse{RawResponse: resp.Response, StorageAccount: val}, nil -} - -// getPropertiesHandleError handles the GetProperties error response. -func (client *StorageAccountsClient) getPropertiesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// List - Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. -func (client *StorageAccountsClient) List(options *StorageAccountsListOptions) StorageAccountListResultPager { - return &storageAccountListResultPager{ - pipeline: client.con.Pipeline(), - requester: func(ctx context.Context) (*azcore.Request, error) { - return client.listCreateRequest(ctx, options) - }, - responder: client.listHandleResponse, - errorer: client.listHandleError, - advancer: func(ctx context.Context, resp StorageAccountListResultResponse) (*azcore.Request, error) { - return azcore.NewRequest(ctx, http.MethodGet, *resp.StorageAccountListResult.NextLink) - }, - statusCodes: []int{http.StatusOK}, - } -} - -// listCreateRequest creates the List request. -func (client *StorageAccountsClient) listCreateRequest(ctx context.Context, options *StorageAccountsListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *StorageAccountsClient) listHandleResponse(resp *azcore.Response) (StorageAccountListResultResponse, error) { - var val *StorageAccountListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountListResultResponse{}, err - } - return StorageAccountListResultResponse{RawResponse: resp.Response, StorageAccountListResult: val}, nil -} - -// listHandleError handles the List error response. -func (client *StorageAccountsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// ListAccountSAS - List SAS credentials of a storage account. -func (client *StorageAccountsClient) ListAccountSAS(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters, options *StorageAccountsListAccountSASOptions) (ListAccountSasResponseResponse, error) { - req, err := client.listAccountSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return ListAccountSasResponseResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ListAccountSasResponseResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ListAccountSasResponseResponse{}, client.listAccountSASHandleError(resp) - } - return client.listAccountSASHandleResponse(resp) -} - -// listAccountSASCreateRequest creates the ListAccountSAS request. -func (client *StorageAccountsClient) listAccountSASCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters, options *StorageAccountsListAccountSASOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// listAccountSASHandleResponse handles the ListAccountSAS response. -func (client *StorageAccountsClient) listAccountSASHandleResponse(resp *azcore.Response) (ListAccountSasResponseResponse, error) { - var val *ListAccountSasResponse - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ListAccountSasResponseResponse{}, err - } - return ListAccountSasResponseResponse{RawResponse: resp.Response, ListAccountSasResponse: val}, nil -} - -// listAccountSASHandleError handles the ListAccountSAS error response. -func (client *StorageAccountsClient) listAccountSASHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// ListByResourceGroup - Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys -// operation for this. -func (client *StorageAccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *StorageAccountsListByResourceGroupOptions) (StorageAccountListResultResponse, error) { - req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - if err != nil { - return StorageAccountListResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageAccountListResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageAccountListResultResponse{}, client.listByResourceGroupHandleError(resp) - } - return client.listByResourceGroupHandleResponse(resp) -} - -// listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *StorageAccountsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *StorageAccountsListByResourceGroupOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listByResourceGroupHandleResponse handles the ListByResourceGroup response. -func (client *StorageAccountsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (StorageAccountListResultResponse, error) { - var val *StorageAccountListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountListResultResponse{}, err - } - return StorageAccountListResultResponse{RawResponse: resp.Response, StorageAccountListResult: val}, nil -} - -// listByResourceGroupHandleError handles the ListByResourceGroup error response. -func (client *StorageAccountsClient) listByResourceGroupHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// ListKeys - Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. -func (client *StorageAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsListKeysOptions) (StorageAccountListKeysResultResponse, error) { - req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return StorageAccountListKeysResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageAccountListKeysResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageAccountListKeysResultResponse{}, client.listKeysHandleError(resp) - } - return client.listKeysHandleResponse(resp) -} - -// listKeysCreateRequest creates the ListKeys request. -func (client *StorageAccountsClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsListKeysOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - if options != nil && options.Expand != nil { - reqQP.Set("$expand", "kerb") - } - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listKeysHandleResponse handles the ListKeys response. -func (client *StorageAccountsClient) listKeysHandleResponse(resp *azcore.Response) (StorageAccountListKeysResultResponse, error) { - var val *StorageAccountListKeysResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountListKeysResultResponse{}, err - } - return StorageAccountListKeysResultResponse{RawResponse: resp.Response, StorageAccountListKeysResult: val}, nil -} - -// listKeysHandleError handles the ListKeys error response. -func (client *StorageAccountsClient) listKeysHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// ListServiceSAS - List service SAS credentials of a specific resource. -func (client *StorageAccountsClient) ListServiceSAS(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters, options *StorageAccountsListServiceSASOptions) (ListServiceSasResponseResponse, error) { - req, err := client.listServiceSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return ListServiceSasResponseResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ListServiceSasResponseResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ListServiceSasResponseResponse{}, client.listServiceSASHandleError(resp) - } - return client.listServiceSASHandleResponse(resp) -} - -// listServiceSASCreateRequest creates the ListServiceSAS request. -func (client *StorageAccountsClient) listServiceSASCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters, options *StorageAccountsListServiceSASOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// listServiceSASHandleResponse handles the ListServiceSAS response. -func (client *StorageAccountsClient) listServiceSASHandleResponse(resp *azcore.Response) (ListServiceSasResponseResponse, error) { - var val *ListServiceSasResponse - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ListServiceSasResponseResponse{}, err - } - return ListServiceSasResponseResponse{RawResponse: resp.Response, ListServiceSasResponse: val}, nil -} - -// listServiceSASHandleError handles the ListServiceSAS error response. -func (client *StorageAccountsClient) listServiceSASHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// RegenerateKey - Regenerates one of the access keys or Kerberos keys for the specified storage account. -func (client *StorageAccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, regenerateKey StorageAccountRegenerateKeyParameters, options *StorageAccountsRegenerateKeyOptions) (StorageAccountListKeysResultResponse, error) { - req, err := client.regenerateKeyCreateRequest(ctx, resourceGroupName, accountName, regenerateKey, options) - if err != nil { - return StorageAccountListKeysResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageAccountListKeysResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageAccountListKeysResultResponse{}, client.regenerateKeyHandleError(resp) - } - return client.regenerateKeyHandleResponse(resp) -} - -// regenerateKeyCreateRequest creates the RegenerateKey request. -func (client *StorageAccountsClient) regenerateKeyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, regenerateKey StorageAccountRegenerateKeyParameters, options *StorageAccountsRegenerateKeyOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(regenerateKey) -} - -// regenerateKeyHandleResponse handles the RegenerateKey response. -func (client *StorageAccountsClient) regenerateKeyHandleResponse(resp *azcore.Response) (StorageAccountListKeysResultResponse, error) { - var val *StorageAccountListKeysResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountListKeysResultResponse{}, err - } - return StorageAccountListKeysResultResponse{RawResponse: resp.Response, StorageAccountListKeysResult: val}, nil -} - -// regenerateKeyHandleError handles the RegenerateKey error response. -func (client *StorageAccountsClient) regenerateKeyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// BeginRestoreBlobRanges - Restore blobs in the specified blob ranges -func (client *StorageAccountsClient) BeginRestoreBlobRanges(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *StorageAccountsBeginRestoreBlobRangesOptions) (BlobRestoreStatusPollerResponse, error) { - resp, err := client.restoreBlobRanges(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return BlobRestoreStatusPollerResponse{}, err - } - result := BlobRestoreStatusPollerResponse{ - RawResponse: resp.Response, - } - pt, err := armcore.NewPoller("StorageAccountsClient.RestoreBlobRanges", "location", resp, client.restoreBlobRangesHandleError) - if err != nil { - return BlobRestoreStatusPollerResponse{}, err - } - poller := &blobRestoreStatusPoller{ - pipeline: client.con.Pipeline(), - pt: pt, - } - result.Poller = poller - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (BlobRestoreStatusResponse, error) { - return poller.pollUntilDone(ctx, frequency) - } - return result, nil -} - -// ResumeRestoreBlobRanges creates a new BlobRestoreStatusPoller from the specified resume token. -// token - The value must come from a previous call to BlobRestoreStatusPoller.ResumeToken(). -func (client *StorageAccountsClient) ResumeRestoreBlobRanges(ctx context.Context, token string) (BlobRestoreStatusPollerResponse, error) { - pt, err := armcore.NewPollerFromResumeToken("StorageAccountsClient.RestoreBlobRanges", token, client.restoreBlobRangesHandleError) - if err != nil { - return BlobRestoreStatusPollerResponse{}, err - } - poller := &blobRestoreStatusPoller{ - pipeline: client.con.Pipeline(), - pt: pt, - } - resp, err := poller.Poll(ctx) - if err != nil { - return BlobRestoreStatusPollerResponse{}, err - } - result := BlobRestoreStatusPollerResponse{ - RawResponse: resp, - } - result.Poller = poller - result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (BlobRestoreStatusResponse, error) { - return poller.pollUntilDone(ctx, frequency) - } - return result, nil -} - -// RestoreBlobRanges - Restore blobs in the specified blob ranges -func (client *StorageAccountsClient) restoreBlobRanges(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *StorageAccountsBeginRestoreBlobRangesOptions) (*azcore.Response, error) { - req, err := client.restoreBlobRangesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { - return nil, client.restoreBlobRangesHandleError(resp) - } - return resp, nil -} - -// restoreBlobRangesCreateRequest creates the RestoreBlobRanges request. -func (client *StorageAccountsClient) restoreBlobRangesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *StorageAccountsBeginRestoreBlobRangesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// restoreBlobRangesHandleResponse handles the RestoreBlobRanges response. -func (client *StorageAccountsClient) restoreBlobRangesHandleResponse(resp *azcore.Response) (BlobRestoreStatusResponse, error) { - var val *BlobRestoreStatus - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobRestoreStatusResponse{}, err - } - return BlobRestoreStatusResponse{RawResponse: resp.Response, BlobRestoreStatus: val}, nil -} - -// restoreBlobRangesHandleError handles the RestoreBlobRanges error response. -func (client *StorageAccountsClient) restoreBlobRangesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// RevokeUserDelegationKeys - Revoke user delegation keys. -func (client *StorageAccountsClient) RevokeUserDelegationKeys(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsRevokeUserDelegationKeysOptions) (*http.Response, error) { - req, err := client.revokeUserDelegationKeysCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK) { - return nil, client.revokeUserDelegationKeysHandleError(resp) - } - return resp.Response, nil -} - -// revokeUserDelegationKeysCreateRequest creates the RevokeUserDelegationKeys request. -func (client *StorageAccountsClient) revokeUserDelegationKeysCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsRevokeUserDelegationKeysOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - return req, nil -} - -// revokeUserDelegationKeysHandleError handles the RevokeUserDelegationKeys error response. -func (client *StorageAccountsClient) revokeUserDelegationKeysHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Update - The update operation can be used to update the SKU, encryption, access tier, or tags for a storage account. It can also be used to map the account -// to a custom domain. Only one custom domain is -// supported per storage account; the replacement/change of custom domain is not supported. In order to replace an old custom domain, the old value must -// be cleared/unregistered before a new value can be -// set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account -// keys, use the regenerate keys operation. The -// location and name of the storage account cannot be changed after creation. -func (client *StorageAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountUpdateParameters, options *StorageAccountsUpdateOptions) (StorageAccountResponse, error) { - req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return StorageAccountResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageAccountResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageAccountResponse{}, client.updateHandleError(resp) - } - return client.updateHandleResponse(resp) -} - -// updateCreateRequest creates the Update request. -func (client *StorageAccountsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountUpdateParameters, options *StorageAccountsUpdateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// updateHandleResponse handles the Update response. -func (client *StorageAccountsClient) updateHandleResponse(resp *azcore.Response) (StorageAccountResponse, error) { - var val *StorageAccount - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountResponse{}, err - } - return StorageAccountResponse{RawResponse: resp.Response, StorageAccount: val}, nil -} - -// updateHandleError handles the Update error response. -func (client *StorageAccountsClient) updateHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_tableservices_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_tableservices_client.go deleted file mode 100644 index b26355addeff..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_tableservices_client.go +++ /dev/null @@ -1,217 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "net/url" - "strings" -) - -// TableServicesClient contains the methods for the TableServices group. -// Don't use this type directly, use NewTableServicesClient() instead. -type TableServicesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewTableServicesClient creates a new instance of TableServicesClient with the specified values. -func NewTableServicesClient(con *armcore.Connection, subscriptionID string) *TableServicesClient { - return &TableServicesClient{con: con, subscriptionID: subscriptionID} -} - -// GetServiceProperties - Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource -// Sharing) rules. -func (client *TableServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesGetServicePropertiesOptions) (TableServicePropertiesResponse, error) { - req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return TableServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return TableServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return TableServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) - } - return client.getServicePropertiesHandleResponse(resp) -} - -// getServicePropertiesCreateRequest creates the GetServiceProperties request. -func (client *TableServicesClient) getServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesGetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{tableServiceName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getServicePropertiesHandleResponse handles the GetServiceProperties response. -func (client *TableServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (TableServicePropertiesResponse, error) { - var val *TableServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return TableServicePropertiesResponse{}, err - } - return TableServicePropertiesResponse{RawResponse: resp.Response, TableServiceProperties: val}, nil -} - -// getServicePropertiesHandleError handles the GetServiceProperties error response. -func (client *TableServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - List all table services for the storage account. -func (client *TableServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesListOptions) (ListTableServicesResponse, error) { - req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return ListTableServicesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ListTableServicesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ListTableServicesResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *TableServicesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *TableServicesClient) listHandleResponse(resp *azcore.Response) (ListTableServicesResponse, error) { - var val *ListTableServices - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ListTableServicesResponse{}, err - } - return ListTableServicesResponse{RawResponse: resp.Response, ListTableServices: val}, nil -} - -// listHandleError handles the List error response. -func (client *TableServicesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// SetServiceProperties - Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource -// Sharing) rules. -func (client *TableServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters TableServiceProperties, options *TableServicesSetServicePropertiesOptions) (TableServicePropertiesResponse, error) { - req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return TableServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return TableServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return TableServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) - } - return client.setServicePropertiesHandleResponse(resp) -} - -// setServicePropertiesCreateRequest creates the SetServiceProperties request. -func (client *TableServicesClient) setServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters TableServiceProperties, options *TableServicesSetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{tableServiceName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// setServicePropertiesHandleResponse handles the SetServiceProperties response. -func (client *TableServicesClient) setServicePropertiesHandleResponse(resp *azcore.Response) (TableServicePropertiesResponse, error) { - var val *TableServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return TableServicePropertiesResponse{}, err - } - return TableServicePropertiesResponse{RawResponse: resp.Response, TableServiceProperties: val}, nil -} - -// setServicePropertiesHandleError handles the SetServiceProperties error response. -func (client *TableServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_usages_client.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_usages_client.go deleted file mode 100644 index d2ed8401e4e3..000000000000 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_usages_client.go +++ /dev/null @@ -1,92 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// UsagesClient contains the methods for the Usages group. -// Don't use this type directly, use NewUsagesClient() instead. -type UsagesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewUsagesClient creates a new instance of UsagesClient with the specified values. -func NewUsagesClient(con *armcore.Connection, subscriptionID string) *UsagesClient { - return &UsagesClient{con: con, subscriptionID: subscriptionID} -} - -// ListByLocation - Gets the current usage count and the limit for the resources of the location under the subscription. -func (client *UsagesClient) ListByLocation(ctx context.Context, location string, options *UsagesListByLocationOptions) (UsageListResultResponse, error) { - req, err := client.listByLocationCreateRequest(ctx, location, options) - if err != nil { - return UsageListResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return UsageListResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return UsageListResultResponse{}, client.listByLocationHandleError(resp) - } - return client.listByLocationHandleResponse(resp) -} - -// listByLocationCreateRequest creates the ListByLocation request. -func (client *UsagesClient) listByLocationCreateRequest(ctx context.Context, location string, options *UsagesListByLocationOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if location == "" { - return nil, errors.New("parameter location cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listByLocationHandleResponse handles the ListByLocation response. -func (client *UsagesClient) listByLocationHandleResponse(resp *azcore.Response) (UsageListResultResponse, error) { - var val *UsageListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return UsageListResultResponse{}, err - } - return UsageListResultResponse{RawResponse: resp.Response, UsageListResult: val}, nil -} - -// listByLocationHandleError handles the ListByLocation error response. -func (client *UsagesClient) listByLocationHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/CHANGELOG.md b/sdk/arm/storage/2021-01-01/armstorage/CHANGELOG.md deleted file mode 100644 index c7196df9ed8b..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -# Release History - -## v0.1.0 (released) diff --git a/sdk/arm/storage/2021-01-01/armstorage/_meta.json b/sdk/arm/storage/2021-01-01/armstorage/_meta.json deleted file mode 100644 index da2797e7694f..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/_meta.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "commit": "92ab22b49bd085116af0c61fada2c6c360702e9e", - "readme": "/_/azure-rest-api-specs/specification/storage/resource-manager/readme.md", - "tag": "package-2021-01", - "use": "@autorest/go@4.0.0-preview.19", - "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", - "autorest_command": "autorest --use=@autorest/go@4.0.0-preview.19 --version:3.2.1 --tag=\"package-2021-01\" --output-folder=/_/azure-sdk-for-go/sdk/arm/storage/2021-01-01/armstorage --file-prefix=\"zz_generated_\" --credential-scope=\"https://management.azure.com//.default\" --azure-arm=true --go.clear-output-folder=false --modelerfour.lenient-model-deduplication --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/storage/resource-manager/readme.md", - "additional_properties": { - "additional_options": "--version:3.2.1 --file-prefix=\"zz_generated_\" --credential-scope=\"https://management.azure.com//.default\" --azure-arm=true --go.clear-output-folder=false --modelerfour.lenient-model-deduplication --go.license-header=MICROSOFT_MIT_NO_VERSION" - } -} \ No newline at end of file diff --git a/sdk/arm/storage/2021-01-01/armstorage/example_usage_test.go b/sdk/arm/storage/2021-01-01/armstorage/example_usage_test.go deleted file mode 100644 index 63ad04d9b8da..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/example_usage_test.go +++ /dev/null @@ -1,30 +0,0 @@ -// +build go1.13 - -// 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" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" -) - -func ExampleUsagesClient_ListByLocation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - client := armstorage.NewUsagesClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.ListByLocation(context.Background(), "", nil) - if err != nil { - log.Fatalf("failed to delete account: %v", err) - } - for _, u := range *resp.UsageListResult.Value { - log.Printf("usage: %v, limit: %v, current value: %v", *u.Name.Value, *u.Limit, *u.CurrentValue) - } -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobcontainers_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobcontainers_client.go deleted file mode 100644 index ab96f561aa30..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobcontainers_client.go +++ /dev/null @@ -1,963 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// BlobContainersClient contains the methods for the BlobContainers group. -// Don't use this type directly, use NewBlobContainersClient() instead. -type BlobContainersClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewBlobContainersClient creates a new instance of BlobContainersClient with the specified values. -func NewBlobContainersClient(con *armcore.Connection, subscriptionID string) *BlobContainersClient { - return &BlobContainersClient{con: con, subscriptionID: subscriptionID} -} - -// ClearLegalHold - Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the -// specified tags in the request. -func (client *BlobContainersClient) ClearLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersClearLegalHoldOptions) (LegalHoldResponse, error) { - req, err := client.clearLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) - if err != nil { - return LegalHoldResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return LegalHoldResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return LegalHoldResponse{}, client.clearLegalHoldHandleError(resp) - } - return client.clearLegalHoldHandleResponse(resp) -} - -// clearLegalHoldCreateRequest creates the ClearLegalHold request. -func (client *BlobContainersClient) clearLegalHoldCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersClearLegalHoldOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(legalHold) -} - -// clearLegalHoldHandleResponse handles the ClearLegalHold response. -func (client *BlobContainersClient) clearLegalHoldHandleResponse(resp *azcore.Response) (LegalHoldResponse, error) { - var val *LegalHold - if err := resp.UnmarshalAsJSON(&val); err != nil { - return LegalHoldResponse{}, err - } - return LegalHoldResponse{RawResponse: resp.Response, LegalHold: val}, nil -} - -// clearLegalHoldHandleError handles the ClearLegalHold error response. -func (client *BlobContainersClient) clearLegalHoldHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Create - Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for -// that container. It does not include a list of the blobs -// contained by the container. -func (client *BlobContainersClient) Create(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersCreateOptions) (BlobContainerResponse, error) { - req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) - if err != nil { - return BlobContainerResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return BlobContainerResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { - return BlobContainerResponse{}, client.createHandleError(resp) - } - return client.createHandleResponse(resp) -} - -// createCreateRequest creates the Create request. -func (client *BlobContainersClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersCreateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(blobContainer) -} - -// createHandleResponse handles the Create response. -func (client *BlobContainersClient) createHandleResponse(resp *azcore.Response) (BlobContainerResponse, error) { - var val *BlobContainer - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobContainerResponse{}, err - } - return BlobContainerResponse{RawResponse: resp.Response, BlobContainer: val}, nil -} - -// createHandleError handles the Create error response. -func (client *BlobContainersClient) createHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// CreateOrUpdateImmutabilityPolicy - Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this -// operation. -func (client *BlobContainersClient) CreateOrUpdateImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersCreateOrUpdateImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { - req, err := client.createOrUpdateImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, options) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ImmutabilityPolicyResponse{}, client.createOrUpdateImmutabilityPolicyHandleError(resp) - } - return client.createOrUpdateImmutabilityPolicyHandleResponse(resp) -} - -// createOrUpdateImmutabilityPolicyCreateRequest creates the CreateOrUpdateImmutabilityPolicy request. -func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersCreateOrUpdateImmutabilityPolicyOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - urlPath = strings.ReplaceAll(urlPath, "{immutabilityPolicyName}", url.PathEscape("default")) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - if options != nil && options.IfMatch != nil { - req.Header.Set("If-Match", *options.IfMatch) - } - req.Header.Set("Accept", "application/json") - if options != nil && options.Parameters != nil { - return req, req.MarshalAsJSON(options.Parameters) - } - return req, nil -} - -// createOrUpdateImmutabilityPolicyHandleResponse handles the CreateOrUpdateImmutabilityPolicy response. -func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyHandleResponse(resp *azcore.Response) (ImmutabilityPolicyResponse, error) { - var val *ImmutabilityPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ImmutabilityPolicyResponse{}, err - } - result := ImmutabilityPolicyResponse{RawResponse: resp.Response, ImmutabilityPolicy: val} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val - } - return result, nil -} - -// createOrUpdateImmutabilityPolicyHandleError handles the CreateOrUpdateImmutabilityPolicy error response. -func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Delete - Deletes specified container under its account. -func (client *BlobContainersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, containerName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *BlobContainersClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *BlobContainersClient) deleteHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// DeleteImmutabilityPolicy - Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in -// If-Match is required for this operation. Deleting a locked immutability -// policy is not allowed, the only way is to delete the container after deleting all expired blobs inside the policy locked container. -func (client *BlobContainersClient) DeleteImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersDeleteImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { - req, err := client.deleteImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ImmutabilityPolicyResponse{}, client.deleteImmutabilityPolicyHandleError(resp) - } - return client.deleteImmutabilityPolicyHandleResponse(resp) -} - -// deleteImmutabilityPolicyCreateRequest creates the DeleteImmutabilityPolicy request. -func (client *BlobContainersClient) deleteImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersDeleteImmutabilityPolicyOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - urlPath = strings.ReplaceAll(urlPath, "{immutabilityPolicyName}", url.PathEscape("default")) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("If-Match", ifMatch) - req.Header.Set("Accept", "application/json") - return req, nil -} - -// deleteImmutabilityPolicyHandleResponse handles the DeleteImmutabilityPolicy response. -func (client *BlobContainersClient) deleteImmutabilityPolicyHandleResponse(resp *azcore.Response) (ImmutabilityPolicyResponse, error) { - var val *ImmutabilityPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ImmutabilityPolicyResponse{}, err - } - result := ImmutabilityPolicyResponse{RawResponse: resp.Response, ImmutabilityPolicy: val} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val - } - return result, nil -} - -// deleteImmutabilityPolicyHandleError handles the DeleteImmutabilityPolicy error response. -func (client *BlobContainersClient) deleteImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// ExtendImmutabilityPolicy - Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy -// will be this action. ETag in If-Match is required for this operation. -func (client *BlobContainersClient) ExtendImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersExtendImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { - req, err := client.extendImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ImmutabilityPolicyResponse{}, client.extendImmutabilityPolicyHandleError(resp) - } - return client.extendImmutabilityPolicyHandleResponse(resp) -} - -// extendImmutabilityPolicyCreateRequest creates the ExtendImmutabilityPolicy request. -func (client *BlobContainersClient) extendImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersExtendImmutabilityPolicyOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("If-Match", ifMatch) - req.Header.Set("Accept", "application/json") - if options != nil && options.Parameters != nil { - return req, req.MarshalAsJSON(options.Parameters) - } - return req, nil -} - -// extendImmutabilityPolicyHandleResponse handles the ExtendImmutabilityPolicy response. -func (client *BlobContainersClient) extendImmutabilityPolicyHandleResponse(resp *azcore.Response) (ImmutabilityPolicyResponse, error) { - var val *ImmutabilityPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ImmutabilityPolicyResponse{}, err - } - result := ImmutabilityPolicyResponse{RawResponse: resp.Response, ImmutabilityPolicy: val} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val - } - return result, nil -} - -// extendImmutabilityPolicyHandleError handles the ExtendImmutabilityPolicy error response. -func (client *BlobContainersClient) extendImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Get - Gets properties of a specified container. -func (client *BlobContainersClient) Get(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersGetOptions) (BlobContainerResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, containerName, options) - if err != nil { - return BlobContainerResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return BlobContainerResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return BlobContainerResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *BlobContainersClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *BlobContainersClient) getHandleResponse(resp *azcore.Response) (BlobContainerResponse, error) { - var val *BlobContainer - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobContainerResponse{}, err - } - return BlobContainerResponse{RawResponse: resp.Response, BlobContainer: val}, nil -} - -// getHandleError handles the Get error response. -func (client *BlobContainersClient) getHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// GetImmutabilityPolicy - Gets the existing immutability policy along with the corresponding ETag in response headers and body. -func (client *BlobContainersClient) GetImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersGetImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { - req, err := client.getImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, options) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ImmutabilityPolicyResponse{}, client.getImmutabilityPolicyHandleError(resp) - } - return client.getImmutabilityPolicyHandleResponse(resp) -} - -// getImmutabilityPolicyCreateRequest creates the GetImmutabilityPolicy request. -func (client *BlobContainersClient) getImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersGetImmutabilityPolicyOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - urlPath = strings.ReplaceAll(urlPath, "{immutabilityPolicyName}", url.PathEscape("default")) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - if options != nil && options.IfMatch != nil { - req.Header.Set("If-Match", *options.IfMatch) - } - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getImmutabilityPolicyHandleResponse handles the GetImmutabilityPolicy response. -func (client *BlobContainersClient) getImmutabilityPolicyHandleResponse(resp *azcore.Response) (ImmutabilityPolicyResponse, error) { - var val *ImmutabilityPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ImmutabilityPolicyResponse{}, err - } - result := ImmutabilityPolicyResponse{RawResponse: resp.Response, ImmutabilityPolicy: val} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val - } - return result, nil -} - -// getImmutabilityPolicyHandleError handles the GetImmutabilityPolicy error response. -func (client *BlobContainersClient) getImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Lease - The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, -// or can be infinite. -func (client *BlobContainersClient) Lease(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersLeaseOptions) (LeaseContainerResponseResponse, error) { - req, err := client.leaseCreateRequest(ctx, resourceGroupName, accountName, containerName, options) - if err != nil { - return LeaseContainerResponseResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return LeaseContainerResponseResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return LeaseContainerResponseResponse{}, client.leaseHandleError(resp) - } - return client.leaseHandleResponse(resp) -} - -// leaseCreateRequest creates the Lease request. -func (client *BlobContainersClient) leaseCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersLeaseOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - if options != nil && options.Parameters != nil { - return req, req.MarshalAsJSON(options.Parameters) - } - return req, nil -} - -// leaseHandleResponse handles the Lease response. -func (client *BlobContainersClient) leaseHandleResponse(resp *azcore.Response) (LeaseContainerResponseResponse, error) { - var val *LeaseContainerResponse - if err := resp.UnmarshalAsJSON(&val); err != nil { - return LeaseContainerResponseResponse{}, err - } - return LeaseContainerResponseResponse{RawResponse: resp.Response, LeaseContainerResponse: val}, nil -} - -// leaseHandleError handles the Lease error response. -func (client *BlobContainersClient) leaseHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// List - Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. -func (client *BlobContainersClient) List(resourceGroupName string, accountName string, options *BlobContainersListOptions) ListContainerItemsPager { - return &listContainerItemsPager{ - pipeline: client.con.Pipeline(), - requester: func(ctx context.Context) (*azcore.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, accountName, options) - }, - responder: client.listHandleResponse, - errorer: client.listHandleError, - advancer: func(ctx context.Context, resp ListContainerItemsResponse) (*azcore.Request, error) { - return azcore.NewRequest(ctx, http.MethodGet, *resp.ListContainerItems.NextLink) - }, - statusCodes: []int{http.StatusOK}, - } -} - -// listCreateRequest creates the List request. -func (client *BlobContainersClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *BlobContainersListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - if options != nil && options.Maxpagesize != nil { - reqQP.Set("$maxpagesize", *options.Maxpagesize) - } - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } - if options != nil && options.Include != nil { - reqQP.Set("$include", string(*options.Include)) - } - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *BlobContainersClient) listHandleResponse(resp *azcore.Response) (ListContainerItemsResponse, error) { - var val *ListContainerItems - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ListContainerItemsResponse{}, err - } - return ListContainerItemsResponse{RawResponse: resp.Response, ListContainerItems: val}, nil -} - -// listHandleError handles the List error response. -func (client *BlobContainersClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// LockImmutabilityPolicy - Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. -// ETag in If-Match is required for this operation. -func (client *BlobContainersClient) LockImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersLockImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { - req, err := client.lockImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ImmutabilityPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ImmutabilityPolicyResponse{}, client.lockImmutabilityPolicyHandleError(resp) - } - return client.lockImmutabilityPolicyHandleResponse(resp) -} - -// lockImmutabilityPolicyCreateRequest creates the LockImmutabilityPolicy request. -func (client *BlobContainersClient) lockImmutabilityPolicyCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersLockImmutabilityPolicyOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("If-Match", ifMatch) - req.Header.Set("Accept", "application/json") - return req, nil -} - -// lockImmutabilityPolicyHandleResponse handles the LockImmutabilityPolicy response. -func (client *BlobContainersClient) lockImmutabilityPolicyHandleResponse(resp *azcore.Response) (ImmutabilityPolicyResponse, error) { - var val *ImmutabilityPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ImmutabilityPolicyResponse{}, err - } - result := ImmutabilityPolicyResponse{RawResponse: resp.Response, ImmutabilityPolicy: val} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = &val - } - return result, nil -} - -// lockImmutabilityPolicyHandleError handles the LockImmutabilityPolicy error response. -func (client *BlobContainersClient) lockImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// SetLegalHold - Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear -// out the existing tags that are not specified in the request. -func (client *BlobContainersClient) SetLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersSetLegalHoldOptions) (LegalHoldResponse, error) { - req, err := client.setLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) - if err != nil { - return LegalHoldResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return LegalHoldResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return LegalHoldResponse{}, client.setLegalHoldHandleError(resp) - } - return client.setLegalHoldHandleResponse(resp) -} - -// setLegalHoldCreateRequest creates the SetLegalHold request. -func (client *BlobContainersClient) setLegalHoldCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersSetLegalHoldOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(legalHold) -} - -// setLegalHoldHandleResponse handles the SetLegalHold response. -func (client *BlobContainersClient) setLegalHoldHandleResponse(resp *azcore.Response) (LegalHoldResponse, error) { - var val *LegalHold - if err := resp.UnmarshalAsJSON(&val); err != nil { - return LegalHoldResponse{}, err - } - return LegalHoldResponse{RawResponse: resp.Response, LegalHold: val}, nil -} - -// setLegalHoldHandleError handles the SetLegalHold error response. -func (client *BlobContainersClient) setLegalHoldHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Update - Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified -// container doesn't already exist. -func (client *BlobContainersClient) Update(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersUpdateOptions) (BlobContainerResponse, error) { - req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) - if err != nil { - return BlobContainerResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return BlobContainerResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return BlobContainerResponse{}, client.updateHandleError(resp) - } - return client.updateHandleResponse(resp) -} - -// updateCreateRequest creates the Update request. -func (client *BlobContainersClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersUpdateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if containerName == "" { - return nil, errors.New("parameter containerName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(blobContainer) -} - -// updateHandleResponse handles the Update response. -func (client *BlobContainersClient) updateHandleResponse(resp *azcore.Response) (BlobContainerResponse, error) { - var val *BlobContainer - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobContainerResponse{}, err - } - return BlobContainerResponse{RawResponse: resp.Response, BlobContainer: val}, nil -} - -// updateHandleError handles the Update error response. -func (client *BlobContainersClient) updateHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobservices_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobservices_client.go deleted file mode 100644 index 931c61587fcc..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobservices_client.go +++ /dev/null @@ -1,228 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// BlobServicesClient contains the methods for the BlobServices group. -// Don't use this type directly, use NewBlobServicesClient() instead. -type BlobServicesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewBlobServicesClient creates a new instance of BlobServicesClient with the specified values. -func NewBlobServicesClient(con *armcore.Connection, subscriptionID string) *BlobServicesClient { - return &BlobServicesClient{con: con, subscriptionID: subscriptionID} -} - -// GetServiceProperties - Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource -// Sharing) rules. -func (client *BlobServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *BlobServicesGetServicePropertiesOptions) (BlobServicePropertiesResponse, error) { - req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return BlobServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return BlobServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return BlobServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) - } - return client.getServicePropertiesHandleResponse(resp) -} - -// getServicePropertiesCreateRequest creates the GetServiceProperties request. -func (client *BlobServicesClient) getServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *BlobServicesGetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{BlobServicesName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getServicePropertiesHandleResponse handles the GetServiceProperties response. -func (client *BlobServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (BlobServicePropertiesResponse, error) { - var val *BlobServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobServicePropertiesResponse{}, err - } - return BlobServicePropertiesResponse{RawResponse: resp.Response, BlobServiceProperties: val}, nil -} - -// getServicePropertiesHandleError handles the GetServiceProperties error response. -func (client *BlobServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// List - List blob services of storage account. It returns a collection of one object named default. -func (client *BlobServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *BlobServicesListOptions) (BlobServiceItemsResponse, error) { - req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return BlobServiceItemsResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return BlobServiceItemsResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return BlobServiceItemsResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *BlobServicesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *BlobServicesListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *BlobServicesClient) listHandleResponse(resp *azcore.Response) (BlobServiceItemsResponse, error) { - var val *BlobServiceItems - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobServiceItemsResponse{}, err - } - return BlobServiceItemsResponse{RawResponse: resp.Response, BlobServiceItems: val}, nil -} - -// listHandleError handles the List error response. -func (client *BlobServicesClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// SetServiceProperties - Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource -// Sharing) rules. -func (client *BlobServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters BlobServiceProperties, options *BlobServicesSetServicePropertiesOptions) (BlobServicePropertiesResponse, error) { - req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return BlobServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return BlobServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return BlobServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) - } - return client.setServicePropertiesHandleResponse(resp) -} - -// setServicePropertiesCreateRequest creates the SetServiceProperties request. -func (client *BlobServicesClient) setServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters BlobServiceProperties, options *BlobServicesSetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{BlobServicesName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// setServicePropertiesHandleResponse handles the SetServiceProperties response. -func (client *BlobServicesClient) setServicePropertiesHandleResponse(resp *azcore.Response) (BlobServicePropertiesResponse, error) { - var val *BlobServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobServicePropertiesResponse{}, err - } - return BlobServicePropertiesResponse{RawResponse: resp.Response, BlobServiceProperties: val}, nil -} - -// setServicePropertiesHandleError handles the SetServiceProperties error response. -func (client *BlobServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_connection.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_connection.go deleted file mode 100644 index a8e95054e84c..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_connection.go +++ /dev/null @@ -1,12 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import "github.com/Azure/azure-sdk-for-go/sdk/arm/storage" - -const telemetryInfo = "azsdk-go-armstorage/2021-01-01/" + storage.Version diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_encryptionscopes_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_encryptionscopes_client.go deleted file mode 100644 index ad00df24ac44..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_encryptionscopes_client.go +++ /dev/null @@ -1,293 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -// EncryptionScopesClient contains the methods for the EncryptionScopes group. -// Don't use this type directly, use NewEncryptionScopesClient() instead. -type EncryptionScopesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewEncryptionScopesClient creates a new instance of EncryptionScopesClient with the specified values. -func NewEncryptionScopesClient(con *armcore.Connection, subscriptionID string) *EncryptionScopesClient { - return &EncryptionScopesClient{con: con, subscriptionID: subscriptionID} -} - -// Get - Returns the properties for the specified encryption scope. -func (client *EncryptionScopesClient) Get(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesGetOptions) (EncryptionScopeResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, encryptionScopeName, options) - if err != nil { - return EncryptionScopeResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return EncryptionScopeResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return EncryptionScopeResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *EncryptionScopesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if encryptionScopeName == "" { - return nil, errors.New("parameter encryptionScopeName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{encryptionScopeName}", url.PathEscape(encryptionScopeName)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *EncryptionScopesClient) getHandleResponse(resp *azcore.Response) (EncryptionScopeResponse, error) { - var val *EncryptionScope - if err := resp.UnmarshalAsJSON(&val); err != nil { - return EncryptionScopeResponse{}, err - } - return EncryptionScopeResponse{RawResponse: resp.Response, EncryptionScope: val}, nil -} - -// getHandleError handles the Get error response. -func (client *EncryptionScopesClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - Lists all the encryption scopes available under the specified storage account. -func (client *EncryptionScopesClient) List(resourceGroupName string, accountName string, options *EncryptionScopesListOptions) EncryptionScopeListResultPager { - return &encryptionScopeListResultPager{ - pipeline: client.con.Pipeline(), - requester: func(ctx context.Context) (*azcore.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, accountName, options) - }, - responder: client.listHandleResponse, - errorer: client.listHandleError, - advancer: func(ctx context.Context, resp EncryptionScopeListResultResponse) (*azcore.Request, error) { - return azcore.NewRequest(ctx, http.MethodGet, *resp.EncryptionScopeListResult.NextLink) - }, - statusCodes: []int{http.StatusOK}, - } -} - -// listCreateRequest creates the List request. -func (client *EncryptionScopesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *EncryptionScopesListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *EncryptionScopesClient) listHandleResponse(resp *azcore.Response) (EncryptionScopeListResultResponse, error) { - var val *EncryptionScopeListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return EncryptionScopeListResultResponse{}, err - } - return EncryptionScopeListResultResponse{RawResponse: resp.Response, EncryptionScopeListResult: val}, nil -} - -// listHandleError handles the List error response. -func (client *EncryptionScopesClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} - -// Patch - Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. -func (client *EncryptionScopesClient) Patch(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesPatchOptions) (EncryptionScopeResponse, error) { - req, err := client.patchCreateRequest(ctx, resourceGroupName, accountName, encryptionScopeName, encryptionScope, options) - if err != nil { - return EncryptionScopeResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return EncryptionScopeResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return EncryptionScopeResponse{}, client.patchHandleError(resp) - } - return client.patchHandleResponse(resp) -} - -// patchCreateRequest creates the Patch request. -func (client *EncryptionScopesClient) patchCreateRequest(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesPatchOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if encryptionScopeName == "" { - return nil, errors.New("parameter encryptionScopeName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{encryptionScopeName}", url.PathEscape(encryptionScopeName)) - req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(encryptionScope) -} - -// patchHandleResponse handles the Patch response. -func (client *EncryptionScopesClient) patchHandleResponse(resp *azcore.Response) (EncryptionScopeResponse, error) { - var val *EncryptionScope - if err := resp.UnmarshalAsJSON(&val); err != nil { - return EncryptionScopeResponse{}, err - } - return EncryptionScopeResponse{RawResponse: resp.Response, EncryptionScope: val}, nil -} - -// patchHandleError handles the Patch error response. -func (client *EncryptionScopesClient) patchHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Put - Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent -// request is issued with different properties, the -// encryption scope properties will be updated per the specified request. -func (client *EncryptionScopesClient) Put(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesPutOptions) (EncryptionScopeResponse, error) { - req, err := client.putCreateRequest(ctx, resourceGroupName, accountName, encryptionScopeName, encryptionScope, options) - if err != nil { - return EncryptionScopeResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return EncryptionScopeResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { - return EncryptionScopeResponse{}, client.putHandleError(resp) - } - return client.putHandleResponse(resp) -} - -// putCreateRequest creates the Put request. -func (client *EncryptionScopesClient) putCreateRequest(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesPutOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if encryptionScopeName == "" { - return nil, errors.New("parameter encryptionScopeName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{encryptionScopeName}", url.PathEscape(encryptionScopeName)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(encryptionScope) -} - -// putHandleResponse handles the Put response. -func (client *EncryptionScopesClient) putHandleResponse(resp *azcore.Response) (EncryptionScopeResponse, error) { - var val *EncryptionScope - if err := resp.UnmarshalAsJSON(&val); err != nil { - return EncryptionScopeResponse{}, err - } - return EncryptionScopeResponse{RawResponse: resp.Response, EncryptionScope: val}, nil -} - -// putHandleError handles the Put error response. -func (client *EncryptionScopesClient) putHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_fileservices_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_fileservices_client.go deleted file mode 100644 index e6db1adcc048..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_fileservices_client.go +++ /dev/null @@ -1,215 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "net/url" - "strings" -) - -// FileServicesClient contains the methods for the FileServices group. -// Don't use this type directly, use NewFileServicesClient() instead. -type FileServicesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewFileServicesClient creates a new instance of FileServicesClient with the specified values. -func NewFileServicesClient(con *armcore.Connection, subscriptionID string) *FileServicesClient { - return &FileServicesClient{con: con, subscriptionID: subscriptionID} -} - -// GetServiceProperties - Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. -func (client *FileServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesGetServicePropertiesOptions) (FileServicePropertiesResponse, error) { - req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return FileServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return FileServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return FileServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) - } - return client.getServicePropertiesHandleResponse(resp) -} - -// getServicePropertiesCreateRequest creates the GetServiceProperties request. -func (client *FileServicesClient) getServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesGetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{FileServicesName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getServicePropertiesHandleResponse handles the GetServiceProperties response. -func (client *FileServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (FileServicePropertiesResponse, error) { - var val *FileServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return FileServicePropertiesResponse{}, err - } - return FileServicePropertiesResponse{RawResponse: resp.Response, FileServiceProperties: val}, nil -} - -// getServicePropertiesHandleError handles the GetServiceProperties error response. -func (client *FileServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - List all file services in storage accounts -func (client *FileServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesListOptions) (FileServiceItemsResponse, error) { - req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return FileServiceItemsResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return FileServiceItemsResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return FileServiceItemsResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *FileServicesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *FileServicesClient) listHandleResponse(resp *azcore.Response) (FileServiceItemsResponse, error) { - var val *FileServiceItems - if err := resp.UnmarshalAsJSON(&val); err != nil { - return FileServiceItemsResponse{}, err - } - return FileServiceItemsResponse{RawResponse: resp.Response, FileServiceItems: val}, nil -} - -// listHandleError handles the List error response. -func (client *FileServicesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// SetServiceProperties - Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. -func (client *FileServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters FileServiceProperties, options *FileServicesSetServicePropertiesOptions) (FileServicePropertiesResponse, error) { - req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) - if err != nil { - return FileServicePropertiesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return FileServicePropertiesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return FileServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) - } - return client.setServicePropertiesHandleResponse(resp) -} - -// setServicePropertiesCreateRequest creates the SetServiceProperties request. -func (client *FileServicesClient) setServicePropertiesCreateRequest(ctx context.Context, resourceGroupName string, accountName string, parameters FileServiceProperties, options *FileServicesSetServicePropertiesOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - urlPath = strings.ReplaceAll(urlPath, "{FileServicesName}", url.PathEscape("default")) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(parameters) -} - -// setServicePropertiesHandleResponse handles the SetServiceProperties response. -func (client *FileServicesClient) setServicePropertiesHandleResponse(resp *azcore.Response) (FileServicePropertiesResponse, error) { - var val *FileServiceProperties - if err := resp.UnmarshalAsJSON(&val); err != nil { - return FileServicePropertiesResponse{}, err - } - return FileServicePropertiesResponse{RawResponse: resp.Response, FileServiceProperties: val}, nil -} - -// setServicePropertiesHandleError handles the SetServiceProperties error response. -func (client *FileServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_objectreplicationpolicies_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_objectreplicationpolicies_client.go deleted file mode 100644 index bd1530d3b043..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_objectreplicationpolicies_client.go +++ /dev/null @@ -1,277 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "net/url" - "strings" -) - -// ObjectReplicationPoliciesClient contains the methods for the ObjectReplicationPolicies group. -// Don't use this type directly, use NewObjectReplicationPoliciesClient() instead. -type ObjectReplicationPoliciesClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewObjectReplicationPoliciesClient creates a new instance of ObjectReplicationPoliciesClient with the specified values. -func NewObjectReplicationPoliciesClient(con *armcore.Connection, subscriptionID string) *ObjectReplicationPoliciesClient { - return &ObjectReplicationPoliciesClient{con: con, subscriptionID: subscriptionID} -} - -// CreateOrUpdate - Create or update the object replication policy of the storage account. -func (client *ObjectReplicationPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, properties ObjectReplicationPolicy, options *ObjectReplicationPoliciesCreateOrUpdateOptions) (ObjectReplicationPolicyResponse, error) { - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, objectReplicationPolicyID, properties, options) - if err != nil { - return ObjectReplicationPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ObjectReplicationPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ObjectReplicationPolicyResponse{}, client.createOrUpdateHandleError(resp) - } - return client.createOrUpdateHandleResponse(resp) -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ObjectReplicationPoliciesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, properties ObjectReplicationPolicy, options *ObjectReplicationPoliciesCreateOrUpdateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if objectReplicationPolicyID == "" { - return nil, errors.New("parameter objectReplicationPolicyID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{objectReplicationPolicyId}", url.PathEscape(objectReplicationPolicyID)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(properties) -} - -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *ObjectReplicationPoliciesClient) createOrUpdateHandleResponse(resp *azcore.Response) (ObjectReplicationPolicyResponse, error) { - var val *ObjectReplicationPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ObjectReplicationPolicyResponse{}, err - } - return ObjectReplicationPolicyResponse{RawResponse: resp.Response, ObjectReplicationPolicy: val}, nil -} - -// createOrUpdateHandleError handles the CreateOrUpdate error response. -func (client *ObjectReplicationPoliciesClient) createOrUpdateHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Delete - Deletes the object replication policy associated with the specified storage account. -func (client *ObjectReplicationPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, objectReplicationPolicyID, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *ObjectReplicationPoliciesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if objectReplicationPolicyID == "" { - return nil, errors.New("parameter objectReplicationPolicyID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{objectReplicationPolicyId}", url.PathEscape(objectReplicationPolicyID)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *ObjectReplicationPoliciesClient) deleteHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Get - Get the object replication policy of the storage account by policy ID. -func (client *ObjectReplicationPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesGetOptions) (ObjectReplicationPolicyResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, objectReplicationPolicyID, options) - if err != nil { - return ObjectReplicationPolicyResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ObjectReplicationPolicyResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ObjectReplicationPolicyResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *ObjectReplicationPoliciesClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if objectReplicationPolicyID == "" { - return nil, errors.New("parameter objectReplicationPolicyID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{objectReplicationPolicyId}", url.PathEscape(objectReplicationPolicyID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *ObjectReplicationPoliciesClient) getHandleResponse(resp *azcore.Response) (ObjectReplicationPolicyResponse, error) { - var val *ObjectReplicationPolicy - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ObjectReplicationPolicyResponse{}, err - } - return ObjectReplicationPolicyResponse{RawResponse: resp.Response, ObjectReplicationPolicy: val}, nil -} - -// getHandleError handles the Get error response. -func (client *ObjectReplicationPoliciesClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - List the object replication policies associated with the storage account. -func (client *ObjectReplicationPoliciesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *ObjectReplicationPoliciesListOptions) (ObjectReplicationPoliciesResponse, error) { - req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) - if err != nil { - return ObjectReplicationPoliciesResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return ObjectReplicationPoliciesResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return ObjectReplicationPoliciesResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *ObjectReplicationPoliciesClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *ObjectReplicationPoliciesListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *ObjectReplicationPoliciesClient) listHandleResponse(resp *azcore.Response) (ObjectReplicationPoliciesResponse, error) { - var val *ObjectReplicationPolicies - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ObjectReplicationPoliciesResponse{}, err - } - return ObjectReplicationPoliciesResponse{RawResponse: resp.Response, ObjectReplicationPolicies: val}, nil -} - -// listHandleError handles the List error response. -func (client *ObjectReplicationPoliciesClient) listHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_operations_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_operations_client.go deleted file mode 100644 index d15aceb2855a..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_operations_client.go +++ /dev/null @@ -1,81 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" - "net/http" -) - -// OperationsClient contains the methods for the Operations group. -// Don't use this type directly, use NewOperationsClient() instead. -type OperationsClient struct { - con *armcore.Connection -} - -// NewOperationsClient creates a new instance of OperationsClient with the specified values. -func NewOperationsClient(con *armcore.Connection) *OperationsClient { - return &OperationsClient{con: con} -} - -// List - Lists all of the available Storage Rest API operations. -func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationListResultResponse, error) { - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return OperationListResultResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return OperationListResultResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return OperationListResultResponse{}, client.listHandleError(resp) - } - return client.listHandleResponse(resp) -} - -// listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsListOptions) (*azcore.Request, error) { - urlPath := "/providers/Microsoft.Storage/operations" - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *OperationsClient) listHandleResponse(resp *azcore.Response) (OperationListResultResponse, error) { - var val *OperationListResult - if err := resp.UnmarshalAsJSON(&val); err != nil { - return OperationListResultResponse{}, err - } - return OperationListResultResponse{RawResponse: resp.Response, OperationListResult: val}, nil -} - -// listHandleError handles the List error response. -func (client *OperationsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) - } - if len(body) == 0 { - return azcore.NewResponseError(errors.New(resp.Status), resp.Response) - } - return azcore.NewResponseError(errors.New(string(body)), resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_pollers.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_pollers.go deleted file mode 100644 index 14c93eff50fe..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_pollers.go +++ /dev/null @@ -1,142 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "time" -) - -// BlobRestoreStatusPoller provides polling facilities until the operation reaches a terminal state. -type BlobRestoreStatusPoller interface { - azcore.Poller - // FinalResponse performs a final GET to the service and returns the final response - // for the polling operation. If there is an error performing the final GET then an error is returned. - // If the final GET succeeded then the final BlobRestoreStatusResponse will be returned. - FinalResponse(ctx context.Context) (BlobRestoreStatusResponse, error) -} - -type blobRestoreStatusPoller struct { - pipeline azcore.Pipeline - pt armcore.Poller -} - -func (p *blobRestoreStatusPoller) Done() bool { - return p.pt.Done() -} - -func (p *blobRestoreStatusPoller) Poll(ctx context.Context) (*http.Response, error) { - return p.pt.Poll(ctx, p.pipeline) -} - -func (p *blobRestoreStatusPoller) FinalResponse(ctx context.Context) (BlobRestoreStatusResponse, error) { - respType := BlobRestoreStatusResponse{BlobRestoreStatus: &BlobRestoreStatus{}} - resp, err := p.pt.FinalResponse(ctx, p.pipeline, respType.BlobRestoreStatus) - if err != nil { - return BlobRestoreStatusResponse{}, err - } - respType.RawResponse = resp - return respType, nil -} - -func (p *blobRestoreStatusPoller) ResumeToken() (string, error) { - return p.pt.ResumeToken() -} - -func (p *blobRestoreStatusPoller) pollUntilDone(ctx context.Context, freq time.Duration) (BlobRestoreStatusResponse, error) { - respType := BlobRestoreStatusResponse{BlobRestoreStatus: &BlobRestoreStatus{}} - resp, err := p.pt.PollUntilDone(ctx, freq, p.pipeline, respType.BlobRestoreStatus) - if err != nil { - return BlobRestoreStatusResponse{}, err - } - respType.RawResponse = resp - return respType, nil -} - -// HTTPPoller provides polling facilities until the operation reaches a terminal state. -type HTTPPoller interface { - azcore.Poller - // FinalResponse performs a final GET to the service and returns the final response - // for the polling operation. If there is an error performing the final GET then an error is returned. - // If the final GET succeeded then the final *http.Response will be returned. - FinalResponse(ctx context.Context) (*http.Response, error) -} - -type httpPoller struct { - pipeline azcore.Pipeline - pt armcore.Poller -} - -func (p *httpPoller) Done() bool { - return p.pt.Done() -} - -func (p *httpPoller) Poll(ctx context.Context) (*http.Response, error) { - return p.pt.Poll(ctx, p.pipeline) -} - -func (p *httpPoller) FinalResponse(ctx context.Context) (*http.Response, error) { - return p.pt.FinalResponse(ctx, p.pipeline, nil) -} - -func (p *httpPoller) ResumeToken() (string, error) { - return p.pt.ResumeToken() -} - -func (p *httpPoller) pollUntilDone(ctx context.Context, freq time.Duration) (*http.Response, error) { - return p.pt.PollUntilDone(ctx, freq, p.pipeline, nil) -} - -// StorageAccountPoller provides polling facilities until the operation reaches a terminal state. -type StorageAccountPoller interface { - azcore.Poller - // FinalResponse performs a final GET to the service and returns the final response - // for the polling operation. If there is an error performing the final GET then an error is returned. - // If the final GET succeeded then the final StorageAccountResponse will be returned. - FinalResponse(ctx context.Context) (StorageAccountResponse, error) -} - -type storageAccountPoller struct { - pipeline azcore.Pipeline - pt armcore.Poller -} - -func (p *storageAccountPoller) Done() bool { - return p.pt.Done() -} - -func (p *storageAccountPoller) Poll(ctx context.Context) (*http.Response, error) { - return p.pt.Poll(ctx, p.pipeline) -} - -func (p *storageAccountPoller) FinalResponse(ctx context.Context) (StorageAccountResponse, error) { - respType := StorageAccountResponse{StorageAccount: &StorageAccount{}} - resp, err := p.pt.FinalResponse(ctx, p.pipeline, respType.StorageAccount) - if err != nil { - return StorageAccountResponse{}, err - } - respType.RawResponse = resp - return respType, nil -} - -func (p *storageAccountPoller) ResumeToken() (string, error) { - return p.pt.ResumeToken() -} - -func (p *storageAccountPoller) pollUntilDone(ctx context.Context, freq time.Duration) (StorageAccountResponse, error) { - respType := StorageAccountResponse{StorageAccount: &StorageAccount{}} - resp, err := p.pt.PollUntilDone(ctx, freq, p.pipeline, respType.StorageAccount) - if err != nil { - return StorageAccountResponse{}, err - } - respType.RawResponse = resp - return respType, nil -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_queue_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_queue_client.go deleted file mode 100644 index f62324ca8138..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_queue_client.go +++ /dev/null @@ -1,348 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "net/url" - "strings" -) - -// QueueClient contains the methods for the Queue group. -// Don't use this type directly, use NewQueueClient() instead. -type QueueClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewQueueClient creates a new instance of QueueClient with the specified values. -func NewQueueClient(con *armcore.Connection, subscriptionID string) *QueueClient { - return &QueueClient{con: con, subscriptionID: subscriptionID} -} - -// Create - Creates a new queue with the specified queue name, under the specified account. -func (client *QueueClient) Create(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue StorageQueue, options *QueueCreateOptions) (StorageQueueResponse, error) { - req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, queueName, queue, options) - if err != nil { - return StorageQueueResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageQueueResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageQueueResponse{}, client.createHandleError(resp) - } - return client.createHandleResponse(resp) -} - -// createCreateRequest creates the Create request. -func (client *QueueClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue StorageQueue, options *QueueCreateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(queue) -} - -// createHandleResponse handles the Create response. -func (client *QueueClient) createHandleResponse(resp *azcore.Response) (StorageQueueResponse, error) { - var val *StorageQueue - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageQueueResponse{}, err - } - return StorageQueueResponse{RawResponse: resp.Response, StorageQueue: val}, nil -} - -// createHandleError handles the Create error response. -func (client *QueueClient) createHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Delete - Deletes the queue with the specified queue name, under the specified account if it exists. -func (client *QueueClient) Delete(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, queueName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *QueueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *QueueClient) deleteHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Get - Gets the queue with the specified queue name, under the specified account if it exists. -func (client *QueueClient) Get(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueGetOptions) (StorageQueueResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, queueName, options) - if err != nil { - return StorageQueueResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageQueueResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageQueueResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *QueueClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *QueueClient) getHandleResponse(resp *azcore.Response) (StorageQueueResponse, error) { - var val *StorageQueue - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageQueueResponse{}, err - } - return StorageQueueResponse{RawResponse: resp.Response, StorageQueue: val}, nil -} - -// getHandleError handles the Get error response. -func (client *QueueClient) getHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - Gets a list of all the queues under the specified storage account -func (client *QueueClient) List(resourceGroupName string, accountName string, options *QueueListOptions) ListQueueResourcePager { - return &listQueueResourcePager{ - pipeline: client.con.Pipeline(), - requester: func(ctx context.Context) (*azcore.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, accountName, options) - }, - responder: client.listHandleResponse, - errorer: client.listHandleError, - advancer: func(ctx context.Context, resp ListQueueResourceResponse) (*azcore.Request, error) { - return azcore.NewRequest(ctx, http.MethodGet, *resp.ListQueueResource.NextLink) - }, - statusCodes: []int{http.StatusOK}, - } -} - -// listCreateRequest creates the List request. -func (client *QueueClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *QueueListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - if options != nil && options.Maxpagesize != nil { - reqQP.Set("$maxpagesize", *options.Maxpagesize) - } - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *QueueClient) listHandleResponse(resp *azcore.Response) (ListQueueResourceResponse, error) { - var val *ListQueueResource - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ListQueueResourceResponse{}, err - } - return ListQueueResourceResponse{RawResponse: resp.Response, ListQueueResource: val}, nil -} - -// listHandleError handles the List error response. -func (client *QueueClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Update - Creates a new queue with the specified queue name, under the specified account. -func (client *QueueClient) Update(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue StorageQueue, options *QueueUpdateOptions) (StorageQueueResponse, error) { - req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, queueName, queue, options) - if err != nil { - return StorageQueueResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return StorageQueueResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return StorageQueueResponse{}, client.updateHandleError(resp) - } - return client.updateHandleResponse(resp) -} - -// updateCreateRequest creates the Update request. -func (client *QueueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue StorageQueue, options *QueueUpdateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if queueName == "" { - return nil, errors.New("parameter queueName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{queueName}", url.PathEscape(queueName)) - req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, req.MarshalAsJSON(queue) -} - -// updateHandleResponse handles the Update response. -func (client *QueueClient) updateHandleResponse(resp *azcore.Response) (StorageQueueResponse, error) { - var val *StorageQueue - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageQueueResponse{}, err - } - return StorageQueueResponse{RawResponse: resp.Response, StorageQueue: val}, nil -} - -// updateHandleError handles the Update error response. -func (client *QueueClient) updateHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_table_client.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_table_client.go deleted file mode 100644 index ff665562b137..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_table_client.go +++ /dev/null @@ -1,342 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/armcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" - "net/url" - "strings" -) - -// TableClient contains the methods for the Table group. -// Don't use this type directly, use NewTableClient() instead. -type TableClient struct { - con *armcore.Connection - subscriptionID string -} - -// NewTableClient creates a new instance of TableClient with the specified values. -func NewTableClient(con *armcore.Connection, subscriptionID string) *TableClient { - return &TableClient{con: con, subscriptionID: subscriptionID} -} - -// Create - Creates a new table with the specified table name, under the specified account. -func (client *TableClient) Create(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableCreateOptions) (TableResponse, error) { - req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, tableName, options) - if err != nil { - return TableResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return TableResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return TableResponse{}, client.createHandleError(resp) - } - return client.createHandleResponse(resp) -} - -// createCreateRequest creates the Create request. -func (client *TableClient) createCreateRequest(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableCreateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if tableName == "" { - return nil, errors.New("parameter tableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) - req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// createHandleResponse handles the Create response. -func (client *TableClient) createHandleResponse(resp *azcore.Response) (TableResponse, error) { - var val *Table - if err := resp.UnmarshalAsJSON(&val); err != nil { - return TableResponse{}, err - } - return TableResponse{RawResponse: resp.Response, Table: val}, nil -} - -// createHandleError handles the Create error response. -func (client *TableClient) createHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Delete - Deletes the table with the specified table name, under the specified account if it exists. -func (client *TableClient) Delete(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableDeleteOptions) (*http.Response, error) { - req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, tableName, options) - if err != nil { - return nil, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !resp.HasStatusCode(http.StatusNoContent) { - return nil, client.deleteHandleError(resp) - } - return resp.Response, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *TableClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableDeleteOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if tableName == "" { - return nil, errors.New("parameter tableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) - req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// deleteHandleError handles the Delete error response. -func (client *TableClient) deleteHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Get - Gets the table with the specified table name, under the specified account if it exists. -func (client *TableClient) Get(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableGetOptions) (TableResponse, error) { - req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, tableName, options) - if err != nil { - return TableResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return TableResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return TableResponse{}, client.getHandleError(resp) - } - return client.getHandleResponse(resp) -} - -// getCreateRequest creates the Get request. -func (client *TableClient) getCreateRequest(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableGetOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if tableName == "" { - return nil, errors.New("parameter tableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *TableClient) getHandleResponse(resp *azcore.Response) (TableResponse, error) { - var val *Table - if err := resp.UnmarshalAsJSON(&val); err != nil { - return TableResponse{}, err - } - return TableResponse{RawResponse: resp.Response, Table: val}, nil -} - -// getHandleError handles the Get error response. -func (client *TableClient) getHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// List - Gets a list of all the tables under the specified storage account -func (client *TableClient) List(resourceGroupName string, accountName string, options *TableListOptions) ListTableResourcePager { - return &listTableResourcePager{ - pipeline: client.con.Pipeline(), - requester: func(ctx context.Context) (*azcore.Request, error) { - return client.listCreateRequest(ctx, resourceGroupName, accountName, options) - }, - responder: client.listHandleResponse, - errorer: client.listHandleError, - advancer: func(ctx context.Context, resp ListTableResourceResponse) (*azcore.Request, error) { - return azcore.NewRequest(ctx, http.MethodGet, *resp.ListTableResource.NextLink) - }, - statusCodes: []int{http.StatusOK}, - } -} - -// listCreateRequest creates the List request. -func (client *TableClient) listCreateRequest(ctx context.Context, resourceGroupName string, accountName string, options *TableListOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// listHandleResponse handles the List response. -func (client *TableClient) listHandleResponse(resp *azcore.Response) (ListTableResourceResponse, error) { - var val *ListTableResource - if err := resp.UnmarshalAsJSON(&val); err != nil { - return ListTableResourceResponse{}, err - } - return ListTableResourceResponse{RawResponse: resp.Response, ListTableResource: val}, nil -} - -// listHandleError handles the List error response. -func (client *TableClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} - -// Update - Creates a new table with the specified table name, under the specified account. -func (client *TableClient) Update(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableUpdateOptions) (TableResponse, error) { - req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, tableName, options) - if err != nil { - return TableResponse{}, err - } - resp, err := client.con.Pipeline().Do(req) - if err != nil { - return TableResponse{}, err - } - if !resp.HasStatusCode(http.StatusOK) { - return TableResponse{}, client.updateHandleError(resp) - } - return client.updateHandleResponse(resp) -} - -// updateCreateRequest creates the Update request. -func (client *TableClient) updateCreateRequest(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableUpdateOptions) (*azcore.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}" - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if accountName == "" { - return nil, errors.New("parameter accountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if tableName == "" { - return nil, errors.New("parameter tableName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{tableName}", url.PathEscape(tableName)) - req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - req.Telemetry(telemetryInfo) - reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") - req.URL.RawQuery = reqQP.Encode() - req.Header.Set("Accept", "application/json") - return req, nil -} - -// updateHandleResponse handles the Update response. -func (client *TableClient) updateHandleResponse(resp *azcore.Response) (TableResponse, error) { - var val *Table - if err := resp.UnmarshalAsJSON(&val); err != nil { - return TableResponse{}, err - } - return TableResponse{RawResponse: resp.Response, Table: val}, nil -} - -// updateHandleError handles the Update error response. -func (client *TableClient) updateHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) - } - return azcore.NewResponseError(&err, resp.Response) -} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_time_rfc3339.go b/sdk/arm/storage/2021-01-01/armstorage/zz_generated_time_rfc3339.go deleted file mode 100644 index 500d7e8c60b4..000000000000 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_time_rfc3339.go +++ /dev/null @@ -1,57 +0,0 @@ -// +build go1.13 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armstorage - -import ( - "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 -} diff --git a/sdk/arm/storage/go.mod b/sdk/arm/storage/go.mod deleted file mode 100644 index 761841f02113..000000000000 --- a/sdk/arm/storage/go.mod +++ /dev/null @@ -1,11 +0,0 @@ -module github.com/Azure/azure-sdk-for-go/sdk/arm/storage - -go 1.13 - -require ( - github.com/Azure/azure-sdk-for-go v53.4.0+incompatible - github.com/Azure/azure-sdk-for-go/sdk/armcore v0.7.0 - github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.5 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.8.0 - github.com/Azure/azure-sdk-for-go/sdk/to v0.1.4 -) diff --git a/sdk/arm/storage/go_mod_tidy_hack.go b/sdk/arm/storage/go_mod_tidy_hack.go deleted file mode 100644 index 87aea098f125..000000000000 --- a/sdk/arm/storage/go_mod_tidy_hack.go +++ /dev/null @@ -1,13 +0,0 @@ -// +build modhack - -package storage - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of -// the resultant binary. - -// Necessary for safely adding multi-module repo. -// See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository -import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/arm/storage/README.md b/sdk/storage/armstorage/README.md similarity index 100% rename from sdk/arm/storage/README.md rename to sdk/storage/armstorage/README.md diff --git a/sdk/storage/armstorage/_meta.json b/sdk/storage/armstorage/_meta.json new file mode 100644 index 000000000000..2f533d6820f6 --- /dev/null +++ b/sdk/storage/armstorage/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "f69f2e8053ac8ae352b11c33655234dea4cf4cfd", + "readme": "/_/azure-rest-api-specs/specification/storage/resource-manager/readme.md", + "tag": "package-2021-04", + "use": "@autorest/go@4.0.0-preview.20", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@autorest/go@4.0.0-preview.20 --version:3.2.1 --go --track2 --go-sdk-folder=/_/azure-sdk-for-go --file-prefix=\"zz_generated_\" --clear-output-folder=false --modelerfour.lenient-model-deduplication /_/azure-rest-api-specs/specification/storage/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--version:3.2.1 --go --track2 --file-prefix=\"zz_generated_\" --clear-output-folder=false --modelerfour.lenient-model-deduplication" + } +} \ No newline at end of file diff --git a/sdk/arm/storage/ci.yml b/sdk/storage/armstorage/ci.yml similarity index 70% rename from sdk/arm/storage/ci.yml rename to sdk/storage/armstorage/ci.yml index 82df49aa9dcb..307eea0ed166 100644 --- a/sdk/arm/storage/ci.yml +++ b/sdk/storage/armstorage/ci.yml @@ -2,14 +2,14 @@ trigger: paths: include: - - sdk/arm/storage/ + - sdk/storage/armstorage/ pr: paths: include: - - sdk/arm/storage/ + - sdk/storage/armstorage/ stages: - template: ../../../eng/pipelines/templates/jobs/archetype-sdk-client-samples.yml parameters: - ServiceDirectory: 'arm/storage' + ServiceDirectory: 'storage/armstorage' diff --git a/sdk/arm/storage/2021-01-01/armstorage/example_blobcontainers_test.go b/sdk/storage/armstorage/example_blobcontainers_test.go similarity index 93% rename from sdk/arm/storage/2021-01-01/armstorage/example_blobcontainers_test.go rename to sdk/storage/armstorage/example_blobcontainers_test.go index ec2b64190011..88c25737b171 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/example_blobcontainers_test.go +++ b/sdk/storage/armstorage/example_blobcontainers_test.go @@ -9,9 +9,9 @@ import ( "context" "log" - "github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/storage/armstorage" ) func ExampleBlobContainersClient_Create() { @@ -58,10 +58,10 @@ func ExampleBlobContainersClient_List() { pager := client.List("", "", nil) for pager.NextPage(context.Background()) { resp := pager.PageResponse() - if len(*resp.ListContainerItems.Value) == 0 { + if len(resp.ListContainerItems.Value) == 0 { log.Fatal("missing payload") } - for _, val := range *resp.ListContainerItems.Value { + for _, val := range resp.ListContainerItems.Value { log.Printf("container item: %v", *val.ID) } } diff --git a/sdk/arm/storage/2021-01-01/armstorage/example_storageaccounts_test.go b/sdk/storage/armstorage/example_storageaccounts_test.go similarity index 89% rename from sdk/arm/storage/2021-01-01/armstorage/example_storageaccounts_test.go rename to sdk/storage/armstorage/example_storageaccounts_test.go index 01bc5b8ca12e..2198783dcc79 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/example_storageaccounts_test.go +++ b/sdk/storage/armstorage/example_storageaccounts_test.go @@ -10,9 +10,9 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/storage/armstorage" "github.com/Azure/azure-sdk-for-go/sdk/to" ) @@ -56,10 +56,10 @@ func ExampleStorageAccountsClient_List() { pager := client.List(nil) for pager.NextPage(context.Background()) { resp := pager.PageResponse() - if len(*resp.StorageAccountListResult.Value) == 0 { + if len(resp.StorageAccountListResult.Value) == 0 { log.Fatal("missing payload") } - for _, val := range *resp.StorageAccountListResult.Value { + for _, val := range resp.StorageAccountListResult.Value { log.Printf("storage account: %v", *val.ID) } } @@ -74,12 +74,18 @@ func ExampleStorageAccountsClient_ListByResourceGroup() { log.Fatalf("failed to obtain a credential: %v", err) } client := armstorage.NewStorageAccountsClient(armcore.NewDefaultConnection(cred, nil), "") - resp, err := client.ListByResourceGroup(context.Background(), "", nil) - if err != nil { - log.Fatalf("failed to obtain a response: %v", err) + pager := client.ListByResourceGroup("", nil) + for pager.NextPage(context.Background()) { + resp := pager.PageResponse() + if len(resp.StorageAccountListResult.Value) == 0 { + log.Fatal("missing payload") + } + for _, val := range resp.StorageAccountListResult.Value { + log.Printf("storage account: %v", *val.ID) + } } - for _, sa := range *resp.StorageAccountListResult.Value { - log.Printf("storage account ID: %v", *sa.ID) + if err := pager.Err(); err != nil { + log.Fatal(err) } } @@ -112,7 +118,7 @@ func ExampleStorageAccountsClient_ListKeys() { if err != nil { log.Fatalf("failed to delete account: %v", err) } - for _, k := range *resp.StorageAccountListKeysResult.Keys { + for _, k := range resp.StorageAccountListKeysResult.Keys { log.Printf("account key: %v", *k.KeyName) } } @@ -140,7 +146,7 @@ func ExampleStorageAccountsClient_RegenerateKey() { if err != nil { log.Fatalf("failed to delete account: %v", err) } - for _, k := range *resp.StorageAccountListKeysResult.Keys { + for _, k := range resp.StorageAccountListKeysResult.Keys { log.Printf("key: %v, value: %v", *k.KeyName, *k.Value) } } @@ -156,7 +162,7 @@ func ExampleStorageAccountsClient_Update() { "", "", armstorage.StorageAccountUpdateParameters{ - Tags: &map[string]*string{ + Tags: map[string]*string{ "who rocks": to.StringPtr("golang"), "where": to.StringPtr("on azure")}}, nil) if err != nil { diff --git a/sdk/arm/storage/2019-06-01/armstorage/example_usage_test.go b/sdk/storage/armstorage/example_usage_test.go similarity index 87% rename from sdk/arm/storage/2019-06-01/armstorage/example_usage_test.go rename to sdk/storage/armstorage/example_usage_test.go index 63ad04d9b8da..669ef9e94b91 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/example_usage_test.go +++ b/sdk/storage/armstorage/example_usage_test.go @@ -9,9 +9,9 @@ import ( "context" "log" - "github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/storage/armstorage" ) func ExampleUsagesClient_ListByLocation() { @@ -24,7 +24,7 @@ func ExampleUsagesClient_ListByLocation() { if err != nil { log.Fatalf("failed to delete account: %v", err) } - for _, u := range *resp.UsageListResult.Value { + for _, u := range resp.UsageListResult.Value { log.Printf("usage: %v, limit: %v, current value: %v", *u.Name.Value, *u.Limit, *u.CurrentValue) } } diff --git a/sdk/storage/armstorage/go.mod b/sdk/storage/armstorage/go.mod new file mode 100644 index 000000000000..d738456a4c78 --- /dev/null +++ b/sdk/storage/armstorage/go.mod @@ -0,0 +1,10 @@ +module github.com/Azure/azure-sdk-for-go/sdk/storage/armstorage + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.7.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/to v0.1.4 // indirect +) diff --git a/sdk/arm/storage/go.sum b/sdk/storage/armstorage/go.sum similarity index 74% rename from sdk/arm/storage/go.sum rename to sdk/storage/armstorage/go.sum index fa5feb523964..8bedd6b99c31 100644 --- a/sdk/arm/storage/go.sum +++ b/sdk/storage/armstorage/go.sum @@ -1,14 +1,11 @@ -github.com/Azure/azure-sdk-for-go v53.4.0+incompatible h1:ky9S0JoJOvO39ncwrYAVMEBiIjFB/WkbZsWkg/nbYx0= -github.com/Azure/azure-sdk-for-go v53.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go/sdk/armcore v0.7.0 h1:+LyX2LaBmlKPsmTJV+U04wbtu9SoHYRmZPgLHjbSuOk= github.com/Azure/azure-sdk-for-go/sdk/armcore v0.7.0/go.mod h1:6yYd2qNvutd94jHTMUg9KrdbR39jNzI4d+15lm2gxkg= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.7.1 h1:qvtCPHEhkkkiuHqoQU3c0a21l6qO3sXgpa3aC/SO4w8= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.7.1/go.mod h1:6yYd2qNvutd94jHTMUg9KrdbR39jNzI4d+15lm2gxkg= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.0/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.4 h1:WCOYbqX0ZXM/GvcZ8fUDhOLQ46saqP4yMI97YBb53hw= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.4/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.5 h1:5M4hJrG3tACs94wIfrJXx5EiURSZS7LWwIWi1xj/jQk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.5/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.8.0 h1:wb00szFWtKeIef2Q5X8gdd0mYp8oSHmJOYUh/QXD8sw= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.8.0/go.mod h1:acANgl9stsT5xflESXKjZx4rhZJSr0TGgTDYY0xJPIE= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.1 h1:yQw8Ah26gBP4dv66ZNjZpRBRV+gaHH/0TLn1taU4FZ4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.1/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.1 h1:KchdKK3XlOjkzBROV+q3D+YgfRTvwoeBwbaoX4aVkjI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.1/go.mod h1:acANgl9stsT5xflESXKjZx4rhZJSr0TGgTDYY0xJPIE= github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw= github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= @@ -21,6 +18,7 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobcontainers_client.go b/sdk/storage/armstorage/zz_generated_blobcontainers_client.go similarity index 84% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobcontainers_client.go rename to sdk/storage/armstorage/zz_generated_blobcontainers_client.go index dd57754fba63..eb3023303918 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobcontainers_client.go +++ b/sdk/storage/armstorage/zz_generated_blobcontainers_client.go @@ -13,10 +13,10 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" + "time" ) // BlobContainersClient contains the methods for the BlobContainers group. @@ -33,6 +33,7 @@ func NewBlobContainersClient(con *armcore.Connection, subscriptionID string) *Bl // ClearLegalHold - Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the // specified tags in the request. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) ClearLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersClearLegalHoldOptions) (LegalHoldResponse, error) { req, err := client.clearLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) if err != nil { @@ -73,7 +74,7 @@ func (client *BlobContainersClient) clearLegalHoldCreateRequest(ctx context.Cont } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(legalHold) @@ -90,9 +91,9 @@ func (client *BlobContainersClient) clearLegalHoldHandleResponse(resp *azcore.Re // clearLegalHoldHandleError handles the ClearLegalHold error response. func (client *BlobContainersClient) clearLegalHoldHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -103,6 +104,7 @@ func (client *BlobContainersClient) clearLegalHoldHandleError(resp *azcore.Respo // Create - Creates a new container under the specified account as described by request body. The container resource includes metadata and properties for // that container. It does not include a list of the blobs // contained by the container. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) Create(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersCreateOptions) (BlobContainerResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) if err != nil { @@ -143,7 +145,7 @@ func (client *BlobContainersClient) createCreateRequest(ctx context.Context, res } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(blobContainer) @@ -160,9 +162,9 @@ func (client *BlobContainersClient) createHandleResponse(resp *azcore.Response) // createHandleError handles the Create error response. func (client *BlobContainersClient) createHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -172,6 +174,7 @@ func (client *BlobContainersClient) createHandleError(resp *azcore.Response) err // CreateOrUpdateImmutabilityPolicy - Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this // operation. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) CreateOrUpdateImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersCreateOrUpdateImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { req, err := client.createOrUpdateImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { @@ -213,14 +216,14 @@ func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyCreateReques } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() if options != nil && options.IfMatch != nil { req.Header.Set("If-Match", *options.IfMatch) } req.Header.Set("Accept", "application/json") if options != nil && options.Parameters != nil { - return req, req.MarshalAsJSON(options.Parameters) + return req, req.MarshalAsJSON(*options.Parameters) } return req, nil } @@ -240,9 +243,9 @@ func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyHandleRespon // createOrUpdateImmutabilityPolicyHandleError handles the CreateOrUpdateImmutabilityPolicy error response. func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -251,6 +254,7 @@ func (client *BlobContainersClient) createOrUpdateImmutabilityPolicyHandleError( } // Delete - Deletes specified container under its account. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) Delete(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { @@ -291,16 +295,16 @@ func (client *BlobContainersClient) deleteCreateRequest(ctx context.Context, res } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() return req, nil } // deleteHandleError handles the Delete error response. func (client *BlobContainersClient) deleteHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -311,6 +315,7 @@ func (client *BlobContainersClient) deleteHandleError(resp *azcore.Response) err // DeleteImmutabilityPolicy - Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in // If-Match is required for this operation. Deleting a locked immutability // policy is not allowed, the only way is to delete the container after deleting all expired blobs inside the policy locked container. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) DeleteImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersDeleteImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { req, err := client.deleteImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { @@ -352,7 +357,7 @@ func (client *BlobContainersClient) deleteImmutabilityPolicyCreateRequest(ctx co } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("If-Match", ifMatch) req.Header.Set("Accept", "application/json") @@ -374,9 +379,9 @@ func (client *BlobContainersClient) deleteImmutabilityPolicyHandleResponse(resp // deleteImmutabilityPolicyHandleError handles the DeleteImmutabilityPolicy error response. func (client *BlobContainersClient) deleteImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -386,6 +391,7 @@ func (client *BlobContainersClient) deleteImmutabilityPolicyHandleError(resp *az // ExtendImmutabilityPolicy - Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only action allowed on a Locked policy // will be this action. ETag in If-Match is required for this operation. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) ExtendImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersExtendImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { req, err := client.extendImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { @@ -426,12 +432,12 @@ func (client *BlobContainersClient) extendImmutabilityPolicyCreateRequest(ctx co } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("If-Match", ifMatch) req.Header.Set("Accept", "application/json") if options != nil && options.Parameters != nil { - return req, req.MarshalAsJSON(options.Parameters) + return req, req.MarshalAsJSON(*options.Parameters) } return req, nil } @@ -451,9 +457,9 @@ func (client *BlobContainersClient) extendImmutabilityPolicyHandleResponse(resp // extendImmutabilityPolicyHandleError handles the ExtendImmutabilityPolicy error response. func (client *BlobContainersClient) extendImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -462,6 +468,7 @@ func (client *BlobContainersClient) extendImmutabilityPolicyHandleError(resp *az } // Get - Gets properties of a specified container. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) Get(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersGetOptions) (BlobContainerResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { @@ -502,7 +509,7 @@ func (client *BlobContainersClient) getCreateRequest(ctx context.Context, resour } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -519,9 +526,9 @@ func (client *BlobContainersClient) getHandleResponse(resp *azcore.Response) (Bl // getHandleError handles the Get error response. func (client *BlobContainersClient) getHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -530,6 +537,7 @@ func (client *BlobContainersClient) getHandleError(resp *azcore.Response) error } // GetImmutabilityPolicy - Gets the existing immutability policy along with the corresponding ETag in response headers and body. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) GetImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersGetImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { req, err := client.getImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { @@ -571,7 +579,7 @@ func (client *BlobContainersClient) getImmutabilityPolicyCreateRequest(ctx conte } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() if options != nil && options.IfMatch != nil { req.Header.Set("If-Match", *options.IfMatch) @@ -595,9 +603,9 @@ func (client *BlobContainersClient) getImmutabilityPolicyHandleResponse(resp *az // getImmutabilityPolicyHandleError handles the GetImmutabilityPolicy error response. func (client *BlobContainersClient) getImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -607,6 +615,7 @@ func (client *BlobContainersClient) getImmutabilityPolicyHandleError(resp *azcor // Lease - The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, // or can be infinite. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) Lease(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersLeaseOptions) (LeaseContainerResponseResponse, error) { req, err := client.leaseCreateRequest(ctx, resourceGroupName, accountName, containerName, options) if err != nil { @@ -647,11 +656,11 @@ func (client *BlobContainersClient) leaseCreateRequest(ctx context.Context, reso } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") if options != nil && options.Parameters != nil { - return req, req.MarshalAsJSON(options.Parameters) + return req, req.MarshalAsJSON(*options.Parameters) } return req, nil } @@ -667,9 +676,9 @@ func (client *BlobContainersClient) leaseHandleResponse(resp *azcore.Response) ( // leaseHandleError handles the Lease error response. func (client *BlobContainersClient) leaseHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -678,6 +687,7 @@ func (client *BlobContainersClient) leaseHandleError(resp *azcore.Response) erro } // List - Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) List(resourceGroupName string, accountName string, options *BlobContainersListOptions) ListContainerItemsPager { return &listContainerItemsPager{ pipeline: client.con.Pipeline(), @@ -714,7 +724,7 @@ func (client *BlobContainersClient) listCreateRequest(ctx context.Context, resou } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") if options != nil && options.Maxpagesize != nil { reqQP.Set("$maxpagesize", *options.Maxpagesize) } @@ -740,9 +750,9 @@ func (client *BlobContainersClient) listHandleResponse(resp *azcore.Response) (L // listHandleError handles the List error response. func (client *BlobContainersClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -752,6 +762,7 @@ func (client *BlobContainersClient) listHandleError(resp *azcore.Response) error // LockImmutabilityPolicy - Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. // ETag in If-Match is required for this operation. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) LockImmutabilityPolicy(ctx context.Context, resourceGroupName string, accountName string, containerName string, ifMatch string, options *BlobContainersLockImmutabilityPolicyOptions) (ImmutabilityPolicyResponse, error) { req, err := client.lockImmutabilityPolicyCreateRequest(ctx, resourceGroupName, accountName, containerName, ifMatch, options) if err != nil { @@ -792,7 +803,7 @@ func (client *BlobContainersClient) lockImmutabilityPolicyCreateRequest(ctx cont } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("If-Match", ifMatch) req.Header.Set("Accept", "application/json") @@ -814,9 +825,9 @@ func (client *BlobContainersClient) lockImmutabilityPolicyHandleResponse(resp *a // lockImmutabilityPolicyHandleError handles the LockImmutabilityPolicy error response. func (client *BlobContainersClient) lockImmutabilityPolicyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -824,8 +835,124 @@ func (client *BlobContainersClient) lockImmutabilityPolicyHandleError(resp *azco return azcore.NewResponseError(errors.New(string(body)), resp.Response) } +// BeginObjectLevelWorm - This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites +// require a container level immutability policy either in locked or +// unlocked state, Account level versioning must be enabled and there should be no Legal hold on the container. +// If the operation fails it returns the *CloudError error type. +func (client *BlobContainersClient) BeginObjectLevelWorm(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersBeginObjectLevelWormOptions) (HTTPPollerResponse, error) { + resp, err := client.objectLevelWorm(ctx, resourceGroupName, accountName, containerName, options) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewPoller("BlobContainersClient.ObjectLevelWorm", "location", resp, client.objectLevelWormHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pipeline: client.con.Pipeline(), + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeObjectLevelWorm creates a new HTTPPoller from the specified resume token. +// token - The value must come from a previous call to HTTPPoller.ResumeToken(). +func (client *BlobContainersClient) ResumeObjectLevelWorm(ctx context.Context, token string) (HTTPPollerResponse, error) { + pt, err := armcore.NewPollerFromResumeToken("BlobContainersClient.ObjectLevelWorm", token, client.objectLevelWormHandleError) + if err != nil { + return HTTPPollerResponse{}, err + } + poller := &httpPoller{ + pipeline: client.con.Pipeline(), + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return HTTPPollerResponse{}, err + } + result := HTTPPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ObjectLevelWorm - This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require +// a container level immutability policy either in locked or +// unlocked state, Account level versioning must be enabled and there should be no Legal hold on the container. +// If the operation fails it returns the *CloudError error type. +func (client *BlobContainersClient) objectLevelWorm(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersBeginObjectLevelWormOptions) (*azcore.Response, error) { + req, err := client.objectLevelWormCreateRequest(ctx, resourceGroupName, accountName, containerName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.objectLevelWormHandleError(resp) + } + return resp, nil +} + +// objectLevelWormCreateRequest creates the ObjectLevelWorm request. +func (client *BlobContainersClient) objectLevelWormCreateRequest(ctx context.Context, resourceGroupName string, accountName string, containerName string, options *BlobContainersBeginObjectLevelWormOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if containerName == "" { + return nil, errors.New("parameter containerName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// objectLevelWormHandleError handles the ObjectLevelWorm error response. +func (client *BlobContainersClient) objectLevelWormHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudError{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + // SetLegalHold - Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold follows an append pattern and does not clear // out the existing tags that are not specified in the request. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) SetLegalHold(ctx context.Context, resourceGroupName string, accountName string, containerName string, legalHold LegalHold, options *BlobContainersSetLegalHoldOptions) (LegalHoldResponse, error) { req, err := client.setLegalHoldCreateRequest(ctx, resourceGroupName, accountName, containerName, legalHold, options) if err != nil { @@ -866,7 +993,7 @@ func (client *BlobContainersClient) setLegalHoldCreateRequest(ctx context.Contex } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(legalHold) @@ -883,9 +1010,9 @@ func (client *BlobContainersClient) setLegalHoldHandleResponse(resp *azcore.Resp // setLegalHoldHandleError handles the SetLegalHold error response. func (client *BlobContainersClient) setLegalHoldHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -895,6 +1022,7 @@ func (client *BlobContainersClient) setLegalHoldHandleError(resp *azcore.Respons // Update - Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified // container doesn't already exist. +// If the operation fails it returns a generic error. func (client *BlobContainersClient) Update(ctx context.Context, resourceGroupName string, accountName string, containerName string, blobContainer BlobContainer, options *BlobContainersUpdateOptions) (BlobContainerResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, containerName, blobContainer, options) if err != nil { @@ -935,7 +1063,7 @@ func (client *BlobContainersClient) updateCreateRequest(ctx context.Context, res } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(blobContainer) @@ -952,9 +1080,9 @@ func (client *BlobContainersClient) updateHandleResponse(resp *azcore.Response) // updateHandleError handles the Update error response. func (client *BlobContainersClient) updateHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobinventorypolicies_client.go b/sdk/storage/armstorage/zz_generated_blobinventorypolicies_client.go similarity index 86% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobinventorypolicies_client.go rename to sdk/storage/armstorage/zz_generated_blobinventorypolicies_client.go index 4dd78d00c2e5..8563bc0c4619 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_blobinventorypolicies_client.go +++ b/sdk/storage/armstorage/zz_generated_blobinventorypolicies_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -30,6 +31,7 @@ func NewBlobInventoryPoliciesClient(con *armcore.Connection, subscriptionID stri } // CreateOrUpdate - Sets the blob inventory policy to the specified storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *BlobInventoryPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName BlobInventoryPolicyName, properties BlobInventoryPolicy, options *BlobInventoryPoliciesCreateOrUpdateOptions) (BlobInventoryPolicyResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, blobInventoryPolicyName, properties, options) if err != nil { @@ -70,7 +72,7 @@ func (client *BlobInventoryPoliciesClient) createOrUpdateCreateRequest(ctx conte } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(properties) @@ -87,14 +89,19 @@ func (client *BlobInventoryPoliciesClient) createOrUpdateHandleResponse(resp *az // createOrUpdateHandleError handles the CreateOrUpdate error response. func (client *BlobInventoryPoliciesClient) createOrUpdateHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Delete - Deletes the blob inventory policy associated with the specified storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *BlobInventoryPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName BlobInventoryPolicyName, options *BlobInventoryPoliciesDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, blobInventoryPolicyName, options) if err != nil { @@ -135,7 +142,7 @@ func (client *BlobInventoryPoliciesClient) deleteCreateRequest(ctx context.Conte } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -143,14 +150,19 @@ func (client *BlobInventoryPoliciesClient) deleteCreateRequest(ctx context.Conte // deleteHandleError handles the Delete error response. func (client *BlobInventoryPoliciesClient) deleteHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Get - Gets the blob inventory policy associated with the specified storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *BlobInventoryPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, blobInventoryPolicyName BlobInventoryPolicyName, options *BlobInventoryPoliciesGetOptions) (BlobInventoryPolicyResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, blobInventoryPolicyName, options) if err != nil { @@ -191,7 +203,7 @@ func (client *BlobInventoryPoliciesClient) getCreateRequest(ctx context.Context, } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -208,14 +220,19 @@ func (client *BlobInventoryPoliciesClient) getHandleResponse(resp *azcore.Respon // getHandleError handles the Get error response. func (client *BlobInventoryPoliciesClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // List - Gets the blob inventory policy associated with the specified storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *BlobInventoryPoliciesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *BlobInventoryPoliciesListOptions) (ListBlobInventoryPolicyResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -252,7 +269,7 @@ func (client *BlobInventoryPoliciesClient) listCreateRequest(ctx context.Context } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -269,9 +286,13 @@ func (client *BlobInventoryPoliciesClient) listHandleResponse(resp *azcore.Respo // listHandleError handles the List error response. func (client *BlobInventoryPoliciesClient) listHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobservices_client.go b/sdk/storage/armstorage/zz_generated_blobservices_client.go similarity index 94% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobservices_client.go rename to sdk/storage/armstorage/zz_generated_blobservices_client.go index 96d0a0281e91..4d29cc0e26c8 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobservices_client.go +++ b/sdk/storage/armstorage/zz_generated_blobservices_client.go @@ -10,10 +10,8 @@ package armstorage import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -33,6 +31,7 @@ func NewBlobServicesClient(con *armcore.Connection, subscriptionID string) *Blob // GetServiceProperties - Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource // Sharing) rules. +// If the operation fails it returns a generic error. func (client *BlobServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *BlobServicesGetServicePropertiesOptions) (BlobServicePropertiesResponse, error) { req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -70,7 +69,7 @@ func (client *BlobServicesClient) getServicePropertiesCreateRequest(ctx context. } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -87,9 +86,9 @@ func (client *BlobServicesClient) getServicePropertiesHandleResponse(resp *azcor // getServicePropertiesHandleError handles the GetServiceProperties error response. func (client *BlobServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -98,6 +97,7 @@ func (client *BlobServicesClient) getServicePropertiesHandleError(resp *azcore.R } // List - List blob services of storage account. It returns a collection of one object named default. +// If the operation fails it returns a generic error. func (client *BlobServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *BlobServicesListOptions) (BlobServiceItemsResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -134,7 +134,7 @@ func (client *BlobServicesClient) listCreateRequest(ctx context.Context, resourc } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -151,9 +151,9 @@ func (client *BlobServicesClient) listHandleResponse(resp *azcore.Response) (Blo // listHandleError handles the List error response. func (client *BlobServicesClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -163,6 +163,7 @@ func (client *BlobServicesClient) listHandleError(resp *azcore.Response) error { // SetServiceProperties - Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource // Sharing) rules. +// If the operation fails it returns a generic error. func (client *BlobServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters BlobServiceProperties, options *BlobServicesSetServicePropertiesOptions) (BlobServicePropertiesResponse, error) { req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -200,7 +201,7 @@ func (client *BlobServicesClient) setServicePropertiesCreateRequest(ctx context. } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) @@ -217,9 +218,9 @@ func (client *BlobServicesClient) setServicePropertiesHandleResponse(resp *azcor // setServicePropertiesHandleError handles the SetServiceProperties error response. func (client *BlobServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) diff --git a/sdk/arm/storage/version.go b/sdk/storage/armstorage/zz_generated_connection.go similarity index 82% rename from sdk/arm/storage/version.go rename to sdk/storage/armstorage/zz_generated_connection.go index 4c3efce0711a..15f02a134eb9 100644 --- a/sdk/arm/storage/version.go +++ b/sdk/storage/armstorage/zz_generated_connection.go @@ -5,6 +5,6 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package storage +package armstorage -const Version = "v0.1.0" +const telemetryInfo = "azsdk-go-armstorage/v0.1.0" diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_constants.go b/sdk/storage/armstorage/zz_generated_constants.go similarity index 87% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_constants.go rename to sdk/storage/armstorage/zz_generated_constants.go index 4b6ff27aa2b7..8b896131fe13 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_constants.go +++ b/sdk/storage/armstorage/zz_generated_constants.go @@ -195,6 +195,33 @@ func (c DefaultAction) ToPtr() *DefaultAction { return &c } +// DefaultSharePermission - Default share permission for users using Kerberos authentication if RBAC role is not assigned. +type DefaultSharePermission string + +const ( + DefaultSharePermissionNone DefaultSharePermission = "None" + DefaultSharePermissionStorageFileDataSmbShareContributor DefaultSharePermission = "StorageFileDataSmbShareContributor" + DefaultSharePermissionStorageFileDataSmbShareElevatedContributor DefaultSharePermission = "StorageFileDataSmbShareElevatedContributor" + DefaultSharePermissionStorageFileDataSmbShareOwner DefaultSharePermission = "StorageFileDataSmbShareOwner" + DefaultSharePermissionStorageFileDataSmbShareReader DefaultSharePermission = "StorageFileDataSmbShareReader" +) + +// PossibleDefaultSharePermissionValues returns the possible values for the DefaultSharePermission const type. +func PossibleDefaultSharePermissionValues() []DefaultSharePermission { + return []DefaultSharePermission{ + DefaultSharePermissionNone, + DefaultSharePermissionStorageFileDataSmbShareContributor, + DefaultSharePermissionStorageFileDataSmbShareElevatedContributor, + DefaultSharePermissionStorageFileDataSmbShareOwner, + DefaultSharePermissionStorageFileDataSmbShareReader, + } +} + +// ToPtr returns a *DefaultSharePermission pointing to the current value. +func (c DefaultSharePermission) ToPtr() *DefaultSharePermission { + return &c +} + // DirectoryServiceOptions - Indicates the directory service used. type DirectoryServiceOptions string @@ -281,6 +308,25 @@ func (c EncryptionScopeState) ToPtr() *EncryptionScopeState { return &c } +// ExpirationAction - The SAS expiration action. Can only be Log. +type ExpirationAction string + +const ( + ExpirationActionLog ExpirationAction = "Log" +) + +// PossibleExpirationActionValues returns the possible values for the ExpirationAction const type. +func PossibleExpirationActionValues() []ExpirationAction { + return []ExpirationAction{ + ExpirationActionLog, + } +} + +// ToPtr returns a *ExpirationAction pointing to the current value. +func (c ExpirationAction) ToPtr() *ExpirationAction { + return &c +} + // ExtendedLocationTypes - The type of extendedLocation. type ExtendedLocationTypes string @@ -300,6 +346,27 @@ func (c ExtendedLocationTypes) ToPtr() *ExtendedLocationTypes { return &c } +// Format - This is a required field, it specifies the format for the inventory files. +type Format string + +const ( + FormatCSV Format = "Csv" + FormatParquet Format = "Parquet" +) + +// PossibleFormatValues returns the possible values for the Format const type. +func PossibleFormatValues() []Format { + return []Format{ + FormatCSV, + FormatParquet, + } +} + +// ToPtr returns a *Format pointing to the current value. +func (c Format) ToPtr() *Format { + return &c +} + // GeoReplicationStatus - 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 @@ -595,6 +662,33 @@ func (c LeaseDuration) ToPtr() *LeaseDuration { return &c } +// LeaseShareAction - Specifies the lease action. Can be one of the available actions. +type LeaseShareAction string + +const ( + LeaseShareActionAcquire LeaseShareAction = "Acquire" + LeaseShareActionBreak LeaseShareAction = "Break" + LeaseShareActionChange LeaseShareAction = "Change" + LeaseShareActionRelease LeaseShareAction = "Release" + LeaseShareActionRenew LeaseShareAction = "Renew" +) + +// PossibleLeaseShareActionValues returns the possible values for the LeaseShareAction const type. +func PossibleLeaseShareActionValues() []LeaseShareAction { + return []LeaseShareAction{ + LeaseShareActionAcquire, + LeaseShareActionBreak, + LeaseShareActionChange, + LeaseShareActionRelease, + LeaseShareActionRenew, + } +} + +// ToPtr returns a *LeaseShareAction pointing to the current value. +func (c LeaseShareAction) ToPtr() *LeaseShareAction { + return &c +} + // LeaseState - Lease state of the container. type LeaseState string @@ -661,41 +755,42 @@ func (c ListContainersInclude) ToPtr() *ListContainersInclude { return &c } -type ListSharesExpand string +type ManagementPolicyName string const ( - ListSharesExpandDeleted ListSharesExpand = "deleted" - ListSharesExpandSnapshots ListSharesExpand = "snapshots" + ManagementPolicyNameDefault ManagementPolicyName = "default" ) -// PossibleListSharesExpandValues returns the possible values for the ListSharesExpand const type. -func PossibleListSharesExpandValues() []ListSharesExpand { - return []ListSharesExpand{ - ListSharesExpandDeleted, - ListSharesExpandSnapshots, +// PossibleManagementPolicyNameValues returns the possible values for the ManagementPolicyName const type. +func PossibleManagementPolicyNameValues() []ManagementPolicyName { + return []ManagementPolicyName{ + ManagementPolicyNameDefault, } } -// ToPtr returns a *ListSharesExpand pointing to the current value. -func (c ListSharesExpand) ToPtr() *ListSharesExpand { +// ToPtr returns a *ManagementPolicyName pointing to the current value. +func (c ManagementPolicyName) ToPtr() *ManagementPolicyName { return &c } -type ManagementPolicyName string +// MigrationState - This property denotes the container level immutability to object level immutability migration state. +type MigrationState string const ( - ManagementPolicyNameDefault ManagementPolicyName = "default" + MigrationStateCompleted MigrationState = "Completed" + MigrationStateInProgress MigrationState = "InProgress" ) -// PossibleManagementPolicyNameValues returns the possible values for the ManagementPolicyName const type. -func PossibleManagementPolicyNameValues() []ManagementPolicyName { - return []ManagementPolicyName{ - ManagementPolicyNameDefault, +// PossibleMigrationStateValues returns the possible values for the MigrationState const type. +func PossibleMigrationStateValues() []MigrationState { + return []MigrationState{ + MigrationStateCompleted, + MigrationStateInProgress, } } -// ToPtr returns a *ManagementPolicyName pointing to the current value. -func (c ManagementPolicyName) ToPtr() *ManagementPolicyName { +// ToPtr returns a *MigrationState pointing to the current value. +func (c MigrationState) ToPtr() *MigrationState { return &c } @@ -741,6 +836,27 @@ func (c Name) ToPtr() *Name { return &c } +// ObjectType - This is a required field. This field specifies the scope of the inventory created either at the blob or container level. +type ObjectType string + +const ( + ObjectTypeBlob ObjectType = "Blob" + ObjectTypeContainer ObjectType = "Container" +) + +// PossibleObjectTypeValues returns the possible values for the ObjectType const type. +func PossibleObjectTypeValues() []ObjectType { + return []ObjectType{ + ObjectTypeBlob, + ObjectTypeContainer, + } +} + +// ToPtr returns a *ObjectType pointing to the current value. +func (c ObjectType) ToPtr() *ObjectType { + return &c +} + // Permissions - 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). type Permissions string @@ -869,24 +985,6 @@ func (c PublicAccess) ToPtr() *PublicAccess { return &c } -type PutSharesExpand string - -const ( - PutSharesExpandSnapshots PutSharesExpand = "snapshots" -) - -// PossiblePutSharesExpandValues returns the possible values for the PutSharesExpand const type. -func PossiblePutSharesExpandValues() []PutSharesExpand { - return []PutSharesExpand{ - PutSharesExpandSnapshots, - } -} - -// ToPtr returns a *PutSharesExpand pointing to the current value. -func (c PutSharesExpand) ToPtr() *PutSharesExpand { - return &c -} - // Reason - Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. type Reason string @@ -1048,6 +1146,27 @@ func (c SKUTier) ToPtr() *SKUTier { return &c } +// Schedule - This is a required field. This field is used to schedule an inventory formation. +type Schedule string + +const ( + ScheduleDaily Schedule = "Daily" + ScheduleWeekly Schedule = "Weekly" +) + +// PossibleScheduleValues returns the possible values for the Schedule const type. +func PossibleScheduleValues() []Schedule { + return []Schedule{ + ScheduleDaily, + ScheduleWeekly, + } +} + +// ToPtr returns a *Schedule pointing to the current value. +func (c Schedule) ToPtr() *Schedule { + return &c +} + // Services - The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). type Services string @@ -1153,11 +1272,11 @@ func (c SignedResourceTypes) ToPtr() *SignedResourceTypes { type State string const ( - StateDeprovisioning State = "deprovisioning" - StateFailed State = "failed" - StateNetworkSourceDeleted State = "networkSourceDeleted" - StateProvisioning State = "provisioning" - StateSucceeded State = "succeeded" + StateDeprovisioning State = "Deprovisioning" + StateFailed State = "Failed" + StateNetworkSourceDeleted State = "NetworkSourceDeleted" + StateProvisioning State = "Provisioning" + StateSucceeded State = "Succeeded" ) // PossibleStateValues returns the possible values for the State const type. diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_deletedaccounts_client.go b/sdk/storage/armstorage/zz_generated_deletedaccounts_client.go similarity index 85% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_deletedaccounts_client.go rename to sdk/storage/armstorage/zz_generated_deletedaccounts_client.go index ca7a84e2ef1e..e1c8acb49c55 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_deletedaccounts_client.go +++ b/sdk/storage/armstorage/zz_generated_deletedaccounts_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -30,6 +31,7 @@ func NewDeletedAccountsClient(con *armcore.Connection, subscriptionID string) *D } // Get - Get properties of specified deleted account resource. +// If the operation fails it returns the *ErrorResponse error type. func (client *DeletedAccountsClient) Get(ctx context.Context, deletedAccountName string, location string, options *DeletedAccountsGetOptions) (DeletedAccountResponse, error) { req, err := client.getCreateRequest(ctx, deletedAccountName, location, options) if err != nil { @@ -66,7 +68,7 @@ func (client *DeletedAccountsClient) getCreateRequest(ctx context.Context, delet } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -83,14 +85,19 @@ func (client *DeletedAccountsClient) getHandleResponse(resp *azcore.Response) (D // getHandleError handles the Get error response. func (client *DeletedAccountsClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // List - Lists deleted accounts under the subscription. +// If the operation fails it returns the *ErrorResponse error type. func (client *DeletedAccountsClient) List(options *DeletedAccountsListOptions) DeletedAccountListResultPager { return &deletedAccountListResultPager{ pipeline: client.con.Pipeline(), @@ -119,7 +126,7 @@ func (client *DeletedAccountsClient) listCreateRequest(ctx context.Context, opti } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -136,9 +143,13 @@ func (client *DeletedAccountsClient) listHandleResponse(resp *azcore.Response) ( // listHandleError handles the List error response. func (client *DeletedAccountsClient) listHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_encryptionscopes_client.go b/sdk/storage/armstorage/zz_generated_encryptionscopes_client.go similarity index 89% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_encryptionscopes_client.go rename to sdk/storage/armstorage/zz_generated_encryptionscopes_client.go index 8f0bfc834141..8ee5f609340d 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_encryptionscopes_client.go +++ b/sdk/storage/armstorage/zz_generated_encryptionscopes_client.go @@ -13,7 +13,6 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -32,6 +31,7 @@ func NewEncryptionScopesClient(con *armcore.Connection, subscriptionID string) * } // Get - Returns the properties for the specified encryption scope. +// If the operation fails it returns the *ErrorResponse error type. func (client *EncryptionScopesClient) Get(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, options *EncryptionScopesGetOptions) (EncryptionScopeResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, encryptionScopeName, options) if err != nil { @@ -72,7 +72,7 @@ func (client *EncryptionScopesClient) getCreateRequest(ctx context.Context, reso } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -89,14 +89,19 @@ func (client *EncryptionScopesClient) getHandleResponse(resp *azcore.Response) ( // getHandleError handles the Get error response. func (client *EncryptionScopesClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // List - Lists all the encryption scopes available under the specified storage account. +// If the operation fails it returns a generic error. func (client *EncryptionScopesClient) List(resourceGroupName string, accountName string, options *EncryptionScopesListOptions) EncryptionScopeListResultPager { return &encryptionScopeListResultPager{ pipeline: client.con.Pipeline(), @@ -133,7 +138,7 @@ func (client *EncryptionScopesClient) listCreateRequest(ctx context.Context, res } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -150,9 +155,9 @@ func (client *EncryptionScopesClient) listHandleResponse(resp *azcore.Response) // listHandleError handles the List error response. func (client *EncryptionScopesClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -161,6 +166,7 @@ func (client *EncryptionScopesClient) listHandleError(resp *azcore.Response) err } // Patch - Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. +// If the operation fails it returns the *ErrorResponse error type. func (client *EncryptionScopesClient) Patch(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesPatchOptions) (EncryptionScopeResponse, error) { req, err := client.patchCreateRequest(ctx, resourceGroupName, accountName, encryptionScopeName, encryptionScope, options) if err != nil { @@ -201,7 +207,7 @@ func (client *EncryptionScopesClient) patchCreateRequest(ctx context.Context, re } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(encryptionScope) @@ -218,16 +224,21 @@ func (client *EncryptionScopesClient) patchHandleResponse(resp *azcore.Response) // patchHandleError handles the Patch error response. func (client *EncryptionScopesClient) patchHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // Put - Synchronously creates or updates an encryption scope under the specified storage account. If an encryption scope is already created and a subsequent // request is issued with different properties, the // encryption scope properties will be updated per the specified request. +// If the operation fails it returns the *ErrorResponse error type. func (client *EncryptionScopesClient) Put(ctx context.Context, resourceGroupName string, accountName string, encryptionScopeName string, encryptionScope EncryptionScope, options *EncryptionScopesPutOptions) (EncryptionScopeResponse, error) { req, err := client.putCreateRequest(ctx, resourceGroupName, accountName, encryptionScopeName, encryptionScope, options) if err != nil { @@ -268,7 +279,7 @@ func (client *EncryptionScopesClient) putCreateRequest(ctx context.Context, reso } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(encryptionScope) @@ -285,9 +296,13 @@ func (client *EncryptionScopesClient) putHandleResponse(resp *azcore.Response) ( // putHandleError handles the Put error response. func (client *EncryptionScopesClient) putHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileservices_client.go b/sdk/storage/armstorage/zz_generated_fileservices_client.go similarity index 86% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileservices_client.go rename to sdk/storage/armstorage/zz_generated_fileservices_client.go index ace1ab31cc7a..b811eca985da 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileservices_client.go +++ b/sdk/storage/armstorage/zz_generated_fileservices_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -30,6 +31,7 @@ func NewFileServicesClient(con *armcore.Connection, subscriptionID string) *File } // GetServiceProperties - Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesGetServicePropertiesOptions) (FileServicePropertiesResponse, error) { req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -67,7 +69,7 @@ func (client *FileServicesClient) getServicePropertiesCreateRequest(ctx context. } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -84,14 +86,19 @@ func (client *FileServicesClient) getServicePropertiesHandleResponse(resp *azcor // getServicePropertiesHandleError handles the GetServiceProperties error response. func (client *FileServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // List - List all file services in storage accounts +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *FileServicesListOptions) (FileServiceItemsResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -128,7 +135,7 @@ func (client *FileServicesClient) listCreateRequest(ctx context.Context, resourc } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -145,14 +152,19 @@ func (client *FileServicesClient) listHandleResponse(resp *azcore.Response) (Fil // listHandleError handles the List error response. func (client *FileServicesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // SetServiceProperties - Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters FileServiceProperties, options *FileServicesSetServicePropertiesOptions) (FileServicePropertiesResponse, error) { req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -190,7 +202,7 @@ func (client *FileServicesClient) setServicePropertiesCreateRequest(ctx context. } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) @@ -207,9 +219,13 @@ func (client *FileServicesClient) setServicePropertiesHandleResponse(resp *azcor // setServicePropertiesHandleError handles the SetServiceProperties error response. func (client *FileServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_fileshares_client.go b/sdk/storage/armstorage/zz_generated_fileshares_client.go similarity index 71% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_fileshares_client.go rename to sdk/storage/armstorage/zz_generated_fileshares_client.go index 5978047506bc..ae35d52feeac 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_fileshares_client.go +++ b/sdk/storage/armstorage/zz_generated_fileshares_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -32,6 +33,7 @@ func NewFileSharesClient(con *armcore.Connection, subscriptionID string) *FileSh // Create - Creates a new share under the specified account as described by request body. The share resource includes metadata and properties for that share. // It does not include a list of the files contained by // the share. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileSharesClient) Create(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesCreateOptions) (FileShareResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options) if err != nil { @@ -73,9 +75,9 @@ func (client *FileSharesClient) createCreateRequest(ctx context.Context, resourc req.Telemetry(telemetryInfo) reqQP := req.URL.Query() if options != nil && options.Expand != nil { - reqQP.Set("$expand", string(*options.Expand)) + reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(fileShare) @@ -92,14 +94,19 @@ func (client *FileSharesClient) createHandleResponse(resp *azcore.Response) (Fil // createHandleError handles the Create error response. func (client *FileSharesClient) createHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Delete - Deletes specified share under its account. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileSharesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, shareName, options) if err != nil { @@ -140,7 +147,10 @@ func (client *FileSharesClient) deleteCreateRequest(ctx context.Context, resourc } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") + if options != nil && options.Include != nil { + reqQP.Set("$include", *options.Include) + } req.URL.RawQuery = reqQP.Encode() if options != nil && options.XMSSnapshot != nil { req.Header.Set("x-ms-snapshot", *options.XMSSnapshot) @@ -151,14 +161,19 @@ func (client *FileSharesClient) deleteCreateRequest(ctx context.Context, resourc // deleteHandleError handles the Delete error response. func (client *FileSharesClient) deleteHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // Get - Gets properties of a specified share. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileSharesClient) Get(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesGetOptions) (FileShareResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, shareName, options) if err != nil { @@ -199,9 +214,9 @@ func (client *FileSharesClient) getCreateRequest(ctx context.Context, resourceGr } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") if options != nil && options.Expand != nil { - reqQP.Set("$expand", "stats") + reqQP.Set("$expand", *options.Expand) } req.URL.RawQuery = reqQP.Encode() if options != nil && options.XMSSnapshot != nil { @@ -222,14 +237,100 @@ func (client *FileSharesClient) getHandleResponse(resp *azcore.Response) (FileSh // getHandleError handles the Get error response. func (client *FileSharesClient) getHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Lease - The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can +// be infinite. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. +func (client *FileSharesClient) Lease(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesLeaseOptions) (LeaseShareResponseResponse, error) { + req, err := client.leaseCreateRequest(ctx, resourceGroupName, accountName, shareName, options) + if err != nil { + return LeaseShareResponseResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LeaseShareResponseResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LeaseShareResponseResponse{}, client.leaseHandleError(resp) } - return azcore.NewResponseError(&err, resp.Response) + return client.leaseHandleResponse(resp) +} + +// leaseCreateRequest creates the Lease request. +func (client *FileSharesClient) leaseCreateRequest(ctx context.Context, resourceGroupName string, accountName string, shareName string, options *FileSharesLeaseOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if accountName == "" { + return nil, errors.New("parameter accountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + if shareName == "" { + return nil, errors.New("parameter shareName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2021-04-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.XMSSnapshot != nil { + req.Header.Set("x-ms-snapshot", *options.XMSSnapshot) + } + req.Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, req.MarshalAsJSON(*options.Parameters) + } + return req, nil +} + +// leaseHandleResponse handles the Lease response. +func (client *FileSharesClient) leaseHandleResponse(resp *azcore.Response) (LeaseShareResponseResponse, error) { + var val *LeaseShareResponse + if err := resp.UnmarshalAsJSON(&val); err != nil { + return LeaseShareResponseResponse{}, err + } + result := LeaseShareResponseResponse{RawResponse: resp.Response, LeaseShareResponse: val} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + return result, nil +} + +// leaseHandleError handles the Lease error response. +func (client *FileSharesClient) leaseHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // List - Lists all shares. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileSharesClient) List(resourceGroupName string, accountName string, options *FileSharesListOptions) FileShareItemsPager { return &fileShareItemsPager{ pipeline: client.con.Pipeline(), @@ -266,7 +367,7 @@ func (client *FileSharesClient) listCreateRequest(ctx context.Context, resourceG } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") if options != nil && options.Maxpagesize != nil { reqQP.Set("$maxpagesize", *options.Maxpagesize) } @@ -274,7 +375,7 @@ func (client *FileSharesClient) listCreateRequest(ctx context.Context, resourceG reqQP.Set("$filter", *options.Filter) } if options != nil && options.Expand != nil { - reqQP.Set("$expand", string(*options.Expand)) + reqQP.Set("$expand", *options.Expand) } req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") @@ -292,14 +393,19 @@ func (client *FileSharesClient) listHandleResponse(resp *azcore.Response) (FileS // listHandleError handles the List error response. func (client *FileSharesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // Restore - Restore a file share within a valid retention days if share soft delete is enabled +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileSharesClient) Restore(ctx context.Context, resourceGroupName string, accountName string, shareName string, deletedShare DeletedShare, options *FileSharesRestoreOptions) (*http.Response, error) { req, err := client.restoreCreateRequest(ctx, resourceGroupName, accountName, shareName, deletedShare, options) if err != nil { @@ -340,7 +446,7 @@ func (client *FileSharesClient) restoreCreateRequest(ctx context.Context, resour } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(deletedShare) @@ -348,15 +454,20 @@ func (client *FileSharesClient) restoreCreateRequest(ctx context.Context, resour // restoreHandleError handles the Restore error response. func (client *FileSharesClient) restoreHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // Update - Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified // share does not already exist. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *FileSharesClient) Update(ctx context.Context, resourceGroupName string, accountName string, shareName string, fileShare FileShare, options *FileSharesUpdateOptions) (FileShareResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, shareName, fileShare, options) if err != nil { @@ -397,7 +508,7 @@ func (client *FileSharesClient) updateCreateRequest(ctx context.Context, resourc } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(fileShare) @@ -414,9 +525,13 @@ func (client *FileSharesClient) updateHandleResponse(resp *azcore.Response) (Fil // updateHandleError handles the Update error response. func (client *FileSharesClient) updateHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_managementpolicies_client.go b/sdk/storage/armstorage/zz_generated_managementpolicies_client.go similarity index 94% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_managementpolicies_client.go rename to sdk/storage/armstorage/zz_generated_managementpolicies_client.go index 686bde50a855..d39e07aec6b6 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_managementpolicies_client.go +++ b/sdk/storage/armstorage/zz_generated_managementpolicies_client.go @@ -10,10 +10,8 @@ package armstorage import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -32,6 +30,7 @@ func NewManagementPoliciesClient(con *armcore.Connection, subscriptionID string) } // CreateOrUpdate - Sets the managementpolicy to the specified storage account. +// If the operation fails it returns a generic error. func (client *ManagementPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, properties ManagementPolicy, options *ManagementPoliciesCreateOrUpdateOptions) (ManagementPolicyResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, managementPolicyName, properties, options) if err != nil { @@ -72,7 +71,7 @@ func (client *ManagementPoliciesClient) createOrUpdateCreateRequest(ctx context. } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(properties) @@ -89,9 +88,9 @@ func (client *ManagementPoliciesClient) createOrUpdateHandleResponse(resp *azcor // createOrUpdateHandleError handles the CreateOrUpdate error response. func (client *ManagementPoliciesClient) createOrUpdateHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -100,6 +99,7 @@ func (client *ManagementPoliciesClient) createOrUpdateHandleError(resp *azcore.R } // Delete - Deletes the managementpolicy associated with the specified storage account. +// If the operation fails it returns a generic error. func (client *ManagementPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, managementPolicyName, options) if err != nil { @@ -140,16 +140,16 @@ func (client *ManagementPoliciesClient) deleteCreateRequest(ctx context.Context, } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() return req, nil } // deleteHandleError handles the Delete error response. func (client *ManagementPoliciesClient) deleteHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -158,6 +158,7 @@ func (client *ManagementPoliciesClient) deleteHandleError(resp *azcore.Response) } // Get - Gets the managementpolicy associated with the specified storage account. +// If the operation fails it returns a generic error. func (client *ManagementPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, managementPolicyName ManagementPolicyName, options *ManagementPoliciesGetOptions) (ManagementPolicyResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, managementPolicyName, options) if err != nil { @@ -198,7 +199,7 @@ func (client *ManagementPoliciesClient) getCreateRequest(ctx context.Context, re } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -215,9 +216,9 @@ func (client *ManagementPoliciesClient) getHandleResponse(resp *azcore.Response) // getHandleError handles the Get error response. func (client *ManagementPoliciesClient) getHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_models.go b/sdk/storage/armstorage/zz_generated_models.go similarity index 73% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_models.go rename to sdk/storage/armstorage/zz_generated_models.go index bef60ea4dc48..ea7fb2a33d37 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_models.go +++ b/sdk/storage/armstorage/zz_generated_models.go @@ -8,41 +8,88 @@ package armstorage import ( - "context" "encoding/json" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" "reflect" "time" ) -// AccountSasParameters - The parameters to list SAS credentials of a storage account. -type AccountSasParameters struct { - // An IP address or a range of IP addresses from which to accept requests. - IPAddressOrRange *string `json:"signedIp,omitempty"` +type AccessPolicy struct { + // Expiry time of the access policy + Expiry *time.Time `json:"expiry,omitempty"` - // The key to sign the account SAS token with. - KeyToSign *string `json:"keyToSign,omitempty"` + // List of abbreviated permissions. + Permission *string `json:"permission,omitempty"` - // 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"` + // Start time of the access policy + Start *time.Time `json:"start,omitempty"` +} - // The protocol permitted for a request made with the account SAS. - Protocols *HTTPProtocol `json:"signedProtocol,omitempty"` +// MarshalJSON implements the json.Marshaller interface for type AccessPolicy. +func (a AccessPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "expiry", (*timeRFC3339)(a.Expiry)) + populate(objectMap, "permission", a.Permission) + populate(objectMap, "start", (*timeRFC3339)(a.Start)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccessPolicy. +func (a *AccessPolicy) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "expiry": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.Expiry = (*time.Time)(&aux) + delete(rawMsg, key) + case "permission": + err = unpopulate(val, &a.Permission) + delete(rawMsg, key) + case "start": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.Start = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` - // The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level + // 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"` - // The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). + // 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"` - // The time at which the shared access signature becomes invalid. + // REQUIRED; The time at which the shared access signature becomes invalid. SharedAccessExpiryTime *time.Time `json:"signedExpiry,omitempty"` + // An IP address or a range of IP addresses from which to accept requests. + IPAddressOrRange *string `json:"signedIp,omitempty"` + + // The key to sign the account SAS token with. + KeyToSign *string `json:"keyToSign,omitempty"` + + // The protocol permitted for a request made with the account SAS. + Protocols *HTTPProtocol `json:"signedProtocol,omitempty"` + // The time at which the SAS becomes valid. SharedAccessStartTime *time.Time `json:"signedStart,omitempty"` } @@ -63,7 +110,7 @@ func (a AccountSasParameters) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type AccountSasParameters. func (a *AccountSasParameters) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -108,22 +155,22 @@ func (a *AccountSasParameters) UnmarshalJSON(data []byte) error { // ActiveDirectoryProperties - Settings properties for Active Directory (AD). type ActiveDirectoryProperties struct { - // Specifies the security identifier (SID) for Azure Storage. + // REQUIRED; Specifies the security identifier (SID) for Azure Storage. AzureStorageSid *string `json:"azureStorageSid,omitempty"` - // Specifies the domain GUID. + // REQUIRED; Specifies the domain GUID. DomainGUID *string `json:"domainGuid,omitempty"` - // Specifies the primary domain that the AD DNS server is authoritative for. + // REQUIRED; Specifies the primary domain that the AD DNS server is authoritative for. DomainName *string `json:"domainName,omitempty"` - // Specifies the security identifier (SID). + // REQUIRED; Specifies the security identifier (SID). DomainSid *string `json:"domainSid,omitempty"` - // Specifies the Active Directory forest to get. + // REQUIRED; Specifies the Active Directory forest to get. ForestName *string `json:"forestName,omitempty"` - // Specifies the NetBIOS domain name. + // REQUIRED; Specifies the NetBIOS domain name. NetBiosDomainName *string `json:"netBiosDomainName,omitempty"` } @@ -148,11 +195,14 @@ func (a AzureEntityResource) marshalInternal() map[string]interface{} { // AzureFilesIdentityBasedAuthentication - Settings for Azure Files identity based authentication. type AzureFilesIdentityBasedAuthentication struct { + // REQUIRED; Indicates the directory service used. + DirectoryServiceOptions *DirectoryServiceOptions `json:"directoryServiceOptions,omitempty"` + // Required if choose AD. ActiveDirectoryProperties *ActiveDirectoryProperties `json:"activeDirectoryProperties,omitempty"` - // Indicates the directory service used. - DirectoryServiceOptions *DirectoryServiceOptions `json:"directoryServiceOptions,omitempty"` + // Default share permission for users using Kerberos authentication if RBAC role is not assigned. + DefaultSharePermission *DefaultSharePermission `json:"defaultSharePermission,omitempty"` } // BlobContainer - Properties of the blob container, including Id, resource name, resource type, Etag. @@ -169,13 +219,9 @@ func (b BlobContainer) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// BlobContainerResponse is the response envelope for operations that return a BlobContainer type. -type BlobContainerResponse struct { - // Properties of the blob container, including Id, resource name, resource type, Etag. - BlobContainer *BlobContainer - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// BlobContainersBeginObjectLevelWormOptions contains the optional parameters for the BlobContainers.BeginObjectLevelWorm method. +type BlobContainersBeginObjectLevelWormOptions struct { + // placeholder for future optional parameters } // BlobContainersClearLegalHoldOptions contains the optional parameters for the BlobContainers.ClearLegalHold method. @@ -286,34 +332,89 @@ type BlobInventoryPolicy struct { SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` } -// BlobInventoryPolicyDefinition - An object that defines the blob inventory rule. Each definition consists of a set of filters. +// MarshalJSON implements the json.Marshaller interface for type BlobInventoryPolicy. +func (b BlobInventoryPolicy) MarshalJSON() ([]byte, error) { + objectMap := b.Resource.marshalInternal() + populate(objectMap, "properties", b.Properties) + populate(objectMap, "systemData", b.SystemData) + return json.Marshal(objectMap) +} + +// 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"` + + // 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"` + + // REQUIRED; This is a required field. This field is used to schedule an inventory formation. + Schedule *Schedule `json:"schedule,omitempty"` + + // 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 + // field for the 'Blob' definition.objectType include 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, + // Expiry-Time, hdiisfolder, Owner, Group, + // Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime'. The valid values for 'Container' definition.objectType include 'Name, + // Last-Modified, Metadata, LeaseStatus, + // LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold'. Schema field values 'Expiry-Time, hdiisfolder, Owner, Group, Permissions, + // Acl' are valid only for Hns enabled accounts. + SchemaFields []*string `json:"schemaFields,omitempty"` + // An object that defines the filter set. Filters *BlobInventoryPolicyFilter `json:"filters,omitempty"` } -// BlobInventoryPolicyFilter - An object that defines the blob inventory rule filter conditions. -type BlobInventoryPolicyFilter struct { - // An array of predefined enum values. Valid values include blockBlob, appendBlob, pageBlob. Hns accounts does not support pageBlobs. - BlobTypes *[]*string `json:"blobTypes,omitempty"` +// MarshalJSON implements the json.Marshaller interface for type BlobInventoryPolicyDefinition. +func (b BlobInventoryPolicyDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "filters", b.Filters) + populate(objectMap, "format", b.Format) + populate(objectMap, "objectType", b.ObjectType) + populate(objectMap, "schedule", b.Schedule) + populate(objectMap, "schemaFields", b.SchemaFields) + return json.Marshal(objectMap) +} - // Includes blob versions in blob inventory when value set to true. +// BlobInventoryPolicyFilter - An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties +// are applicable, 'blobTypes' is required and others are optional. For +// 'Container' definition.objectType only prefixMatch is applicable and is optional. +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"` + + // 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"` - // Includes blob snapshots in blob inventory when value set to true. + // 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"` // An array of strings for blob prefixes to be matched. - PrefixMatch *[]*string `json:"prefixMatch,omitempty"` + PrefixMatch []*string `json:"prefixMatch,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BlobInventoryPolicyFilter. +func (b BlobInventoryPolicyFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "blobTypes", b.BlobTypes) + populate(objectMap, "includeBlobVersions", b.IncludeBlobVersions) + populate(objectMap, "includeSnapshots", b.IncludeSnapshots) + populate(objectMap, "prefixMatch", b.PrefixMatch) + return json.Marshal(objectMap) } // 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"` + // READ-ONLY; Returns the last modified date and time of the blob inventory policy. LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - - // The storage account blob inventory policy object. It is composed of policy rules. - Policy *BlobInventoryPolicySchema `json:"policy,omitempty"` } // MarshalJSON implements the json.Marshaller interface for type BlobInventoryPolicyProperties. @@ -326,7 +427,7 @@ func (b BlobInventoryPolicyProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type BlobInventoryPolicyProperties. func (b *BlobInventoryPolicyProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -349,48 +450,48 @@ func (b *BlobInventoryPolicyProperties) UnmarshalJSON(data []byte) error { return nil } -// BlobInventoryPolicyResponse is the response envelope for operations that return a BlobInventoryPolicy type. -type BlobInventoryPolicyResponse struct { - // The storage account blob inventory policy. - BlobInventoryPolicy *BlobInventoryPolicy - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // BlobInventoryPolicyRule - An object that wraps the blob inventory rule. Each rule is uniquely defined by name. type BlobInventoryPolicyRule struct { - // An object that defines the blob inventory policy rule. + // REQUIRED; An object that defines the blob inventory policy rule. Definition *BlobInventoryPolicyDefinition `json:"definition,omitempty"` - // Rule is enabled when set to true. + // REQUIRED; Container name where blob inventory files are stored. Must be pre-created. + Destination *string `json:"destination,omitempty"` + + // REQUIRED; Rule is enabled when set to true. Enabled *bool `json:"enabled,omitempty"` - // A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. + // 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"` } // BlobInventoryPolicySchema - The storage account blob inventory policy rules. type BlobInventoryPolicySchema struct { - // Container name where blob inventory files are stored. Must be pre-created. - Destination *string `json:"destination,omitempty"` - - // Policy is enabled if set to true. + // REQUIRED; Policy is enabled if set to true. Enabled *bool `json:"enabled,omitempty"` - // The storage account blob inventory policy rules. The rule is applied when it is enabled. - Rules *[]*BlobInventoryPolicyRule `json:"rules,omitempty"` + // REQUIRED; The storage account blob inventory policy rules. The rule is applied when it is enabled. + Rules []*BlobInventoryPolicyRule `json:"rules,omitempty"` - // The valid value is Inventory + // REQUIRED; The valid value is Inventory Type *InventoryRuleType `json:"type,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type BlobInventoryPolicySchema. +func (b BlobInventoryPolicySchema) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "enabled", b.Enabled) + populate(objectMap, "rules", b.Rules) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + // BlobRestoreParameters - Blob restore parameters type BlobRestoreParameters struct { - // Blob ranges to restore. - BlobRanges *[]*BlobRestoreRange `json:"blobRanges,omitempty"` + // REQUIRED; Blob ranges to restore. + BlobRanges []*BlobRestoreRange `json:"blobRanges,omitempty"` - // Restore blob to the specified time. + // REQUIRED; Restore blob to the specified time. TimeToRestore *time.Time `json:"timeToRestore,omitempty"` } @@ -404,7 +505,7 @@ func (b BlobRestoreParameters) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type BlobRestoreParameters. func (b *BlobRestoreParameters) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -429,10 +530,10 @@ func (b *BlobRestoreParameters) UnmarshalJSON(data []byte) error { // BlobRestoreRange - Blob range type BlobRestoreRange struct { - // Blob end range. This is exclusive. Empty means account end. + // REQUIRED; Blob end range. This is exclusive. Empty means account end. EndRange *string `json:"endRange,omitempty"` - // Blob start range. This is inclusive. Empty means account start. + // REQUIRED; Blob start range. This is inclusive. Empty means account start. StartRange *string `json:"startRange,omitempty"` } @@ -453,38 +554,16 @@ type BlobRestoreStatus struct { Status *BlobRestoreProgressStatus `json:"status,omitempty" azure:"ro"` } -// BlobRestoreStatusPollerResponse is the response envelope for operations that asynchronously return a BlobRestoreStatus type. -type BlobRestoreStatusPollerResponse struct { - // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received - PollUntilDone func(ctx context.Context, frequency time.Duration) (BlobRestoreStatusResponse, error) - - // Poller contains an initialized poller. - Poller BlobRestoreStatusPoller - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// BlobRestoreStatusResponse is the response envelope for operations that return a BlobRestoreStatus type. -type BlobRestoreStatusResponse struct { - // Blob restore status. - BlobRestoreStatus *BlobRestoreStatus - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - type BlobServiceItems struct { // READ-ONLY; List of blob services returned. - Value *[]*BlobServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*BlobServiceProperties `json:"value,omitempty" azure:"ro"` } -// BlobServiceItemsResponse is the response envelope for operations that return a BlobServiceItems type. -type BlobServiceItemsResponse struct { - BlobServiceItems *BlobServiceItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type BlobServiceItems. +func (b BlobServiceItems) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) } // BlobServiceProperties - The properties of a storage account’s Blob service. @@ -497,6 +576,14 @@ type BlobServiceProperties struct { SKU *SKU `json:"sku,omitempty" azure:"ro"` } +// MarshalJSON implements the json.Marshaller interface for type BlobServiceProperties. +func (b BlobServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := b.Resource.marshalInternal() + populate(objectMap, "properties", b.BlobServiceProperties) + populate(objectMap, "sku", b.SKU) + return json.Marshal(objectMap) +} + // BlobServicePropertiesAutoGenerated - The properties of a storage account’s Blob service. type BlobServicePropertiesAutoGenerated struct { // Deprecated in favor of isVersioningEnabled property. @@ -531,15 +618,6 @@ type BlobServicePropertiesAutoGenerated struct { RestorePolicy *RestorePolicyProperties `json:"restorePolicy,omitempty"` } -// BlobServicePropertiesResponse is the response envelope for operations that return a BlobServiceProperties type. -type BlobServicePropertiesResponse struct { - // The properties of a storage account’s Blob service. - BlobServiceProperties *BlobServiceProperties - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // BlobServicesGetServicePropertiesOptions contains the optional parameters for the BlobServices.GetServiceProperties method. type BlobServicesGetServicePropertiesOptions struct { // placeholder for future optional parameters @@ -578,43 +656,32 @@ type CheckNameAvailabilityResult struct { Reason *Reason `json:"reason,omitempty" azure:"ro"` } -// CheckNameAvailabilityResultResponse is the response envelope for operations that return a CheckNameAvailabilityResult type. -type CheckNameAvailabilityResultResponse struct { - // The CheckNameAvailability operation response. - CheckNameAvailabilityResult *CheckNameAvailabilityResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // CloudError - An error response from the Storage service. +// Implements the error and azcore.HTTPResponse interfaces. type CloudError struct { + raw string // An error response from the Storage service. InnerError *CloudErrorBody `json:"error,omitempty"` } // Error implements the error interface for type CloudError. +// The contents of the error text are not contractual and subject to change. func (e CloudError) Error() string { - msg := "" - if e.InnerError != nil { - msg += "InnerError: \n" - if e.InnerError.Code != nil { - msg += fmt.Sprintf("\tCode: %v\n", *e.InnerError.Code) - } - if e.InnerError.Message != nil { - msg += fmt.Sprintf("\tMessage: %v\n", *e.InnerError.Message) - } - if e.InnerError.Target != nil { - msg += fmt.Sprintf("\tTarget: %v\n", *e.InnerError.Target) - } - if e.InnerError.Details != nil { - msg += fmt.Sprintf("\tDetails: %v\n", *e.InnerError.Details) - } - } - if msg == "" { - msg = "missing error info" - } - return msg + return e.raw +} + +// CloudErrorAutoGenerated - An error response from the Storage service. +// Implements the error and azcore.HTTPResponse interfaces. +type CloudErrorAutoGenerated struct { + raw string + // An error response from the Storage service. + InnerError *CloudErrorBodyAutoGenerated `json:"error,omitempty"` +} + +// Error implements the error interface for type CloudErrorAutoGenerated. +// The contents of the error text are not contractual and subject to change. +func (e CloudErrorAutoGenerated) Error() string { + return e.raw } // CloudErrorBody - An error response from the Storage service. @@ -623,7 +690,32 @@ type CloudErrorBody struct { Code *string `json:"code,omitempty"` // A list of additional details about the error. - Details *[]*CloudErrorBody `json:"details,omitempty"` + Details []*CloudErrorBody `json:"details,omitempty"` + + // A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + + // The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBody. +func (c CloudErrorBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + +// CloudErrorBodyAutoGenerated - An error response from the Storage service. +type CloudErrorBodyAutoGenerated struct { + // An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + + // A list of additional details about the error. + Details []*CloudErrorBodyAutoGenerated `json:"details,omitempty"` // A message describing the error, intended to be suitable for display in a user interface. Message *string `json:"message,omitempty"` @@ -632,20 +724,40 @@ type CloudErrorBody struct { Target *string `json:"target,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type CloudErrorBodyAutoGenerated. +func (c CloudErrorBodyAutoGenerated) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", c.Code) + populate(objectMap, "details", c.Details) + populate(objectMap, "message", c.Message) + populate(objectMap, "target", c.Target) + return json.Marshal(objectMap) +} + // 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"` + // Block override of encryption scope from the container default. + DenyEncryptionScopeOverride *bool `json:"denyEncryptionScopeOverride,omitempty"` + + // 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"` + + // A name-value pair to associate with the container as metadata. + Metadata map[string]*string `json:"metadata,omitempty"` + + // Specifies whether data in the container may be accessed publicly and the level of access. + PublicAccess *PublicAccess `json:"publicAccess,omitempty"` + // READ-ONLY; Indicates whether the blob container was deleted. Deleted *bool `json:"deleted,omitempty" azure:"ro"` // READ-ONLY; Blob container deletion time. DeletedTime *time.Time `json:"deletedTime,omitempty" azure:"ro"` - // Block override of encryption scope from the container default. - DenyEncryptionScopeOverride *bool `json:"denyEncryptionScopeOverride,omitempty"` - // 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. @@ -674,12 +786,6 @@ type ContainerProperties struct { // READ-ONLY; The LegalHold property of the container. LegalHold *LegalHoldProperties `json:"legalHold,omitempty" azure:"ro"` - // A name-value pair to associate with the container as metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` - - // Specifies whether data in the container may be accessed publicly and the level of access. - PublicAccess *PublicAccess `json:"publicAccess,omitempty"` - // READ-ONLY; Remaining retention days for soft deleted blob container. RemainingRetentionDays *int32 `json:"remainingRetentionDays,omitempty" azure:"ro"` @@ -697,6 +803,7 @@ func (c ContainerProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "hasImmutabilityPolicy", c.HasImmutabilityPolicy) populate(objectMap, "hasLegalHold", c.HasLegalHold) populate(objectMap, "immutabilityPolicy", c.ImmutabilityPolicy) + populate(objectMap, "immutableStorageWithVersioning", c.ImmutableStorageWithVersioning) populate(objectMap, "lastModifiedTime", (*timeRFC3339)(c.LastModifiedTime)) populate(objectMap, "leaseDuration", c.LeaseDuration) populate(objectMap, "leaseState", c.LeaseState) @@ -711,7 +818,7 @@ func (c ContainerProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type ContainerProperties. func (c *ContainerProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -741,6 +848,9 @@ func (c *ContainerProperties) UnmarshalJSON(data []byte) error { case "immutabilityPolicy": err = unpopulate(val, &c.ImmutabilityPolicy) delete(rawMsg, key) + case "immutableStorageWithVersioning": + err = unpopulate(val, &c.ImmutableStorageWithVersioning) + delete(rawMsg, key) case "lastModifiedTime": var aux timeRFC3339 err = unpopulate(val, &aux) @@ -780,31 +890,49 @@ func (c *ContainerProperties) UnmarshalJSON(data []byte) error { // CorsRule - Specifies a CORS rule for the Blob service. type CorsRule struct { - // Required if CorsRule element is present. A list of headers allowed to be part of the cross-origin request. - AllowedHeaders *[]*string `json:"allowedHeaders,omitempty"` + // 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"` - // 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"` + // 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"` - // 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"` + // 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"` - // Required if CorsRule element is present. A list of response headers to expose to CORS clients. - ExposedHeaders *[]*string `json:"exposedHeaders,omitempty"` + // REQUIRED; Required if CorsRule element is present. A list of response headers to expose to CORS clients. + ExposedHeaders []*string `json:"exposedHeaders,omitempty"` - // Required if CorsRule element is present. The number of seconds that the client/browser should cache a preflight response. + // 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"` } +// MarshalJSON implements the json.Marshaller interface for type CorsRule. +func (c CorsRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowedHeaders", c.AllowedHeaders) + populate(objectMap, "allowedMethods", c.AllowedMethods) + populate(objectMap, "allowedOrigins", c.AllowedOrigins) + populate(objectMap, "exposedHeaders", c.ExposedHeaders) + populate(objectMap, "maxAgeInSeconds", c.MaxAgeInSeconds) + return json.Marshal(objectMap) +} + // 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 `json:"corsRules,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CorsRules. +func (c CorsRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "corsRules", c.CorsRules) + return json.Marshal(objectMap) } // CustomDomain - The custom domain assigned to this storage account. This can be set via Update. type CustomDomain struct { - // Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. + // REQUIRED; Gets or sets the custom domain name assigned to the storage account. Name is the CNAME source. Name *string `json:"name,omitempty"` // Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -813,7 +941,7 @@ type CustomDomain struct { // DateAfterCreation - Object to define the number of days after creation. type DateAfterCreation struct { - // Value indicating the age in days after creation + // REQUIRED; Value indicating the age in days after creation DaysAfterCreationGreaterThan *float32 `json:"daysAfterCreationGreaterThan,omitempty"` } @@ -843,6 +971,13 @@ type DeletedAccount struct { Properties *DeletedAccountProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type DeletedAccount. +func (d DeletedAccount) MarshalJSON() ([]byte, error) { + objectMap := d.ProxyResource.marshalInternal() + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + // 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 @@ -850,16 +985,15 @@ type DeletedAccountListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` // READ-ONLY; Gets the list of deleted accounts and their properties. - Value *[]*DeletedAccount `json:"value,omitempty" azure:"ro"` + Value []*DeletedAccount `json:"value,omitempty" azure:"ro"` } -// DeletedAccountListResultResponse is the response envelope for operations that return a DeletedAccountListResult type. -type DeletedAccountListResultResponse struct { - // The response from the List Deleted Accounts operation. - DeletedAccountListResult *DeletedAccountListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type DeletedAccountListResult. +func (d DeletedAccountListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) } // DeletedAccountProperties - Attributes of a deleted storage account. @@ -880,15 +1014,6 @@ type DeletedAccountProperties struct { StorageAccountResourceID *string `json:"storageAccountResourceId,omitempty" azure:"ro"` } -// DeletedAccountResponse is the response envelope for operations that return a DeletedAccount type. -type DeletedAccountResponse struct { - // Deleted storage account - DeletedAccount *DeletedAccount - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // DeletedAccountsGetOptions contains the optional parameters for the DeletedAccounts.Get method. type DeletedAccountsGetOptions struct { // placeholder for future optional parameters @@ -901,10 +1026,10 @@ type DeletedAccountsListOptions struct { // DeletedShare - The deleted share to be restored. type DeletedShare struct { - // Required. Identify the name of the deleted share that will be restored. + // REQUIRED; Required. Identify the name of the deleted share that will be restored. DeletedShareName *string `json:"deletedShareName,omitempty"` - // Required. Identify the version of the deleted share that will be restored. + // REQUIRED; Required. Identify the version of the deleted share that will be restored. DeletedShareVersion *string `json:"deletedShareVersion,omitempty"` } @@ -919,12 +1044,12 @@ type Dimension struct { // Encryption - The encryption settings on the storage account. type Encryption struct { + // REQUIRED; The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault + KeySource *KeySource `json:"keySource,omitempty"` + // The identity to be used with service-side encryption at rest. EncryptionIdentity *EncryptionIdentity `json:"identity,omitempty"` - // The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, Microsoft.Keyvault - KeySource *KeySource `json:"keySource,omitempty"` - // Properties provided by key vault. KeyVaultProperties *KeyVaultProperties `json:"keyvaultproperties,omitempty"` @@ -958,13 +1083,13 @@ func (e EncryptionScope) MarshalJSON() ([]byte, error) { // EncryptionScopeKeyVaultProperties - The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute // is set to 'Microsoft.KeyVault'. type EncryptionScopeKeyVaultProperties struct { - // READ-ONLY; The object identifier of the current versioned Key Vault Key in use. - CurrentVersionedKeyIdentifier *string `json:"currentVersionedKeyIdentifier,omitempty" azure:"ro"` - // 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"` + // READ-ONLY; The object identifier of the current versioned Key Vault Key in use. + CurrentVersionedKeyIdentifier *string `json:"currentVersionedKeyIdentifier,omitempty" azure:"ro"` + // READ-ONLY; Timestamp of last rotation of the Key Vault Key. LastKeyRotationTimestamp *time.Time `json:"lastKeyRotationTimestamp,omitempty" azure:"ro"` } @@ -980,7 +1105,7 @@ func (e EncryptionScopeKeyVaultProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionScopeKeyVaultProperties. func (e *EncryptionScopeKeyVaultProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -1013,29 +1138,22 @@ type EncryptionScopeListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` // READ-ONLY; List of encryption scopes requested. - Value *[]*EncryptionScope `json:"value,omitempty" azure:"ro"` + Value []*EncryptionScope `json:"value,omitempty" azure:"ro"` } -// EncryptionScopeListResultResponse is the response envelope for operations that return a EncryptionScopeListResult type. -type EncryptionScopeListResultResponse struct { - // List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. - EncryptionScopeListResult *EncryptionScopeListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type EncryptionScopeListResult. +func (e EncryptionScopeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) } // EncryptionScopeProperties - Properties of the encryption scope. type EncryptionScopeProperties struct { - // READ-ONLY; Gets the creation date and time of the encryption scope in UTC. - CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` - // 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"` - // READ-ONLY; Gets the last modification date and time of the encryption scope in UTC. - LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - // 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"` @@ -1044,6 +1162,12 @@ type EncryptionScopeProperties struct { // The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. State *EncryptionScopeState `json:"state,omitempty"` + + // READ-ONLY; Gets the creation date and time of the encryption scope in UTC. + CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` + + // READ-ONLY; Gets the last modification date and time of the encryption scope in UTC. + LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` } // MarshalJSON implements the json.Marshaller interface for type EncryptionScopeProperties. @@ -1060,7 +1184,7 @@ func (e EncryptionScopeProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionScopeProperties. func (e *EncryptionScopeProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -1097,15 +1221,6 @@ func (e *EncryptionScopeProperties) UnmarshalJSON(data []byte) error { return nil } -// EncryptionScopeResponse is the response envelope for operations that return a EncryptionScope type. -type EncryptionScopeResponse struct { - // The Encryption Scope resource. - EncryptionScope *EncryptionScope - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // EncryptionScopesGetOptions contains the optional parameters for the EncryptionScopes.Get method. type EncryptionScopesGetOptions struct { // placeholder for future optional parameters @@ -1152,7 +1267,7 @@ func (e EncryptionService) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionService. func (e *EncryptionService) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -1195,6 +1310,12 @@ type EncryptionServices struct { // 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 *StorageAccountInternetEndpoints `json:"internetEndpoints,omitempty"` + + // Gets the microsoft routing storage endpoints. + MicrosoftEndpoints *StorageAccountMicrosoftEndpoints `json:"microsoftEndpoints,omitempty"` + // READ-ONLY; Gets the blob endpoint. Blob *string `json:"blob,omitempty" azure:"ro"` @@ -1204,12 +1325,6 @@ type Endpoints struct { // READ-ONLY; Gets the file endpoint. File *string `json:"file,omitempty" azure:"ro"` - // Gets the internet routing storage endpoints - InternetEndpoints *StorageAccountInternetEndpoints `json:"internetEndpoints,omitempty"` - - // Gets the microsoft routing storage endpoints. - MicrosoftEndpoints *StorageAccountMicrosoftEndpoints `json:"microsoftEndpoints,omitempty"` - // READ-ONLY; Gets the queue endpoint. Queue *string `json:"queue,omitempty" azure:"ro"` @@ -1221,27 +1336,17 @@ type Endpoints struct { } // ErrorResponse - An error response from the storage resource provider. +// Implements the error and azcore.HTTPResponse interfaces. type ErrorResponse struct { + raw string // Azure Storage Resource Provider error response body. InnerError *ErrorResponseBody `json:"error,omitempty"` } // Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. func (e ErrorResponse) Error() string { - msg := "" - if e.InnerError != nil { - msg += "InnerError: \n" - if e.InnerError.Code != nil { - msg += fmt.Sprintf("\tCode: %v\n", *e.InnerError.Code) - } - if e.InnerError.Message != nil { - msg += fmt.Sprintf("\tMessage: %v\n", *e.InnerError.Message) - } - } - if msg == "" { - msg = "missing error info" - } - return msg + return e.raw } // ErrorResponseBody - Error response body contract. @@ -1264,15 +1369,14 @@ type ExtendedLocation struct { type FileServiceItems struct { // READ-ONLY; List of file services returned. - Value *[]*FileServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*FileServiceProperties `json:"value,omitempty" azure:"ro"` } -// FileServiceItemsResponse is the response envelope for operations that return a FileServiceItems type. -type FileServiceItemsResponse struct { - FileServiceItems *FileServiceItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type FileServiceItems. +func (f FileServiceItems) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) } // FileServiceProperties - The properties of File services in storage account. @@ -1285,6 +1389,14 @@ type FileServiceProperties struct { SKU *SKU `json:"sku,omitempty" azure:"ro"` } +// MarshalJSON implements the json.Marshaller interface for type FileServiceProperties. +func (f FileServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := f.Resource.marshalInternal() + populate(objectMap, "properties", f.FileServiceProperties) + populate(objectMap, "sku", f.SKU) + return json.Marshal(objectMap) +} + // FileServicePropertiesAutoGenerated - The properties of File services in storage account. type FileServicePropertiesAutoGenerated 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 @@ -1299,15 +1411,6 @@ type FileServicePropertiesAutoGenerated struct { ShareDeleteRetentionPolicy *DeleteRetentionPolicy `json:"shareDeleteRetentionPolicy,omitempty"` } -// FileServicePropertiesResponse is the response envelope for operations that return a FileServiceProperties type. -type FileServicePropertiesResponse struct { - // The properties of File services in storage account. - FileServiceProperties *FileServiceProperties - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // FileServicesGetServicePropertiesOptions contains the optional parameters for the FileServices.GetServiceProperties method. type FileServicesGetServicePropertiesOptions struct { // placeholder for future optional parameters @@ -1344,22 +1447,28 @@ type FileShareItem struct { Properties *FileShareProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type FileShareItem. +func (f FileShareItem) MarshalJSON() ([]byte, error) { + objectMap := f.AzureEntityResource.marshalInternal() + populate(objectMap, "properties", f.Properties) + return json.Marshal(objectMap) +} + // FileShareItems - Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. 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"` // READ-ONLY; List of file shares returned. - Value *[]*FileShareItem `json:"value,omitempty" azure:"ro"` + Value []*FileShareItem `json:"value,omitempty" azure:"ro"` } -// FileShareItemsResponse is the response envelope for operations that return a FileShareItems type. -type FileShareItemsResponse struct { - // Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. - FileShareItems *FileShareItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type FileShareItems. +func (f FileShareItems) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) } // FileShareProperties - The properties of the file share. @@ -1367,6 +1476,22 @@ 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"` + // The authentication protocol that is used for the file share. Can only be specified when creating a share. + EnabledProtocols *EnabledProtocols `json:"enabledProtocols,omitempty"` + + // A name-value pair to associate with the share as metadata. + Metadata map[string]*string `json:"metadata,omitempty"` + + // The property is for NFS share only. The default is NoRootSquash. + RootSquash *RootSquashType `json:"rootSquash,omitempty"` + + // 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"` + + // List of stored access policies specified on the share. + SignedIdentifiers []*SignedIdentifier `json:"signedIdentifiers,omitempty"` + // READ-ONLY; Indicates the last modification time for share access tier. AccessTierChangeTime *time.Time `json:"accessTierChangeTime,omitempty" azure:"ro"` @@ -1379,24 +1504,20 @@ type FileShareProperties struct { // READ-ONLY; The deleted time if the share was deleted. DeletedTime *time.Time `json:"deletedTime,omitempty" azure:"ro"` - // The authentication protocol that is used for the file share. Can only be specified when creating a share. - EnabledProtocols *EnabledProtocols `json:"enabledProtocols,omitempty"` - // READ-ONLY; Returns the date and time the share was last modified. LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - // A name-value pair to associate with the share as metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` + // 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"` - // READ-ONLY; Remaining retention days for share that was soft deleted. - RemainingRetentionDays *int32 `json:"remainingRetentionDays,omitempty" azure:"ro"` + // READ-ONLY; Lease state of the share. + LeaseState *LeaseState `json:"leaseState,omitempty" azure:"ro"` - // The property is for NFS share only. The default is NoRootSquash. - RootSquash *RootSquashType `json:"rootSquash,omitempty"` + // READ-ONLY; The lease status of the share. + LeaseStatus *LeaseStatus `json:"leaseStatus,omitempty" azure:"ro"` - // 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"` + // READ-ONLY; Remaining retention days for share that was soft deleted. + RemainingRetentionDays *int32 `json:"remainingRetentionDays,omitempty" azure:"ro"` // 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"` @@ -1418,11 +1539,15 @@ func (f FileShareProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "deletedTime", (*timeRFC3339)(f.DeletedTime)) populate(objectMap, "enabledProtocols", f.EnabledProtocols) populate(objectMap, "lastModifiedTime", (*timeRFC3339)(f.LastModifiedTime)) + populate(objectMap, "leaseDuration", f.LeaseDuration) + populate(objectMap, "leaseState", f.LeaseState) + populate(objectMap, "leaseStatus", f.LeaseStatus) populate(objectMap, "metadata", f.Metadata) populate(objectMap, "remainingRetentionDays", f.RemainingRetentionDays) populate(objectMap, "rootSquash", f.RootSquash) populate(objectMap, "shareQuota", f.ShareQuota) populate(objectMap, "shareUsageBytes", f.ShareUsageBytes) + populate(objectMap, "signedIdentifiers", f.SignedIdentifiers) populate(objectMap, "snapshotTime", (*timeRFC3339)(f.SnapshotTime)) populate(objectMap, "version", f.Version) return json.Marshal(objectMap) @@ -1430,7 +1555,7 @@ func (f FileShareProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type FileShareProperties. func (f *FileShareProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -1464,6 +1589,15 @@ func (f *FileShareProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, &aux) f.LastModifiedTime = (*time.Time)(&aux) delete(rawMsg, key) + case "leaseDuration": + err = unpopulate(val, &f.LeaseDuration) + delete(rawMsg, key) + case "leaseState": + err = unpopulate(val, &f.LeaseState) + delete(rawMsg, key) + case "leaseStatus": + err = unpopulate(val, &f.LeaseStatus) + delete(rawMsg, key) case "metadata": err = unpopulate(val, &f.Metadata) delete(rawMsg, key) @@ -1479,6 +1613,9 @@ func (f *FileShareProperties) UnmarshalJSON(data []byte) error { case "shareUsageBytes": err = unpopulate(val, &f.ShareUsageBytes) delete(rawMsg, key) + case "signedIdentifiers": + err = unpopulate(val, &f.SignedIdentifiers) + delete(rawMsg, key) case "snapshotTime": var aux timeRFC3339 err = unpopulate(val, &aux) @@ -1495,39 +1632,44 @@ func (f *FileShareProperties) UnmarshalJSON(data []byte) error { return nil } -// FileShareResponse is the response envelope for operations that return a FileShare type. -type FileShareResponse struct { - // Properties of the file share, including Id, resource name, resource type, Etag. - FileShare *FileShare - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // FileSharesCreateOptions contains the optional parameters for the FileShares.Create method. type FileSharesCreateOptions struct { - // Optional, used to create a snapshot. - Expand *PutSharesExpand + // Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ',' + Expand *string } // FileSharesDeleteOptions contains the optional parameters for the FileShares.Delete method. type FileSharesDeleteOptions struct { + // Optional. Valid values are: snapshots, leased-snapshots, none. The default value is snapshots. For 'snapshots', the file share is deleted including all + // of its file share snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included + // all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the file share contains any + // snapshots (leased or unleased), the deletion fails. + Include *string // Optional, used to delete a snapshot. XMSSnapshot *string } // FileSharesGetOptions contains the optional parameters for the FileShares.Get method. type FileSharesGetOptions struct { - // Optional, used to expand the properties within share's properties. + // Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Expand *string // Optional, used to retrieve properties of a snapshot. XMSSnapshot *string } +// FileSharesLeaseOptions contains the optional parameters for the FileShares.Lease method. +type FileSharesLeaseOptions struct { + // Lease Share request body. + Parameters *LeaseShareRequest + // Optional. Specify the snapshot time to lease a snapshot. + XMSSnapshot *string +} + // FileSharesListOptions contains the optional parameters for the FileShares.List method. type FileSharesListOptions struct { - // Optional, used to expand the properties within share's properties. - Expand *ListSharesExpand + // Optional, used to expand the properties within share's properties. Valid values are: deleted, snapshots. Should be passed as a string with delimiter + // ',' + Expand *string // Optional. When specified, only share names starting with the filter will be listed. Filter *string // Optional. Specified maximum number of shares that can be included in the list. @@ -1573,7 +1715,7 @@ func (g GeoReplicationStats) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type GeoReplicationStats. func (g *GeoReplicationStats) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -1599,61 +1741,75 @@ func (g *GeoReplicationStats) UnmarshalJSON(data []byte) error { return nil } -// HTTPPollerResponse contains the asynchronous HTTP response from the call to the service endpoint. -type HTTPPollerResponse struct { - // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received - PollUntilDone func(ctx context.Context, frequency time.Duration) (*http.Response, error) - - // Poller contains an initialized poller. - Poller HTTPPoller - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // 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"` + // The action of IP ACL rule. Action *string `json:"action,omitempty"` - - // Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. - IPAddressOrRange *string `json:"value,omitempty"` } // Identity for the resource. type Identity struct { + // REQUIRED; The identity type. + Type *IdentityType `json:"type,omitempty"` + + // 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"` + // READ-ONLY; The principal ID of resource identity. PrincipalID *string `json:"principalId,omitempty" azure:"ro"` // READ-ONLY; The tenant ID of resource. TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} - // The identity type. - Type *IdentityType `json:"type,omitempty"` - - // 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"` +// MarshalJSON implements the json.Marshaller interface for type Identity. +func (i Identity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", i.PrincipalID) + populate(objectMap, "tenantId", i.TenantID) + populate(objectMap, "type", i.Type) + populate(objectMap, "userAssignedIdentities", i.UserAssignedIdentities) + return json.Marshal(objectMap) } // ImmutabilityPolicy - The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. type ImmutabilityPolicy struct { AzureEntityResource - // The properties of an ImmutabilityPolicy of a blob container. + // REQUIRED; The properties of an ImmutabilityPolicy of a blob container. Properties *ImmutabilityPolicyProperty `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type ImmutabilityPolicy. +func (i ImmutabilityPolicy) MarshalJSON() ([]byte, error) { + objectMap := i.AzureEntityResource.marshalInternal() + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + // ImmutabilityPolicyProperties - The properties of an ImmutabilityPolicy of a blob container. type ImmutabilityPolicyProperties struct { - // READ-ONLY; ImmutabilityPolicy Etag. - Etag *string `json:"etag,omitempty" azure:"ro"` - // The properties of an ImmutabilityPolicy of a blob container. Properties *ImmutabilityPolicyProperty `json:"properties,omitempty"` + // READ-ONLY; ImmutabilityPolicy Etag. + Etag *string `json:"etag,omitempty" azure:"ro"` + // READ-ONLY; The ImmutabilityPolicy update history of the blob container. - UpdateHistory *[]*UpdateHistoryProperty `json:"updateHistory,omitempty" azure:"ro"` + UpdateHistory []*UpdateHistoryProperty `json:"updateHistory,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImmutabilityPolicyProperties. +func (i ImmutabilityPolicyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "etag", i.Etag) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "updateHistory", i.UpdateHistory) + return json.Marshal(objectMap) } // ImmutabilityPolicyProperty - The properties of an ImmutabilityPolicy of a blob container. @@ -1670,23 +1826,104 @@ type ImmutabilityPolicyProperty struct { State *ImmutabilityPolicyState `json:"state,omitempty" azure:"ro"` } -// ImmutabilityPolicyResponse is the response envelope for operations that return a ImmutabilityPolicy type. -type ImmutabilityPolicyResponse struct { - // ETag contains the information returned from the ETag header response. - ETag *string +// 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"` + + // READ-ONLY; This property denotes the container level immutability to object level immutability migration state. + MigrationState *MigrationState `json:"migrationState,omitempty" azure:"ro"` + + // READ-ONLY; Returns the date and time the object level immutability was enabled. + TimeStamp *time.Time `json:"timeStamp,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ImmutableStorageWithVersioning. +func (i ImmutableStorageWithVersioning) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "enabled", i.Enabled) + populate(objectMap, "migrationState", i.MigrationState) + populate(objectMap, "timeStamp", (*timeRFC3339)(i.TimeStamp)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ImmutableStorageWithVersioning. +func (i *ImmutableStorageWithVersioning) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "enabled": + err = unpopulate(val, &i.Enabled) + delete(rawMsg, key) + case "migrationState": + err = unpopulate(val, &i.MigrationState) + delete(rawMsg, key) + case "timeStamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + i.TimeStamp = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// KeyCreationTime - Storage account keys creation time. +type KeyCreationTime struct { + Key1 *time.Time `json:"key1,omitempty"` + Key2 *time.Time `json:"key2,omitempty"` +} - // The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. - ImmutabilityPolicy *ImmutabilityPolicy +// MarshalJSON implements the json.Marshaller interface for type KeyCreationTime. +func (k KeyCreationTime) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "key1", (*timeRFC3339)(k.Key1)) + populate(objectMap, "key2", (*timeRFC3339)(k.Key2)) + return json.Marshal(objectMap) +} - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyCreationTime. +func (k *KeyCreationTime) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "key1": + var aux timeRFC3339 + err = unpopulate(val, &aux) + k.Key1 = (*time.Time)(&aux) + delete(rawMsg, key) + case "key2": + var aux timeRFC3339 + err = unpopulate(val, &aux) + k.Key2 = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// KeyPolicy assigned to the storage account. +type KeyPolicy struct { + // REQUIRED; The key expiration period in days. + KeyExpirationPeriodInDays *int32 `json:"keyExpirationPeriodInDays,omitempty"` } // KeyVaultProperties - Properties of key vault. type KeyVaultProperties struct { - // READ-ONLY; The object identifier of the current versioned Key Vault Key in use. - CurrentVersionedKeyIdentifier *string `json:"currentVersionedKeyIdentifier,omitempty" azure:"ro"` - // The name of KeyVault key. KeyName *string `json:"keyname,omitempty"` @@ -1696,6 +1933,9 @@ type KeyVaultProperties struct { // The version of KeyVault key. KeyVersion *string `json:"keyversion,omitempty"` + // READ-ONLY; The object identifier of the current versioned Key Vault Key in use. + CurrentVersionedKeyIdentifier *string `json:"currentVersionedKeyIdentifier,omitempty" azure:"ro"` + // READ-ONLY; Timestamp of last rotation of the Key Vault Key. LastKeyRotationTimestamp *time.Time `json:"lastKeyRotationTimestamp,omitempty" azure:"ro"` } @@ -1713,7 +1953,7 @@ func (k KeyVaultProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultProperties. func (k *KeyVaultProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -1747,12 +1987,12 @@ func (k *KeyVaultProperties) UnmarshalJSON(data []byte) error { // LastAccessTimeTrackingPolicy - The blob service properties for Last access time based tracking policy. type LastAccessTimeTrackingPolicy struct { - // An array of predefined supported blob types. Only blockBlob is the supported value. This field is currently read only - BlobType *[]*string `json:"blobType,omitempty"` - - // When set to true last access time based tracking is enabled. + // REQUIRED; When set to true last access time based tracking is enabled. Enable *bool `json:"enable,omitempty"` + // An array of predefined supported blob types. Only blockBlob is the supported value. This field is currently read only + BlobType []*string `json:"blobType,omitempty"` + // Name of the policy. The valid value is AccessTimeTracking. This field is currently read only Name *Name `json:"name,omitempty"` @@ -1761,9 +2001,19 @@ type LastAccessTimeTrackingPolicy struct { TrackingGranularityInDays *int32 `json:"trackingGranularityInDays,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type LastAccessTimeTrackingPolicy. +func (l LastAccessTimeTrackingPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "blobType", l.BlobType) + populate(objectMap, "enable", l.Enable) + populate(objectMap, "name", l.Name) + populate(objectMap, "trackingGranularityInDays", l.TrackingGranularityInDays) + return json.Marshal(objectMap) +} + // LeaseContainerRequest - Lease Container request schema. type LeaseContainerRequest struct { - // Specifies the lease action. Can be one of the available actions. + // REQUIRED; Specifies the lease action. Can be one of the available actions. Action *LeaseContainerRequestAction `json:"action,omitempty"` // Optional. For a break action, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. @@ -1788,44 +2038,69 @@ type LeaseContainerResponse struct { LeaseTimeSeconds *string `json:"leaseTimeSeconds,omitempty"` } -// LeaseContainerResponseResponse is the response envelope for operations that return a LeaseContainerResponse type. -type LeaseContainerResponseResponse struct { - // Lease Container response schema. - LeaseContainerResponse *LeaseContainerResponse +// 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"` + + // 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"` + + // 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"` + + // Identifies the lease. Can be specified in any valid GUID string format. + LeaseID *string `json:"leaseId,omitempty"` - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response + // Optional for acquire, required for change. Proposed lease ID, in a GUID string format. + ProposedLeaseID *string `json:"proposedLeaseId,omitempty"` +} + +// 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"` + + // Approximate time remaining in the lease period, in seconds. + LeaseTimeSeconds *string `json:"leaseTimeSeconds,omitempty"` } // 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"` + // 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"` +} - // Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case at SRP. - Tags *[]*string `json:"tags,omitempty"` +// MarshalJSON implements the json.Marshaller interface for type LegalHold. +func (l LegalHold) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hasLegalHold", l.HasLegalHold) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) } // LegalHoldProperties - The LegalHold property of a blob container. type LegalHoldProperties struct { + // The list of LegalHold tags of a blob container. + Tags []*TagProperty `json:"tags,omitempty"` + // 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"` - - // The list of LegalHold tags of a blob container. - Tags *[]*TagProperty `json:"tags,omitempty"` } -// LegalHoldResponse is the response envelope for operations that return a LegalHold type. -type LegalHoldResponse struct { - // The LegalHold property of a blob container. - LegalHold *LegalHold - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type LegalHoldProperties. +func (l LegalHoldProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "hasLegalHold", l.HasLegalHold) + populate(objectMap, "tags", l.Tags) + return json.Marshal(objectMap) } // ListAccountSasResponse - The List SAS credentials operation response. @@ -1834,28 +2109,17 @@ type ListAccountSasResponse struct { AccountSasToken *string `json:"accountSasToken,omitempty" azure:"ro"` } -// ListAccountSasResponseResponse is the response envelope for operations that return a ListAccountSasResponse type. -type ListAccountSasResponseResponse struct { - // The List SAS credentials operation response. - ListAccountSasResponse *ListAccountSasResponse - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // 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 `json:"value,omitempty" azure:"ro"` } -// ListBlobInventoryPolicyResponse is the response envelope for operations that return a ListBlobInventoryPolicy type. -type ListBlobInventoryPolicyResponse struct { - // List of blob inventory policies returned. - ListBlobInventoryPolicy *ListBlobInventoryPolicy - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type ListBlobInventoryPolicy. +func (l ListBlobInventoryPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) } // ListContainerItem - The blob container properties be listed out. @@ -1865,22 +2129,28 @@ type ListContainerItem struct { Properties *ContainerProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type ListContainerItem. +func (l ListContainerItem) MarshalJSON() ([]byte, error) { + objectMap := l.AzureEntityResource.marshalInternal() + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + // ListContainerItems - Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. 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"` // READ-ONLY; List of blobs containers returned. - Value *[]*ListContainerItem `json:"value,omitempty" azure:"ro"` + Value []*ListContainerItem `json:"value,omitempty" azure:"ro"` } -// ListContainerItemsResponse is the response envelope for operations that return a ListContainerItems type. -type ListContainerItemsResponse struct { - // Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. - ListContainerItems *ListContainerItems - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type ListContainerItems. +func (l ListContainerItems) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) } type ListQueue struct { @@ -1889,9 +2159,23 @@ type ListQueue struct { QueueProperties *ListQueueProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type ListQueue. +func (l ListQueue) MarshalJSON() ([]byte, error) { + objectMap := l.Resource.marshalInternal() + populate(objectMap, "properties", l.QueueProperties) + return json.Marshal(objectMap) +} + type ListQueueProperties struct { // A name-value pair that represents queue metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` + Metadata map[string]*string `json:"metadata,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ListQueueProperties. +func (l ListQueueProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "metadata", l.Metadata) + return json.Marshal(objectMap) } // ListQueueResource - Response schema. Contains list of queues returned @@ -1900,29 +2184,27 @@ type ListQueueResource struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` // READ-ONLY; List of queues returned. - Value *[]*ListQueue `json:"value,omitempty" azure:"ro"` + Value []*ListQueue `json:"value,omitempty" azure:"ro"` } -// ListQueueResourceResponse is the response envelope for operations that return a ListQueueResource type. -type ListQueueResourceResponse struct { - // Response schema. Contains list of queues returned - ListQueueResource *ListQueueResource - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type ListQueueResource. +func (l ListQueueResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) } type ListQueueServices struct { // READ-ONLY; List of queue services returned. - Value *[]*QueueServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*QueueServiceProperties `json:"value,omitempty" azure:"ro"` } -// ListQueueServicesResponse is the response envelope for operations that return a ListQueueServices type. -type ListQueueServicesResponse struct { - ListQueueServices *ListQueueServices - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type ListQueueServices. +func (l ListQueueServices) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) } // ListServiceSasResponse - The List service SAS credentials operation response. @@ -1931,44 +2213,33 @@ type ListServiceSasResponse struct { ServiceSasToken *string `json:"serviceSasToken,omitempty" azure:"ro"` } -// ListServiceSasResponseResponse is the response envelope for operations that return a ListServiceSasResponse type. -type ListServiceSasResponseResponse struct { - // The List service SAS credentials operation response. - ListServiceSasResponse *ListServiceSasResponse - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // 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"` // READ-ONLY; List of tables returned. - Value *[]*Table `json:"value,omitempty" azure:"ro"` + Value []*Table `json:"value,omitempty" azure:"ro"` } -// ListTableResourceResponse is the response envelope for operations that return a ListTableResource type. -type ListTableResourceResponse struct { - // Response schema. Contains list of tables returned - ListTableResource *ListTableResource - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type ListTableResource. +func (l ListTableResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) } type ListTableServices struct { // READ-ONLY; List of table services returned. - Value *[]*TableServiceProperties `json:"value,omitempty" azure:"ro"` + Value []*TableServiceProperties `json:"value,omitempty" azure:"ro"` } -// ListTableServicesResponse is the response envelope for operations that return a ListTableServices type. -type ListTableServicesResponse struct { - ListTableServices *ListTableServices - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type ListTableServices. +func (l ListTableServices) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) } // ManagementPoliciesCreateOrUpdateOptions contains the optional parameters for the ManagementPolicies.CreateOrUpdate method. @@ -1993,6 +2264,13 @@ type ManagementPolicy struct { Properties *ManagementPolicyProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type ManagementPolicy. +func (m ManagementPolicy) MarshalJSON() ([]byte, error) { + objectMap := m.Resource.marshalInternal() + populate(objectMap, "properties", m.Properties) + return json.Marshal(objectMap) +} + // ManagementPolicyAction - Actions are applied to the filtered blobs when the execution condition is met. type ManagementPolicyAction struct { // The management policy action for base blob @@ -2022,7 +2300,7 @@ type ManagementPolicyBaseBlob struct { // ManagementPolicyDefinition - An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. type ManagementPolicyDefinition struct { - // An object that defines the action set. + // REQUIRED; An object that defines the action set. Actions *ManagementPolicyAction `json:"actions,omitempty"` // An object that defines the filter set. @@ -2032,23 +2310,32 @@ type ManagementPolicyDefinition struct { // ManagementPolicyFilter - Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is // performed on all filters. type ManagementPolicyFilter struct { - // An array of blob index tag based filters, there can be at most 10 tag filters - BlobIndexMatch *[]*TagFilter `json:"blobIndexMatch,omitempty"` + // 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"` - // 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"` + // An array of blob index tag based filters, there can be at most 10 tag filters + BlobIndexMatch []*TagFilter `json:"blobIndexMatch,omitempty"` // An array of strings for prefixes to be match. - PrefixMatch *[]*string `json:"prefixMatch,omitempty"` + PrefixMatch []*string `json:"prefixMatch,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementPolicyFilter. +func (m ManagementPolicyFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "blobIndexMatch", m.BlobIndexMatch) + populate(objectMap, "blobTypes", m.BlobTypes) + populate(objectMap, "prefixMatch", m.PrefixMatch) + return json.Marshal(objectMap) } // 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"` + // READ-ONLY; Returns the date and time the ManagementPolicies was last modified. LastModifiedTime *time.Time `json:"lastModifiedTime,omitempty" azure:"ro"` - - // 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"` } // MarshalJSON implements the json.Marshaller interface for type ManagementPolicyProperties. @@ -2061,7 +2348,7 @@ func (m ManagementPolicyProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type ManagementPolicyProperties. func (m *ManagementPolicyProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -2084,34 +2371,32 @@ func (m *ManagementPolicyProperties) UnmarshalJSON(data []byte) error { return nil } -// ManagementPolicyResponse is the response envelope for operations that return a ManagementPolicy type. -type ManagementPolicyResponse struct { - // The Get Storage Account ManagementPolicies operation response. - ManagementPolicy *ManagementPolicy - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // ManagementPolicyRule - An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. type ManagementPolicyRule struct { - // An object that defines the Lifecycle rule. + // REQUIRED; An object that defines the Lifecycle rule. Definition *ManagementPolicyDefinition `json:"definition,omitempty"` - // Rule is enabled if set to true. - Enabled *bool `json:"enabled,omitempty"` - - // A rule name can contain any combination of alpha numeric characters. Rule name is case-sensitive. It must be unique within a policy. + // 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"` - // The valid value is Lifecycle + // REQUIRED; The valid value is Lifecycle Type *RuleType `json:"type,omitempty"` + + // Rule is enabled if set to true. + Enabled *bool `json:"enabled,omitempty"` } // 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 { - // 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"` + // 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"` +} + +// MarshalJSON implements the json.Marshaller interface for type ManagementPolicySchema. +func (m ManagementPolicySchema) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "rules", m.Rules) + return json.Marshal(objectMap) } // ManagementPolicySnapShot - Management policy action for snapshot. @@ -2147,7 +2432,7 @@ type MetricSpecification struct { Category *string `json:"category,omitempty"` // Dimensions of blobs, including blob type and access tier. - Dimensions *[]*Dimension `json:"dimensions,omitempty"` + Dimensions []*Dimension `json:"dimensions,omitempty"` // Display description of metric specification. DisplayDescription *string `json:"displayDescription,omitempty"` @@ -2168,6 +2453,21 @@ type MetricSpecification struct { Unit *string `json:"unit,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type MetricSpecification. +func (m MetricSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregationType", m.AggregationType) + populate(objectMap, "category", m.Category) + populate(objectMap, "dimensions", m.Dimensions) + populate(objectMap, "displayDescription", m.DisplayDescription) + populate(objectMap, "displayName", m.DisplayName) + populate(objectMap, "fillGapWithZero", m.FillGapWithZero) + populate(objectMap, "name", m.Name) + populate(objectMap, "resourceIdDimensionNameOverride", m.ResourceIDDimensionNameOverride) + populate(objectMap, "unit", m.Unit) + return json.Marshal(objectMap) +} + // Multichannel setting. Applies to Premium FileStorage only. type Multichannel struct { // Indicates whether multichannel is enabled @@ -2176,28 +2476,46 @@ type Multichannel struct { // 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"` + // 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"` - // Specifies the default action of allow or deny when no other rules match. - DefaultAction *DefaultAction `json:"defaultAction,omitempty"` - // Sets the IP ACL rules - IPRules *[]*IPRule `json:"ipRules,omitempty"` + IPRules []*IPRule `json:"ipRules,omitempty"` // Sets the resource access rules - ResourceAccessRules *[]*ResourceAccessRule `json:"resourceAccessRules,omitempty"` + ResourceAccessRules []*ResourceAccessRule `json:"resourceAccessRules,omitempty"` // Sets the virtual network rules - VirtualNetworkRules *[]*VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` + VirtualNetworkRules []*VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkRuleSet. +func (n NetworkRuleSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "bypass", n.Bypass) + populate(objectMap, "defaultAction", n.DefaultAction) + populate(objectMap, "ipRules", n.IPRules) + populate(objectMap, "resourceAccessRules", n.ResourceAccessRules) + populate(objectMap, "virtualNetworkRules", n.VirtualNetworkRules) + return json.Marshal(objectMap) } // ObjectReplicationPolicies - List storage account object replication policies. type ObjectReplicationPolicies struct { // The replication policy between two storage accounts. - Value *[]*ObjectReplicationPolicy `json:"value,omitempty"` + Value []*ObjectReplicationPolicy `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ObjectReplicationPolicies. +func (o ObjectReplicationPolicies) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) } // ObjectReplicationPoliciesCreateOrUpdateOptions contains the optional parameters for the ObjectReplicationPolicies.CreateOrUpdate method. @@ -2220,15 +2538,6 @@ type ObjectReplicationPoliciesListOptions struct { // placeholder for future optional parameters } -// ObjectReplicationPoliciesResponse is the response envelope for operations that return a ObjectReplicationPolicies type. -type ObjectReplicationPoliciesResponse struct { - // List storage account object replication policies. - ObjectReplicationPolicies *ObjectReplicationPolicies - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // ObjectReplicationPolicy - The replication policy between two storage accounts. Multiple rules can be defined in one policy. type ObjectReplicationPolicy struct { Resource @@ -2236,6 +2545,13 @@ type ObjectReplicationPolicy struct { Properties *ObjectReplicationPolicyProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type ObjectReplicationPolicy. +func (o ObjectReplicationPolicy) MarshalJSON() ([]byte, error) { + objectMap := o.Resource.marshalInternal() + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + // ObjectReplicationPolicyFilter - Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the // filter. If multiple filters are defined, a logical AND is performed on all // filters. @@ -2244,25 +2560,33 @@ type ObjectReplicationPolicyFilter struct { MinCreationTime *string `json:"minCreationTime,omitempty"` // Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. - PrefixMatch *[]*string `json:"prefixMatch,omitempty"` + PrefixMatch []*string `json:"prefixMatch,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ObjectReplicationPolicyFilter. +func (o ObjectReplicationPolicyFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "minCreationTime", o.MinCreationTime) + populate(objectMap, "prefixMatch", o.PrefixMatch) + return json.Marshal(objectMap) } // ObjectReplicationPolicyProperties - The Storage Account ObjectReplicationPolicy properties. type ObjectReplicationPolicyProperties struct { - // Required. Destination account name. + // REQUIRED; Required. Destination account name. It should be full resource id if allowCrossTenantReplication set to false. DestinationAccount *string `json:"destinationAccount,omitempty"` + // REQUIRED; Required. Source account name. It should be full resource id if allowCrossTenantReplication set to false. + SourceAccount *string `json:"sourceAccount,omitempty"` + + // The storage account object replication rules. + Rules []*ObjectReplicationPolicyRule `json:"rules,omitempty"` + // READ-ONLY; Indicates when the policy is enabled on the source account. EnabledTime *time.Time `json:"enabledTime,omitempty" azure:"ro"` // READ-ONLY; A unique id for object replication policy. PolicyID *string `json:"policyId,omitempty" azure:"ro"` - - // The storage account object replication rules. - Rules *[]*ObjectReplicationPolicyRule `json:"rules,omitempty"` - - // Required. Source account name. - SourceAccount *string `json:"sourceAccount,omitempty"` } // MarshalJSON implements the json.Marshaller interface for type ObjectReplicationPolicyProperties. @@ -2278,7 +2602,7 @@ func (o ObjectReplicationPolicyProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type ObjectReplicationPolicyProperties. func (o *ObjectReplicationPolicyProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -2310,28 +2634,19 @@ func (o *ObjectReplicationPolicyProperties) UnmarshalJSON(data []byte) error { return nil } -// ObjectReplicationPolicyResponse is the response envelope for operations that return a ObjectReplicationPolicy type. -type ObjectReplicationPolicyResponse struct { - // The replication policy between two storage accounts. Multiple rules can be defined in one policy. - ObjectReplicationPolicy *ObjectReplicationPolicy - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // ObjectReplicationPolicyRule - The replication policy rule between two containers. type ObjectReplicationPolicyRule struct { - // Required. Destination container name. + // REQUIRED; Required. Destination container name. DestinationContainer *string `json:"destinationContainer,omitempty"` + // REQUIRED; Required. Source container name. + SourceContainer *string `json:"sourceContainer,omitempty"` + // Optional. An object that defines the filter set. Filters *ObjectReplicationPolicyFilter `json:"filters,omitempty"` // 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"` - - // Required. Source container name. - SourceContainer *string `json:"sourceContainer,omitempty"` } // Operation - Storage REST API operation definition. @@ -2367,16 +2682,14 @@ type OperationDisplay struct { // 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 `json:"value,omitempty"` } -// OperationListResultResponse is the response envelope for operations that return a OperationListResult type. -type OperationListResultResponse struct { - // 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. - OperationListResult *OperationListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) } // OperationProperties - Properties of operation, include metric specifications. @@ -2403,42 +2716,38 @@ type PrivateEndpointConnection struct { Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnection. +func (p PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + // 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 `json:"value,omitempty"` } -// PrivateEndpointConnectionListResultResponse is the response envelope for operations that return a PrivateEndpointConnectionListResult type. -type PrivateEndpointConnectionListResultResponse struct { - // List of private endpoint connection associated with the specified storage account - PrivateEndpointConnectionListResult *PrivateEndpointConnectionListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type PrivateEndpointConnectionListResult. +func (p PrivateEndpointConnectionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) } // 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"` + // The resource of private end point. PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` - // A collection of information about the state of the connection between service consumer and provider. - PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` - // READ-ONLY; The provisioning state of the private endpoint connection resource. ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty" azure:"ro"` } -// PrivateEndpointConnectionResponse is the response envelope for operations that return a PrivateEndpointConnection type. -type PrivateEndpointConnectionResponse struct { - // The Private Endpoint Connection resource. - PrivateEndpointConnection *PrivateEndpointConnection - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // PrivateEndpointConnectionsDeleteOptions contains the optional parameters for the PrivateEndpointConnections.Delete method. type PrivateEndpointConnectionsDeleteOptions struct { // placeholder for future optional parameters @@ -2466,31 +2775,45 @@ type PrivateLinkResource struct { Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResource. +func (p PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + // PrivateLinkResourceListResult - A list of private link resources type PrivateLinkResourceListResult struct { // Array of private link resources - Value *[]*PrivateLinkResource `json:"value,omitempty"` + Value []*PrivateLinkResource `json:"value,omitempty"` } -// PrivateLinkResourceListResultResponse is the response envelope for operations that return a PrivateLinkResourceListResult type. -type PrivateLinkResourceListResultResponse struct { - // A list of private link resources - PrivateLinkResourceListResult *PrivateLinkResourceListResult - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceListResult. +func (p PrivateLinkResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) } // PrivateLinkResourceProperties - Properties of a private link resource. type PrivateLinkResourceProperties struct { + // The private link resource Private link DNS zone name. + RequiredZoneNames []*string `json:"requiredZoneNames,omitempty"` + // READ-ONLY; The private link resource group id. GroupID *string `json:"groupId,omitempty" azure:"ro"` // READ-ONLY; The private link resource required member names. - RequiredMembers *[]*string `json:"requiredMembers,omitempty" azure:"ro"` + RequiredMembers []*string `json:"requiredMembers,omitempty" azure:"ro"` +} - // The private link resource Private link DNS zone name. - RequiredZoneNames *[]*string `json:"requiredZoneNames,omitempty"` +// MarshalJSON implements the json.Marshaller interface for type PrivateLinkResourceProperties. +func (p PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "groupId", p.GroupID) + populate(objectMap, "requiredMembers", p.RequiredMembers) + populate(objectMap, "requiredZoneNames", p.RequiredZoneNames) + return json.Marshal(objectMap) } // PrivateLinkResourcesListByStorageAccountOptions contains the optional parameters for the PrivateLinkResources.ListByStorageAccount method. @@ -2521,6 +2844,11 @@ type ProxyResource struct { Resource } +func (p ProxyResource) marshalInternal() map[string]interface{} { + objectMap := p.Resource.marshalInternal() + return objectMap +} + // QueueCreateOptions contains the optional parameters for the Queue.Create method. type QueueCreateOptions struct { // placeholder for future optional parameters @@ -2545,12 +2873,20 @@ type QueueListOptions struct { } type QueueProperties struct { + // A name-value pair that represents queue metadata. + Metadata map[string]*string `json:"metadata,omitempty"` + // 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"` +} - // A name-value pair that represents queue metadata. - Metadata *map[string]*string `json:"metadata,omitempty"` +// MarshalJSON implements the json.Marshaller interface for type QueueProperties. +func (q QueueProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "approximateMessageCount", q.ApproximateMessageCount) + populate(objectMap, "metadata", q.Metadata) + return json.Marshal(objectMap) } // QueueServiceProperties - The properties of a storage account’s Queue service. @@ -2560,6 +2896,13 @@ type QueueServiceProperties struct { QueueServiceProperties *QueueServicePropertiesAutoGenerated `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type QueueServiceProperties. +func (q QueueServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := q.Resource.marshalInternal() + populate(objectMap, "properties", q.QueueServiceProperties) + return json.Marshal(objectMap) +} + // QueueServicePropertiesAutoGenerated - The properties of a storage account’s Queue service. type QueueServicePropertiesAutoGenerated 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 @@ -2568,15 +2911,6 @@ type QueueServicePropertiesAutoGenerated struct { Cors *CorsRules `json:"cors,omitempty"` } -// QueueServicePropertiesResponse is the response envelope for operations that return a QueueServiceProperties type. -type QueueServicePropertiesResponse struct { - // The properties of a storage account’s Queue service. - QueueServiceProperties *QueueServiceProperties - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // QueueServicesGetServicePropertiesOptions contains the optional parameters for the QueueServices.GetServiceProperties method. type QueueServicesGetServicePropertiesOptions struct { // placeholder for future optional parameters @@ -2609,6 +2943,12 @@ type Resource struct { Type *string `json:"type,omitempty" azure:"ro"` } +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + func (r Resource) marshalInternal() map[string]interface{} { objectMap := make(map[string]interface{}) populate(objectMap, "id", r.ID) @@ -2628,12 +2968,12 @@ type ResourceAccessRule struct { // 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"` + // how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. Days *int32 `json:"days,omitempty"` - // Blob restore is enabled if set to true. - Enabled *bool `json:"enabled,omitempty"` - // READ-ONLY; Deprecated in favor of minRestoreTime property. LastEnabledTime *time.Time `json:"lastEnabledTime,omitempty" azure:"ro"` @@ -2653,7 +2993,7 @@ func (r RestorePolicyProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type RestorePolicyProperties. func (r *RestorePolicyProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -2695,7 +3035,16 @@ type Restriction struct { Type *string `json:"type,omitempty" azure:"ro"` // 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 `json:"values,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Restriction. +func (r Restriction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reasonCode", r.ReasonCode) + populate(objectMap, "type", r.Type) + populate(objectMap, "values", r.Values) + return json.Marshal(objectMap) } // RoutingPreference - Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default @@ -2713,7 +3062,7 @@ type RoutingPreference struct { // SKU - The SKU of the storage account. type SKU struct { - // The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. + // 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"` // READ-ONLY; The SKU tier. This is based on the SKU name. @@ -2731,42 +3080,64 @@ type SKUCapability struct { // 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"` + + // The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. + Restrictions []*Restriction `json:"restrictions,omitempty"` + // 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 `json:"capabilities,omitempty" azure:"ro"` // READ-ONLY; Indicates the type of storage account. Kind *Kind `json:"kind,omitempty" azure:"ro"` // 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"` - - // 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"` + Locations []*string `json:"locations,omitempty" azure:"ro"` // READ-ONLY; The type of the resource, usually it is 'storageAccounts'. ResourceType *string `json:"resourceType,omitempty" azure:"ro"` - // The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. - Restrictions *[]*Restriction `json:"restrictions,omitempty"` - // READ-ONLY; The SKU tier. This is based on the SKU name. Tier *SKUTier `json:"tier,omitempty" azure:"ro"` } +// MarshalJSON implements the json.Marshaller interface for type SKUInformation. +func (s SKUInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capabilities", s.Capabilities) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "locations", s.Locations) + populate(objectMap, "name", s.Name) + populate(objectMap, "resourceType", s.ResourceType) + populate(objectMap, "restrictions", s.Restrictions) + populate(objectMap, "tier", s.Tier) + return json.Marshal(objectMap) +} + // SKUsListOptions contains the optional parameters for the SKUs.List method. type SKUsListOptions struct { // placeholder for future optional parameters } +// SasPolicy assigned to the storage account. +type SasPolicy struct { + // REQUIRED; The SAS expiration action. Can only be Log. + ExpirationAction *ExpirationAction `json:"expirationAction,omitempty"` + + // REQUIRED; The SAS expiration period, DD.HH:MM:SS. + SasExpirationPeriod *string `json:"sasExpirationPeriod,omitempty"` +} + // 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"` + // The response header override for cache control. CacheControl *string `json:"rscc,omitempty"` - // The canonical path to the signed resource. - CanonicalizedResource *string `json:"canonicalizedResource,omitempty"` - // The response header override for content disposition. ContentDisposition *string `json:"rscd,omitempty"` @@ -2843,7 +3214,7 @@ func (s ServiceSasParameters) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type ServiceSasParameters. func (s *ServiceSasParameters) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -2919,7 +3290,22 @@ func (s *ServiceSasParameters) UnmarshalJSON(data []byte) error { // ServiceSpecification - One property of operation, include metric specifications. type ServiceSpecification struct { // Metric specifications of operation. - MetricSpecifications *[]*MetricSpecification `json:"metricSpecifications,omitempty"` + MetricSpecifications []*MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ServiceSpecification. +func (s ServiceSpecification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "metricSpecifications", s.MetricSpecifications) + return json.Marshal(objectMap) +} + +type SignedIdentifier struct { + // Access policy + AccessPolicy *AccessPolicy `json:"accessPolicy,omitempty"` + + // An unique identifier of the stored access policy. + ID *string `json:"id,omitempty"` } // SmbSetting - Setting for SMB protocol @@ -2949,27 +3335,49 @@ type StorageAccount struct { // The identity of the resource. Identity *Identity `json:"identity,omitempty"` - // READ-ONLY; Gets the Kind. - Kind *Kind `json:"kind,omitempty" azure:"ro"` - // Properties of the storage account. Properties *StorageAccountProperties `json:"properties,omitempty"` + // READ-ONLY; Gets the Kind. + Kind *Kind `json:"kind,omitempty" azure:"ro"` + // READ-ONLY; Gets the SKU. SKU *SKU `json:"sku,omitempty" azure:"ro"` } +// MarshalJSON implements the json.Marshaller interface for type StorageAccount. +func (s StorageAccount) MarshalJSON() ([]byte, error) { + objectMap := s.TrackedResource.marshalInternal() + populate(objectMap, "extendedLocation", s.ExtendedLocation) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + return json.Marshal(objectMap) +} + // StorageAccountCheckNameAvailabilityParameters - The parameters used to check the availability of the storage account name. type StorageAccountCheckNameAvailabilityParameters struct { - // The storage account name. + // REQUIRED; The storage account name. Name *string `json:"name,omitempty"` - // The type of resource, Microsoft.Storage/storageAccounts + // REQUIRED; The type of resource, Microsoft.Storage/storageAccounts Type *string `json:"type,omitempty"` } // StorageAccountCreateParameters - The parameters used when creating a storage account. type StorageAccountCreateParameters struct { + // REQUIRED; Required. Indicates the type of storage account. + Kind *Kind `json:"kind,omitempty"` + + // 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"` + + // REQUIRED; Required. Gets or sets the SKU name. + SKU *SKU `json:"sku,omitempty"` + // 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"` @@ -2977,24 +3385,26 @@ type StorageAccountCreateParameters struct { // The identity of the resource. Identity *Identity `json:"identity,omitempty"` - // Required. Indicates the type of storage account. - Kind *Kind `json:"kind,omitempty"` - - // 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"` - // The parameters used to create the storage account. Properties *StorageAccountPropertiesCreateParameters `json:"properties,omitempty"` - // Required. Gets or sets the SKU name. - SKU *SKU `json:"sku,omitempty"` - // 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 `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type StorageAccountCreateParameters. +func (s StorageAccountCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "extendedLocation", s.ExtendedLocation) + populate(objectMap, "identity", s.Identity) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "location", s.Location) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) } // StorageAccountInternetEndpoints - The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. @@ -3014,6 +3424,9 @@ type StorageAccountInternetEndpoints struct { // StorageAccountKey - An access key for the storage account. type StorageAccountKey struct { + // READ-ONLY; Creation time of the key, in round trip date format. + CreationTime *time.Time `json:"creationTime,omitempty" azure:"ro"` + // READ-ONLY; Name of the key. KeyName *string `json:"keyName,omitempty" azure:"ro"` @@ -3024,19 +3437,58 @@ type StorageAccountKey struct { Value *string `json:"value,omitempty" azure:"ro"` } +// MarshalJSON implements the json.Marshaller interface for type StorageAccountKey. +func (s StorageAccountKey) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "creationTime", (*timeRFC3339)(s.CreationTime)) + populate(objectMap, "keyName", s.KeyName) + populate(objectMap, "permissions", s.Permissions) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StorageAccountKey. +func (s *StorageAccountKey) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "creationTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.CreationTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "keyName": + err = unpopulate(val, &s.KeyName) + delete(rawMsg, key) + case "permissions": + err = unpopulate(val, &s.Permissions) + delete(rawMsg, key) + case "value": + err = unpopulate(val, &s.Value) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + // StorageAccountListKeysResult - The response from the ListKeys operation. type StorageAccountListKeysResult struct { // READ-ONLY; Gets the list of storage account keys and their properties for the specified storage account. - Keys *[]*StorageAccountKey `json:"keys,omitempty" azure:"ro"` + Keys []*StorageAccountKey `json:"keys,omitempty" azure:"ro"` } -// StorageAccountListKeysResultResponse is the response envelope for operations that return a StorageAccountListKeysResult type. -type StorageAccountListKeysResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the ListKeys operation. - StorageAccountListKeysResult *StorageAccountListKeysResult +// MarshalJSON implements the json.Marshaller interface for type StorageAccountListKeysResult. +func (s StorageAccountListKeysResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "keys", s.Keys) + return json.Marshal(objectMap) } // StorageAccountListResult - The response from the List Storage Accounts operation. @@ -3046,16 +3498,15 @@ type StorageAccountListResult struct { NextLink *string `json:"nextLink,omitempty" azure:"ro"` // READ-ONLY; Gets the list of storage accounts and their properties. - Value *[]*StorageAccount `json:"value,omitempty" azure:"ro"` + Value []*StorageAccount `json:"value,omitempty" azure:"ro"` } -// StorageAccountListResultResponse is the response envelope for operations that return a StorageAccountListResult type. -type StorageAccountListResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the List Storage Accounts operation. - StorageAccountListResult *StorageAccountListResult +// MarshalJSON implements the json.Marshaller interface for type StorageAccountListResult. +func (s StorageAccountListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) } // StorageAccountMicrosoftEndpoints - The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing @@ -3080,26 +3531,14 @@ type StorageAccountMicrosoftEndpoints struct { Web *string `json:"web,omitempty" azure:"ro"` } -// StorageAccountPollerResponse is the response envelope for operations that asynchronously return a StorageAccount type. -type StorageAccountPollerResponse struct { - // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received - PollUntilDone func(ctx context.Context, frequency time.Duration) (StorageAccountResponse, error) - - // Poller contains an initialized poller. - Poller StorageAccountPoller - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - // StorageAccountProperties - Properties of the storage account. type StorageAccountProperties struct { - // READ-ONLY; Required for storage accounts where kind = BlobStorage. The access tier used for billing. - AccessTier *AccessTier `json:"accessTier,omitempty" azure:"ro"` - // 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"` + // Allow or disallow cross AAD tenant object replication. The default interpretation is true for this property. + AllowCrossTenantReplication *bool `json:"allowCrossTenantReplication,omitempty"` + // 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. @@ -3108,6 +3547,27 @@ type StorageAccountProperties struct { // Provides the identity based authentication settings for Azure Files. AzureFilesIdentityBasedAuthentication *AzureFilesIdentityBasedAuthentication `json:"azureFilesIdentityBasedAuthentication,omitempty"` + // Allows https traffic only to storage service if sets to true. + EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` + + // NFS 3.0 protocol support enabled if set to true. + EnableNfsV3 *bool `json:"isNfsV3Enabled,omitempty"` + + // Account HierarchicalNamespace enabled if sets to true. + IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"` + + // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. + LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` + + // 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"` + + // Maintains information about the network routing choice opted by the user for data transfer + RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` + + // READ-ONLY; Required for storage accounts where kind = BlobStorage. The access tier used for billing. + AccessTier *AccessTier `json:"accessTier,omitempty" azure:"ro"` + // READ-ONLY; Blob restore status BlobRestoreStatus *BlobRestoreStatus `json:"blobRestoreStatus,omitempty" azure:"ro"` @@ -3117,12 +3577,6 @@ type StorageAccountProperties struct { // READ-ONLY; Gets the custom domain the user assigned to this storage account. CustomDomain *CustomDomain `json:"customDomain,omitempty" azure:"ro"` - // Allows https traffic only to storage service if sets to true. - EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"` - - // NFS 3.0 protocol support enabled if set to true. - EnableNfsV3 *bool `json:"isNfsV3Enabled,omitempty"` - // READ-ONLY; Gets the encryption settings on the account. If unspecified, the account is unencrypted. Encryption *Encryption `json:"encryption,omitempty" azure:"ro"` @@ -3132,20 +3586,17 @@ type StorageAccountProperties struct { // READ-ONLY; Geo Replication Stats GeoReplicationStats *GeoReplicationStats `json:"geoReplicationStats,omitempty" azure:"ro"` - // Account HierarchicalNamespace enabled if sets to true. - IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"` + // READ-ONLY; Storage account keys creation time. + KeyCreationTime *KeyCreationTime `json:"keyCreationTime,omitempty" azure:"ro"` - // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` + // READ-ONLY; KeyPolicy assigned to the storage account. + KeyPolicy *KeyPolicy `json:"keyPolicy,omitempty" azure:"ro"` // 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"` - // 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"` - // READ-ONLY; Network rule set NetworkRuleSet *NetworkRuleSet `json:"networkAcls,omitempty" azure:"ro"` @@ -3157,13 +3608,13 @@ type StorageAccountProperties struct { PrimaryLocation *string `json:"primaryLocation,omitempty" azure:"ro"` // READ-ONLY; List of private endpoint connection associated with the specified storage account - PrivateEndpointConnections *[]*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` + PrivateEndpointConnections []*PrivateEndpointConnection `json:"privateEndpointConnections,omitempty" azure:"ro"` // READ-ONLY; Gets the status of the storage account at the time the operation was called. ProvisioningState *ProvisioningState `json:"provisioningState,omitempty" azure:"ro"` - // Maintains information about the network routing choice opted by the user for data transfer - RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` + // READ-ONLY; SasPolicy assigned to the storage account. + SasPolicy *SasPolicy `json:"sasPolicy,omitempty" azure:"ro"` // 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. @@ -3185,6 +3636,7 @@ func (s StorageAccountProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) populate(objectMap, "accessTier", s.AccessTier) populate(objectMap, "allowBlobPublicAccess", s.AllowBlobPublicAccess) + populate(objectMap, "allowCrossTenantReplication", s.AllowCrossTenantReplication) populate(objectMap, "allowSharedKeyAccess", s.AllowSharedKeyAccess) populate(objectMap, "azureFilesIdentityBasedAuthentication", s.AzureFilesIdentityBasedAuthentication) populate(objectMap, "blobRestoreStatus", s.BlobRestoreStatus) @@ -3196,6 +3648,8 @@ func (s StorageAccountProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "failoverInProgress", s.FailoverInProgress) populate(objectMap, "geoReplicationStats", s.GeoReplicationStats) populate(objectMap, "isHnsEnabled", s.IsHnsEnabled) + populate(objectMap, "keyCreationTime", s.KeyCreationTime) + populate(objectMap, "keyPolicy", s.KeyPolicy) populate(objectMap, "largeFileSharesState", s.LargeFileSharesState) populate(objectMap, "lastGeoFailoverTime", (*timeRFC3339)(s.LastGeoFailoverTime)) populate(objectMap, "minimumTlsVersion", s.MinimumTLSVersion) @@ -3205,6 +3659,7 @@ func (s StorageAccountProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "privateEndpointConnections", s.PrivateEndpointConnections) populate(objectMap, "provisioningState", s.ProvisioningState) populate(objectMap, "routingPreference", s.RoutingPreference) + populate(objectMap, "sasPolicy", s.SasPolicy) populate(objectMap, "secondaryEndpoints", s.SecondaryEndpoints) populate(objectMap, "secondaryLocation", s.SecondaryLocation) populate(objectMap, "statusOfPrimary", s.StatusOfPrimary) @@ -3214,7 +3669,7 @@ func (s StorageAccountProperties) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type StorageAccountProperties. func (s *StorageAccountProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -3227,6 +3682,9 @@ func (s *StorageAccountProperties) UnmarshalJSON(data []byte) error { case "allowBlobPublicAccess": err = unpopulate(val, &s.AllowBlobPublicAccess) delete(rawMsg, key) + case "allowCrossTenantReplication": + err = unpopulate(val, &s.AllowCrossTenantReplication) + delete(rawMsg, key) case "allowSharedKeyAccess": err = unpopulate(val, &s.AllowSharedKeyAccess) delete(rawMsg, key) @@ -3262,6 +3720,12 @@ func (s *StorageAccountProperties) UnmarshalJSON(data []byte) error { case "isHnsEnabled": err = unpopulate(val, &s.IsHnsEnabled) delete(rawMsg, key) + case "keyCreationTime": + err = unpopulate(val, &s.KeyCreationTime) + delete(rawMsg, key) + case "keyPolicy": + err = unpopulate(val, &s.KeyPolicy) + delete(rawMsg, key) case "largeFileSharesState": err = unpopulate(val, &s.LargeFileSharesState) delete(rawMsg, key) @@ -3291,6 +3755,9 @@ func (s *StorageAccountProperties) UnmarshalJSON(data []byte) error { case "routingPreference": err = unpopulate(val, &s.RoutingPreference) delete(rawMsg, key) + case "sasPolicy": + err = unpopulate(val, &s.SasPolicy) + delete(rawMsg, key) case "secondaryEndpoints": err = unpopulate(val, &s.SecondaryEndpoints) delete(rawMsg, key) @@ -3319,6 +3786,9 @@ type StorageAccountPropertiesCreateParameters 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"` + // Allow or disallow cross AAD tenant object replication. The default interpretation is true for this property. + AllowCrossTenantReplication *bool `json:"allowCrossTenantReplication,omitempty"` + // 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. @@ -3344,6 +3814,9 @@ type StorageAccountPropertiesCreateParameters struct { // Account HierarchicalNamespace enabled if sets to true. IsHnsEnabled *bool `json:"isHnsEnabled,omitempty"` + // KeyPolicy assigned to the storage account. + KeyPolicy *KeyPolicy `json:"keyPolicy,omitempty"` + // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` @@ -3355,6 +3828,9 @@ type StorageAccountPropertiesCreateParameters struct { // Maintains information about the network routing choice opted by the user for data transfer RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` + + // SasPolicy assigned to the storage account. + SasPolicy *SasPolicy `json:"sasPolicy,omitempty"` } // StorageAccountPropertiesUpdateParameters - The parameters used when updating a storage account. @@ -3365,6 +3841,9 @@ type StorageAccountPropertiesUpdateParameters 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"` + // Allow or disallow cross AAD tenant object replication. The default interpretation is true for this property. + AllowCrossTenantReplication *bool `json:"allowCrossTenantReplication,omitempty"` + // 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. @@ -3384,6 +3863,9 @@ type StorageAccountPropertiesUpdateParameters struct { // Provides the encryption settings on the account. The default setting is unencrypted. Encryption *Encryption `json:"encryption,omitempty"` + // KeyPolicy assigned to the storage account. + KeyPolicy *KeyPolicy `json:"keyPolicy,omitempty"` + // Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. LargeFileSharesState *LargeFileSharesState `json:"largeFileSharesState,omitempty"` @@ -3395,23 +3877,17 @@ type StorageAccountPropertiesUpdateParameters struct { // Maintains information about the network routing choice opted by the user for data transfer RoutingPreference *RoutingPreference `json:"routingPreference,omitempty"` + + // SasPolicy assigned to the storage account. + SasPolicy *SasPolicy `json:"sasPolicy,omitempty"` } // StorageAccountRegenerateKeyParameters - The parameters used to regenerate the storage account key. type StorageAccountRegenerateKeyParameters struct { - // The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. + // REQUIRED; The name of storage keys that want to be regenerated, possible values are key1, key2, kerb1, kerb2. KeyName *string `json:"keyName,omitempty"` } -// StorageAccountResponse is the response envelope for operations that return a StorageAccount type. -type StorageAccountResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The storage account. - StorageAccount *StorageAccount -} - // StorageAccountUpdateParameters - The parameters that can be provided when updating the storage account properties. type StorageAccountUpdateParameters struct { // The identity of the resource. @@ -3430,7 +3906,7 @@ type StorageAccountUpdateParameters struct { // 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 `json:"tags,omitempty"` } // MarshalJSON implements the json.Marshaller interface for type StorageAccountUpdateParameters. @@ -3530,26 +4006,17 @@ func (s StorageQueue) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// StorageQueueResponse is the response envelope for operations that return a StorageQueue type. -type StorageQueueResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - StorageQueue *StorageQueue -} - // StorageSKUListResult - The response from the List Storage SKUs operation. type StorageSKUListResult struct { // READ-ONLY; Get the list result of storage SKUs and their properties. - Value *[]*SKUInformation `json:"value,omitempty" azure:"ro"` + Value []*SKUInformation `json:"value,omitempty" azure:"ro"` } -// StorageSKUListResultResponse is the response envelope for operations that return a StorageSKUListResult type. -type StorageSKUListResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the List Storage SKUs operation. - StorageSKUListResult *StorageSKUListResult +// MarshalJSON implements the json.Marshaller interface for type StorageSKUListResult. +func (s StorageSKUListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) } // SystemData - Metadata pertaining to creation and last modification of the resource. @@ -3587,7 +4054,7 @@ func (s SystemData) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -3631,6 +4098,13 @@ type Table struct { TableProperties *TableProperties `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type Table. +func (t Table) MarshalJSON() ([]byte, error) { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "properties", t.TableProperties) + return json.Marshal(objectMap) +} + // TableCreateOptions contains the optional parameters for the Table.Create method. type TableCreateOptions struct { // placeholder for future optional parameters @@ -3656,15 +4130,6 @@ type TableProperties struct { TableName *string `json:"tableName,omitempty" azure:"ro"` } -// TableResponse is the response envelope for operations that return a Table type. -type TableResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // Properties of the table, including Id, resource name, resource type. - Table *Table -} - // TableServiceProperties - The properties of a storage account’s Table service. type TableServiceProperties struct { Resource @@ -3672,6 +4137,13 @@ type TableServiceProperties struct { TableServiceProperties *TableServicePropertiesAutoGenerated `json:"properties,omitempty"` } +// MarshalJSON implements the json.Marshaller interface for type TableServiceProperties. +func (t TableServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "properties", t.TableServiceProperties) + return json.Marshal(objectMap) +} + // TableServicePropertiesAutoGenerated - The properties of a storage account’s Table service. type TableServicePropertiesAutoGenerated 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 @@ -3680,15 +4152,6 @@ type TableServicePropertiesAutoGenerated struct { Cors *CorsRules `json:"cors,omitempty"` } -// TableServicePropertiesResponse is the response envelope for operations that return a TableServiceProperties type. -type TableServicePropertiesResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The properties of a storage account’s Table service. - TableServiceProperties *TableServiceProperties -} - // TableServicesGetServicePropertiesOptions contains the optional parameters for the TableServices.GetServiceProperties method. type TableServicesGetServicePropertiesOptions struct { // placeholder for future optional parameters @@ -3711,13 +4174,13 @@ type TableUpdateOptions struct { // TagFilter - Blob index tag based filtering for blob objects type TagFilter struct { - // This is the filter tag name, it can have 1 - 128 characters + // REQUIRED; This is the filter tag name, it can have 1 - 128 characters Name *string `json:"name,omitempty"` - // This is the comparison operator which is used for object comparison and filtering. Only == (equality operator) is currently supported + // 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"` - // This is the filter tag value field used for tag based filtering, it can have 0 - 256 characters + // REQUIRED; This is the filter tag value field used for tag based filtering, it can have 0 - 256 characters Value *string `json:"value,omitempty"` } @@ -3752,7 +4215,7 @@ func (t TagProperty) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type TagProperty. func (t *TagProperty) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -3787,11 +4250,24 @@ func (t *TagProperty) UnmarshalJSON(data []byte) error { // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location' type TrackedResource struct { Resource - // The geo-location where the resource lives + // REQUIRED; The geo-location where the resource lives Location *string `json:"location,omitempty"` // Resource tags. - Tags *map[string]*string `json:"tags,omitempty"` + Tags map[string]*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := t.marshalInternal() + return json.Marshal(objectMap) +} + +func (t TrackedResource) marshalInternal() map[string]interface{} { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "location", t.Location) + populate(objectMap, "tags", t.Tags) + return objectMap } // UpdateHistoryProperty - An update history of the ImmutabilityPolicy of a blob container. @@ -3829,7 +4305,7 @@ func (u UpdateHistoryProperty) MarshalJSON() ([]byte, error) { // UnmarshalJSON implements the json.Unmarshaller interface for type UpdateHistoryProperty. func (u *UpdateHistoryProperty) UnmarshalJSON(data []byte) error { - var rawMsg map[string]*json.RawMessage + var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return err } @@ -3882,16 +4358,14 @@ type Usage struct { // 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 `json:"value,omitempty"` } -// UsageListResultResponse is the response envelope for operations that return a UsageListResult type. -type UsageListResultResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response - - // The response from the List Usages operation. - UsageListResult *UsageListResult +// MarshalJSON implements the json.Marshaller interface for type UsageListResult. +func (u UsageListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) } // UsageName - The usage names that can be used; currently limited to StorageAccount. @@ -3919,14 +4393,14 @@ type UserAssignedIdentity struct { // 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"` + // The action of virtual network rule. Action *string `json:"action,omitempty"` // Gets the state of virtual network rule. State *State `json:"state,omitempty"` - - // Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. - VirtualNetworkResourceID *string `json:"id,omitempty"` } func populate(m map[string]interface{}, k string, v interface{}) { @@ -3939,9 +4413,9 @@ func populate(m map[string]interface{}, k string, v interface{}) { } } -func unpopulate(data *json.RawMessage, v interface{}) error { +func unpopulate(data json.RawMessage, v interface{}) error { if data == nil { return nil } - return json.Unmarshal(*data, v) + return json.Unmarshal(data, v) } diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_objectreplicationpolicies_client.go b/sdk/storage/armstorage/zz_generated_objectreplicationpolicies_client.go similarity index 87% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_objectreplicationpolicies_client.go rename to sdk/storage/armstorage/zz_generated_objectreplicationpolicies_client.go index f36e3078942c..5aaec90c84a6 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_objectreplicationpolicies_client.go +++ b/sdk/storage/armstorage/zz_generated_objectreplicationpolicies_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -30,6 +31,7 @@ func NewObjectReplicationPoliciesClient(con *armcore.Connection, subscriptionID } // CreateOrUpdate - Create or update the object replication policy of the storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *ObjectReplicationPoliciesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, properties ObjectReplicationPolicy, options *ObjectReplicationPoliciesCreateOrUpdateOptions) (ObjectReplicationPolicyResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, accountName, objectReplicationPolicyID, properties, options) if err != nil { @@ -70,7 +72,7 @@ func (client *ObjectReplicationPoliciesClient) createOrUpdateCreateRequest(ctx c } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(properties) @@ -87,14 +89,19 @@ func (client *ObjectReplicationPoliciesClient) createOrUpdateHandleResponse(resp // createOrUpdateHandleError handles the CreateOrUpdate error response. func (client *ObjectReplicationPoliciesClient) createOrUpdateHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Delete - Deletes the object replication policy associated with the specified storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *ObjectReplicationPoliciesClient) Delete(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, objectReplicationPolicyID, options) if err != nil { @@ -135,7 +142,7 @@ func (client *ObjectReplicationPoliciesClient) deleteCreateRequest(ctx context.C } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -143,14 +150,19 @@ func (client *ObjectReplicationPoliciesClient) deleteCreateRequest(ctx context.C // deleteHandleError handles the Delete error response. func (client *ObjectReplicationPoliciesClient) deleteHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Get - Get the object replication policy of the storage account by policy ID. +// If the operation fails it returns the *ErrorResponse error type. func (client *ObjectReplicationPoliciesClient) Get(ctx context.Context, resourceGroupName string, accountName string, objectReplicationPolicyID string, options *ObjectReplicationPoliciesGetOptions) (ObjectReplicationPolicyResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, objectReplicationPolicyID, options) if err != nil { @@ -191,7 +203,7 @@ func (client *ObjectReplicationPoliciesClient) getCreateRequest(ctx context.Cont } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -208,14 +220,19 @@ func (client *ObjectReplicationPoliciesClient) getHandleResponse(resp *azcore.Re // getHandleError handles the Get error response. func (client *ObjectReplicationPoliciesClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // List - List the object replication policies associated with the storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *ObjectReplicationPoliciesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *ObjectReplicationPoliciesListOptions) (ObjectReplicationPoliciesResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -252,7 +269,7 @@ func (client *ObjectReplicationPoliciesClient) listCreateRequest(ctx context.Con } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -269,9 +286,13 @@ func (client *ObjectReplicationPoliciesClient) listHandleResponse(resp *azcore.R // listHandleError handles the List error response. func (client *ObjectReplicationPoliciesClient) listHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_operations_client.go b/sdk/storage/armstorage/zz_generated_operations_client.go similarity index 93% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_operations_client.go rename to sdk/storage/armstorage/zz_generated_operations_client.go index c602b5e5e4b3..01895e0d7b94 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_operations_client.go +++ b/sdk/storage/armstorage/zz_generated_operations_client.go @@ -10,10 +10,8 @@ package armstorage import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" ) @@ -29,6 +27,7 @@ func NewOperationsClient(con *armcore.Connection) *OperationsClient { } // List - Lists all of the available Storage Rest API operations. +// If the operation fails it returns a generic error. func (client *OperationsClient) List(ctx context.Context, options *OperationsListOptions) (OperationListResultResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { @@ -53,7 +52,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -70,9 +69,9 @@ func (client *OperationsClient) listHandleResponse(resp *azcore.Response) (Opera // listHandleError handles the List error response. func (client *OperationsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_pagers.go b/sdk/storage/armstorage/zz_generated_pagers.go similarity index 100% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_pagers.go rename to sdk/storage/armstorage/zz_generated_pagers.go diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pollers.go b/sdk/storage/armstorage/zz_generated_pollers.go similarity index 100% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_pollers.go rename to sdk/storage/armstorage/zz_generated_pollers.go diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_privateendpointconnections_client.go b/sdk/storage/armstorage/zz_generated_privateendpointconnections_client.go similarity index 89% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_privateendpointconnections_client.go rename to sdk/storage/armstorage/zz_generated_privateendpointconnections_client.go index 88533b102ead..e8a8b1f0a26b 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_privateendpointconnections_client.go +++ b/sdk/storage/armstorage/zz_generated_privateendpointconnections_client.go @@ -13,7 +13,6 @@ import ( "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -32,6 +31,7 @@ func NewPrivateEndpointConnectionsClient(con *armcore.Connection, subscriptionID } // Delete - Deletes the specified private endpoint connection associated with the storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *PrivateEndpointConnectionsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionName, options) if err != nil { @@ -72,7 +72,7 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -80,14 +80,19 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // deleteHandleError handles the Delete error response. func (client *PrivateEndpointConnectionsClient) deleteHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Get - Gets the specified private endpoint connection associated with the storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsGetOptions) (PrivateEndpointConnectionResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionName, options) if err != nil { @@ -128,7 +133,7 @@ func (client *PrivateEndpointConnectionsClient) getCreateRequest(ctx context.Con } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -145,14 +150,19 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *azcore.R // getHandleError handles the Get error response. func (client *PrivateEndpointConnectionsClient) getHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // List - List all the private endpoint connections associated with the storage account. +// If the operation fails it returns a generic error. func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, accountName string, options *PrivateEndpointConnectionsListOptions) (PrivateEndpointConnectionListResultResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -189,7 +199,7 @@ func (client *PrivateEndpointConnectionsClient) listCreateRequest(ctx context.Co } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -206,9 +216,9 @@ func (client *PrivateEndpointConnectionsClient) listHandleResponse(resp *azcore. // listHandleError handles the List error response. func (client *PrivateEndpointConnectionsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -217,6 +227,7 @@ func (client *PrivateEndpointConnectionsClient) listHandleError(resp *azcore.Res } // Put - Update the state of specified private endpoint connection associated with the storage account. +// If the operation fails it returns the *ErrorResponse error type. func (client *PrivateEndpointConnectionsClient) Put(ctx context.Context, resourceGroupName string, accountName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsPutOptions) (PrivateEndpointConnectionResponse, error) { req, err := client.putCreateRequest(ctx, resourceGroupName, accountName, privateEndpointConnectionName, properties, options) if err != nil { @@ -257,7 +268,7 @@ func (client *PrivateEndpointConnectionsClient) putCreateRequest(ctx context.Con } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(properties) @@ -274,9 +285,13 @@ func (client *PrivateEndpointConnectionsClient) putHandleResponse(resp *azcore.R // putHandleError handles the Put error response. func (client *PrivateEndpointConnectionsClient) putHandleError(resp *azcore.Response) error { - var err ErrorResponse - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_privatelinkresources_client.go b/sdk/storage/armstorage/zz_generated_privatelinkresources_client.go similarity index 95% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_privatelinkresources_client.go rename to sdk/storage/armstorage/zz_generated_privatelinkresources_client.go index b463edfd946d..de16eba53a58 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_privatelinkresources_client.go +++ b/sdk/storage/armstorage/zz_generated_privatelinkresources_client.go @@ -10,10 +10,8 @@ package armstorage import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -32,6 +30,7 @@ func NewPrivateLinkResourcesClient(con *armcore.Connection, subscriptionID strin } // ListByStorageAccount - Gets the private link resources that need to be created for a storage account. +// If the operation fails it returns a generic error. func (client *PrivateLinkResourcesClient) ListByStorageAccount(ctx context.Context, resourceGroupName string, accountName string, options *PrivateLinkResourcesListByStorageAccountOptions) (PrivateLinkResourceListResultResponse, error) { req, err := client.listByStorageAccountCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -68,7 +67,7 @@ func (client *PrivateLinkResourcesClient) listByStorageAccountCreateRequest(ctx } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -85,9 +84,9 @@ func (client *PrivateLinkResourcesClient) listByStorageAccountHandleResponse(res // listByStorageAccountHandleError handles the ListByStorageAccount error response. func (client *PrivateLinkResourcesClient) listByStorageAccountHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queue_client.go b/sdk/storage/armstorage/zz_generated_queue_client.go similarity index 85% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_queue_client.go rename to sdk/storage/armstorage/zz_generated_queue_client.go index 6fa37d4d196b..a27302def7dd 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queue_client.go +++ b/sdk/storage/armstorage/zz_generated_queue_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -30,6 +31,7 @@ func NewQueueClient(con *armcore.Connection, subscriptionID string) *QueueClient } // Create - Creates a new queue with the specified queue name, under the specified account. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueClient) Create(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue StorageQueue, options *QueueCreateOptions) (StorageQueueResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, queueName, queue, options) if err != nil { @@ -70,7 +72,7 @@ func (client *QueueClient) createCreateRequest(ctx context.Context, resourceGrou } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(queue) @@ -87,14 +89,19 @@ func (client *QueueClient) createHandleResponse(resp *azcore.Response) (StorageQ // createHandleError handles the Create error response. func (client *QueueClient) createHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Delete - Deletes the queue with the specified queue name, under the specified account if it exists. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueClient) Delete(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, queueName, options) if err != nil { @@ -135,7 +142,7 @@ func (client *QueueClient) deleteCreateRequest(ctx context.Context, resourceGrou } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -143,14 +150,19 @@ func (client *QueueClient) deleteCreateRequest(ctx context.Context, resourceGrou // deleteHandleError handles the Delete error response. func (client *QueueClient) deleteHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // Get - Gets the queue with the specified queue name, under the specified account if it exists. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueClient) Get(ctx context.Context, resourceGroupName string, accountName string, queueName string, options *QueueGetOptions) (StorageQueueResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, queueName, options) if err != nil { @@ -191,7 +203,7 @@ func (client *QueueClient) getCreateRequest(ctx context.Context, resourceGroupNa } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -208,14 +220,19 @@ func (client *QueueClient) getHandleResponse(resp *azcore.Response) (StorageQueu // getHandleError handles the Get error response. func (client *QueueClient) getHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // List - Gets a list of all the queues under the specified storage account +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueClient) List(resourceGroupName string, accountName string, options *QueueListOptions) ListQueueResourcePager { return &listQueueResourcePager{ pipeline: client.con.Pipeline(), @@ -252,7 +269,7 @@ func (client *QueueClient) listCreateRequest(ctx context.Context, resourceGroupN } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") if options != nil && options.Maxpagesize != nil { reqQP.Set("$maxpagesize", *options.Maxpagesize) } @@ -275,14 +292,19 @@ func (client *QueueClient) listHandleResponse(resp *azcore.Response) (ListQueueR // listHandleError handles the List error response. func (client *QueueClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Update - Creates a new queue with the specified queue name, under the specified account. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueClient) Update(ctx context.Context, resourceGroupName string, accountName string, queueName string, queue StorageQueue, options *QueueUpdateOptions) (StorageQueueResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, queueName, queue, options) if err != nil { @@ -323,7 +345,7 @@ func (client *QueueClient) updateCreateRequest(ctx context.Context, resourceGrou } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(queue) @@ -340,9 +362,13 @@ func (client *QueueClient) updateHandleResponse(resp *azcore.Response) (StorageQ // updateHandleError handles the Update error response. func (client *QueueClient) updateHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_queueservices_client.go b/sdk/storage/armstorage/zz_generated_queueservices_client.go similarity index 86% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_queueservices_client.go rename to sdk/storage/armstorage/zz_generated_queueservices_client.go index c5a7287c0309..28491fdd8db3 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_queueservices_client.go +++ b/sdk/storage/armstorage/zz_generated_queueservices_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -31,6 +32,7 @@ func NewQueueServicesClient(con *armcore.Connection, subscriptionID string) *Que // GetServiceProperties - Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource // Sharing) rules. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesGetServicePropertiesOptions) (QueueServicePropertiesResponse, error) { req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -68,7 +70,7 @@ func (client *QueueServicesClient) getServicePropertiesCreateRequest(ctx context } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -85,14 +87,19 @@ func (client *QueueServicesClient) getServicePropertiesHandleResponse(resp *azco // getServicePropertiesHandleError handles the GetServiceProperties error response. func (client *QueueServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // List - List all queue services for the storage account +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *QueueServicesListOptions) (ListQueueServicesResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -129,7 +136,7 @@ func (client *QueueServicesClient) listCreateRequest(ctx context.Context, resour } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -146,15 +153,20 @@ func (client *QueueServicesClient) listHandleResponse(resp *azcore.Response) (Li // listHandleError handles the List error response. func (client *QueueServicesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // SetServiceProperties - Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource // Sharing) rules. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *QueueServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters QueueServiceProperties, options *QueueServicesSetServicePropertiesOptions) (QueueServicePropertiesResponse, error) { req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -192,7 +204,7 @@ func (client *QueueServicesClient) setServicePropertiesCreateRequest(ctx context } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) @@ -209,9 +221,13 @@ func (client *QueueServicesClient) setServicePropertiesHandleResponse(resp *azco // setServicePropertiesHandleError handles the SetServiceProperties error response. func (client *QueueServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/storage/armstorage/zz_generated_response_types.go b/sdk/storage/armstorage/zz_generated_response_types.go new file mode 100644 index 000000000000..560a08b8360d --- /dev/null +++ b/sdk/storage/armstorage/zz_generated_response_types.go @@ -0,0 +1,428 @@ +// +build go1.13 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armstorage + +import ( + "context" + "net/http" + "time" +) + +// BlobContainerResponse is the response envelope for operations that return a BlobContainer type. +type BlobContainerResponse struct { + // Properties of the blob container, including Id, resource name, resource type, Etag. + BlobContainer *BlobContainer + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BlobInventoryPolicyResponse is the response envelope for operations that return a BlobInventoryPolicy type. +type BlobInventoryPolicyResponse struct { + // The storage account blob inventory policy. + BlobInventoryPolicy *BlobInventoryPolicy + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BlobRestoreStatusPollerResponse is the response envelope for operations that asynchronously return a BlobRestoreStatus type. +type BlobRestoreStatusPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (BlobRestoreStatusResponse, error) + + // Poller contains an initialized poller. + Poller BlobRestoreStatusPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BlobRestoreStatusResponse is the response envelope for operations that return a BlobRestoreStatus type. +type BlobRestoreStatusResponse struct { + // Blob restore status. + BlobRestoreStatus *BlobRestoreStatus + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BlobServiceItemsResponse is the response envelope for operations that return a BlobServiceItems type. +type BlobServiceItemsResponse struct { + BlobServiceItems *BlobServiceItems + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BlobServicePropertiesResponse is the response envelope for operations that return a BlobServiceProperties type. +type BlobServicePropertiesResponse struct { + // The properties of a storage account’s Blob service. + BlobServiceProperties *BlobServiceProperties + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CheckNameAvailabilityResultResponse is the response envelope for operations that return a CheckNameAvailabilityResult type. +type CheckNameAvailabilityResultResponse struct { + // The CheckNameAvailability operation response. + CheckNameAvailabilityResult *CheckNameAvailabilityResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedAccountListResultResponse is the response envelope for operations that return a DeletedAccountListResult type. +type DeletedAccountListResultResponse struct { + // The response from the List Deleted Accounts operation. + DeletedAccountListResult *DeletedAccountListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedAccountResponse is the response envelope for operations that return a DeletedAccount type. +type DeletedAccountResponse struct { + // Deleted storage account + DeletedAccount *DeletedAccount + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EncryptionScopeListResultResponse is the response envelope for operations that return a EncryptionScopeListResult type. +type EncryptionScopeListResultResponse struct { + // List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. + EncryptionScopeListResult *EncryptionScopeListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EncryptionScopeResponse is the response envelope for operations that return a EncryptionScope type. +type EncryptionScopeResponse struct { + // The Encryption Scope resource. + EncryptionScope *EncryptionScope + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FileServiceItemsResponse is the response envelope for operations that return a FileServiceItems type. +type FileServiceItemsResponse struct { + FileServiceItems *FileServiceItems + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FileServicePropertiesResponse is the response envelope for operations that return a FileServiceProperties type. +type FileServicePropertiesResponse struct { + // The properties of File services in storage account. + FileServiceProperties *FileServiceProperties + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FileShareItemsResponse is the response envelope for operations that return a FileShareItems type. +type FileShareItemsResponse struct { + // Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. + FileShareItems *FileShareItems + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// FileShareResponse is the response envelope for operations that return a FileShare type. +type FileShareResponse struct { + // Properties of the file share, including Id, resource name, resource type, Etag. + FileShare *FileShare + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// HTTPPollerResponse contains the asynchronous HTTP response from the call to the service endpoint. +type HTTPPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (*http.Response, error) + + // Poller contains an initialized poller. + Poller HTTPPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ImmutabilityPolicyResponse is the response envelope for operations that return a ImmutabilityPolicy type. +type ImmutabilityPolicyResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. + ImmutabilityPolicy *ImmutabilityPolicy + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LeaseContainerResponseResponse is the response envelope for operations that return a LeaseContainerResponse type. +type LeaseContainerResponseResponse struct { + // Lease Container response schema. + LeaseContainerResponse *LeaseContainerResponse + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LeaseShareResponseResponse is the response envelope for operations that return a LeaseShareResponse type. +type LeaseShareResponseResponse struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Lease Share response schema. + LeaseShareResponse *LeaseShareResponse + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LegalHoldResponse is the response envelope for operations that return a LegalHold type. +type LegalHoldResponse struct { + // The LegalHold property of a blob container. + LegalHold *LegalHold + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListAccountSasResponseResponse is the response envelope for operations that return a ListAccountSasResponse type. +type ListAccountSasResponseResponse struct { + // The List SAS credentials operation response. + ListAccountSasResponse *ListAccountSasResponse + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListBlobInventoryPolicyResponse is the response envelope for operations that return a ListBlobInventoryPolicy type. +type ListBlobInventoryPolicyResponse struct { + // List of blob inventory policies returned. + ListBlobInventoryPolicy *ListBlobInventoryPolicy + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListContainerItemsResponse is the response envelope for operations that return a ListContainerItems type. +type ListContainerItemsResponse struct { + // Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. + ListContainerItems *ListContainerItems + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListQueueResourceResponse is the response envelope for operations that return a ListQueueResource type. +type ListQueueResourceResponse struct { + // Response schema. Contains list of queues returned + ListQueueResource *ListQueueResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListQueueServicesResponse is the response envelope for operations that return a ListQueueServices type. +type ListQueueServicesResponse struct { + ListQueueServices *ListQueueServices + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListServiceSasResponseResponse is the response envelope for operations that return a ListServiceSasResponse type. +type ListServiceSasResponseResponse struct { + // The List service SAS credentials operation response. + ListServiceSasResponse *ListServiceSasResponse + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListTableResourceResponse is the response envelope for operations that return a ListTableResource type. +type ListTableResourceResponse struct { + // Response schema. Contains list of tables returned + ListTableResource *ListTableResource + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ListTableServicesResponse is the response envelope for operations that return a ListTableServices type. +type ListTableServicesResponse struct { + ListTableServices *ListTableServices + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ManagementPolicyResponse is the response envelope for operations that return a ManagementPolicy type. +type ManagementPolicyResponse struct { + // The Get Storage Account ManagementPolicies operation response. + ManagementPolicy *ManagementPolicy + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectReplicationPoliciesResponse is the response envelope for operations that return a ObjectReplicationPolicies type. +type ObjectReplicationPoliciesResponse struct { + // List storage account object replication policies. + ObjectReplicationPolicies *ObjectReplicationPolicies + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ObjectReplicationPolicyResponse is the response envelope for operations that return a ObjectReplicationPolicy type. +type ObjectReplicationPolicyResponse struct { + // The replication policy between two storage accounts. Multiple rules can be defined in one policy. + ObjectReplicationPolicy *ObjectReplicationPolicy + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationListResultResponse is the response envelope for operations that return a OperationListResult type. +type OperationListResultResponse struct { + // 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. + OperationListResult *OperationListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionListResultResponse is the response envelope for operations that return a PrivateEndpointConnectionListResult type. +type PrivateEndpointConnectionListResultResponse struct { + // List of private endpoint connection associated with the specified storage account + PrivateEndpointConnectionListResult *PrivateEndpointConnectionListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateEndpointConnectionResponse is the response envelope for operations that return a PrivateEndpointConnection type. +type PrivateEndpointConnectionResponse struct { + // The Private Endpoint Connection resource. + PrivateEndpointConnection *PrivateEndpointConnection + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PrivateLinkResourceListResultResponse is the response envelope for operations that return a PrivateLinkResourceListResult type. +type PrivateLinkResourceListResultResponse struct { + // A list of private link resources + PrivateLinkResourceListResult *PrivateLinkResourceListResult + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QueueServicePropertiesResponse is the response envelope for operations that return a QueueServiceProperties type. +type QueueServicePropertiesResponse struct { + // The properties of a storage account’s Queue service. + QueueServiceProperties *QueueServiceProperties + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageAccountListKeysResultResponse is the response envelope for operations that return a StorageAccountListKeysResult type. +type StorageAccountListKeysResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The response from the ListKeys operation. + StorageAccountListKeysResult *StorageAccountListKeysResult +} + +// StorageAccountListResultResponse is the response envelope for operations that return a StorageAccountListResult type. +type StorageAccountListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The response from the List Storage Accounts operation. + StorageAccountListResult *StorageAccountListResult +} + +// StorageAccountPollerResponse is the response envelope for operations that asynchronously return a StorageAccount type. +type StorageAccountPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (StorageAccountResponse, error) + + // Poller contains an initialized poller. + Poller StorageAccountPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// StorageAccountResponse is the response envelope for operations that return a StorageAccount type. +type StorageAccountResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The storage account. + StorageAccount *StorageAccount +} + +// StorageQueueResponse is the response envelope for operations that return a StorageQueue type. +type StorageQueueResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + StorageQueue *StorageQueue +} + +// StorageSKUListResultResponse is the response envelope for operations that return a StorageSKUListResult type. +type StorageSKUListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The response from the List Storage SKUs operation. + StorageSKUListResult *StorageSKUListResult +} + +// TableResponse is the response envelope for operations that return a Table type. +type TableResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // Properties of the table, including Id, resource name, resource type. + Table *Table +} + +// TableServicePropertiesResponse is the response envelope for operations that return a TableServiceProperties type. +type TableServicePropertiesResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The properties of a storage account’s Table service. + TableServiceProperties *TableServiceProperties +} + +// UsageListResultResponse is the response envelope for operations that return a UsageListResult type. +type UsageListResultResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response + + // The response from the List Usages operation. + UsageListResult *UsageListResult +} diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_skus_client.go b/sdk/storage/armstorage/zz_generated_skus_client.go similarity index 94% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_skus_client.go rename to sdk/storage/armstorage/zz_generated_skus_client.go index b7314dfa202a..bd3f37c32118 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_skus_client.go +++ b/sdk/storage/armstorage/zz_generated_skus_client.go @@ -10,10 +10,8 @@ package armstorage import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -32,6 +30,7 @@ func NewSKUsClient(con *armcore.Connection, subscriptionID string) *SKUsClient { } // List - Lists the available SKUs supported by Microsoft.Storage for given subscription. +// If the operation fails it returns a generic error. func (client *SKUsClient) List(ctx context.Context, options *SKUsListOptions) (StorageSKUListResultResponse, error) { req, err := client.listCreateRequest(ctx, options) if err != nil { @@ -60,7 +59,7 @@ func (client *SKUsClient) listCreateRequest(ctx context.Context, options *SKUsLi } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -77,9 +76,9 @@ func (client *SKUsClient) listHandleResponse(resp *azcore.Response) (StorageSKUL // listHandleError handles the List error response. func (client *SKUsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_storageaccounts_client.go b/sdk/storage/armstorage/zz_generated_storageaccounts_client.go similarity index 93% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_storageaccounts_client.go rename to sdk/storage/armstorage/zz_generated_storageaccounts_client.go index c22395bf86be..8ea7ff41b495 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_storageaccounts_client.go +++ b/sdk/storage/armstorage/zz_generated_storageaccounts_client.go @@ -10,10 +10,8 @@ package armstorage import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -33,6 +31,7 @@ func NewStorageAccountsClient(con *armcore.Connection, subscriptionID string) *S } // CheckNameAvailability - Checks that the storage account name is valid and is not already in use. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) CheckNameAvailability(ctx context.Context, accountName StorageAccountCheckNameAvailabilityParameters, options *StorageAccountsCheckNameAvailabilityOptions) (CheckNameAvailabilityResultResponse, error) { req, err := client.checkNameAvailabilityCreateRequest(ctx, accountName, options) if err != nil { @@ -61,7 +60,7 @@ func (client *StorageAccountsClient) checkNameAvailabilityCreateRequest(ctx cont } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(accountName) @@ -78,9 +77,9 @@ func (client *StorageAccountsClient) checkNameAvailabilityHandleResponse(resp *a // checkNameAvailabilityHandleError handles the CheckNameAvailability error response. func (client *StorageAccountsClient) checkNameAvailabilityHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -92,6 +91,7 @@ func (client *StorageAccountsClient) checkNameAvailabilityHandleError(resp *azco // is issued with different properties, the account properties // will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request // will succeed. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) BeginCreate(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountCreateParameters, options *StorageAccountsBeginCreateOptions) (StorageAccountPollerResponse, error) { resp, err := client.create(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -144,6 +144,7 @@ func (client *StorageAccountsClient) ResumeCreate(ctx context.Context, token str // is issued with different properties, the account properties // will be updated. If an account is already created and a subsequent create or update request is issued with the exact same set of properties, the request // will succeed. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) create(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountCreateParameters, options *StorageAccountsBeginCreateOptions) (*azcore.Response, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -180,26 +181,17 @@ func (client *StorageAccountsClient) createCreateRequest(ctx context.Context, re } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) } -// createHandleResponse handles the Create response. -func (client *StorageAccountsClient) createHandleResponse(resp *azcore.Response) (StorageAccountResponse, error) { - var val *StorageAccount - if err := resp.UnmarshalAsJSON(&val); err != nil { - return StorageAccountResponse{}, err - } - return StorageAccountResponse{RawResponse: resp.Response, StorageAccount: val}, nil -} - // createHandleError handles the Create error response. func (client *StorageAccountsClient) createHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -208,6 +200,7 @@ func (client *StorageAccountsClient) createHandleError(resp *azcore.Response) er } // Delete - Deletes a storage account in Microsoft Azure. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -244,16 +237,16 @@ func (client *StorageAccountsClient) deleteCreateRequest(ctx context.Context, re } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() return req, nil } // deleteHandleError handles the Delete error response. func (client *StorageAccountsClient) deleteHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -264,6 +257,7 @@ func (client *StorageAccountsClient) deleteHandleError(resp *azcore.Response) er // BeginFailover - Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's // primary cluster to secondary cluster for RA-GRS accounts. The // secondary cluster will become primary after failover. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) BeginFailover(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsBeginFailoverOptions) (HTTPPollerResponse, error) { resp, err := client.failover(ctx, resourceGroupName, accountName, options) if err != nil { @@ -315,6 +309,7 @@ func (client *StorageAccountsClient) ResumeFailover(ctx context.Context, token s // Failover - Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary // cluster to secondary cluster for RA-GRS accounts. The // secondary cluster will become primary after failover. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) failover(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsBeginFailoverOptions) (*azcore.Response, error) { req, err := client.failoverCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -351,16 +346,16 @@ func (client *StorageAccountsClient) failoverCreateRequest(ctx context.Context, } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() return req, nil } // failoverHandleError handles the Failover error response. func (client *StorageAccountsClient) failoverHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -370,6 +365,7 @@ func (client *StorageAccountsClient) failoverHandleError(resp *azcore.Response) // GetProperties - Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The // ListKeys operation should be used to retrieve storage keys. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) GetProperties(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsGetPropertiesOptions) (StorageAccountResponse, error) { req, err := client.getPropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -406,7 +402,7 @@ func (client *StorageAccountsClient) getPropertiesCreateRequest(ctx context.Cont } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", string(*options.Expand)) } @@ -426,9 +422,9 @@ func (client *StorageAccountsClient) getPropertiesHandleResponse(resp *azcore.Re // getPropertiesHandleError handles the GetProperties error response. func (client *StorageAccountsClient) getPropertiesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -437,6 +433,7 @@ func (client *StorageAccountsClient) getPropertiesHandleError(resp *azcore.Respo } // List - Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) List(options *StorageAccountsListOptions) StorageAccountListResultPager { return &storageAccountListResultPager{ pipeline: client.con.Pipeline(), @@ -465,7 +462,7 @@ func (client *StorageAccountsClient) listCreateRequest(ctx context.Context, opti } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -482,9 +479,9 @@ func (client *StorageAccountsClient) listHandleResponse(resp *azcore.Response) ( // listHandleError handles the List error response. func (client *StorageAccountsClient) listHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -493,6 +490,7 @@ func (client *StorageAccountsClient) listHandleError(resp *azcore.Response) erro } // ListAccountSAS - List SAS credentials of a storage account. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) ListAccountSAS(ctx context.Context, resourceGroupName string, accountName string, parameters AccountSasParameters, options *StorageAccountsListAccountSASOptions) (ListAccountSasResponseResponse, error) { req, err := client.listAccountSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -529,7 +527,7 @@ func (client *StorageAccountsClient) listAccountSASCreateRequest(ctx context.Con } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) @@ -546,9 +544,9 @@ func (client *StorageAccountsClient) listAccountSASHandleResponse(resp *azcore.R // listAccountSASHandleError handles the ListAccountSAS error response. func (client *StorageAccountsClient) listAccountSASHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -558,6 +556,7 @@ func (client *StorageAccountsClient) listAccountSASHandleError(resp *azcore.Resp // ListByResourceGroup - Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys // operation for this. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) ListByResourceGroup(resourceGroupName string, options *StorageAccountsListByResourceGroupOptions) StorageAccountListResultPager { return &storageAccountListResultPager{ pipeline: client.con.Pipeline(), @@ -590,7 +589,7 @@ func (client *StorageAccountsClient) listByResourceGroupCreateRequest(ctx contex } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -607,9 +606,9 @@ func (client *StorageAccountsClient) listByResourceGroupHandleResponse(resp *azc // listByResourceGroupHandleError handles the ListByResourceGroup error response. func (client *StorageAccountsClient) listByResourceGroupHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -618,6 +617,7 @@ func (client *StorageAccountsClient) listByResourceGroupHandleError(resp *azcore } // ListKeys - Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsListKeysOptions) (StorageAccountListKeysResultResponse, error) { req, err := client.listKeysCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -654,7 +654,7 @@ func (client *StorageAccountsClient) listKeysCreateRequest(ctx context.Context, } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", "kerb") } @@ -674,9 +674,9 @@ func (client *StorageAccountsClient) listKeysHandleResponse(resp *azcore.Respons // listKeysHandleError handles the ListKeys error response. func (client *StorageAccountsClient) listKeysHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -685,6 +685,7 @@ func (client *StorageAccountsClient) listKeysHandleError(resp *azcore.Response) } // ListServiceSAS - List service SAS credentials of a specific resource. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) ListServiceSAS(ctx context.Context, resourceGroupName string, accountName string, parameters ServiceSasParameters, options *StorageAccountsListServiceSASOptions) (ListServiceSasResponseResponse, error) { req, err := client.listServiceSASCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -721,7 +722,7 @@ func (client *StorageAccountsClient) listServiceSASCreateRequest(ctx context.Con } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) @@ -738,9 +739,9 @@ func (client *StorageAccountsClient) listServiceSASHandleResponse(resp *azcore.R // listServiceSASHandleError handles the ListServiceSAS error response. func (client *StorageAccountsClient) listServiceSASHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -749,6 +750,7 @@ func (client *StorageAccountsClient) listServiceSASHandleError(resp *azcore.Resp } // RegenerateKey - Regenerates one of the access keys or Kerberos keys for the specified storage account. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) RegenerateKey(ctx context.Context, resourceGroupName string, accountName string, regenerateKey StorageAccountRegenerateKeyParameters, options *StorageAccountsRegenerateKeyOptions) (StorageAccountListKeysResultResponse, error) { req, err := client.regenerateKeyCreateRequest(ctx, resourceGroupName, accountName, regenerateKey, options) if err != nil { @@ -785,7 +787,7 @@ func (client *StorageAccountsClient) regenerateKeyCreateRequest(ctx context.Cont } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(regenerateKey) @@ -802,9 +804,9 @@ func (client *StorageAccountsClient) regenerateKeyHandleResponse(resp *azcore.Re // regenerateKeyHandleError handles the RegenerateKey error response. func (client *StorageAccountsClient) regenerateKeyHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -813,6 +815,7 @@ func (client *StorageAccountsClient) regenerateKeyHandleError(resp *azcore.Respo } // BeginRestoreBlobRanges - Restore blobs in the specified blob ranges +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) BeginRestoreBlobRanges(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *StorageAccountsBeginRestoreBlobRangesOptions) (BlobRestoreStatusPollerResponse, error) { resp, err := client.restoreBlobRanges(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -862,6 +865,7 @@ func (client *StorageAccountsClient) ResumeRestoreBlobRanges(ctx context.Context } // RestoreBlobRanges - Restore blobs in the specified blob ranges +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) restoreBlobRanges(ctx context.Context, resourceGroupName string, accountName string, parameters BlobRestoreParameters, options *StorageAccountsBeginRestoreBlobRangesOptions) (*azcore.Response, error) { req, err := client.restoreBlobRangesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -898,26 +902,17 @@ func (client *StorageAccountsClient) restoreBlobRangesCreateRequest(ctx context. } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) } -// restoreBlobRangesHandleResponse handles the RestoreBlobRanges response. -func (client *StorageAccountsClient) restoreBlobRangesHandleResponse(resp *azcore.Response) (BlobRestoreStatusResponse, error) { - var val *BlobRestoreStatus - if err := resp.UnmarshalAsJSON(&val); err != nil { - return BlobRestoreStatusResponse{}, err - } - return BlobRestoreStatusResponse{RawResponse: resp.Response, BlobRestoreStatus: val}, nil -} - // restoreBlobRangesHandleError handles the RestoreBlobRanges error response. func (client *StorageAccountsClient) restoreBlobRangesHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -926,6 +921,7 @@ func (client *StorageAccountsClient) restoreBlobRangesHandleError(resp *azcore.R } // RevokeUserDelegationKeys - Revoke user delegation keys. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) RevokeUserDelegationKeys(ctx context.Context, resourceGroupName string, accountName string, options *StorageAccountsRevokeUserDelegationKeysOptions) (*http.Response, error) { req, err := client.revokeUserDelegationKeysCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -962,16 +958,16 @@ func (client *StorageAccountsClient) revokeUserDelegationKeysCreateRequest(ctx c } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() return req, nil } // revokeUserDelegationKeysHandleError handles the RevokeUserDelegationKeys error response. func (client *StorageAccountsClient) revokeUserDelegationKeysHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) @@ -986,6 +982,7 @@ func (client *StorageAccountsClient) revokeUserDelegationKeysHandleError(resp *a // set. The update of multiple properties is supported. This call does not change the storage keys for the account. If you want to change the storage account // keys, use the regenerate keys operation. The // location and name of the storage account cannot be changed after creation. +// If the operation fails it returns a generic error. func (client *StorageAccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters StorageAccountUpdateParameters, options *StorageAccountsUpdateOptions) (StorageAccountResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -1022,7 +1019,7 @@ func (client *StorageAccountsClient) updateCreateRequest(ctx context.Context, re } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) @@ -1039,9 +1036,9 @@ func (client *StorageAccountsClient) updateHandleResponse(resp *azcore.Response) // updateHandleError handles the Update error response. func (client *StorageAccountsClient) updateHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response) diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_table_client.go b/sdk/storage/armstorage/zz_generated_table_client.go similarity index 84% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_table_client.go rename to sdk/storage/armstorage/zz_generated_table_client.go index 4d8eae841c0c..83b7026cd305 100644 --- a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_table_client.go +++ b/sdk/storage/armstorage/zz_generated_table_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -30,6 +31,7 @@ func NewTableClient(con *armcore.Connection, subscriptionID string) *TableClient } // Create - Creates a new table with the specified table name, under the specified account. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableClient) Create(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableCreateOptions) (TableResponse, error) { req, err := client.createCreateRequest(ctx, resourceGroupName, accountName, tableName, options) if err != nil { @@ -70,7 +72,7 @@ func (client *TableClient) createCreateRequest(ctx context.Context, resourceGrou } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -87,14 +89,19 @@ func (client *TableClient) createHandleResponse(resp *azcore.Response) (TableRes // createHandleError handles the Create error response. func (client *TableClient) createHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Delete - Deletes the table with the specified table name, under the specified account if it exists. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableClient) Delete(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableDeleteOptions) (*http.Response, error) { req, err := client.deleteCreateRequest(ctx, resourceGroupName, accountName, tableName, options) if err != nil { @@ -135,7 +142,7 @@ func (client *TableClient) deleteCreateRequest(ctx context.Context, resourceGrou } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -143,14 +150,19 @@ func (client *TableClient) deleteCreateRequest(ctx context.Context, resourceGrou // deleteHandleError handles the Delete error response. func (client *TableClient) deleteHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // Get - Gets the table with the specified table name, under the specified account if it exists. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableClient) Get(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableGetOptions) (TableResponse, error) { req, err := client.getCreateRequest(ctx, resourceGroupName, accountName, tableName, options) if err != nil { @@ -191,7 +203,7 @@ func (client *TableClient) getCreateRequest(ctx context.Context, resourceGroupNa } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -208,14 +220,19 @@ func (client *TableClient) getHandleResponse(resp *azcore.Response) (TableRespon // getHandleError handles the Get error response. func (client *TableClient) getHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // List - Gets a list of all the tables under the specified storage account +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableClient) List(resourceGroupName string, accountName string, options *TableListOptions) ListTableResourcePager { return &listTableResourcePager{ pipeline: client.con.Pipeline(), @@ -252,7 +269,7 @@ func (client *TableClient) listCreateRequest(ctx context.Context, resourceGroupN } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -269,14 +286,19 @@ func (client *TableClient) listHandleResponse(resp *azcore.Response) (ListTableR // listHandleError handles the List error response. func (client *TableClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // Update - Creates a new table with the specified table name, under the specified account. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableClient) Update(ctx context.Context, resourceGroupName string, accountName string, tableName string, options *TableUpdateOptions) (TableResponse, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, accountName, tableName, options) if err != nil { @@ -317,7 +339,7 @@ func (client *TableClient) updateCreateRequest(ctx context.Context, resourceGrou } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2019-06-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -334,9 +356,13 @@ func (client *TableClient) updateHandleResponse(resp *azcore.Response) (TableRes // updateHandleError handles the Update error response. func (client *TableClient) updateHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_tableservices_client.go b/sdk/storage/armstorage/zz_generated_tableservices_client.go similarity index 86% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_tableservices_client.go rename to sdk/storage/armstorage/zz_generated_tableservices_client.go index 708c71ca1edb..636199a64966 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_tableservices_client.go +++ b/sdk/storage/armstorage/zz_generated_tableservices_client.go @@ -10,6 +10,7 @@ package armstorage import ( "context" "errors" + "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "net/http" @@ -31,6 +32,7 @@ func NewTableServicesClient(con *armcore.Connection, subscriptionID string) *Tab // GetServiceProperties - Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource // Sharing) rules. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableServicesClient) GetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesGetServicePropertiesOptions) (TableServicePropertiesResponse, error) { req, err := client.getServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -68,7 +70,7 @@ func (client *TableServicesClient) getServicePropertiesCreateRequest(ctx context } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -85,14 +87,19 @@ func (client *TableServicesClient) getServicePropertiesHandleResponse(resp *azco // getServicePropertiesHandleError handles the GetServiceProperties error response. func (client *TableServicesClient) getServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } // List - List all table services for the storage account. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableServicesClient) List(ctx context.Context, resourceGroupName string, accountName string, options *TableServicesListOptions) (ListTableServicesResponse, error) { req, err := client.listCreateRequest(ctx, resourceGroupName, accountName, options) if err != nil { @@ -129,7 +136,7 @@ func (client *TableServicesClient) listCreateRequest(ctx context.Context, resour } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -146,15 +153,20 @@ func (client *TableServicesClient) listHandleResponse(resp *azcore.Response) (Li // listHandleError handles the List error response. func (client *TableServicesClient) listHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) } // SetServiceProperties - Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource // Sharing) rules. +// If the operation fails it returns the *CloudErrorAutoGenerated error type. func (client *TableServicesClient) SetServiceProperties(ctx context.Context, resourceGroupName string, accountName string, parameters TableServiceProperties, options *TableServicesSetServicePropertiesOptions) (TableServicePropertiesResponse, error) { req, err := client.setServicePropertiesCreateRequest(ctx, resourceGroupName, accountName, parameters, options) if err != nil { @@ -192,7 +204,7 @@ func (client *TableServicesClient) setServicePropertiesCreateRequest(ctx context } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, req.MarshalAsJSON(parameters) @@ -209,9 +221,13 @@ func (client *TableServicesClient) setServicePropertiesHandleResponse(resp *azco // setServicePropertiesHandleError handles the SetServiceProperties error response. func (client *TableServicesClient) setServicePropertiesHandleError(resp *azcore.Response) error { - var err CloudError - if err := resp.UnmarshalAsJSON(&err); err != nil { - return azcore.NewResponseError(resp.UnmarshalError(err), resp.Response) + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := CloudErrorAutoGenerated{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) } - return azcore.NewResponseError(&err, resp.Response) + return azcore.NewResponseError(&errType, resp.Response) } diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_time_rfc3339.go b/sdk/storage/armstorage/zz_generated_time_rfc3339.go similarity index 100% rename from sdk/arm/storage/2019-06-01/armstorage/zz_generated_time_rfc3339.go rename to sdk/storage/armstorage/zz_generated_time_rfc3339.go diff --git a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_usages_client.go b/sdk/storage/armstorage/zz_generated_usages_client.go similarity index 95% rename from sdk/arm/storage/2021-01-01/armstorage/zz_generated_usages_client.go rename to sdk/storage/armstorage/zz_generated_usages_client.go index 518644c007ad..ecc47715de13 100644 --- a/sdk/arm/storage/2021-01-01/armstorage/zz_generated_usages_client.go +++ b/sdk/storage/armstorage/zz_generated_usages_client.go @@ -10,10 +10,8 @@ package armstorage import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/armcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "io/ioutil" "net/http" "net/url" "strings" @@ -32,6 +30,7 @@ func NewUsagesClient(con *armcore.Connection, subscriptionID string) *UsagesClie } // ListByLocation - Gets the current usage count and the limit for the resources of the location under the subscription. +// If the operation fails it returns a generic error. func (client *UsagesClient) ListByLocation(ctx context.Context, location string, options *UsagesListByLocationOptions) (UsageListResultResponse, error) { req, err := client.listByLocationCreateRequest(ctx, location, options) if err != nil { @@ -64,7 +63,7 @@ func (client *UsagesClient) listByLocationCreateRequest(ctx context.Context, loc } req.Telemetry(telemetryInfo) reqQP := req.URL.Query() - reqQP.Set("api-version", "2021-01-01") + reqQP.Set("api-version", "2021-04-01") req.URL.RawQuery = reqQP.Encode() req.Header.Set("Accept", "application/json") return req, nil @@ -81,9 +80,9 @@ func (client *UsagesClient) listByLocationHandleResponse(resp *azcore.Response) // listByLocationHandleError handles the ListByLocation error response. func (client *UsagesClient) listByLocationHandleError(resp *azcore.Response) error { - body, err := ioutil.ReadAll(resp.Body) + body, err := resp.Payload() if err != nil { - return fmt.Errorf("%s; failed to read response body: %w", resp.Status, err) + return azcore.NewResponseError(err, resp.Response) } if len(body) == 0 { return azcore.NewResponseError(errors.New(resp.Status), resp.Response)