From 36788eec036587b4d3d9b85426c9ef6bf00208fb Mon Sep 17 00:00:00 2001 From: Sourav Gupta Date: Fri, 16 Sep 2022 19:24:48 +0530 Subject: [PATCH 1/4] Adding code for container soft delete --- sdk/storage/azblob/container/client.go | 12 ++++++ sdk/storage/azblob/container/responses.go | 3 ++ sdk/storage/azblob/service/client.go | 8 ++++ sdk/storage/azblob/service/client_test.go | 45 +++++++++++++++++++++ sdk/storage/azblob/service/examples_test.go | 34 ++++++++++++++++ sdk/storage/azblob/service/responses.go | 3 ++ 6 files changed, 105 insertions(+) diff --git a/sdk/storage/azblob/container/client.go b/sdk/storage/azblob/container/client.go index ea579e62af5a..b995acee8a4c 100644 --- a/sdk/storage/azblob/container/client.go +++ b/sdk/storage/azblob/container/client.go @@ -160,6 +160,18 @@ func (c *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResp return resp, err } +// Restore operation restore the contents and properties of a soft deleted container to a specified container. +// For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/restore-container. +func (c *Client) Restore(ctx context.Context, deletedContainerName string, deletedContainerVersion string) (RestoreResponse, error) { + opts := &generated.ContainerClientRestoreOptions{ + DeletedContainerName: &deletedContainerName, + DeletedContainerVersion: &deletedContainerVersion, + } + resp, err := c.generated().Restore(ctx, opts) + + return resp, err +} + // GetProperties returns the container's properties. // For more information, see https://docs.microsoft.com/rest/api/storageservices/get-container-metadata. func (c *Client) GetProperties(ctx context.Context, o *GetPropertiesOptions) (GetPropertiesResponse, error) { diff --git a/sdk/storage/azblob/container/responses.go b/sdk/storage/azblob/container/responses.go index 261ee643ca99..9d8672b135be 100644 --- a/sdk/storage/azblob/container/responses.go +++ b/sdk/storage/azblob/container/responses.go @@ -16,6 +16,9 @@ type CreateResponse = generated.ContainerClientCreateResponse // DeleteResponse contains the response from method Client.Delete. type DeleteResponse = generated.ContainerClientDeleteResponse +// RestoreResponse contains the response from method Client.Restore. +type RestoreResponse = generated.ContainerClientRestoreResponse + // GetPropertiesResponse contains the response from method Client.GetProperties. type GetPropertiesResponse = generated.ContainerClientGetPropertiesResponse diff --git a/sdk/storage/azblob/service/client.go b/sdk/storage/azblob/service/client.go index 892140193783..c4b922f8ac68 100644 --- a/sdk/storage/azblob/service/client.go +++ b/sdk/storage/azblob/service/client.go @@ -123,6 +123,14 @@ func (s *Client) DeleteContainer(ctx context.Context, containerName string, opti return containerDeleteResp, err } +// RestoreContainer restores soft-deleted container +// Operation will only be successful if used within the specified number of days set in the delete retention policy +func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, deletedContainerVersion string) (RestoreContainerResponse, error) { + containerClient := s.NewContainerClient(deletedContainerName) + containerRestoreResp, err := containerClient.Restore(ctx, deletedContainerName, deletedContainerVersion) + return containerRestoreResp, err +} + // GetAccountInfo provides account level information func (s *Client) GetAccountInfo(ctx context.Context, o *GetAccountInfoOptions) (GetAccountInfoResponse, error) { getAccountInfoOptions := o.format() diff --git a/sdk/storage/azblob/service/client_test.go b/sdk/storage/azblob/service/client_test.go index a3c8573bc9e3..7ac2f9e3822e 100644 --- a/sdk/storage/azblob/service/client_test.go +++ b/sdk/storage/azblob/service/client_test.go @@ -599,3 +599,48 @@ func (s *ServiceUnrecordedTestsSuite) TestSASContainerClient2() { //_, err = containerClient2.Create(ctx, nil) //_require.Nil(err) } + +// make sure that container soft delete is enabled +// TODO: convert this test to recorded +func (s *ServiceUnrecordedTestsSuite) TestContainerRestore() { + _require := require.New(s.T()) + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + testName := s.T().Name() + containerName := testcommon.GenerateContainerName(testName) + + _, err = svcClient.CreateContainer(context.Background(), containerName, nil) + _require.Nil(err) + + _, err = svcClient.DeleteContainer(context.Background(), containerName, nil) + _require.Nil(err) + + prefix := testcommon.ContainerPrefix + listOptions := service.ListContainersOptions{Prefix: &prefix, Include: service.ListContainersInclude{Metadata: true, Deleted: true}} + pager := svcClient.NewListContainersPager(&listOptions) + + contRestored := false + for pager.More() { + resp, err := pager.NextPage(context.Background()) + _require.Nil(err) + for _, cont := range resp.ContainerItems { + _require.NotNil(cont.Name) + + if *cont.Deleted && *cont.Name == containerName { + contRestored = true + _, err = svcClient.RestoreContainer(context.Background(), containerName, *cont.Version) + _require.Nil(err) + break + } + } + if contRestored { + break + } + } + + _require.Equal(contRestored, true) + + _, err = svcClient.DeleteContainer(context.Background(), containerName, nil) + _require.Nil(err) +} diff --git a/sdk/storage/azblob/service/examples_test.go b/sdk/storage/azblob/service/examples_test.go index 57b15b8ed3ef..5b302eed8d3f 100644 --- a/sdk/storage/azblob/service/examples_test.go +++ b/sdk/storage/azblob/service/examples_test.go @@ -129,6 +129,40 @@ func Example_service_Client_DeleteContainer() { handleError(err) } +func Example_service_Client_RestoreContainer() { + accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") + if !ok { + panic("AZURE_STORAGE_ACCOUNT_NAME could not be found") + } + serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", accountName) + + cred, err := azidentity.NewDefaultAzureCredential(nil) + handleError(err) + serviceClient, err := service.NewClient(serviceURL, cred, nil) + handleError(err) + + listOptions := service.ListContainersOptions{ + Include: service.ListContainersInclude{ + Metadata: true, // Include Metadata + Deleted: true, // Include deleted containers in the result as well + }, + } + pager := serviceClient.NewListContainersPager(&listOptions) + + for pager.More() { + resp, err := pager.NextPage(context.TODO()) + if err != nil { + log.Fatal(err) + } + for _, cont := range resp.ContainerItems { + if *cont.Deleted { + _, err = serviceClient.RestoreContainer(context.TODO(), *cont.Name, *cont.Version) + handleError(err) + } + } + } +} + func Example_service_Client_ListContainers() { accountName, ok := os.LookupEnv("AZURE_STORAGE_ACCOUNT_NAME") if !ok { diff --git a/sdk/storage/azblob/service/responses.go b/sdk/storage/azblob/service/responses.go index 1eb5ab3d5ffd..26e3c085bd90 100644 --- a/sdk/storage/azblob/service/responses.go +++ b/sdk/storage/azblob/service/responses.go @@ -16,6 +16,9 @@ type CreateContainerResponse = generated.ContainerClientCreateResponse // DeleteContainerResponse contains the response from method container.Client.Delete type DeleteContainerResponse = generated.ContainerClientDeleteResponse +// RestoreContainerResponse contains the response from method container.Client.Restore +type RestoreContainerResponse = generated.ContainerClientRestoreResponse + // GetAccountInfoResponse contains the response from method Client.GetAccountInfo. type GetAccountInfoResponse = generated.ServiceClientGetAccountInfoResponse From 06cac8316d294f94f8ebb94b7915b45967166233 Mon Sep 17 00:00:00 2001 From: Sourav Gupta Date: Mon, 19 Sep 2022 13:01:54 +0530 Subject: [PATCH 2/4] Converting function parameters to option bag --- sdk/storage/azblob/container/client.go | 11 +++++++---- sdk/storage/azblob/container/models.go | 8 ++++++++ sdk/storage/azblob/service/client.go | 8 ++++++-- sdk/storage/azblob/service/client_test.go | 21 ++++++++++++++++++++- sdk/storage/azblob/service/examples_test.go | 5 ++++- sdk/storage/azblob/service/models.go | 3 +++ 6 files changed, 48 insertions(+), 8 deletions(-) diff --git a/sdk/storage/azblob/container/client.go b/sdk/storage/azblob/container/client.go index b995acee8a4c..a597b6270bc9 100644 --- a/sdk/storage/azblob/container/client.go +++ b/sdk/storage/azblob/container/client.go @@ -162,10 +162,13 @@ func (c *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResp // Restore operation restore the contents and properties of a soft deleted container to a specified container. // For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/restore-container. -func (c *Client) Restore(ctx context.Context, deletedContainerName string, deletedContainerVersion string) (RestoreResponse, error) { - opts := &generated.ContainerClientRestoreOptions{ - DeletedContainerName: &deletedContainerName, - DeletedContainerVersion: &deletedContainerVersion, +func (c *Client) Restore(ctx context.Context, options *RestoreOptions) (RestoreResponse, error) { + var opts *generated.ContainerClientRestoreOptions + if options != nil { + opts = &generated.ContainerClientRestoreOptions{ + DeletedContainerName: &options.DeletedContainerName, + DeletedContainerVersion: &options.DeletedContainerVersion, + } } resp, err := c.generated().Restore(ctx, opts) diff --git a/sdk/storage/azblob/container/models.go b/sdk/storage/azblob/container/models.go index 971a10a3dbef..6386f405b055 100644 --- a/sdk/storage/azblob/container/models.go +++ b/sdk/storage/azblob/container/models.go @@ -84,6 +84,14 @@ func (o *DeleteOptions) format() (*generated.ContainerClientDeleteOptions, *gene // --------------------------------------------------------------------------------------------------------------------- +// RestoreOptions contains the optional parameters for the Client.Restore method. +type RestoreOptions struct { + DeletedContainerName string + DeletedContainerVersion string +} + +// --------------------------------------------------------------------------------------------------------------------- + // GetPropertiesOptions contains the optional parameters for the ContainerClient.GetProperties method. type GetPropertiesOptions struct { LeaseAccessConditions *LeaseAccessConditions diff --git a/sdk/storage/azblob/service/client.go b/sdk/storage/azblob/service/client.go index c4b922f8ac68..908aea2e86af 100644 --- a/sdk/storage/azblob/service/client.go +++ b/sdk/storage/azblob/service/client.go @@ -125,9 +125,13 @@ func (s *Client) DeleteContainer(ctx context.Context, containerName string, opti // RestoreContainer restores soft-deleted container // Operation will only be successful if used within the specified number of days set in the delete retention policy -func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, deletedContainerVersion string) (RestoreContainerResponse, error) { +func (s *Client) RestoreContainer(ctx context.Context, options *RestoreContainerOptions) (RestoreContainerResponse, error) { + var deletedContainerName string + if options != nil { + deletedContainerName = options.DeletedContainerName + } containerClient := s.NewContainerClient(deletedContainerName) - containerRestoreResp, err := containerClient.Restore(ctx, deletedContainerName, deletedContainerVersion) + containerRestoreResp, err := containerClient.Restore(ctx, options) return containerRestoreResp, err } diff --git a/sdk/storage/azblob/service/client_test.go b/sdk/storage/azblob/service/client_test.go index 7ac2f9e3822e..4a945a28c204 100644 --- a/sdk/storage/azblob/service/client_test.go +++ b/sdk/storage/azblob/service/client_test.go @@ -629,7 +629,10 @@ func (s *ServiceUnrecordedTestsSuite) TestContainerRestore() { if *cont.Deleted && *cont.Name == containerName { contRestored = true - _, err = svcClient.RestoreContainer(context.Background(), containerName, *cont.Version) + _, err = svcClient.RestoreContainer(context.Background(), &service.RestoreContainerOptions{ + DeletedContainerName: containerName, + DeletedContainerVersion: *cont.Version, + }) _require.Nil(err) break } @@ -644,3 +647,19 @@ func (s *ServiceUnrecordedTestsSuite) TestContainerRestore() { _, err = svcClient.DeleteContainer(context.Background(), containerName, nil) _require.Nil(err) } + +// TODO: convert this test to recorded +func (s *ServiceUnrecordedTestsSuite) TestContainerRestoreFailures() { + _require := require.New(s.T()) + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + _, err = svcClient.RestoreContainer(context.Background(), nil) + testcommon.ValidateBlobErrorCode(_require, err, bloberror.MissingRequiredHeader) + + _, err = svcClient.RestoreContainer(context.Background(), &service.RestoreContainerOptions{ + DeletedContainerName: "", + DeletedContainerVersion: "", + }) + testcommon.ValidateBlobErrorCode(_require, err, bloberror.MissingRequiredHeader) +} diff --git a/sdk/storage/azblob/service/examples_test.go b/sdk/storage/azblob/service/examples_test.go index 5b302eed8d3f..bbfa1b1a9af1 100644 --- a/sdk/storage/azblob/service/examples_test.go +++ b/sdk/storage/azblob/service/examples_test.go @@ -156,7 +156,10 @@ func Example_service_Client_RestoreContainer() { } for _, cont := range resp.ContainerItems { if *cont.Deleted { - _, err = serviceClient.RestoreContainer(context.TODO(), *cont.Name, *cont.Version) + _, err = serviceClient.RestoreContainer(context.TODO(), &service.RestoreContainerOptions{ + DeletedContainerName: *cont.Name, + DeletedContainerVersion: *cont.Version, + }) handleError(err) } } diff --git a/sdk/storage/azblob/service/models.go b/sdk/storage/azblob/service/models.go index 6667166c43fa..5c3c0f1dc7f0 100644 --- a/sdk/storage/azblob/service/models.go +++ b/sdk/storage/azblob/service/models.go @@ -36,6 +36,9 @@ type CreateContainerOptions = container.CreateOptions // DeleteContainerOptions contains the optional parameters for the container.Client.Delete method. type DeleteContainerOptions = container.DeleteOptions +// RestoreContainerOptions contains the optional parameters for the container.Client.Restore method. +type RestoreContainerOptions = container.RestoreOptions + // CorsRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another // domain. Web browsers implement a security restriction known as same-origin policy that // prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin From 2409ab68c7153f6399cca4cdaf7b90934050b39f Mon Sep 17 00:00:00 2001 From: Sourav Gupta Date: Tue, 20 Sep 2022 11:34:24 +0530 Subject: [PATCH 3/4] Removing deleted container name from options --- sdk/storage/azblob/container/client.go | 12 +++++++----- sdk/storage/azblob/container/models.go | 1 - sdk/storage/azblob/service/client.go | 6 +----- sdk/storage/azblob/service/client_test.go | 11 ++++++----- sdk/storage/azblob/service/examples_test.go | 3 +-- 5 files changed, 15 insertions(+), 18 deletions(-) diff --git a/sdk/storage/azblob/container/client.go b/sdk/storage/azblob/container/client.go index a597b6270bc9..3b43ed430ec0 100644 --- a/sdk/storage/azblob/container/client.go +++ b/sdk/storage/azblob/container/client.go @@ -163,12 +163,14 @@ func (c *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResp // Restore operation restore the contents and properties of a soft deleted container to a specified container. // For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/restore-container. func (c *Client) Restore(ctx context.Context, options *RestoreOptions) (RestoreResponse, error) { - var opts *generated.ContainerClientRestoreOptions + urlParts, err := blob.ParseURL(c.URL()) + if err != nil { + return RestoreResponse{}, err + } + + opts := &generated.ContainerClientRestoreOptions{DeletedContainerName: &urlParts.ContainerName} if options != nil { - opts = &generated.ContainerClientRestoreOptions{ - DeletedContainerName: &options.DeletedContainerName, - DeletedContainerVersion: &options.DeletedContainerVersion, - } + opts.DeletedContainerVersion = &options.DeletedContainerVersion } resp, err := c.generated().Restore(ctx, opts) diff --git a/sdk/storage/azblob/container/models.go b/sdk/storage/azblob/container/models.go index 6386f405b055..2da4ed73086f 100644 --- a/sdk/storage/azblob/container/models.go +++ b/sdk/storage/azblob/container/models.go @@ -86,7 +86,6 @@ func (o *DeleteOptions) format() (*generated.ContainerClientDeleteOptions, *gene // RestoreOptions contains the optional parameters for the Client.Restore method. type RestoreOptions struct { - DeletedContainerName string DeletedContainerVersion string } diff --git a/sdk/storage/azblob/service/client.go b/sdk/storage/azblob/service/client.go index 908aea2e86af..36612ec212a0 100644 --- a/sdk/storage/azblob/service/client.go +++ b/sdk/storage/azblob/service/client.go @@ -125,11 +125,7 @@ func (s *Client) DeleteContainer(ctx context.Context, containerName string, opti // RestoreContainer restores soft-deleted container // Operation will only be successful if used within the specified number of days set in the delete retention policy -func (s *Client) RestoreContainer(ctx context.Context, options *RestoreContainerOptions) (RestoreContainerResponse, error) { - var deletedContainerName string - if options != nil { - deletedContainerName = options.DeletedContainerName - } +func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, options *RestoreContainerOptions) (RestoreContainerResponse, error) { containerClient := s.NewContainerClient(deletedContainerName) containerRestoreResp, err := containerClient.Restore(ctx, options) return containerRestoreResp, err diff --git a/sdk/storage/azblob/service/client_test.go b/sdk/storage/azblob/service/client_test.go index 4a945a28c204..d3314f4b60a7 100644 --- a/sdk/storage/azblob/service/client_test.go +++ b/sdk/storage/azblob/service/client_test.go @@ -629,8 +629,7 @@ func (s *ServiceUnrecordedTestsSuite) TestContainerRestore() { if *cont.Deleted && *cont.Name == containerName { contRestored = true - _, err = svcClient.RestoreContainer(context.Background(), &service.RestoreContainerOptions{ - DeletedContainerName: containerName, + _, err = svcClient.RestoreContainer(context.Background(), containerName, &service.RestoreContainerOptions{ DeletedContainerVersion: *cont.Version, }) _require.Nil(err) @@ -654,11 +653,13 @@ func (s *ServiceUnrecordedTestsSuite) TestContainerRestoreFailures() { svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) _require.NoError(err) - _, err = svcClient.RestoreContainer(context.Background(), nil) + testName := s.T().Name() + containerName := testcommon.GenerateContainerName(testName) + + _, err = svcClient.RestoreContainer(context.Background(), containerName, nil) testcommon.ValidateBlobErrorCode(_require, err, bloberror.MissingRequiredHeader) - _, err = svcClient.RestoreContainer(context.Background(), &service.RestoreContainerOptions{ - DeletedContainerName: "", + _, err = svcClient.RestoreContainer(context.Background(), "", &service.RestoreContainerOptions{ DeletedContainerVersion: "", }) testcommon.ValidateBlobErrorCode(_require, err, bloberror.MissingRequiredHeader) diff --git a/sdk/storage/azblob/service/examples_test.go b/sdk/storage/azblob/service/examples_test.go index bbfa1b1a9af1..b1f4ccf144d9 100644 --- a/sdk/storage/azblob/service/examples_test.go +++ b/sdk/storage/azblob/service/examples_test.go @@ -156,8 +156,7 @@ func Example_service_Client_RestoreContainer() { } for _, cont := range resp.ContainerItems { if *cont.Deleted { - _, err = serviceClient.RestoreContainer(context.TODO(), &service.RestoreContainerOptions{ - DeletedContainerName: *cont.Name, + _, err = serviceClient.RestoreContainer(context.TODO(), *cont.Name, &service.RestoreContainerOptions{ DeletedContainerVersion: *cont.Version, }) handleError(err) From d1740f230ad6530b8ebe708a0699dcb19a67bbe6 Mon Sep 17 00:00:00 2001 From: Sourav Gupta Date: Wed, 21 Sep 2022 22:36:43 +0530 Subject: [PATCH 4/4] Changes as suggested --- sdk/storage/azblob/container/client.go | 8 ++++---- sdk/storage/azblob/container/models.go | 2 +- sdk/storage/azblob/service/client.go | 4 ++-- sdk/storage/azblob/service/client_test.go | 10 +++------- sdk/storage/azblob/service/examples_test.go | 4 +--- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/sdk/storage/azblob/container/client.go b/sdk/storage/azblob/container/client.go index 3b43ed430ec0..aa58acdce1b8 100644 --- a/sdk/storage/azblob/container/client.go +++ b/sdk/storage/azblob/container/client.go @@ -162,15 +162,15 @@ func (c *Client) Delete(ctx context.Context, options *DeleteOptions) (DeleteResp // Restore operation restore the contents and properties of a soft deleted container to a specified container. // For more information, see https://docs.microsoft.com/en-us/rest/api/storageservices/restore-container. -func (c *Client) Restore(ctx context.Context, options *RestoreOptions) (RestoreResponse, error) { +func (c *Client) Restore(ctx context.Context, deletedContainerVersion string, options *RestoreOptions) (RestoreResponse, error) { urlParts, err := blob.ParseURL(c.URL()) if err != nil { return RestoreResponse{}, err } - opts := &generated.ContainerClientRestoreOptions{DeletedContainerName: &urlParts.ContainerName} - if options != nil { - opts.DeletedContainerVersion = &options.DeletedContainerVersion + opts := &generated.ContainerClientRestoreOptions{ + DeletedContainerName: &urlParts.ContainerName, + DeletedContainerVersion: &deletedContainerVersion, } resp, err := c.generated().Restore(ctx, opts) diff --git a/sdk/storage/azblob/container/models.go b/sdk/storage/azblob/container/models.go index 2da4ed73086f..eb65d5fc3c80 100644 --- a/sdk/storage/azblob/container/models.go +++ b/sdk/storage/azblob/container/models.go @@ -86,7 +86,7 @@ func (o *DeleteOptions) format() (*generated.ContainerClientDeleteOptions, *gene // RestoreOptions contains the optional parameters for the Client.Restore method. type RestoreOptions struct { - DeletedContainerVersion string + // placeholder for future options } // --------------------------------------------------------------------------------------------------------------------- diff --git a/sdk/storage/azblob/service/client.go b/sdk/storage/azblob/service/client.go index 36612ec212a0..69740e47680d 100644 --- a/sdk/storage/azblob/service/client.go +++ b/sdk/storage/azblob/service/client.go @@ -125,9 +125,9 @@ func (s *Client) DeleteContainer(ctx context.Context, containerName string, opti // RestoreContainer restores soft-deleted container // Operation will only be successful if used within the specified number of days set in the delete retention policy -func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, options *RestoreContainerOptions) (RestoreContainerResponse, error) { +func (s *Client) RestoreContainer(ctx context.Context, deletedContainerName string, deletedContainerVersion string, options *RestoreContainerOptions) (RestoreContainerResponse, error) { containerClient := s.NewContainerClient(deletedContainerName) - containerRestoreResp, err := containerClient.Restore(ctx, options) + containerRestoreResp, err := containerClient.Restore(ctx, deletedContainerVersion, options) return containerRestoreResp, err } diff --git a/sdk/storage/azblob/service/client_test.go b/sdk/storage/azblob/service/client_test.go index d3314f4b60a7..758bc9180cf6 100644 --- a/sdk/storage/azblob/service/client_test.go +++ b/sdk/storage/azblob/service/client_test.go @@ -629,9 +629,7 @@ func (s *ServiceUnrecordedTestsSuite) TestContainerRestore() { if *cont.Deleted && *cont.Name == containerName { contRestored = true - _, err = svcClient.RestoreContainer(context.Background(), containerName, &service.RestoreContainerOptions{ - DeletedContainerVersion: *cont.Version, - }) + _, err = svcClient.RestoreContainer(context.Background(), containerName, *cont.Version, nil) _require.Nil(err) break } @@ -656,11 +654,9 @@ func (s *ServiceUnrecordedTestsSuite) TestContainerRestoreFailures() { testName := s.T().Name() containerName := testcommon.GenerateContainerName(testName) - _, err = svcClient.RestoreContainer(context.Background(), containerName, nil) + _, err = svcClient.RestoreContainer(context.Background(), containerName, "", nil) testcommon.ValidateBlobErrorCode(_require, err, bloberror.MissingRequiredHeader) - _, err = svcClient.RestoreContainer(context.Background(), "", &service.RestoreContainerOptions{ - DeletedContainerVersion: "", - }) + _, err = svcClient.RestoreContainer(context.Background(), "", "", &service.RestoreContainerOptions{}) testcommon.ValidateBlobErrorCode(_require, err, bloberror.MissingRequiredHeader) } diff --git a/sdk/storage/azblob/service/examples_test.go b/sdk/storage/azblob/service/examples_test.go index b1f4ccf144d9..a552de0660cc 100644 --- a/sdk/storage/azblob/service/examples_test.go +++ b/sdk/storage/azblob/service/examples_test.go @@ -156,9 +156,7 @@ func Example_service_Client_RestoreContainer() { } for _, cont := range resp.ContainerItems { if *cont.Deleted { - _, err = serviceClient.RestoreContainer(context.TODO(), *cont.Name, &service.RestoreContainerOptions{ - DeletedContainerVersion: *cont.Version, - }) + _, err = serviceClient.RestoreContainer(context.TODO(), *cont.Name, *cont.Version, nil) handleError(err) } }