diff --git a/sdk/arm/storage/2019-06-01/armstorage/CHANGELOG.md b/sdk/arm/storage/2019-06-01/armstorage/CHANGELOG.md new file mode 100644 index 000000000000..0add96e338eb --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/CHANGELOG.md @@ -0,0 +1,3 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/c72af9b8dca625d3f1429a0bd913bad7b3879645 + +Code generator @autorest/go@4.0.0-preview.9 \ 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 new file mode 100644 index 000000000000..ec2b64190011 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/example_blobcontainers_test.go @@ -0,0 +1,87 @@ +// +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 new file mode 100644 index 000000000000..8fcf0e62dde0 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/example_storageaccounts_test.go @@ -0,0 +1,177 @@ +// +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": "golang", + "where": "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/example_usage_test.go b/sdk/arm/storage/2019-06-01/armstorage/example_usage_test.go new file mode 100644 index 000000000000..63ad04d9b8da --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/example_usage_test.go @@ -0,0 +1,30 @@ +// +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/2019-06-01/armstorage/go.mod b/sdk/arm/storage/2019-06-01/armstorage/go.mod new file mode 100644 index 000000000000..123fdfda7be1 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/go.mod @@ -0,0 +1,10 @@ +module github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.5.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.4 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.6.0 + github.com/Azure/azure-sdk-for-go/sdk/to v0.1.2 +) diff --git a/sdk/arm/storage/2019-06-01/armstorage/go.sum b/sdk/arm/storage/2019-06-01/armstorage/go.sum new file mode 100644 index 000000000000..e20ff7288c65 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/go.sum @@ -0,0 +1,29 @@ +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.5.1 h1:VGqJCzGuqWjTvMspLSaWHiP1vUOA0lAdjoPXjhltfQQ= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.5.1/go.mod h1:+sBBoB6bha/qi//hAzfa4dd8EWRKBNYzSJjb9IccpXM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.1/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.4 h1:7MfvHEWKfjZSKQNWERlXpHwCRoceEuQef/fB8CWmnQA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.13.4/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.6.0 h1:ksvSe0GxLR0H4narxWihjuz2a90JsmrUELJM9qulh+0= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.6.0/go.mod h1:BfjVb0eeNKsOveaOBnAgUv6nSq5hwScOz7mCm9lqUx8= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.0 h1:HG1ggl8L3ZkV/Ydanf7lKr5kkhhPGCpWdnr1J6v7cO4= +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/to v0.1.2 h1:TZTVOb/ce7nCmOZYga9+ELtPPVVFG2Px4s/w5OycYS0= +github.com/Azure/azure-sdk-for-go/sdk/to v0.1.2/go.mod h1:UL/d4lvWAzSJUuX+19uKdN0ktyjoOyQhgY+HWNgtIYI= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +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= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobcontainers.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobcontainers.go new file mode 100644 index 000000000000..1ab3c5255a6f --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobcontainers.go @@ -0,0 +1,830 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client BlobContainersClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return LegalHoldResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LegalHoldResponse{}, client.clearLegalHoldHandleError(resp) + } + result, err := client.clearLegalHoldHandleResponse(resp) + if err != nil { + return LegalHoldResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := LegalHoldResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.LegalHold) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return BlobContainerResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return BlobContainerResponse{}, client.createHandleError(resp) + } + result, err := client.createHandleResponse(resp) + if err != nil { + return BlobContainerResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := BlobContainerResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.BlobContainer) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ImmutabilityPolicyResponse{}, client.createOrUpdateImmutabilityPolicyHandleError(resp) + } + result, err := client.createOrUpdateImmutabilityPolicyHandleResponse(resp) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + urlPath = strings.ReplaceAll(urlPath, "{immutabilityPolicyName}", url.PathEscape("default")) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + if options != nil { + return req, req.MarshalAsJSON(options.Parameters) + } + return req, nil +} + +// createOrUpdateImmutabilityPolicyHandleResponse handles the CreateOrUpdateImmutabilityPolicy response. +func (client BlobContainersClient) createOrUpdateImmutabilityPolicyHandleResponse(resp *azcore.Response) (ImmutabilityPolicyResponse, error) { + result := ImmutabilityPolicyResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + err := resp.UnmarshalAsJSON(&result.ImmutabilityPolicy) + return result, err +} + +// 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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.Pipeline().Do(req) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ImmutabilityPolicyResponse{}, client.deleteImmutabilityPolicyHandleError(resp) + } + result, err := client.deleteImmutabilityPolicyHandleResponse(resp) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + urlPath = strings.ReplaceAll(urlPath, "{immutabilityPolicyName}", url.PathEscape("default")) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := ImmutabilityPolicyResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + err := resp.UnmarshalAsJSON(&result.ImmutabilityPolicy) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ImmutabilityPolicyResponse{}, client.extendImmutabilityPolicyHandleError(resp) + } + result, err := client.extendImmutabilityPolicyHandleResponse(resp) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + if options != nil { + return req, req.MarshalAsJSON(options.Parameters) + } + return req, nil +} + +// extendImmutabilityPolicyHandleResponse handles the ExtendImmutabilityPolicy response. +func (client BlobContainersClient) extendImmutabilityPolicyHandleResponse(resp *azcore.Response) (ImmutabilityPolicyResponse, error) { + result := ImmutabilityPolicyResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + err := resp.UnmarshalAsJSON(&result.ImmutabilityPolicy) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return BlobContainerResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return BlobContainerResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return BlobContainerResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client BlobContainersClient) getHandleResponse(resp *azcore.Response) (BlobContainerResponse, error) { + result := BlobContainerResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.BlobContainer) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ImmutabilityPolicyResponse{}, client.getImmutabilityPolicyHandleError(resp) + } + result, err := client.getImmutabilityPolicyHandleResponse(resp) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + urlPath = strings.ReplaceAll(urlPath, "{immutabilityPolicyName}", url.PathEscape("default")) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := ImmutabilityPolicyResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + err := resp.UnmarshalAsJSON(&result.ImmutabilityPolicy) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return LeaseContainerResponseResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LeaseContainerResponseResponse{}, client.leaseHandleError(resp) + } + result, err := client.leaseHandleResponse(resp) + if err != nil { + return LeaseContainerResponseResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + if options != nil { + return req, req.MarshalAsJSON(options.Parameters) + } + return req, nil +} + +// leaseHandleResponse handles the Lease response. +func (client BlobContainersClient) leaseHandleResponse(resp *azcore.Response) (LeaseContainerResponseResponse, error) { + result := LeaseContainerResponseResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.LeaseContainerResponse) + return result, err +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + if options != nil && options.Maxpagesize != nil { + query.Set("$maxpagesize", *options.Maxpagesize) + } + if options != nil && options.Filter != nil { + query.Set("$filter", *options.Filter) + } + if options != nil && options.Include != nil { + query.Set("$include", string(*options.Include)) + } + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client BlobContainersClient) listHandleResponse(resp *azcore.Response) (ListContainerItemsResponse, error) { + result := ListContainerItemsResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ListContainerItems) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ImmutabilityPolicyResponse{}, client.lockImmutabilityPolicyHandleError(resp) + } + result, err := client.lockImmutabilityPolicyHandleResponse(resp) + if err != nil { + return ImmutabilityPolicyResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := ImmutabilityPolicyResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + err := resp.UnmarshalAsJSON(&result.ImmutabilityPolicy) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return LegalHoldResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LegalHoldResponse{}, client.setLegalHoldHandleError(resp) + } + result, err := client.setLegalHoldHandleResponse(resp) + if err != nil { + return LegalHoldResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := LegalHoldResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.LegalHold) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return BlobContainerResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return BlobContainerResponse{}, client.updateHandleError(resp) + } + result, err := client.updateHandleResponse(resp) + if err != nil { + return BlobContainerResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{containerName}", url.PathEscape(containerName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := BlobContainerResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.BlobContainer) + return result, err +} + +// 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/2019-06-01/armstorage/zz_generated_blobservices.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobservices.go new file mode 100644 index 000000000000..cc88c275bd43 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_blobservices.go @@ -0,0 +1,212 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client BlobServicesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return BlobServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return BlobServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) + } + result, err := client.getServicePropertiesHandleResponse(resp) + if err != nil { + return BlobServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getServicePropertiesHandleResponse handles the GetServiceProperties response. +func (client BlobServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (BlobServicePropertiesResponse, error) { + result := BlobServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.BlobServiceProperties) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return BlobServiceItemsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return BlobServiceItemsResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return BlobServiceItemsResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client BlobServicesClient) listHandleResponse(resp *azcore.Response) (BlobServiceItemsResponse, error) { + result := BlobServiceItemsResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.BlobServiceItems) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return BlobServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return BlobServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) + } + result, err := client.setServicePropertiesHandleResponse(resp) + if err != nil { + return BlobServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := BlobServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.BlobServiceProperties) + return result, err +} + +// 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/2019-06-01/armstorage/zz_generated_connection.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_connection.go new file mode 100644 index 000000000000..15f02a134eb9 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_connection.go @@ -0,0 +1,10 @@ +// +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 + +const telemetryInfo = "azsdk-go-armstorage/v0.1.0" diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_encryptionscopes.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_encryptionscopes.go new file mode 100644 index 000000000000..fd0bae26b00f --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_encryptionscopes.go @@ -0,0 +1,257 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client EncryptionScopesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return EncryptionScopeResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return EncryptionScopeResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return EncryptionScopeResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client EncryptionScopesClient) getHandleResponse(resp *azcore.Response) (EncryptionScopeResponse, error) { + result := EncryptionScopeResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.EncryptionScope) + return result, err +} + +// 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 err + } + 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client EncryptionScopesClient) listHandleResponse(resp *azcore.Response) (EncryptionScopeListResultResponse, error) { + result := EncryptionScopeListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.EncryptionScopeListResult) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return EncryptionScopeResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return EncryptionScopeResponse{}, client.patchHandleError(resp) + } + result, err := client.patchHandleResponse(resp) + if err != nil { + return EncryptionScopeResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := EncryptionScopeResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.EncryptionScope) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return EncryptionScopeResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return EncryptionScopeResponse{}, client.putHandleError(resp) + } + result, err := client.putHandleResponse(resp) + if err != nil { + return EncryptionScopeResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := EncryptionScopeResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.EncryptionScope) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_enums.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_enums.go new file mode 100644 index 000000000000..f8baaeb955e8 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_enums.go @@ -0,0 +1,973 @@ +// +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" +) + +func PossibleAccessTierValues() []AccessTier { + return []AccessTier{ + AccessTierHot, + AccessTierCool, + } +} + +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" +) + +func PossibleAccountStatusValues() []AccountStatus { + return []AccountStatus{ + AccountStatusAvailable, + AccountStatusUnavailable, + } +} + +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" +) + +func PossibleBlobRestoreProgressStatusValues() []BlobRestoreProgressStatus { + return []BlobRestoreProgressStatus{ + BlobRestoreProgressStatusComplete, + BlobRestoreProgressStatusFailed, + BlobRestoreProgressStatusInProgress, + } +} + +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" +) + +func PossibleBypassValues() []Bypass { + return []Bypass{ + BypassAzureServices, + BypassLogging, + BypassMetrics, + BypassNone, + } +} + +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" +) + +func PossibleCorsRuleAllowedMethodsItemValues() []CorsRuleAllowedMethodsItem { + return []CorsRuleAllowedMethodsItem{ + CorsRuleAllowedMethodsItemDelete, + CorsRuleAllowedMethodsItemGet, + CorsRuleAllowedMethodsItemHead, + CorsRuleAllowedMethodsItemMerge, + CorsRuleAllowedMethodsItemOptions, + CorsRuleAllowedMethodsItemPost, + CorsRuleAllowedMethodsItemPut, + } +} + +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" +) + +func PossibleDefaultActionValues() []DefaultAction { + return []DefaultAction{ + DefaultActionAllow, + DefaultActionDeny, + } +} + +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" +) + +func PossibleDirectoryServiceOptionsValues() []DirectoryServiceOptions { + return []DirectoryServiceOptions{ + DirectoryServiceOptionsAadds, + DirectoryServiceOptionsAd, + DirectoryServiceOptionsNone, + } +} + +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" +) + +func PossibleEnabledProtocolsValues() []EnabledProtocols { + return []EnabledProtocols{ + EnabledProtocolsNfs, + EnabledProtocolsSmb, + } +} + +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" +) + +func PossibleEncryptionScopeSourceValues() []EncryptionScopeSource { + return []EncryptionScopeSource{ + EncryptionScopeSourceMicrosoftKeyVault, + EncryptionScopeSourceMicrosoftStorage, + } +} + +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" +) + +func PossibleEncryptionScopeStateValues() []EncryptionScopeState { + return []EncryptionScopeState{ + EncryptionScopeStateDisabled, + EncryptionScopeStateEnabled, + } +} + +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" +) + +func PossibleGeoReplicationStatusValues() []GeoReplicationStatus { + return []GeoReplicationStatus{ + GeoReplicationStatusBootstrap, + GeoReplicationStatusLive, + GeoReplicationStatusUnavailable, + } +} + +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" +) + +func PossibleHTTPProtocolValues() []HTTPProtocol { + return []HTTPProtocol{ + HTTPProtocolHTTPsHttp, + HTTPProtocolHTTPs, + } +} + +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" +) + +func PossibleImmutabilityPolicyStateValues() []ImmutabilityPolicyState { + return []ImmutabilityPolicyState{ + ImmutabilityPolicyStateLocked, + ImmutabilityPolicyStateUnlocked, + } +} + +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" +) + +func PossibleImmutabilityPolicyUpdateTypeValues() []ImmutabilityPolicyUpdateType { + return []ImmutabilityPolicyUpdateType{ + ImmutabilityPolicyUpdateTypeExtend, + ImmutabilityPolicyUpdateTypeLock, + ImmutabilityPolicyUpdateTypePut, + } +} + +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" +) + +func PossibleKeyPermissionValues() []KeyPermission { + return []KeyPermission{ + KeyPermissionRead, + KeyPermissionFull, + } +} + +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" +) + +func PossibleKeySourceValues() []KeySource { + return []KeySource{ + KeySourceMicrosoftKeyvault, + KeySourceMicrosoftStorage, + } +} + +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" +) + +func PossibleKeyTypeValues() []KeyType { + return []KeyType{ + KeyTypeAccount, + KeyTypeService, + } +} + +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" +) + +func PossibleKindValues() []Kind { + return []Kind{ + KindBlobStorage, + KindBlockBlobStorage, + KindFileStorage, + KindStorage, + KindStorageV2, + } +} + +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" +) + +func PossibleLargeFileSharesStateValues() []LargeFileSharesState { + return []LargeFileSharesState{ + LargeFileSharesStateDisabled, + LargeFileSharesStateEnabled, + } +} + +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" +) + +func PossibleLeaseContainerRequestActionValues() []LeaseContainerRequestAction { + return []LeaseContainerRequestAction{ + LeaseContainerRequestActionAcquire, + LeaseContainerRequestActionBreak, + LeaseContainerRequestActionChange, + LeaseContainerRequestActionRelease, + LeaseContainerRequestActionRenew, + } +} + +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" +) + +func PossibleLeaseDurationValues() []LeaseDuration { + return []LeaseDuration{ + LeaseDurationFixed, + LeaseDurationInfinite, + } +} + +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" +) + +func PossibleLeaseStateValues() []LeaseState { + return []LeaseState{ + LeaseStateAvailable, + LeaseStateBreaking, + LeaseStateBroken, + LeaseStateExpired, + LeaseStateLeased, + } +} + +func (c LeaseState) ToPtr() *LeaseState { + return &c +} + +// LeaseStatus - The lease status of the container. +type LeaseStatus string + +const ( + LeaseStatusLocked LeaseStatus = "Locked" + LeaseStatusUnlocked LeaseStatus = "Unlocked" +) + +func PossibleLeaseStatusValues() []LeaseStatus { + return []LeaseStatus{ + LeaseStatusLocked, + LeaseStatusUnlocked, + } +} + +func (c LeaseStatus) ToPtr() *LeaseStatus { + return &c +} + +type ListContainersInclude string + +const ( + ListContainersIncludeDeleted ListContainersInclude = "deleted" +) + +func PossibleListContainersIncludeValues() []ListContainersInclude { + return []ListContainersInclude{ + ListContainersIncludeDeleted, + } +} + +func (c ListContainersInclude) ToPtr() *ListContainersInclude { + return &c +} + +type ManagementPolicyName string + +const ( + ManagementPolicyNameDefault ManagementPolicyName = "default" +) + +func PossibleManagementPolicyNameValues() []ManagementPolicyName { + return []ManagementPolicyName{ + ManagementPolicyNameDefault, + } +} + +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" +) + +func PossibleMinimumTLSVersionValues() []MinimumTLSVersion { + return []MinimumTLSVersion{ + MinimumTLSVersionTLS10, + MinimumTLSVersionTLS11, + MinimumTLSVersionTLS12, + } +} + +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" +) + +func PossiblePermissionsValues() []Permissions { + return []Permissions{ + PermissionsA, + PermissionsC, + PermissionsD, + PermissionsL, + PermissionsP, + PermissionsR, + PermissionsU, + PermissionsW, + } +} + +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" +) + +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{ + PrivateEndpointConnectionProvisioningStateCreating, + PrivateEndpointConnectionProvisioningStateDeleting, + PrivateEndpointConnectionProvisioningStateFailed, + PrivateEndpointConnectionProvisioningStateSucceeded, + } +} + +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" +) + +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{ + PrivateEndpointServiceConnectionStatusApproved, + PrivateEndpointServiceConnectionStatusPending, + PrivateEndpointServiceConnectionStatusRejected, + } +} + +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" +) + +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateCreating, + ProvisioningStateResolvingDNS, + ProvisioningStateSucceeded, + } +} + +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" +) + +func PossiblePublicAccessValues() []PublicAccess { + return []PublicAccess{ + PublicAccessContainer, + PublicAccessBlob, + PublicAccessNone, + } +} + +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" +) + +func PossibleReasonValues() []Reason { + return []Reason{ + ReasonAccountNameInvalid, + ReasonAlreadyExists, + } +} + +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" +) + +func PossibleReasonCodeValues() []ReasonCode { + return []ReasonCode{ + ReasonCodeNotAvailableForSubscription, + ReasonCodeQuotaID, + } +} + +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" +) + +func PossibleRootSquashTypeValues() []RootSquashType { + return []RootSquashType{ + RootSquashTypeAllSquash, + RootSquashTypeNoRootSquash, + RootSquashTypeRootSquash, + } +} + +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" +) + +func PossibleRoutingChoiceValues() []RoutingChoice { + return []RoutingChoice{ + RoutingChoiceInternetRouting, + RoutingChoiceMicrosoftRouting, + } +} + +func (c RoutingChoice) ToPtr() *RoutingChoice { + return &c +} + +// RuleType - The valid value is Lifecycle +type RuleType string + +const ( + RuleTypeLifecycle RuleType = "Lifecycle" +) + +func PossibleRuleTypeValues() []RuleType { + return []RuleType{ + RuleTypeLifecycle, + } +} + +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" +) + +func PossibleSKUNameValues() []SKUName { + return []SKUName{ + SKUNamePremiumLrs, + SKUNamePremiumZrs, + SKUNameStandardGrs, + SKUNameStandardGzrs, + SKUNameStandardLrs, + SKUNameStandardRagrs, + SKUNameStandardRagzrs, + SKUNameStandardZrs, + } +} + +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" +) + +func PossibleSKUTierValues() []SKUTier { + return []SKUTier{ + SKUTierStandard, + SKUTierPremium, + } +} + +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" +) + +func PossibleServicesValues() []Services { + return []Services{ + ServicesB, + ServicesF, + ServicesQ, + ServicesT, + } +} + +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" +) + +func PossibleShareAccessTierValues() []ShareAccessTier { + return []ShareAccessTier{ + ShareAccessTierCool, + ShareAccessTierHot, + ShareAccessTierPremium, + ShareAccessTierTransactionOptimized, + } +} + +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" +) + +func PossibleSignedResourceValues() []SignedResource { + return []SignedResource{ + SignedResourceB, + SignedResourceC, + SignedResourceF, + SignedResourceS, + } +} + +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" +) + +func PossibleSignedResourceTypesValues() []SignedResourceTypes { + return []SignedResourceTypes{ + SignedResourceTypesC, + SignedResourceTypesO, + SignedResourceTypesS, + } +} + +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" +) + +func PossibleStateValues() []State { + return []State{ + StateProvisioning, + StateDeprovisioning, + StateSucceeded, + StateFailed, + StateNetworkSourceDeleted, + } +} + +func (c State) ToPtr() *State { + return &c +} + +type StorageAccountExpand string + +const ( + StorageAccountExpandGeoReplicationStats StorageAccountExpand = "geoReplicationStats" + StorageAccountExpandBlobRestoreStatus StorageAccountExpand = "blobRestoreStatus" +) + +func PossibleStorageAccountExpandValues() []StorageAccountExpand { + return []StorageAccountExpand{ + StorageAccountExpandGeoReplicationStats, + StorageAccountExpandBlobRestoreStatus, + } +} + +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" +) + +func PossibleUsageUnitValues() []UsageUnit { + return []UsageUnit{ + UsageUnitCount, + UsageUnitBytes, + UsageUnitSeconds, + UsageUnitPercent, + UsageUnitCountsPerSecond, + UsageUnitBytesPerSecond, + } +} + +func (c UsageUnit) ToPtr() *UsageUnit { + return &c +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileservices.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileservices.go new file mode 100644 index 000000000000..934aeb87a0a3 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileservices.go @@ -0,0 +1,198 @@ +// +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" + "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} +} + +// Pipeline returns the pipeline associated with this client. +func (client FileServicesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return FileServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return FileServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) + } + result, err := client.getServicePropertiesHandleResponse(resp) + if err != nil { + return FileServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getServicePropertiesHandleResponse handles the GetServiceProperties response. +func (client FileServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (FileServicePropertiesResponse, error) { + result := FileServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.FileServiceProperties) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return FileServiceItemsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return FileServiceItemsResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return FileServiceItemsResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client FileServicesClient) listHandleResponse(resp *azcore.Response) (FileServiceItemsResponse, error) { + result := FileServiceItemsResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.FileServiceItems) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return FileServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return FileServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) + } + result, err := client.setServicePropertiesHandleResponse(resp) + if err != nil { + return FileServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := FileServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.FileServiceProperties) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileshares.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileshares.go new file mode 100644 index 000000000000..3a247f4482e4 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_fileshares.go @@ -0,0 +1,352 @@ +// +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" + "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} +} + +// Pipeline returns the pipeline associated with this client. +func (client FileSharesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return FileShareResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return FileShareResponse{}, client.createHandleError(resp) + } + result, err := client.createHandleResponse(resp) + if err != nil { + return FileShareResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := FileShareResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.FileShare) + return result, err +} + +// 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 err + } + 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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 err + } + 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.Pipeline().Do(req) + if err != nil { + return FileShareResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return FileShareResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return FileShareResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + if options != nil && options.Expand != nil { + query.Set("$expand", "stats") + } + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client FileSharesClient) getHandleResponse(resp *azcore.Response) (FileShareResponse, error) { + result := FileShareResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.FileShare) + return result, err +} + +// 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 err + } + 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + if options != nil && options.Maxpagesize != nil { + query.Set("$maxpagesize", *options.Maxpagesize) + } + if options != nil && options.Filter != nil { + query.Set("$filter", *options.Filter) + } + if options != nil && options.Expand != nil { + query.Set("$expand", "deleted") + } + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client FileSharesClient) listHandleResponse(resp *azcore.Response) (FileShareItemsResponse, error) { + result := FileShareItemsResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.FileShareItems) + return result, err +} + +// 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 err + } + 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.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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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 err + } + 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.Pipeline().Do(req) + if err != nil { + return FileShareResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return FileShareResponse{}, client.updateHandleError(resp) + } + result, err := client.updateHandleResponse(resp) + if err != nil { + return FileShareResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{shareName}", url.PathEscape(shareName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := FileShareResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.FileShare) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_managementpolicies.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_managementpolicies.go new file mode 100644 index 000000000000..5d400f507e36 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_managementpolicies.go @@ -0,0 +1,199 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client ManagementPoliciesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return ManagementPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ManagementPolicyResponse{}, client.createOrUpdateHandleError(resp) + } + result, err := client.createOrUpdateHandleResponse(resp) + if err != nil { + return ManagementPolicyResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := ManagementPolicyResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ManagementPolicy) + return result, err +} + +// 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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.Pipeline().Do(req) + if err != nil { + return ManagementPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ManagementPolicyResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return ManagementPolicyResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client ManagementPoliciesClient) getHandleResponse(resp *azcore.Response) (ManagementPolicyResponse, error) { + result := ManagementPolicyResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ManagementPolicy) + return result, err +} + +// 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 new file mode 100644 index 000000000000..a3594fb39d0b --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_models.go @@ -0,0 +1,3810 @@ +// +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" + "net/http" + "time" +) + +// 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{}) + if a.IPAddressOrRange != nil { + objectMap["signedIp"] = a.IPAddressOrRange + } + if a.KeyToSign != nil { + objectMap["keyToSign"] = a.KeyToSign + } + if a.Permissions != nil { + objectMap["signedPermission"] = a.Permissions + } + if a.Protocols != nil { + objectMap["signedProtocol"] = a.Protocols + } + if a.ResourceTypes != nil { + objectMap["signedResourceTypes"] = a.ResourceTypes + } + if a.Services != nil { + objectMap["signedServices"] = a.Services + } + if a.SharedAccessExpiryTime != nil { + objectMap["signedExpiry"] = (*timeRFC3339)(a.SharedAccessExpiryTime) + } + if a.SharedAccessStartTime != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &a.IPAddressOrRange) + } + delete(rawMsg, key) + case "keyToSign": + if val != nil { + err = json.Unmarshal(*val, &a.KeyToSign) + } + delete(rawMsg, key) + case "signedPermission": + if val != nil { + err = json.Unmarshal(*val, &a.Permissions) + } + delete(rawMsg, key) + case "signedProtocol": + if val != nil { + err = json.Unmarshal(*val, &a.Protocols) + } + delete(rawMsg, key) + case "signedResourceTypes": + if val != nil { + err = json.Unmarshal(*val, &a.ResourceTypes) + } + delete(rawMsg, key) + case "signedServices": + if val != nil { + err = json.Unmarshal(*val, &a.Services) + } + delete(rawMsg, key) + case "signedExpiry": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + a.SharedAccessExpiryTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "signedStart": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + a.SharedAccessStartTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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{}) + if b.BlobRanges != nil { + objectMap["blobRanges"] = b.BlobRanges + } + if b.TimeToRestore != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &b.BlobRanges) + } + delete(rawMsg, key) + case "timeToRestore": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + b.TimeToRestore = (*time.Time)(&aux) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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 +} + +// 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 += fmt.Sprintf("InnerError: %v\n", *e.InnerError) + } + if msg == "" { + msg = "missing error info" + } + return msg +} + +// 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"` +} + +// 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{}) + if c.DefaultEncryptionScope != nil { + objectMap["defaultEncryptionScope"] = c.DefaultEncryptionScope + } + if c.Deleted != nil { + objectMap["deleted"] = c.Deleted + } + if c.DeletedTime != nil { + objectMap["deletedTime"] = (*timeRFC3339)(c.DeletedTime) + } + if c.DenyEncryptionScopeOverride != nil { + objectMap["denyEncryptionScopeOverride"] = c.DenyEncryptionScopeOverride + } + if c.HasImmutabilityPolicy != nil { + objectMap["hasImmutabilityPolicy"] = c.HasImmutabilityPolicy + } + if c.HasLegalHold != nil { + objectMap["hasLegalHold"] = c.HasLegalHold + } + if c.ImmutabilityPolicy != nil { + objectMap["immutabilityPolicy"] = c.ImmutabilityPolicy + } + if c.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = (*timeRFC3339)(c.LastModifiedTime) + } + if c.LeaseDuration != nil { + objectMap["leaseDuration"] = c.LeaseDuration + } + if c.LeaseState != nil { + objectMap["leaseState"] = c.LeaseState + } + if c.LeaseStatus != nil { + objectMap["leaseStatus"] = c.LeaseStatus + } + if c.LegalHold != nil { + objectMap["legalHold"] = c.LegalHold + } + if c.Metadata != nil { + objectMap["metadata"] = c.Metadata + } + if c.PublicAccess != nil { + objectMap["publicAccess"] = c.PublicAccess + } + if c.RemainingRetentionDays != nil { + objectMap["remainingRetentionDays"] = c.RemainingRetentionDays + } + if c.Version != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &c.DefaultEncryptionScope) + } + delete(rawMsg, key) + case "deleted": + if val != nil { + err = json.Unmarshal(*val, &c.Deleted) + } + delete(rawMsg, key) + case "deletedTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + c.DeletedTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "denyEncryptionScopeOverride": + if val != nil { + err = json.Unmarshal(*val, &c.DenyEncryptionScopeOverride) + } + delete(rawMsg, key) + case "hasImmutabilityPolicy": + if val != nil { + err = json.Unmarshal(*val, &c.HasImmutabilityPolicy) + } + delete(rawMsg, key) + case "hasLegalHold": + if val != nil { + err = json.Unmarshal(*val, &c.HasLegalHold) + } + delete(rawMsg, key) + case "immutabilityPolicy": + if val != nil { + err = json.Unmarshal(*val, &c.ImmutabilityPolicy) + } + delete(rawMsg, key) + case "lastModifiedTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + c.LastModifiedTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "leaseDuration": + if val != nil { + err = json.Unmarshal(*val, &c.LeaseDuration) + } + delete(rawMsg, key) + case "leaseState": + if val != nil { + err = json.Unmarshal(*val, &c.LeaseState) + } + delete(rawMsg, key) + case "leaseStatus": + if val != nil { + err = json.Unmarshal(*val, &c.LeaseStatus) + } + delete(rawMsg, key) + case "legalHold": + if val != nil { + err = json.Unmarshal(*val, &c.LegalHold) + } + delete(rawMsg, key) + case "metadata": + if val != nil { + err = json.Unmarshal(*val, &c.Metadata) + } + delete(rawMsg, key) + case "publicAccess": + if val != nil { + err = json.Unmarshal(*val, &c.PublicAccess) + } + delete(rawMsg, key) + case "remainingRetentionDays": + if val != nil { + err = json.Unmarshal(*val, &c.RemainingRetentionDays) + } + delete(rawMsg, key) + case "version": + if val != nil { + err = json.Unmarshal(*val, &c.Version) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// The Encryption Scope resource. +type EncryptionScope struct { + Resource + // Properties of the encryption scope. + EncryptionScopeProperties *EncryptionScopeProperties `json:"properties,omitempty"` +} + +// 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"` +} + +// 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 +} + +// 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{}) + if e.CreationTime != nil { + objectMap["creationTime"] = (*timeRFC3339)(e.CreationTime) + } + if e.KeyVaultProperties != nil { + objectMap["keyVaultProperties"] = e.KeyVaultProperties + } + if e.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = (*timeRFC3339)(e.LastModifiedTime) + } + if e.Source != nil { + objectMap["source"] = e.Source + } + if e.State != nil { + 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": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + e.CreationTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "keyVaultProperties": + if val != nil { + err = json.Unmarshal(*val, &e.KeyVaultProperties) + } + delete(rawMsg, key) + case "lastModifiedTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + e.LastModifiedTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "source": + if val != nil { + err = json.Unmarshal(*val, &e.Source) + } + delete(rawMsg, key) + case "state": + if val != nil { + err = json.Unmarshal(*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 +} + +// 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{}) + if e.Enabled != nil { + objectMap["enabled"] = e.Enabled + } + if e.KeyType != nil { + objectMap["keyType"] = e.KeyType + } + if e.LastEnabledTime != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &e.Enabled) + } + delete(rawMsg, key) + case "keyType": + if val != nil { + err = json.Unmarshal(*val, &e.KeyType) + } + delete(rawMsg, key) + case "lastEnabledTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + e.LastEnabledTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// The file share properties be listed out. +type FileShareItem struct { + AzureEntityResource + // The file share properties be listed out. + Properties *FileShareProperties `json:"properties,omitempty"` +} + +// 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 +} + +// 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{}) + if f.AccessTier != nil { + objectMap["accessTier"] = f.AccessTier + } + if f.AccessTierChangeTime != nil { + objectMap["accessTierChangeTime"] = (*timeRFC3339)(f.AccessTierChangeTime) + } + if f.AccessTierStatus != nil { + objectMap["accessTierStatus"] = f.AccessTierStatus + } + if f.Deleted != nil { + objectMap["deleted"] = f.Deleted + } + if f.DeletedTime != nil { + objectMap["deletedTime"] = (*timeRFC3339)(f.DeletedTime) + } + if f.EnabledProtocols != nil { + objectMap["enabledProtocols"] = f.EnabledProtocols + } + if f.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = (*timeRFC3339)(f.LastModifiedTime) + } + if f.Metadata != nil { + objectMap["metadata"] = f.Metadata + } + if f.RemainingRetentionDays != nil { + objectMap["remainingRetentionDays"] = f.RemainingRetentionDays + } + if f.RootSquash != nil { + objectMap["rootSquash"] = f.RootSquash + } + if f.ShareQuota != nil { + objectMap["shareQuota"] = f.ShareQuota + } + if f.ShareUsageBytes != nil { + objectMap["shareUsageBytes"] = f.ShareUsageBytes + } + if f.Version != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &f.AccessTier) + } + delete(rawMsg, key) + case "accessTierChangeTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + f.AccessTierChangeTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "accessTierStatus": + if val != nil { + err = json.Unmarshal(*val, &f.AccessTierStatus) + } + delete(rawMsg, key) + case "deleted": + if val != nil { + err = json.Unmarshal(*val, &f.Deleted) + } + delete(rawMsg, key) + case "deletedTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + f.DeletedTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "enabledProtocols": + if val != nil { + err = json.Unmarshal(*val, &f.EnabledProtocols) + } + delete(rawMsg, key) + case "lastModifiedTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + f.LastModifiedTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "metadata": + if val != nil { + err = json.Unmarshal(*val, &f.Metadata) + } + delete(rawMsg, key) + case "remainingRetentionDays": + if val != nil { + err = json.Unmarshal(*val, &f.RemainingRetentionDays) + } + delete(rawMsg, key) + case "rootSquash": + if val != nil { + err = json.Unmarshal(*val, &f.RootSquash) + } + delete(rawMsg, key) + case "shareQuota": + if val != nil { + err = json.Unmarshal(*val, &f.ShareQuota) + } + delete(rawMsg, key) + case "shareUsageBytes": + if val != nil { + err = json.Unmarshal(*val, &f.ShareUsageBytes) + } + delete(rawMsg, key) + case "version": + if val != nil { + err = json.Unmarshal(*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 +} + +// 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{}) + if g.CanFailover != nil { + objectMap["canFailover"] = g.CanFailover + } + if g.LastSyncTime != nil { + objectMap["lastSyncTime"] = (*timeRFC3339)(g.LastSyncTime) + } + if g.Status != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &g.CanFailover) + } + delete(rawMsg, key) + case "lastSyncTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + g.LastSyncTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "status": + if val != nil { + err = json.Unmarshal(*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 +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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{}) + if k.CurrentVersionedKeyIDentifier != nil { + objectMap["currentVersionedKeyIdentifier"] = k.CurrentVersionedKeyIDentifier + } + if k.KeyName != nil { + objectMap["keyname"] = k.KeyName + } + if k.KeyVaultURI != nil { + objectMap["keyvaulturi"] = k.KeyVaultURI + } + if k.KeyVersion != nil { + objectMap["keyversion"] = k.KeyVersion + } + if k.LastKeyRotationTimestamp != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &k.CurrentVersionedKeyIDentifier) + } + delete(rawMsg, key) + case "keyname": + if val != nil { + err = json.Unmarshal(*val, &k.KeyName) + } + delete(rawMsg, key) + case "keyvaulturi": + if val != nil { + err = json.Unmarshal(*val, &k.KeyVaultURI) + } + delete(rawMsg, key) + case "keyversion": + if val != nil { + err = json.Unmarshal(*val, &k.KeyVersion) + } + delete(rawMsg, key) + case "lastKeyRotationTimestamp": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + k.LastKeyRotationTimestamp = (*time.Time)(&aux) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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 +} + +// 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 +} + +// The blob container properties be listed out. +type ListContainerItem struct { + AzureEntityResource + // The blob container properties be listed out. + Properties *ContainerProperties `json:"properties,omitempty"` +} + +// 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"` +} + +// 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 +} + +// 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 +} + +// 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 +} + +// The Get Storage Account ManagementPolicies operation response. +type ManagementPolicy struct { + Resource + // Returns the Storage Account Data Policies Rules. + Properties *ManagementPolicyProperties `json:"properties,omitempty"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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{}) + if m.LastModifiedTime != nil { + objectMap["lastModifiedTime"] = (*timeRFC3339)(m.LastModifiedTime) + } + if m.Policy != nil { + 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": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + m.LastModifiedTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "policy": + if val != nil { + err = json.Unmarshal(*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 +} + +// 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"` +} + +// 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"` +} + +// Management policy action for snapshot. +type ManagementPolicySnapShot struct { + // The function to delete the blob snapshot + Delete *DateAfterCreation `json:"delete,omitempty"` +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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"` +} + +// 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{}) + if o.DestinationAccount != nil { + objectMap["destinationAccount"] = o.DestinationAccount + } + if o.EnabledTime != nil { + objectMap["enabledTime"] = (*timeRFC3339)(o.EnabledTime) + } + if o.PolicyID != nil { + objectMap["policyId"] = o.PolicyID + } + if o.Rules != nil { + objectMap["rules"] = o.Rules + } + if o.SourceAccount != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &o.DestinationAccount) + } + delete(rawMsg, key) + case "enabledTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + o.EnabledTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "policyId": + if val != nil { + err = json.Unmarshal(*val, &o.PolicyID) + } + delete(rawMsg, key) + case "rules": + if val != nil { + err = json.Unmarshal(*val, &o.Rules) + } + delete(rawMsg, key) + case "sourceAccount": + if val != nil { + err = json.Unmarshal(*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 +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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 +} + +// The Private Endpoint resource. +type PrivateEndpoint struct { + // READ-ONLY; The ARM identifier for Private Endpoint + ID *string `json:"id,omitempty" azure:"ro"` +} + +// The Private Endpoint Connection resource. +type PrivateEndpointConnection struct { + Resource + // Resource properties. + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` +} + +// 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 +} + +// 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 +} + +// A private link resource +type PrivateLinkResource struct { + Resource + // Resource properties. + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` +} + +// 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 +} + +// 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 +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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{}) + if r.Days != nil { + objectMap["days"] = r.Days + } + if r.Enabled != nil { + objectMap["enabled"] = r.Enabled + } + if r.LastEnabledTime != nil { + objectMap["lastEnabledTime"] = (*timeRFC3339)(r.LastEnabledTime) + } + if r.MinRestoreTime != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &r.Days) + } + delete(rawMsg, key) + case "enabled": + if val != nil { + err = json.Unmarshal(*val, &r.Enabled) + } + delete(rawMsg, key) + case "lastEnabledTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + r.LastEnabledTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "minRestoreTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + r.MinRestoreTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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"` + + // 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"` + + // 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 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{}) + if s.CacheControl != nil { + objectMap["rscc"] = s.CacheControl + } + if s.CanonicalizedResource != nil { + objectMap["canonicalizedResource"] = s.CanonicalizedResource + } + if s.ContentDisposition != nil { + objectMap["rscd"] = s.ContentDisposition + } + if s.ContentEncoding != nil { + objectMap["rsce"] = s.ContentEncoding + } + if s.ContentLanguage != nil { + objectMap["rscl"] = s.ContentLanguage + } + if s.ContentType != nil { + objectMap["rsct"] = s.ContentType + } + if s.IDentifier != nil { + objectMap["signedIdentifier"] = s.IDentifier + } + if s.IPAddressOrRange != nil { + objectMap["signedIp"] = s.IPAddressOrRange + } + if s.KeyToSign != nil { + objectMap["keyToSign"] = s.KeyToSign + } + if s.PartitionKeyEnd != nil { + objectMap["endPk"] = s.PartitionKeyEnd + } + if s.PartitionKeyStart != nil { + objectMap["startPk"] = s.PartitionKeyStart + } + if s.Permissions != nil { + objectMap["signedPermission"] = s.Permissions + } + if s.Protocols != nil { + objectMap["signedProtocol"] = s.Protocols + } + if s.Resource != nil { + objectMap["signedResource"] = s.Resource + } + if s.RowKeyEnd != nil { + objectMap["endRk"] = s.RowKeyEnd + } + if s.RowKeyStart != nil { + objectMap["startRk"] = s.RowKeyStart + } + if s.SharedAccessExpiryTime != nil { + objectMap["signedExpiry"] = (*timeRFC3339)(s.SharedAccessExpiryTime) + } + if s.SharedAccessStartTime != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &s.CacheControl) + } + delete(rawMsg, key) + case "canonicalizedResource": + if val != nil { + err = json.Unmarshal(*val, &s.CanonicalizedResource) + } + delete(rawMsg, key) + case "rscd": + if val != nil { + err = json.Unmarshal(*val, &s.ContentDisposition) + } + delete(rawMsg, key) + case "rsce": + if val != nil { + err = json.Unmarshal(*val, &s.ContentEncoding) + } + delete(rawMsg, key) + case "rscl": + if val != nil { + err = json.Unmarshal(*val, &s.ContentLanguage) + } + delete(rawMsg, key) + case "rsct": + if val != nil { + err = json.Unmarshal(*val, &s.ContentType) + } + delete(rawMsg, key) + case "signedIdentifier": + if val != nil { + err = json.Unmarshal(*val, &s.IDentifier) + } + delete(rawMsg, key) + case "signedIp": + if val != nil { + err = json.Unmarshal(*val, &s.IPAddressOrRange) + } + delete(rawMsg, key) + case "keyToSign": + if val != nil { + err = json.Unmarshal(*val, &s.KeyToSign) + } + delete(rawMsg, key) + case "endPk": + if val != nil { + err = json.Unmarshal(*val, &s.PartitionKeyEnd) + } + delete(rawMsg, key) + case "startPk": + if val != nil { + err = json.Unmarshal(*val, &s.PartitionKeyStart) + } + delete(rawMsg, key) + case "signedPermission": + if val != nil { + err = json.Unmarshal(*val, &s.Permissions) + } + delete(rawMsg, key) + case "signedProtocol": + if val != nil { + err = json.Unmarshal(*val, &s.Protocols) + } + delete(rawMsg, key) + case "signedResource": + if val != nil { + err = json.Unmarshal(*val, &s.Resource) + } + delete(rawMsg, key) + case "endRk": + if val != nil { + err = json.Unmarshal(*val, &s.RowKeyEnd) + } + delete(rawMsg, key) + case "startRk": + if val != nil { + err = json.Unmarshal(*val, &s.RowKeyStart) + } + delete(rawMsg, key) + case "signedExpiry": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + s.SharedAccessExpiryTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "signedStart": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + s.SharedAccessStartTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// One property of operation, include metric specifications. +type ServiceSpecification struct { + // Metric specifications of operation. + MetricSpecifications *[]MetricSpecification `json:"metricSpecifications,omitempty"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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 +} + +// 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 +} + +// 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{}) + if s.AccessTier != nil { + objectMap["accessTier"] = s.AccessTier + } + if s.AllowBlobPublicAccess != nil { + objectMap["allowBlobPublicAccess"] = s.AllowBlobPublicAccess + } + if s.AzureFilesIDentityBasedAuthentication != nil { + objectMap["azureFilesIdentityBasedAuthentication"] = s.AzureFilesIDentityBasedAuthentication + } + if s.BlobRestoreStatus != nil { + objectMap["blobRestoreStatus"] = s.BlobRestoreStatus + } + if s.CreationTime != nil { + objectMap["creationTime"] = (*timeRFC3339)(s.CreationTime) + } + if s.CustomDomain != nil { + objectMap["customDomain"] = s.CustomDomain + } + if s.EnableHTTPsTrafficOnly != nil { + objectMap["supportsHttpsTrafficOnly"] = s.EnableHTTPsTrafficOnly + } + if s.Encryption != nil { + objectMap["encryption"] = s.Encryption + } + if s.FailoverInProgress != nil { + objectMap["failoverInProgress"] = s.FailoverInProgress + } + if s.GeoReplicationStats != nil { + objectMap["geoReplicationStats"] = s.GeoReplicationStats + } + if s.IsHnsEnabled != nil { + objectMap["isHnsEnabled"] = s.IsHnsEnabled + } + if s.LargeFileSharesState != nil { + objectMap["largeFileSharesState"] = s.LargeFileSharesState + } + if s.LastGeoFailoverTime != nil { + objectMap["lastGeoFailoverTime"] = (*timeRFC3339)(s.LastGeoFailoverTime) + } + if s.MinimumTLSVersion != nil { + objectMap["minimumTlsVersion"] = s.MinimumTLSVersion + } + if s.NetworkRuleSet != nil { + objectMap["networkAcls"] = s.NetworkRuleSet + } + if s.PrimaryEndpoints != nil { + objectMap["primaryEndpoints"] = s.PrimaryEndpoints + } + if s.PrimaryLocation != nil { + objectMap["primaryLocation"] = s.PrimaryLocation + } + if s.PrivateEndpointConnections != nil { + objectMap["privateEndpointConnections"] = s.PrivateEndpointConnections + } + if s.ProvisioningState != nil { + objectMap["provisioningState"] = s.ProvisioningState + } + if s.RoutingPreference != nil { + objectMap["routingPreference"] = s.RoutingPreference + } + if s.SecondaryEndpoints != nil { + objectMap["secondaryEndpoints"] = s.SecondaryEndpoints + } + if s.SecondaryLocation != nil { + objectMap["secondaryLocation"] = s.SecondaryLocation + } + if s.StatusOfPrimary != nil { + objectMap["statusOfPrimary"] = s.StatusOfPrimary + } + if s.StatusOfSecondary != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &s.AccessTier) + } + delete(rawMsg, key) + case "allowBlobPublicAccess": + if val != nil { + err = json.Unmarshal(*val, &s.AllowBlobPublicAccess) + } + delete(rawMsg, key) + case "azureFilesIdentityBasedAuthentication": + if val != nil { + err = json.Unmarshal(*val, &s.AzureFilesIDentityBasedAuthentication) + } + delete(rawMsg, key) + case "blobRestoreStatus": + if val != nil { + err = json.Unmarshal(*val, &s.BlobRestoreStatus) + } + delete(rawMsg, key) + case "creationTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + s.CreationTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "customDomain": + if val != nil { + err = json.Unmarshal(*val, &s.CustomDomain) + } + delete(rawMsg, key) + case "supportsHttpsTrafficOnly": + if val != nil { + err = json.Unmarshal(*val, &s.EnableHTTPsTrafficOnly) + } + delete(rawMsg, key) + case "encryption": + if val != nil { + err = json.Unmarshal(*val, &s.Encryption) + } + delete(rawMsg, key) + case "failoverInProgress": + if val != nil { + err = json.Unmarshal(*val, &s.FailoverInProgress) + } + delete(rawMsg, key) + case "geoReplicationStats": + if val != nil { + err = json.Unmarshal(*val, &s.GeoReplicationStats) + } + delete(rawMsg, key) + case "isHnsEnabled": + if val != nil { + err = json.Unmarshal(*val, &s.IsHnsEnabled) + } + delete(rawMsg, key) + case "largeFileSharesState": + if val != nil { + err = json.Unmarshal(*val, &s.LargeFileSharesState) + } + delete(rawMsg, key) + case "lastGeoFailoverTime": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + s.LastGeoFailoverTime = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "minimumTlsVersion": + if val != nil { + err = json.Unmarshal(*val, &s.MinimumTLSVersion) + } + delete(rawMsg, key) + case "networkAcls": + if val != nil { + err = json.Unmarshal(*val, &s.NetworkRuleSet) + } + delete(rawMsg, key) + case "primaryEndpoints": + if val != nil { + err = json.Unmarshal(*val, &s.PrimaryEndpoints) + } + delete(rawMsg, key) + case "primaryLocation": + if val != nil { + err = json.Unmarshal(*val, &s.PrimaryLocation) + } + delete(rawMsg, key) + case "privateEndpointConnections": + if val != nil { + err = json.Unmarshal(*val, &s.PrivateEndpointConnections) + } + delete(rawMsg, key) + case "provisioningState": + if val != nil { + err = json.Unmarshal(*val, &s.ProvisioningState) + } + delete(rawMsg, key) + case "routingPreference": + if val != nil { + err = json.Unmarshal(*val, &s.RoutingPreference) + } + delete(rawMsg, key) + case "secondaryEndpoints": + if val != nil { + err = json.Unmarshal(*val, &s.SecondaryEndpoints) + } + delete(rawMsg, key) + case "secondaryLocation": + if val != nil { + err = json.Unmarshal(*val, &s.SecondaryLocation) + } + delete(rawMsg, key) + case "statusOfPrimary": + if val != nil { + err = json.Unmarshal(*val, &s.StatusOfPrimary) + } + delete(rawMsg, key) + case "statusOfSecondary": + if val != nil { + err = json.Unmarshal(*val, &s.StatusOfSecondary) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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"` +} + +// 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 +} + +// 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 +} + +// 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 +} + +// 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"` +} + +// 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 +} + +// 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"` +} + +// 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{}) + if t.ObjectIDentifier != nil { + objectMap["objectIdentifier"] = t.ObjectIDentifier + } + if t.Tag != nil { + objectMap["tag"] = t.Tag + } + if t.TenantID != nil { + objectMap["tenantId"] = t.TenantID + } + if t.Timestamp != nil { + objectMap["timestamp"] = (*timeRFC3339)(t.Timestamp) + } + if t.Upn != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &t.ObjectIDentifier) + } + delete(rawMsg, key) + case "tag": + if val != nil { + err = json.Unmarshal(*val, &t.Tag) + } + delete(rawMsg, key) + case "tenantId": + if val != nil { + err = json.Unmarshal(*val, &t.TenantID) + } + delete(rawMsg, key) + case "timestamp": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + t.Timestamp = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "upn": + if val != nil { + err = json.Unmarshal(*val, &t.Upn) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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{}) + if u.ImmutabilityPeriodSinceCreationInDays != nil { + objectMap["immutabilityPeriodSinceCreationInDays"] = u.ImmutabilityPeriodSinceCreationInDays + } + if u.ObjectIDentifier != nil { + objectMap["objectIdentifier"] = u.ObjectIDentifier + } + if u.TenantID != nil { + objectMap["tenantId"] = u.TenantID + } + if u.Timestamp != nil { + objectMap["timestamp"] = (*timeRFC3339)(u.Timestamp) + } + if u.Update != nil { + objectMap["update"] = u.Update + } + if u.Upn != nil { + 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": + if val != nil { + err = json.Unmarshal(*val, &u.ImmutabilityPeriodSinceCreationInDays) + } + delete(rawMsg, key) + case "objectIdentifier": + if val != nil { + err = json.Unmarshal(*val, &u.ObjectIDentifier) + } + delete(rawMsg, key) + case "tenantId": + if val != nil { + err = json.Unmarshal(*val, &u.TenantID) + } + delete(rawMsg, key) + case "timestamp": + if val != nil { + var aux timeRFC3339 + err = json.Unmarshal(*val, &aux) + u.Timestamp = (*time.Time)(&aux) + } + delete(rawMsg, key) + case "update": + if val != nil { + err = json.Unmarshal(*val, &u.Update) + } + delete(rawMsg, key) + case "upn": + if val != nil { + err = json.Unmarshal(*val, &u.Upn) + } + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// 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"` +} + +// 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 +} + +// 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 +} + +// 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"` +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_objectreplicationpolicies.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_objectreplicationpolicies.go new file mode 100644 index 000000000000..8e53d3b6d735 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_objectreplicationpolicies.go @@ -0,0 +1,242 @@ +// +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" + "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} +} + +// Pipeline returns the pipeline associated with this client. +func (client ObjectReplicationPoliciesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return ObjectReplicationPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ObjectReplicationPolicyResponse{}, client.createOrUpdateHandleError(resp) + } + result, err := client.createOrUpdateHandleResponse(resp) + if err != nil { + return ObjectReplicationPolicyResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := ObjectReplicationPolicyResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ObjectReplicationPolicy) + return result, err +} + +// 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 err + } + 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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 err + } + 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.Pipeline().Do(req) + if err != nil { + return ObjectReplicationPolicyResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ObjectReplicationPolicyResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return ObjectReplicationPolicyResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client ObjectReplicationPoliciesClient) getHandleResponse(resp *azcore.Response) (ObjectReplicationPolicyResponse, error) { + result := ObjectReplicationPolicyResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ObjectReplicationPolicy) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return ObjectReplicationPoliciesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ObjectReplicationPoliciesResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return ObjectReplicationPoliciesResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client ObjectReplicationPoliciesClient) listHandleResponse(resp *azcore.Response) (ObjectReplicationPoliciesResponse, error) { + result := ObjectReplicationPoliciesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ObjectReplicationPolicies) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_operations.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_operations.go new file mode 100644 index 000000000000..942127d69727 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_operations.go @@ -0,0 +1,88 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client OperationsClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return OperationListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OperationListResultResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return OperationListResultResponse{}, err + } + return result, nil +} + +// 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client OperationsClient) listHandleResponse(resp *azcore.Response) (OperationListResultResponse, error) { + result := OperationListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.OperationListResult) + return result, err +} + +// 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/2019-06-01/armstorage/zz_generated_pagers.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pagers.go new file mode 100644 index 000000000000..5592121648b9 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pagers.go @@ -0,0 +1,500 @@ +// +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 { + // NextPage returns true if the pager advanced to the next page. + // Returns false if there are no more pages or an error occurred. + NextPage(context.Context) bool + + // Page returns the current EncryptionScopeListResultResponse. + PageResponse() EncryptionScopeListResultResponse + + // Err returns the last error encountered while paging. + Err() error +} + +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 { + // NextPage returns true if the pager advanced to the next page. + // Returns false if there are no more pages or an error occurred. + NextPage(context.Context) bool + + // Page returns the current FileShareItemsResponse. + PageResponse() FileShareItemsResponse + + // Err returns the last error encountered while paging. + Err() error +} + +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 { + // NextPage returns true if the pager advanced to the next page. + // Returns false if there are no more pages or an error occurred. + NextPage(context.Context) bool + + // Page returns the current ListContainerItemsResponse. + PageResponse() ListContainerItemsResponse + + // Err returns the last error encountered while paging. + Err() error +} + +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 { + // NextPage returns true if the pager advanced to the next page. + // Returns false if there are no more pages or an error occurred. + NextPage(context.Context) bool + + // Page returns the current ListQueueResourceResponse. + PageResponse() ListQueueResourceResponse + + // Err returns the last error encountered while paging. + Err() error +} + +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 { + // NextPage returns true if the pager advanced to the next page. + // Returns false if there are no more pages or an error occurred. + NextPage(context.Context) bool + + // Page returns the current ListTableResourceResponse. + PageResponse() ListTableResourceResponse + + // Err returns the last error encountered while paging. + Err() error +} + +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 { + // NextPage returns true if the pager advanced to the next page. + // Returns false if there are no more pages or an error occurred. + NextPage(context.Context) bool + + // Page returns the current StorageAccountListResultResponse. + PageResponse() StorageAccountListResultResponse + + // Err returns the last error encountered while paging. + Err() error +} + +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_pollers.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pollers.go new file mode 100644 index 000000000000..720203eb3fca --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_pollers.go @@ -0,0 +1,154 @@ +// +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 completes +type BlobRestoreStatusPoller interface { + Done() bool + Poll(ctx context.Context) (*http.Response, error) + FinalResponse(ctx context.Context) (BlobRestoreStatusResponse, error) + ResumeToken() (string, error) +} + +type blobRestoreStatusPoller struct { + // the client for making the request + pipeline azcore.Pipeline + pt armcore.Poller +} + +// Done returns true if there was an error or polling has reached a terminal state +func (p *blobRestoreStatusPoller) Done() bool { + return p.pt.Done() +} + +// Poll will send poll the service endpoint and return an http.Response or error received from the service +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 +} + +// ResumeToken generates the string token that can be used with the ResumeBlobRestoreStatusPoller method +// on the client to create a new poller from the data held in the current poller type +func (p *blobRestoreStatusPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *blobRestoreStatusPoller) pollUntilDone(ctx context.Context, frequency time.Duration) (BlobRestoreStatusResponse, error) { + respType := BlobRestoreStatusResponse{BlobRestoreStatus: &BlobRestoreStatus{}} + resp, err := p.pt.PollUntilDone(ctx, frequency, p.pipeline, respType.BlobRestoreStatus) + if err != nil { + return BlobRestoreStatusResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// HTTPPoller provides polling facilities until the operation completes +type HTTPPoller interface { + Done() bool + Poll(ctx context.Context) (*http.Response, error) + FinalResponse(ctx context.Context) (*http.Response, error) + ResumeToken() (string, error) +} + +type httpPoller struct { + // the client for making the request + pipeline azcore.Pipeline + pt armcore.Poller +} + +// Done returns true if there was an error or polling has reached a terminal state +func (p *httpPoller) Done() bool { + return p.pt.Done() +} + +// Poll will send poll the service endpoint and return an http.Response or error received from the service +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) +} + +// ResumeToken generates the string token that can be used with the ResumeHTTPPoller method +// on the client to create a new poller from the data held in the current poller type +func (p *httpPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *httpPoller) pollUntilDone(ctx context.Context, frequency time.Duration) (*http.Response, error) { + return p.pt.PollUntilDone(ctx, frequency, p.pipeline, nil) +} + +// StorageAccountPoller provides polling facilities until the operation completes +type StorageAccountPoller interface { + Done() bool + Poll(ctx context.Context) (*http.Response, error) + FinalResponse(ctx context.Context) (StorageAccountResponse, error) + ResumeToken() (string, error) +} + +type storageAccountPoller struct { + // the client for making the request + pipeline azcore.Pipeline + pt armcore.Poller +} + +// Done returns true if there was an error or polling has reached a terminal state +func (p *storageAccountPoller) Done() bool { + return p.pt.Done() +} + +// Poll will send poll the service endpoint and return an http.Response or error received from the service +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 +} + +// ResumeToken generates the string token that can be used with the ResumeStorageAccountPoller method +// on the client to create a new poller from the data held in the current poller type +func (p *storageAccountPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *storageAccountPoller) pollUntilDone(ctx context.Context, frequency time.Duration) (StorageAccountResponse, error) { + respType := StorageAccountResponse{StorageAccount: &StorageAccount{}} + resp, err := p.pt.PollUntilDone(ctx, frequency, p.pipeline, respType.StorageAccount) + if err != nil { + return StorageAccountResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privateendpointconnections.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privateendpointconnections.go new file mode 100644 index 000000000000..11f5a1ebdaec --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privateendpointconnections.go @@ -0,0 +1,248 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client PrivateEndpointConnectionsClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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 err + } + 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.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateEndpointConnectionResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client PrivateEndpointConnectionsClient) getHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionResponse, error) { + result := PrivateEndpointConnectionResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.PrivateEndpointConnection) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateEndpointConnectionListResultResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return PrivateEndpointConnectionListResultResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client PrivateEndpointConnectionsClient) listHandleResponse(resp *azcore.Response) (PrivateEndpointConnectionListResultResponse, error) { + result := PrivateEndpointConnectionListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.PrivateEndpointConnectionListResult) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateEndpointConnectionResponse{}, client.putHandleError(resp) + } + result, err := client.putHandleResponse(resp) + if err != nil { + return PrivateEndpointConnectionResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := PrivateEndpointConnectionResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.PrivateEndpointConnection) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privatelinkresources.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privatelinkresources.go new file mode 100644 index 000000000000..1ea4db5c4055 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_privatelinkresources.go @@ -0,0 +1,94 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client PrivateLinkResourcesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return PrivateLinkResourceListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PrivateLinkResourceListResultResponse{}, client.listByStorageAccountHandleError(resp) + } + result, err := client.listByStorageAccountHandleResponse(resp) + if err != nil { + return PrivateLinkResourceListResultResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByStorageAccountHandleResponse handles the ListByStorageAccount response. +func (client PrivateLinkResourcesClient) listByStorageAccountHandleResponse(resp *azcore.Response) (PrivateLinkResourceListResultResponse, error) { + result := PrivateLinkResourceListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.PrivateLinkResourceListResult) + return result, err +} + +// 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_queue.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queue.go new file mode 100644 index 000000000000..83f9ebfe8748 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queue.go @@ -0,0 +1,299 @@ +// +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" + "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} +} + +// Pipeline returns the pipeline associated with this client. +func (client QueueClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return StorageQueueResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageQueueResponse{}, client.createHandleError(resp) + } + result, err := client.createHandleResponse(resp) + if err != nil { + return StorageQueueResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := StorageQueueResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageQueue) + return result, err +} + +// 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 err + } + 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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 err + } + 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.Pipeline().Do(req) + if err != nil { + return StorageQueueResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageQueueResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return StorageQueueResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client QueueClient) getHandleResponse(resp *azcore.Response) (StorageQueueResponse, error) { + result := StorageQueueResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageQueue) + return result, err +} + +// 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 err + } + 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + if options != nil && options.Maxpagesize != nil { + query.Set("$maxpagesize", *options.Maxpagesize) + } + if options != nil && options.Filter != nil { + query.Set("$filter", *options.Filter) + } + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client QueueClient) listHandleResponse(resp *azcore.Response) (ListQueueResourceResponse, error) { + result := ListQueueResourceResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ListQueueResource) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return StorageQueueResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageQueueResponse{}, client.updateHandleError(resp) + } + result, err := client.updateHandleResponse(resp) + if err != nil { + return StorageQueueResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := StorageQueueResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageQueue) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queueservices.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queueservices.go new file mode 100644 index 000000000000..400a3367f3e2 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_queueservices.go @@ -0,0 +1,200 @@ +// +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" + "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} +} + +// Pipeline returns the pipeline associated with this client. +func (client QueueServicesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return QueueServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return QueueServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) + } + result, err := client.getServicePropertiesHandleResponse(resp) + if err != nil { + return QueueServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getServicePropertiesHandleResponse handles the GetServiceProperties response. +func (client QueueServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (QueueServicePropertiesResponse, error) { + result := QueueServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.QueueServiceProperties) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return ListQueueServicesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ListQueueServicesResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return ListQueueServicesResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client QueueServicesClient) listHandleResponse(resp *azcore.Response) (ListQueueServicesResponse, error) { + result := ListQueueServicesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ListQueueServices) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return QueueServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return QueueServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) + } + result, err := client.setServicePropertiesHandleResponse(resp) + if err != nil { + return QueueServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := QueueServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.QueueServiceProperties) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_skus.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_skus.go new file mode 100644 index 000000000000..7f86d89401dc --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_skus.go @@ -0,0 +1,92 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client SKUsClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return StorageSKUListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageSKUListResultResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return StorageSKUListResultResponse{}, err + } + return result, nil +} + +// listCreateRequest creates the List request. +func (client SKUsClient) listCreateRequest(ctx context.Context, options *SKUsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus" + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client SKUsClient) listHandleResponse(resp *azcore.Response) (StorageSKUListResultResponse, error) { + result := StorageSKUListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageSKUListResult) + return result, err +} + +// 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.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_storageaccounts.go new file mode 100644 index 000000000000..7f033eb278a9 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_storageaccounts.go @@ -0,0 +1,918 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client StorageAccountsClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return CheckNameAvailabilityResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return CheckNameAvailabilityResultResponse{}, client.checkNameAvailabilityHandleError(resp) + } + result, err := client.checkNameAvailabilityHandleResponse(resp) + if err != nil { + return CheckNameAvailabilityResultResponse{}, err + } + return result, nil +} + +// 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" + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := CheckNameAvailabilityResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.CheckNameAvailabilityResult) + return result, err +} + +// 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{ + pt: pt, + pipeline: client.con.Pipeline(), + } + 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(token string) (StorageAccountPoller, error) { + pt, err := armcore.NewPollerFromResumeToken("StorageAccountsClient.Create", token, client.createHandleError) + if err != nil { + return nil, err + } + return &storageAccountPoller{ + pipeline: client.con.Pipeline(), + pt: pt, + }, 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := StorageAccountResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageAccount) + return result, err +} + +// 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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{ + pt: pt, + pipeline: client.con.Pipeline(), + } + 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(token string) (HTTPPoller, error) { + pt, err := armcore.NewPollerFromResumeToken("StorageAccountsClient.Failover", token, client.failoverHandleError) + if err != nil { + return nil, err + } + return &httpPoller{ + pipeline: client.con.Pipeline(), + pt: pt, + }, 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.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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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.Pipeline().Do(req) + if err != nil { + return StorageAccountResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageAccountResponse{}, client.getPropertiesHandleError(resp) + } + result, err := client.getPropertiesHandleResponse(resp) + if err != nil { + return StorageAccountResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + if options != nil && options.Expand != nil { + query.Set("$expand", string(*options.Expand)) + } + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getPropertiesHandleResponse handles the GetProperties response. +func (client StorageAccountsClient) getPropertiesHandleResponse(resp *azcore.Response) (StorageAccountResponse, error) { + result := StorageAccountResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageAccount) + return result, err +} + +// 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" + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client StorageAccountsClient) listHandleResponse(resp *azcore.Response) (StorageAccountListResultResponse, error) { + result := StorageAccountListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageAccountListResult) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return ListAccountSasResponseResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ListAccountSasResponseResponse{}, client.listAccountSasHandleError(resp) + } + result, err := client.listAccountSasHandleResponse(resp) + if err != nil { + return ListAccountSasResponseResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := ListAccountSasResponseResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ListAccountSasResponse) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return StorageAccountListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageAccountListResultResponse{}, client.listByResourceGroupHandleError(resp) + } + result, err := client.listByResourceGroupHandleResponse(resp) + if err != nil { + return StorageAccountListResultResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client StorageAccountsClient) listByResourceGroupHandleResponse(resp *azcore.Response) (StorageAccountListResultResponse, error) { + result := StorageAccountListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageAccountListResult) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return StorageAccountListKeysResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageAccountListKeysResultResponse{}, client.listKeysHandleError(resp) + } + result, err := client.listKeysHandleResponse(resp) + if err != nil { + return StorageAccountListKeysResultResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + if options != nil && options.Expand != nil { + query.Set("$expand", "kerb") + } + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client StorageAccountsClient) listKeysHandleResponse(resp *azcore.Response) (StorageAccountListKeysResultResponse, error) { + result := StorageAccountListKeysResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageAccountListKeysResult) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return ListServiceSasResponseResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ListServiceSasResponseResponse{}, client.listServiceSasHandleError(resp) + } + result, err := client.listServiceSasHandleResponse(resp) + if err != nil { + return ListServiceSasResponseResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := ListServiceSasResponseResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ListServiceSasResponse) + return result, err +} + +// 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.Pipeline().Do(req) + if err != nil { + return StorageAccountListKeysResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageAccountListKeysResultResponse{}, client.regenerateKeyHandleError(resp) + } + result, err := client.regenerateKeyHandleResponse(resp) + if err != nil { + return StorageAccountListKeysResultResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := StorageAccountListKeysResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageAccountListKeysResult) + return result, err +} + +// 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{ + pt: pt, + pipeline: client.con.Pipeline(), + } + 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(token string) (BlobRestoreStatusPoller, error) { + pt, err := armcore.NewPollerFromResumeToken("StorageAccountsClient.RestoreBlobRanges", token, client.restoreBlobRangesHandleError) + if err != nil { + return nil, err + } + return &blobRestoreStatusPoller{ + pipeline: client.con.Pipeline(), + pt: pt, + }, 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.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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := BlobRestoreStatusResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.BlobRestoreStatus) + return result, err +} + +// 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.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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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.Pipeline().Do(req) + if err != nil { + return StorageAccountResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return StorageAccountResponse{}, client.updateHandleError(resp) + } + result, err := client.updateHandleResponse(resp) + if err != nil { + return StorageAccountResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := StorageAccountResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.StorageAccount) + return result, err +} + +// 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_table.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_table.go new file mode 100644 index 000000000000..51dc09683dff --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_table.go @@ -0,0 +1,293 @@ +// +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" + "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} +} + +// Pipeline returns the pipeline associated with this client. +func (client TableClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return TableResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TableResponse{}, client.createHandleError(resp) + } + result, err := client.createHandleResponse(resp) + if err != nil { + return TableResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createHandleResponse handles the Create response. +func (client TableClient) createHandleResponse(resp *azcore.Response) (TableResponse, error) { + result := TableResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.Table) + return result, err +} + +// 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 err + } + 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.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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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 err + } + 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.Pipeline().Do(req) + if err != nil { + return TableResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TableResponse{}, client.getHandleError(resp) + } + result, err := client.getHandleResponse(resp) + if err != nil { + return TableResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client TableClient) getHandleResponse(resp *azcore.Response) (TableResponse, error) { + result := TableResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.Table) + return result, err +} + +// 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 err + } + 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client TableClient) listHandleResponse(resp *azcore.Response) (ListTableResourceResponse, error) { + result := ListTableResourceResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ListTableResource) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return TableResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TableResponse{}, client.updateHandleError(resp) + } + result, err := client.updateHandleResponse(resp) + if err != nil { + return TableResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client TableClient) updateHandleResponse(resp *azcore.Response) (TableResponse, error) { + result := TableResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.Table) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_tableservices.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_tableservices.go new file mode 100644 index 000000000000..6882560d516e --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_tableservices.go @@ -0,0 +1,200 @@ +// +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" + "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} +} + +// Pipeline returns the pipeline associated with this client. +func (client TableServicesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return TableServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TableServicePropertiesResponse{}, client.getServicePropertiesHandleError(resp) + } + result, err := client.getServicePropertiesHandleResponse(resp) + if err != nil { + return TableServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getServicePropertiesHandleResponse handles the GetServiceProperties response. +func (client TableServicesClient) getServicePropertiesHandleResponse(resp *azcore.Response) (TableServicePropertiesResponse, error) { + result := TableServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.TableServiceProperties) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return ListTableServicesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ListTableServicesResponse{}, client.listHandleError(resp) + } + result, err := client.listHandleResponse(resp) + if err != nil { + return ListTableServicesResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client TableServicesClient) listHandleResponse(resp *azcore.Response) (ListTableServicesResponse, error) { + result := ListTableServicesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.ListTableServices) + return result, err +} + +// 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 err + } + 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.Pipeline().Do(req) + if err != nil { + return TableServicePropertiesResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TableServicePropertiesResponse{}, client.setServicePropertiesHandleError(resp) + } + result, err := client.setServicePropertiesHandleResponse(resp) + if err != nil { + return TableServicePropertiesResponse{}, err + } + return result, nil +} + +// 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}" + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + urlPath = strings.ReplaceAll(urlPath, "{accountName}", url.PathEscape(accountName)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.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) { + result := TableServicePropertiesResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.TableServiceProperties) + return result, err +} + +// 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 err + } + return azcore.NewResponseError(&err, resp.Response) +} diff --git a/sdk/arm/storage/2019-06-01/armstorage/zz_generated_time_rfc3339.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..500d7e8c60b4 --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_time_rfc3339.go @@ -0,0 +1,57 @@ +// +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/2019-06-01/armstorage/zz_generated_usages.go b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_usages.go new file mode 100644 index 000000000000..9815424c95bd --- /dev/null +++ b/sdk/arm/storage/2019-06-01/armstorage/zz_generated_usages.go @@ -0,0 +1,93 @@ +// +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} +} + +// Pipeline returns the pipeline associated with this client. +func (client UsagesClient) Pipeline() azcore.Pipeline { + return client.con.Pipeline() +} + +// 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.Pipeline().Do(req) + if err != nil { + return UsageListResultResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return UsageListResultResponse{}, client.listByLocationHandleError(resp) + } + result, err := client.listByLocationHandleResponse(resp) + if err != nil { + return UsageListResultResponse{}, err + } + return result, nil +} + +// 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" + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + 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) + query := req.URL.Query() + query.Set("api-version", "2019-06-01") + req.URL.RawQuery = query.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByLocationHandleResponse handles the ListByLocation response. +func (client UsagesClient) listByLocationHandleResponse(resp *azcore.Response) (UsageListResultResponse, error) { + result := UsageListResultResponse{RawResponse: resp.Response} + err := resp.UnmarshalAsJSON(&result.UsageListResult) + return result, err +} + +// 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/README.md b/sdk/arm/storage/README.md new file mode 100644 index 000000000000..036a21e2b3cb --- /dev/null +++ b/sdk/arm/storage/README.md @@ -0,0 +1,76 @@ +# Azure Storage Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage) + +The `armstorage` module provides operations for working with Azure storage resources. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/master/sdk/arm/storage/2019-06-01/armstorage) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 or above + +## Install the module + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Storage module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/arm/storage/2019-06-01/armstorage +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Storage. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Connecting to Azure Storage + +Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := armcore.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore). + +## Clients + +Azure Storage modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your `armcore.Connection`. + +```go +client := armstorage.NewBlobContainersClient(con, "") +``` + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Storage` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file