From d6fa08e56f0de824a3675c5edee1d3a52b3938e2 Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:29:23 +0530 Subject: [PATCH 1/5] azfile: STG 91 code generation (#22134) --- sdk/storage/azfile/file/client_test.go | 37 +++++++++ .../azfile/internal/generated/autorest.md | 18 ++++- .../azfile/internal/generated/constants.go | 9 +++ .../azfile/internal/generated/zz_constants.go | 18 +++++ .../internal/generated/zz_directory_client.go | 36 ++++----- .../internal/generated/zz_file_client.go | 75 ++++++++++--------- .../azfile/internal/generated/zz_models.go | 3 +- .../internal/generated/zz_service_client.go | 12 +-- .../internal/generated/zz_share_client.go | 68 ++++++++--------- 9 files changed, 180 insertions(+), 96 deletions(-) create mode 100644 sdk/storage/azfile/internal/generated/constants.go diff --git a/sdk/storage/azfile/file/client_test.go b/sdk/storage/azfile/file/client_test.go index bab8724fa4ec..74648a877a0f 100644 --- a/sdk/storage/azfile/file/client_test.go +++ b/sdk/storage/azfile/file/client_test.go @@ -20,6 +20,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/file" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/fileerror" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/shared" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/testcommon" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/lease" @@ -4340,4 +4341,40 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLNow() { _require.NotEqualValues(*uResp.FileLastWriteTime, *cResp.FileLastWriteTime) } +type serviceVersionTest struct{} + +// newServiceVersionTestPolicy returns a policy that checks the x-ms-version header +func newServiceVersionTestPolicy() policy.Policy { + return &serviceVersionTest{} +} + +func (m serviceVersionTest) Do(req *policy.Request) (*http.Response, error) { + const versionHeader = "x-ms-version" + currentVersion := map[string][]string(req.Raw().Header)[versionHeader] + if currentVersion[0] != generated.ServiceVersion { + return nil, fmt.Errorf(currentVersion[0] + " service version doesn't match expected version: " + generated.ServiceVersion) + } + + return &http.Response{ + Request: req.Raw(), + Status: "Created", + StatusCode: http.StatusCreated, + Header: http.Header{}, + Body: http.NoBody, + }, nil +} + +func TestServiceVersion(t *testing.T) { + client, err := file.NewClientWithNoCredential("https://fake/file/testpath", &file.ClientOptions{ + ClientOptions: policy.ClientOptions{ + PerCallPolicies: []policy.Policy{newServiceVersionTestPolicy()}, + }, + }) + require.NoError(t, err) + require.NotNil(t, client) + + _, err = client.Create(context.Background(), 1024, nil) + require.NoError(t, err) +} + // TODO: Add tests for retry header options diff --git a/sdk/storage/azfile/internal/generated/autorest.md b/sdk/storage/azfile/internal/generated/autorest.md index 921ad0ca976c..9572da0256e2 100644 --- a/sdk/storage/azfile/internal/generated/autorest.md +++ b/sdk/storage/azfile/internal/generated/autorest.md @@ -7,7 +7,7 @@ go: true clear-output-folder: false version: "^3.0.0" license-header: MICROSOFT_MIT_NO_VERSION -input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7dcd41cd28d46eb256bac034760a7e2f0a036238/specification/storage/data-plane/Microsoft.FileStorage/preview/2022-11-02/file.json" +input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/4bafbf3ab1532e390ad5757433679e9ebb5cbf38/specification/storage/data-plane/Microsoft.FileStorage/preview/2023-08-03/file.json" credential-scope: "https://storage.azure.com/.default" output-folder: ../generated file-prefix: "zz_" @@ -22,6 +22,22 @@ export-clients: true use: "@autorest/go@4.0.0-preview.49" ``` +### Updating service version to 2023-11-03 + +```yaml +directive: +- from: + - zz_directory_client.go + - zz_file_client.go + - zz_share_client.go + - zz_service_client.go + where: $ + transform: >- + return $. + replaceAll(`[]string{"2023-08-03"}`, `[]string{ServiceVersion}`). + replaceAll(`2023-08-03`, `2023-11-03`); +``` + ### Don't include share name, directory, or file name in path - we have direct URIs ``` yaml diff --git a/sdk/storage/azfile/internal/generated/constants.go b/sdk/storage/azfile/internal/generated/constants.go new file mode 100644 index 000000000000..8f2bbbb7cb81 --- /dev/null +++ b/sdk/storage/azfile/internal/generated/constants.go @@ -0,0 +1,9 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package generated + +const ServiceVersion = "2023-11-03" diff --git a/sdk/storage/azfile/internal/generated/zz_constants.go b/sdk/storage/azfile/internal/generated/zz_constants.go index 2f356c7c3f63..9df8784a97a1 100644 --- a/sdk/storage/azfile/internal/generated/zz_constants.go +++ b/sdk/storage/azfile/internal/generated/zz_constants.go @@ -9,6 +9,24 @@ package generated +// AccessRight - Access rights of the access policy. +type AccessRight string + +const ( + AccessRightDelete AccessRight = "Delete" + AccessRightRead AccessRight = "Read" + AccessRightWrite AccessRight = "Write" +) + +// PossibleAccessRightValues returns the possible values for the AccessRight const type. +func PossibleAccessRightValues() []AccessRight { + return []AccessRight{ + AccessRightDelete, + AccessRightRead, + AccessRightWrite, + } +} + type CopyStatusType string const ( diff --git a/sdk/storage/azfile/internal/generated/zz_directory_client.go b/sdk/storage/azfile/internal/generated/zz_directory_client.go index 4e05f2f7d860..5a13781a835b 100644 --- a/sdk/storage/azfile/internal/generated/zz_directory_client.go +++ b/sdk/storage/azfile/internal/generated/zz_directory_client.go @@ -35,7 +35,7 @@ type DirectoryClient struct { // Create - Creates a new directory under the specified share or parent directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. func (client *DirectoryClient) Create(ctx context.Context, options *DirectoryClientCreateOptions) (DirectoryClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, options) @@ -74,7 +74,7 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.FilePermission != nil { req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} } @@ -172,7 +172,7 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct // Delete - Removes the specified empty directory. Note that the directory must be empty before it can be deleted. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. func (client *DirectoryClient) Delete(ctx context.Context, options *DirectoryClientDeleteOptions) (DirectoryClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, options) @@ -204,7 +204,7 @@ func (client *DirectoryClient) deleteCreateRequest(ctx context.Context, options if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -234,7 +234,7 @@ func (client *DirectoryClient) deleteHandleResponse(resp *http.Response) (Direct // ForceCloseHandles - Closes all handles open for given directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - handleID - Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that specifies // all handles. // - options - DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles @@ -276,7 +276,7 @@ func (client *DirectoryClient) forceCloseHandlesCreateRequest(ctx context.Contex if options != nil && options.Recursive != nil { req.Raw().Header["x-ms-recursive"] = []string{strconv.FormatBool(*options.Recursive)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -330,7 +330,7 @@ func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Respon // subdirectories. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. func (client *DirectoryClient) GetProperties(ctx context.Context, options *DirectoryClientGetPropertiesOptions) (DirectoryClientGetPropertiesResponse, error) { req, err := client.getPropertiesCreateRequest(ctx, options) @@ -365,7 +365,7 @@ func (client *DirectoryClient) getPropertiesCreateRequest(ctx context.Context, o if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -453,7 +453,7 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) // NewListFilesAndDirectoriesSegmentPager - Returns a list of files or directories under the specified share or directory. // It lists the contents only for a single level of the directory hierarchy. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientListFilesAndDirectoriesSegmentOptions contains the optional parameters for the DirectoryClient.NewListFilesAndDirectoriesSegmentPager // method. // @@ -485,7 +485,7 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentCreateRequest(ctx c reqQP.Set("include", strings.Join(strings.Fields(strings.Trim(fmt.Sprint(options.Include), "[]")), ",")) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.IncludeExtendedInfo != nil { req.Raw().Header["x-ms-file-extended-info"] = []string{strconv.FormatBool(*options.IncludeExtendedInfo)} } @@ -527,7 +527,7 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp // ListHandles - Lists handles for directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. func (client *DirectoryClient) ListHandles(ctx context.Context, options *DirectoryClientListHandlesOptions) (DirectoryClientListHandlesResponse, error) { req, err := client.listHandlesCreateRequest(ctx, options) @@ -568,7 +568,7 @@ func (client *DirectoryClient) listHandlesCreateRequest(ctx context.Context, opt if options != nil && options.Recursive != nil { req.Raw().Header["x-ms-recursive"] = []string{strconv.FormatBool(*options.Recursive)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -607,7 +607,7 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D // Rename - Renames a directory // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - renameSource - Required. Specifies the URI-style path of the source file, up to 2 KB in length. // - options - DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. // - SourceLeaseAccessConditions - SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename @@ -643,7 +643,7 @@ func (client *DirectoryClient) renameCreateRequest(ctx context.Context, renameSo reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["x-ms-file-rename-source"] = []string{renameSource} if options != nil && options.ReplaceIfExists != nil { req.Raw().Header["x-ms-file-rename-replace-if-exists"] = []string{strconv.FormatBool(*options.ReplaceIfExists)} @@ -767,7 +767,7 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct // SetMetadata - Updates user defined metadata for the specified directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. func (client *DirectoryClient) SetMetadata(ctx context.Context, options *DirectoryClientSetMetadataOptions) (DirectoryClientSetMetadataResponse, error) { req, err := client.setMetadataCreateRequest(ctx, options) @@ -804,7 +804,7 @@ func (client *DirectoryClient) setMetadataCreateRequest(ctx context.Context, opt } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -847,7 +847,7 @@ func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (D // SetProperties - Sets properties on the directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. func (client *DirectoryClient) SetProperties(ctx context.Context, options *DirectoryClientSetPropertiesOptions) (DirectoryClientSetPropertiesResponse, error) { req, err := client.setPropertiesCreateRequest(ctx, options) @@ -877,7 +877,7 @@ func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, o reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.FilePermission != nil { req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} } diff --git a/sdk/storage/azfile/internal/generated/zz_file_client.go b/sdk/storage/azfile/internal/generated/zz_file_client.go index fda41c5f79a3..be104c8e1aa0 100644 --- a/sdk/storage/azfile/internal/generated/zz_file_client.go +++ b/sdk/storage/azfile/internal/generated/zz_file_client.go @@ -36,7 +36,7 @@ type FileClient struct { // AbortCopy - Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - copyID - The copy identifier provided in the x-ms-copy-id header of the original Copy File operation. // - options - FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. @@ -69,7 +69,7 @@ func (client *FileClient) abortCopyCreateRequest(ctx context.Context, copyID str } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-copy-action"] = []string{"abort"} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -105,7 +105,7 @@ func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClie // AcquireLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - duration - Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite // lease can be between 15 and 60 seconds. A lease duration cannot be changed using // renew or change. @@ -142,7 +142,7 @@ func (client *FileClient) acquireLeaseCreateRequest(ctx context.Context, duratio if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -194,7 +194,7 @@ func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileC // BreakLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) BreakLease(ctx context.Context, options *FileClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientBreakLeaseResponse, error) { @@ -228,7 +228,7 @@ func (client *FileClient) breakLeaseCreateRequest(ctx context.Context, options * if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -280,7 +280,7 @@ func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileCli // ChangeLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. func (client *FileClient) ChangeLease(ctx context.Context, leaseID string, options *FileClientChangeLeaseOptions) (FileClientChangeLeaseResponse, error) { @@ -315,7 +315,7 @@ func (client *FileClient) changeLeaseCreateRequest(ctx context.Context, leaseID if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -367,7 +367,7 @@ func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileCl // Create - Creates a new file or replaces a file. Note it only initializes the file with no content. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - fileContentLength - Specifies the maximum size for the file, up to 4 TB. // - options - FileClientCreateOptions contains the optional parameters for the FileClient.Create method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. @@ -401,7 +401,7 @@ func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLe if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(fileContentLength, 10)} req.Raw().Header["x-ms-type"] = []string{"file"} if shareFileHTTPHeaders != nil && shareFileHTTPHeaders.ContentType != nil { @@ -529,7 +529,7 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC // Delete - removes the file from the storage account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Delete(ctx context.Context, options *FileClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDeleteResponse, error) { @@ -561,7 +561,7 @@ func (client *FileClient) deleteCreateRequest(ctx context.Context, options *File if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -594,7 +594,7 @@ func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientD // Download - Reads or downloads a file from the system, including its metadata and properties. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Download(ctx context.Context, options *FileClientDownloadOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDownloadResponse, error) { @@ -627,7 +627,7 @@ func (client *FileClient) downloadCreateRequest(ctx context.Context, options *Fi if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Range != nil { req.Raw().Header["x-ms-range"] = []string{*options.Range} } @@ -797,7 +797,7 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien // ForceCloseHandles - Closes all handles open for given file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - handleID - Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that specifies // all handles. // - options - FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. @@ -835,7 +835,7 @@ func (client *FileClient) forceCloseHandlesCreateRequest(ctx context.Context, ha } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-handle-id"] = []string{handleID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -888,7 +888,7 @@ func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) ( // not return the content of the file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetProperties(ctx context.Context, options *FileClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetPropertiesResponse, error) { @@ -923,7 +923,7 @@ func (client *FileClient) getPropertiesCreateRequest(ctx context.Context, option if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1077,7 +1077,7 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File // GetRangeList - Returns the list of valid ranges for a file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetRangeList(ctx context.Context, options *FileClientGetRangeListOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetRangeListResponse, error) { @@ -1113,7 +1113,7 @@ func (client *FileClient) getRangeListCreateRequest(ctx context.Context, options reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Range != nil { req.Raw().Header["x-ms-range"] = []string{*options.Range} } @@ -1172,7 +1172,7 @@ func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileC // ListHandles - Lists handles for file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. func (client *FileClient) ListHandles(ctx context.Context, options *FileClientListHandlesOptions) (FileClientListHandlesResponse, error) { req, err := client.listHandlesCreateRequest(ctx, options) @@ -1210,7 +1210,7 @@ func (client *FileClient) listHandlesCreateRequest(ctx context.Context, options reqQP.Set("sharesnapshot", *options.Sharesnapshot) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -1249,7 +1249,7 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl // ReleaseLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. func (client *FileClient) ReleaseLease(ctx context.Context, leaseID string, options *FileClientReleaseLeaseOptions) (FileClientReleaseLeaseResponse, error) { @@ -1281,7 +1281,7 @@ func (client *FileClient) releaseLeaseCreateRequest(ctx context.Context, leaseID req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"release"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1330,7 +1330,7 @@ func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileC // Rename - Renames a file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - renameSource - Required. Specifies the URI-style path of the source file, up to 2 KB in length. // - options - FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. // - SourceLeaseAccessConditions - SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename @@ -1366,7 +1366,7 @@ func (client *FileClient) renameCreateRequest(ctx context.Context, renameSource reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["x-ms-file-rename-source"] = []string{renameSource} if options != nil && options.ReplaceIfExists != nil { req.Raw().Header["x-ms-file-rename-replace-if-exists"] = []string{strconv.FormatBool(*options.ReplaceIfExists)} @@ -1493,7 +1493,7 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR // SetHTTPHeaders - Sets HTTP headers on the file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. @@ -1524,7 +1524,7 @@ func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.FileContentLength != nil { req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(*options.FileContentLength, 10)} } @@ -1649,7 +1649,7 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil // SetMetadata - Updates user-defined metadata for the specified file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) SetMetadata(ctx context.Context, options *FileClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientSetMetadataResponse, error) { @@ -1686,7 +1686,7 @@ func (client *FileClient) setMetadataCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1739,7 +1739,7 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl // StartCopy - Copies a blob or file to a destination file within the storage account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - copySource - Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file to another file within // the same storage account, you may use Shared Key to authenticate the source file. If you are // copying a file from another storage account, or if you are copying a blob from the same storage account or another storage @@ -1775,7 +1775,7 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Metadata != nil { for k, v := range options.Metadata { if v != nil { @@ -1865,7 +1865,7 @@ func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClie // UploadRange - Upload a range of bytes to a file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - rangeParam - Specifies the range of bytes to be written. Both the start and end of the range must be specified. For an // update operation, the range can be up to 4 MB in size. For a clear operation, the range can be // up to the value of the file's full size. The File service accepts only a single byte range for the Range and 'x-ms-range' @@ -1914,7 +1914,7 @@ func (client *FileClient) uploadRangeCreateRequest(ctx context.Context, rangePar if options != nil && options.ContentMD5 != nil { req.Raw().Header["Content-MD5"] = []string{base64.StdEncoding.EncodeToString(options.ContentMD5)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1987,7 +1987,7 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl // UploadRangeFromURL - Upload a range of bytes to a file where the contents are read from a URL. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - rangeParam - Writes data to the specified byte range in the file. // - copySource - Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file to another file within // the same storage account, you may use Shared Key to authenticate the source file. If you are @@ -2044,7 +2044,7 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r if sourceModifiedAccessConditions != nil && sourceModifiedAccessConditions.SourceIfNoneMatchCRC64 != nil { req.Raw().Header["x-ms-source-if-none-match-crc64"] = []string{base64.StdEncoding.EncodeToString(sourceModifiedAccessConditions.SourceIfNoneMatchCRC64)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -2060,6 +2060,9 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r if client.allowSourceTrailingDot != nil { req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowSourceTrailingDot)} } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_models.go b/sdk/storage/azfile/internal/generated/zz_models.go index a27b53f42cea..10aace210fe4 100644 --- a/sdk/storage/azfile/internal/generated/zz_models.go +++ b/sdk/storage/azfile/internal/generated/zz_models.go @@ -590,7 +590,8 @@ type Handle struct { Path *string `xml:"Path"` // REQUIRED; SMB session ID in context of which the file handle was opened - SessionID *string `xml:"SessionId"` + SessionID *string `xml:"SessionId"` + AccessRightList []*AccessRight `xml:"AccessRightList>AccessRight"` // Time handle was last connected to (UTC) LastReconnectTime *time.Time `xml:"LastReconnectTime"` diff --git a/sdk/storage/azfile/internal/generated/zz_service_client.go b/sdk/storage/azfile/internal/generated/zz_service_client.go index 847b97903bae..fc0cf80a4f2c 100644 --- a/sdk/storage/azfile/internal/generated/zz_service_client.go +++ b/sdk/storage/azfile/internal/generated/zz_service_client.go @@ -31,7 +31,7 @@ type ServiceClient struct { // and CORS (Cross-Origin Resource Sharing) rules. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. func (client *ServiceClient) GetProperties(ctx context.Context, options *ServiceClientGetPropertiesOptions) (ServiceClientGetPropertiesResponse, error) { req, err := client.getPropertiesCreateRequest(ctx, options) @@ -61,7 +61,7 @@ func (client *ServiceClient) getPropertiesCreateRequest(ctx context.Context, opt reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -84,7 +84,7 @@ func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (S // NewListSharesSegmentPager - The List Shares Segment operation returns a list of the shares and share snapshots under the // specified account. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ServiceClientListSharesSegmentOptions contains the optional parameters for the ServiceClient.NewListSharesSegmentPager // method. // @@ -112,7 +112,7 @@ func (client *ServiceClient) ListSharesSegmentCreateRequest(ctx context.Context, reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -136,7 +136,7 @@ func (client *ServiceClient) ListSharesSegmentHandleResponse(resp *http.Response // metrics and CORS (Cross-Origin Resource Sharing) rules. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - storageServiceProperties - The StorageService properties. // - options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. func (client *ServiceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { @@ -167,7 +167,7 @@ func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, sto reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} if err := runtime.MarshalAsXML(req, storageServiceProperties); err != nil { return nil, err diff --git a/sdk/storage/azfile/internal/generated/zz_share_client.go b/sdk/storage/azfile/internal/generated/zz_share_client.go index 3c83f97775df..83a3092cd292 100644 --- a/sdk/storage/azfile/internal/generated/zz_share_client.go +++ b/sdk/storage/azfile/internal/generated/zz_share_client.go @@ -34,7 +34,7 @@ type ShareClient struct { // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - duration - Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite // lease can be between 15 and 60 seconds. A lease duration cannot be changed using // renew or change. @@ -75,7 +75,7 @@ func (client *ShareClient) acquireLeaseCreateRequest(ctx context.Context, durati if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -122,7 +122,7 @@ func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (Shar // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) BreakLease(ctx context.Context, options *ShareClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientBreakLeaseResponse, error) { @@ -163,7 +163,7 @@ func (client *ShareClient) breakLeaseCreateRequest(ctx context.Context, options if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -218,7 +218,7 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. func (client *ShareClient) ChangeLease(ctx context.Context, leaseID string, options *ShareClientChangeLeaseOptions) (ShareClientChangeLeaseResponse, error) { @@ -257,7 +257,7 @@ func (client *ShareClient) changeLeaseCreateRequest(ctx context.Context, leaseID if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -304,7 +304,7 @@ func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (Share // fails. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. func (client *ShareClient) Create(ctx context.Context, options *ShareClientCreateOptions) (ShareClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, options) @@ -346,7 +346,7 @@ func (client *ShareClient) createCreateRequest(ctx context.Context, options *Sha if options != nil && options.AccessTier != nil { req.Raw().Header["x-ms-access-tier"] = []string{string(*options.AccessTier)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.EnabledProtocols != nil { req.Raw().Header["x-ms-enabled-protocols"] = []string{*options.EnabledProtocols} } @@ -389,7 +389,7 @@ func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClien // CreatePermission - Create a permission (a security descriptor). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - sharePermission - A permission (a security descriptor) at the share level. // - options - ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. func (client *ShareClient) CreatePermission(ctx context.Context, sharePermission SharePermission, options *ShareClientCreatePermissionOptions) (ShareClientCreatePermissionResponse, error) { @@ -420,7 +420,7 @@ func (client *ShareClient) createPermissionCreateRequest(ctx context.Context, sh reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -456,7 +456,7 @@ func (client *ShareClient) createPermissionHandleResponse(resp *http.Response) ( // CreateSnapshot - Creates a read-only snapshot of a share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. func (client *ShareClient) CreateSnapshot(ctx context.Context, options *ShareClientCreateSnapshotOptions) (ShareClientCreateSnapshotResponse, error) { req, err := client.createSnapshotCreateRequest(ctx, options) @@ -493,7 +493,7 @@ func (client *ShareClient) createSnapshotCreateRequest(ctx context.Context, opti } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -534,7 +534,7 @@ func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (Sh // contained within it are later deleted during garbage collection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) Delete(ctx context.Context, options *ShareClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientDeleteResponse, error) { @@ -567,7 +567,7 @@ func (client *ShareClient) deleteCreateRequest(ctx context.Context, options *Sha reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.DeleteSnapshots != nil { req.Raw().Header["x-ms-delete-snapshots"] = []string{string(*options.DeleteSnapshots)} } @@ -600,7 +600,7 @@ func (client *ShareClient) deleteHandleResponse(resp *http.Response) (ShareClien // GetAccessPolicy - Returns information about stored access policies specified on the share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetAccessPolicy(ctx context.Context, options *ShareClientGetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetAccessPolicyResponse, error) { @@ -631,7 +631,7 @@ func (client *ShareClient) getAccessPolicyCreateRequest(ctx context.Context, opt reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -674,7 +674,7 @@ func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (S // GetPermission - Returns the permission (security descriptor) for a given key // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - filePermissionKey - Key of the permission to be set for the directory/file. // - options - ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. func (client *ShareClient) GetPermission(ctx context.Context, filePermissionKey string, options *ShareClientGetPermissionOptions) (ShareClientGetPermissionResponse, error) { @@ -706,7 +706,7 @@ func (client *ShareClient) getPermissionCreateRequest(ctx context.Context, fileP } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-file-permission-key"] = []string{filePermissionKey} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -740,7 +740,7 @@ func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (Sha // data returned does not include the share's list of files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetProperties(ctx context.Context, options *ShareClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetPropertiesResponse, error) { @@ -773,7 +773,7 @@ func (client *ShareClient) getPropertiesCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -896,7 +896,7 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha // GetStatistics - Retrieves statistics related to the share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetStatistics(ctx context.Context, options *ShareClientGetStatisticsOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetStatisticsResponse, error) { @@ -927,7 +927,7 @@ func (client *ShareClient) getStatisticsCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -971,7 +971,7 @@ func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (Sha // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. func (client *ShareClient) ReleaseLease(ctx context.Context, leaseID string, options *ShareClientReleaseLeaseOptions) (ShareClientReleaseLeaseResponse, error) { @@ -1007,7 +1007,7 @@ func (client *ShareClient) releaseLeaseCreateRequest(ctx context.Context, leaseI req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"release"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1051,7 +1051,7 @@ func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (Shar // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. func (client *ShareClient) RenewLease(ctx context.Context, leaseID string, options *ShareClientRenewLeaseOptions) (ShareClientRenewLeaseResponse, error) { @@ -1087,7 +1087,7 @@ func (client *ShareClient) renewLeaseCreateRequest(ctx context.Context, leaseID req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"renew"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1133,7 +1133,7 @@ func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareC // Restore - Restores a previously deleted Share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. func (client *ShareClient) Restore(ctx context.Context, options *ShareClientRestoreOptions) (ShareClientRestoreResponse, error) { req, err := client.restoreCreateRequest(ctx, options) @@ -1163,7 +1163,7 @@ func (client *ShareClient) restoreCreateRequest(ctx context.Context, options *Sh reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1212,7 +1212,7 @@ func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClie // SetAccessPolicy - Sets a stored access policy for use with shared access signatures. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - shareACL - The ACL for the share. // - options - ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. @@ -1244,7 +1244,7 @@ func (client *ShareClient) setAccessPolicyCreateRequest(ctx context.Context, sha reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1291,7 +1291,7 @@ func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (S // SetMetadata - Sets one or more user-defined name-value pairs for the specified share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetMetadata(ctx context.Context, options *ShareClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetMetadataResponse, error) { @@ -1329,7 +1329,7 @@ func (client *ShareClient) setMetadataCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1369,7 +1369,7 @@ func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (Share // SetProperties - Sets properties for the specified share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetProperties(ctx context.Context, options *ShareClientSetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetPropertiesResponse, error) { @@ -1400,7 +1400,7 @@ func (client *ShareClient) setPropertiesCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Quota != nil { req.Raw().Header["x-ms-share-quota"] = []string{strconv.FormatInt(int64(*options.Quota), 10)} } From c4d16531baf5bd5bd09febf52480395114e70e8a Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Mon, 18 Dec 2023 11:42:23 +0530 Subject: [PATCH 2/5] azfile: Upload range from URL using OAuth tests (#22145) --- sdk/storage/azfile/CHANGELOG.md | 2 + sdk/storage/azfile/file/client_test.go | 174 +++++++++++++++++++++-- sdk/storage/azfile/file/examples_test.go | 3 +- 3 files changed, 162 insertions(+), 17 deletions(-) diff --git a/sdk/storage/azfile/CHANGELOG.md b/sdk/storage/azfile/CHANGELOG.md index 390a176fd2a2..37a2f95a0bdc 100644 --- a/sdk/storage/azfile/CHANGELOG.md +++ b/sdk/storage/azfile/CHANGELOG.md @@ -9,6 +9,8 @@ ### Bugs Fixed +* Fixed a bug where `UploadRangeFromURL` using OAuth was returning error. + ### Other Changes diff --git a/sdk/storage/azfile/file/client_test.go b/sdk/storage/azfile/file/client_test.go index 74648a877a0f..c61f85e9a51d 100644 --- a/sdk/storage/azfile/file/client_test.go +++ b/sdk/storage/azfile/file/client_test.go @@ -31,7 +31,6 @@ import ( "github.com/stretchr/testify/suite" "hash/crc64" "io" - "io/ioutil" "net/http" "os" "strings" @@ -891,7 +890,7 @@ func (f *FileRecordedTestsSuite) TestFileStartCopyDestEmpty() { _require.NoError(err) // Read the file data to verify the copy - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) defer func() { err = resp.Body.Close() _require.NoError(err) @@ -1491,7 +1490,7 @@ func (f *FileUnrecordedTestsSuite) TestFileStartCopyUsingSASSrc() { dResp, err := copyFileClient.DownloadStream(context.Background(), nil) _require.NoError(err) - data, err := ioutil.ReadAll(dResp.Body) + data, err := io.ReadAll(dResp.Body) defer func() { err = dResp.Body.Close() _require.NoError(err) @@ -1928,7 +1927,76 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLCopySourceAuthBlob( }) _require.NoError(err) - data, err := ioutil.ReadAll(dResp.Body) + data, err := io.ReadAll(dResp.Body) + defer func() { + err = dResp.Body.Close() + _require.NoError(err) + }() + + _require.EqualValues(data, content) +} + +func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLCopySourceAuthFile() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + // Getting token + accessToken, err := cred.GetToken(context.Background(), policy.TokenRequestOptions{Scopes: []string{"https://storage.azure.com/.default"}}) + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + var fileSize int64 = 1024 * 10 + contentSize := 1024 * 8 // 8KB + _, content := testcommon.GenerateData(contentSize) + body := bytes.NewReader(content) + rsc := streaming.NopCloser(body) + contentCRC64 := crc64.Checksum(content, shared.CRC64Table) + + srcFClient := shareClient.NewRootDirectoryClient().NewFileClient("src" + testcommon.GenerateFileName(testName)) + _, err = srcFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + gResp, err := srcFClient.GetProperties(context.Background(), nil) + _require.NoError(err) + _require.Equal(*gResp.ContentLength, fileSize) + + _, err = srcFClient.UploadRange(context.Background(), 0, rsc, nil) + _require.NoError(err) + + destFileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/dest" + testcommon.GenerateFileName(testName) + destFClient, err := file.NewClient(destFileURL, cred, &file.ClientOptions{FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup)}) + _require.NoError(err) + + _, err = destFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + uResp, err := destFClient.UploadRangeFromURL(context.Background(), srcFClient.URL(), 0, 0, int64(contentSize), &file.UploadRangeFromURLOptions{ + SourceContentValidation: file.SourceContentValidationTypeCRC64(contentCRC64), + CopySourceAuthorization: to.Ptr("Bearer " + accessToken.Token), + }) + _require.NoError(err) + _require.NotNil(uResp.XMSContentCRC64) + _require.EqualValues(binary.LittleEndian.Uint64(uResp.XMSContentCRC64), contentCRC64) + + // validate the content uploaded + dResp, err := destFClient.DownloadStream(context.Background(), &file.DownloadStreamOptions{ + Range: file.HTTPRange{Offset: 0, Count: int64(contentSize)}, + }) + _require.NoError(err) + + data, err := io.ReadAll(dResp.Body) defer func() { err = dResp.Body.Close() _require.NoError(err) @@ -2079,7 +2147,7 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadFile() { content := make([]byte, fileSize) _, err = rand.Read(content) _require.NoError(err) - err = ioutil.WriteFile("testFile", content, 0644) + err = os.WriteFile("testFile", content, 0644) _require.NoError(err) defer func() { @@ -2340,7 +2408,7 @@ func (f *FileRecordedTestsSuite) TestUploadDownloadDefaultNonDefaultMD5() { _require.NotNil(resp.ContentMD5) _require.Equal(*resp.ContentType, "application/octet-stream") - downloadedData, err := ioutil.ReadAll(resp.Body) + downloadedData, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[:1024]) @@ -2363,7 +2431,7 @@ func (f *FileRecordedTestsSuite) TestUploadDownloadDefaultNonDefaultMD5() { _require.Equal(*resp.ContentLanguage, "test") // Note: when it's downloading range, range's MD5 is returned, when set rangeGetContentMD5=true, currently set it to false, so should be empty - downloadedData, err = ioutil.ReadAll(resp.Body) + downloadedData, err = io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[1024:]) @@ -2393,7 +2461,7 @@ func (f *FileRecordedTestsSuite) TestUploadDownloadDefaultNonDefaultMD5() { _require.EqualValues(resp.ContentMD5, pResp.ContentMD5) // Note: This case is inted to get entire fClient, entire file's MD5 will be returned. _require.Nil(resp.FileContentMD5) // Note: FileContentMD5 is returned, only when range is specified explicitly. - downloadedData, err = ioutil.ReadAll(resp.Body) + downloadedData, err = io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[:]) @@ -2471,7 +2539,7 @@ func (f *FileRecordedTestsSuite) TestFileDownloadDataEntireFile() { _require.NoError(err) // Specifying a count of 0 results in the value being ignored - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(string(data), testcommon.FileDefaultData) } @@ -2496,7 +2564,7 @@ func (f *FileRecordedTestsSuite) TestFileDownloadDataCountExact() { }) _require.NoError(err) - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(string(data), testcommon.FileDefaultData) } @@ -2521,7 +2589,7 @@ func (f *FileRecordedTestsSuite) TestFileDownloadDataCountOutOfRange() { }) _require.NoError(err) - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(string(data), testcommon.FileDefaultData) } @@ -2613,7 +2681,7 @@ func (f *FileRecordedTestsSuite) TestFileUploadRangeTransactionalMD5() { _require.NoError(err) _require.Equal(*resp.ContentLength, int64(2048)) - downloadedData, err := ioutil.ReadAll(resp.Body) + downloadedData, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[:]) } @@ -2854,7 +2922,7 @@ func (f *FileRecordedTestsSuite) TestClearRangeNonDefaultCount() { dResp, err := fClient.DownloadStream(context.Background(), nil) _require.NoError(err) - _bytes, err := ioutil.ReadAll(dResp.Body) + _bytes, err := io.ReadAll(dResp.Body) _require.NoError(err) _require.EqualValues(_bytes, []byte{0}) } @@ -3094,7 +3162,7 @@ func (f *FileRecordedTestsSuite) TestFileUploadDownloadSmallFile() { // create local file _, content := testcommon.GenerateData(int(fileSize)) srcFileName := "testFileUpload" - err = ioutil.WriteFile(srcFileName, content, 0644) + err = os.WriteFile(srcFileName, content, 0644) _require.NoError(err) defer func() { err = os.Remove(srcFileName) @@ -3613,6 +3681,82 @@ func (f *FileRecordedTestsSuite) TestFileRenameUsingOAuth() { testcommon.ValidateFileErrorCode(_require, err, fileerror.ResourceNotFound) } +func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLUsingOAuth() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + sharedKeyCred, err := testcommon.GetGenericSharedKeyCredential(testcommon.TestAccountDefault) + _require.NoError(err) + + tokenCred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + var fileSize int64 = 1024 * 10 + contentSize := 1024 * 8 // 8KB + _, content := testcommon.GenerateData(contentSize) + body := bytes.NewReader(content) + rsc := streaming.NopCloser(body) + contentCRC64 := crc64.Checksum(content, shared.CRC64Table) + + srcFileName := "src" + testcommon.GenerateFileName(testName) + srcFClient := shareClient.NewRootDirectoryClient().NewFileClient(srcFileName) + _, err = srcFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + _, err = srcFClient.UploadRange(context.Background(), 0, rsc, nil) + _require.NoError(err) + + perms := sas.FilePermissions{Read: true, Write: true} + sasQueryParams, err := sas.SignatureValues{ + Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP) + ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration + ShareName: shareName, + FilePath: srcFileName, + Permissions: perms.String(), + }.SignWithSharedKey(sharedKeyCred) + _require.NoError(err) + + srcFileSAS := srcFClient.URL() + "?" + sasQueryParams.Encode() + + destFileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/dest" + testcommon.GenerateFileName(testName) + destFClient, err := file.NewClient(destFileURL, tokenCred, &file.ClientOptions{FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup)}) + _require.NoError(err) + + _, err = destFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + uResp, err := destFClient.UploadRangeFromURL(context.Background(), srcFileSAS, 0, 0, int64(contentSize), &file.UploadRangeFromURLOptions{ + SourceContentValidation: file.SourceContentValidationTypeCRC64(contentCRC64), + }) + _require.NoError(err) + _require.NotNil(uResp.XMSContentCRC64) + _require.EqualValues(binary.LittleEndian.Uint64(uResp.XMSContentCRC64), contentCRC64) + + // validate the content uploaded + dResp, err := destFClient.DownloadStream(context.Background(), &file.DownloadStreamOptions{ + Range: file.HTTPRange{Offset: 0, Count: int64(contentSize)}, + }) + _require.NoError(err) + + data, err := io.ReadAll(dResp.Body) + defer func() { + err = dResp.Body.Close() + _require.NoError(err) + }() + + _require.EqualValues(data, content) +} + func (f *FileRecordedTestsSuite) TestFileRenameDifferentDir() { _require := require.New(f.T()) testName := f.T().Name() @@ -4152,7 +4296,7 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLTrailingDot() { }) _require.NoError(err) - data, err := ioutil.ReadAll(dResp.Body) + data, err := io.ReadAll(dResp.Body) defer func() { err = dResp.Body.Close() _require.NoError(err) diff --git a/sdk/storage/azfile/file/examples_test.go b/sdk/storage/azfile/file/examples_test.go index fe9556abbda3..7795df8e33c4 100644 --- a/sdk/storage/azfile/file/examples_test.go +++ b/sdk/storage/azfile/file/examples_test.go @@ -19,7 +19,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/service" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/share" "io" - "io/ioutil" "log" "os" "strings" @@ -477,7 +476,7 @@ func Example_fileClient_UploadFile() { handleError(err) _, content := generateData(int(fileSize)) - err = ioutil.WriteFile(srcFileName, content, 0644) + err = os.WriteFile(srcFileName, content, 0644) handleError(err) defer func() { err = os.Remove(srcFileName) From 2897bb5b86696172b7404e9d3925078245129765 Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Fri, 22 Dec 2023 15:42:20 +0530 Subject: [PATCH 3/5] azfile: Add support for AAD audience (#22163) --- sdk/storage/azfile/CHANGELOG.md | 3 + sdk/storage/azfile/assets.json | 2 +- sdk/storage/azfile/directory/client.go | 3 +- sdk/storage/azfile/directory/client_test.go | 123 ++++++++++++++++++-- sdk/storage/azfile/file/client.go | 3 +- sdk/storage/azfile/file/client_test.go | 123 ++++++++++++++++++-- sdk/storage/azfile/internal/base/clients.go | 29 ++++- sdk/storage/azfile/service/client.go | 3 +- sdk/storage/azfile/service/client_test.go | 35 ++++++ sdk/storage/azfile/share/client.go | 3 +- sdk/storage/azfile/share/client_test.go | 105 +++++++++++++++++ 11 files changed, 404 insertions(+), 28 deletions(-) diff --git a/sdk/storage/azfile/CHANGELOG.md b/sdk/storage/azfile/CHANGELOG.md index 37a2f95a0bdc..973dbcf87a93 100644 --- a/sdk/storage/azfile/CHANGELOG.md +++ b/sdk/storage/azfile/CHANGELOG.md @@ -5,6 +5,9 @@ ### Features Added +* Updated service version to `2023-11-03`. +* Added support for Audience when OAuth is used. + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/storage/azfile/assets.json b/sdk/storage/azfile/assets.json index 68320e470010..4c4caf344b81 100644 --- a/sdk/storage/azfile/assets.json +++ b/sdk/storage/azfile/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azfile", - "Tag": "go/storage/azfile_f1d39931a0" + "Tag": "go/storage/azfile_f80b868396" } diff --git a/sdk/storage/azfile/directory/client.go b/sdk/storage/azfile/directory/client.go index 34af659ddcc5..dc90bf7d8fd6 100644 --- a/sdk/storage/azfile/directory/client.go +++ b/sdk/storage/azfile/directory/client.go @@ -36,7 +36,8 @@ type Client base.Client[generated.DirectoryClient] // // Note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(directoryURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/directory/client_test.go b/sdk/storage/azfile/directory/client_test.go index fe4475d706be..6f952fe7aae2 100644 --- a/sdk/storage/azfile/directory/client_test.go +++ b/sdk/storage/azfile/directory/client_test.go @@ -39,27 +39,27 @@ func Test(t *testing.T) { } } -func (s *DirectoryRecordedTestsSuite) SetupSuite() { - s.proxy = testcommon.SetupSuite(&s.Suite) +func (d *DirectoryRecordedTestsSuite) SetupSuite() { + d.proxy = testcommon.SetupSuite(&d.Suite) } -func (s *DirectoryRecordedTestsSuite) TearDownSuite() { - testcommon.TearDownSuite(&s.Suite, s.proxy) +func (d *DirectoryRecordedTestsSuite) TearDownSuite() { + testcommon.TearDownSuite(&d.Suite, d.proxy) } -func (s *DirectoryRecordedTestsSuite) BeforeTest(suite string, test string) { - testcommon.BeforeTest(s.T(), suite, test) +func (d *DirectoryRecordedTestsSuite) BeforeTest(suite string, test string) { + testcommon.BeforeTest(d.T(), suite, test) } -func (s *DirectoryRecordedTestsSuite) AfterTest(suite string, test string) { - testcommon.AfterTest(s.T(), suite, test) +func (d *DirectoryRecordedTestsSuite) AfterTest(suite string, test string) { + testcommon.AfterTest(d.T(), suite, test) } -func (s *DirectoryUnrecordedTestsSuite) BeforeTest(suite string, test string) { +func (d *DirectoryUnrecordedTestsSuite) BeforeTest(suite string, test string) { } -func (s *DirectoryUnrecordedTestsSuite) AfterTest(suite string, test string) { +func (d *DirectoryUnrecordedTestsSuite) AfterTest(suite string, test string) { } @@ -2264,3 +2264,106 @@ func (d *DirectoryRecordedTestsSuite) TestListFileDirEncodedPrefix() { _require.Equal(*resp.Prefix, dirName) } } + +func (d *DirectoryRecordedTestsSuite) TestDirectoryClientDefaultAudience() { + _require := require.New(d.T()) + testName := d.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(d.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + dirName := testcommon.GenerateDirectoryName(testName) + dirURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + dirName + + options := &directory.ClientOptions{ + FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), + Audience: to.Ptr("https://storage.azure.com/"), + } + testcommon.SetClientOptions(d.T(), &options.ClientOptions) + dirClientAudience, err := directory.NewClient(dirURL, cred, options) + _require.NoError(err) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = dirClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (d *DirectoryRecordedTestsSuite) TestDirectoryClientCustomAudience() { + _require := require.New(d.T()) + testName := d.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(d.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + dirName := testcommon.GenerateDirectoryName(testName) + dirURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + dirName + + options := &directory.ClientOptions{ + FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), + Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + } + testcommon.SetClientOptions(d.T(), &options.ClientOptions) + dirClientAudience, err := directory.NewClient(dirURL, cred, options) + _require.NoError(err) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = dirClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (d *DirectoryRecordedTestsSuite) TestDirectoryAudienceNegative() { + _require := require.New(d.T()) + testName := d.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(d.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + dirName := testcommon.GenerateDirectoryName(testName) + dirURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + dirName + + options := &directory.ClientOptions{ + FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), + Audience: to.Ptr("https://badaudience.file.core.windows.net"), + } + testcommon.SetClientOptions(d.T(), &options.ClientOptions) + dirClientAudience, err := directory.NewClient(dirURL, cred, options) + _require.NoError(err) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.Error(err) + testcommon.ValidateFileErrorCode(_require, err, fileerror.AuthenticationFailed) +} diff --git a/sdk/storage/azfile/file/client.go b/sdk/storage/azfile/file/client.go index f1d0d3232af8..fc712327fc73 100644 --- a/sdk/storage/azfile/file/client.go +++ b/sdk/storage/azfile/file/client.go @@ -41,7 +41,8 @@ type Client base.Client[generated.FileClient] // // Note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(fileURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/file/client_test.go b/sdk/storage/azfile/file/client_test.go index c61f85e9a51d..f7aa36c5ab7a 100644 --- a/sdk/storage/azfile/file/client_test.go +++ b/sdk/storage/azfile/file/client_test.go @@ -51,27 +51,27 @@ func Test(t *testing.T) { } } -func (s *FileRecordedTestsSuite) SetupSuite() { - s.proxy = testcommon.SetupSuite(&s.Suite) +func (f *FileRecordedTestsSuite) SetupSuite() { + f.proxy = testcommon.SetupSuite(&f.Suite) } -func (s *FileRecordedTestsSuite) TearDownSuite() { - testcommon.TearDownSuite(&s.Suite, s.proxy) +func (f *FileRecordedTestsSuite) TearDownSuite() { + testcommon.TearDownSuite(&f.Suite, f.proxy) } -func (s *FileRecordedTestsSuite) BeforeTest(suite string, test string) { - testcommon.BeforeTest(s.T(), suite, test) +func (f *FileRecordedTestsSuite) BeforeTest(suite string, test string) { + testcommon.BeforeTest(f.T(), suite, test) } -func (s *FileRecordedTestsSuite) AfterTest(suite string, test string) { - testcommon.AfterTest(s.T(), suite, test) +func (f *FileRecordedTestsSuite) AfterTest(suite string, test string) { + testcommon.AfterTest(f.T(), suite, test) } -func (s *FileUnrecordedTestsSuite) BeforeTest(suite string, test string) { +func (f *FileUnrecordedTestsSuite) BeforeTest(suite string, test string) { } -func (s *FileUnrecordedTestsSuite) AfterTest(suite string, test string) { +func (f *FileUnrecordedTestsSuite) AfterTest(suite string, test string) { } @@ -4521,4 +4521,107 @@ func TestServiceVersion(t *testing.T) { require.NoError(t, err) } +func (f *FileRecordedTestsSuite) TestFileClientDefaultAudience() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + fileName := testcommon.GenerateFileName(testName) + fileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + fileName + + options := &file.ClientOptions{ + FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), + Audience: to.Ptr("https://storage.azure.com/"), + } + testcommon.SetClientOptions(f.T(), &options.ClientOptions) + fileClientAudience, err := file.NewClient(fileURL, cred, options) + _require.NoError(err) + + _, err = fileClientAudience.Create(context.Background(), 2048, nil) + _require.NoError(err) + + _, err = fileClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (f *FileRecordedTestsSuite) TestFileClientCustomAudience() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + fileName := testcommon.GenerateFileName(testName) + fileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + fileName + + options := &file.ClientOptions{ + FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), + Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + } + testcommon.SetClientOptions(f.T(), &options.ClientOptions) + fileClientAudience, err := file.NewClient(fileURL, cred, options) + _require.NoError(err) + + _, err = fileClientAudience.Create(context.Background(), 2048, nil) + _require.NoError(err) + + _, err = fileClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (f *FileRecordedTestsSuite) TestFileClientAudienceNegative() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + fileName := testcommon.GenerateFileName(testName) + fileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + fileName + + options := &file.ClientOptions{ + FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), + Audience: to.Ptr("https://badaudience.file.core.windows.net"), + } + testcommon.SetClientOptions(f.T(), &options.ClientOptions) + fileClientAudience, err := file.NewClient(fileURL, cred, options) + _require.NoError(err) + + _, err = fileClientAudience.Create(context.Background(), 2048, nil) + _require.Error(err) + testcommon.ValidateFileErrorCode(_require, err, fileerror.AuthenticationFailed) +} + // TODO: Add tests for retry header options diff --git a/sdk/storage/azfile/internal/base/clients.go b/sdk/storage/azfile/internal/base/clients.go index 101a58a5f85e..8d081a73c4b9 100644 --- a/sdk/storage/azfile/internal/base/clients.go +++ b/sdk/storage/azfile/internal/base/clients.go @@ -11,15 +11,30 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/shared" + "strings" ) // ClientOptions contains the optional parameters when creating a Client. type ClientOptions struct { azcore.ClientOptions - AllowTrailingDot *bool - FileRequestIntent *generated.ShareTokenIntent + + // AllowTrailingDot specifies if a trailing dot present in request url should be trimmed or not. + AllowTrailingDot *bool + + // FileRequestIntent is required when using TokenCredential for authentication. + // Acceptable value is backup. + FileRequestIntent *generated.ShareTokenIntent + + // AllowSourceTrailingDot specifies if a trailing dot present in source url should be trimmed or not. AllowSourceTrailingDot *bool - pipelineOptions *runtime.PipelineOptions + + // Audience to use when requesting tokens for Azure Active Directory authentication. + // Only has an effect when credential is of type TokenCredential. The value could be + // https://storage.azure.com/ (default) or https://.file.core.windows.net. + Audience *string + + pipelineOptions *runtime.PipelineOptions } type Client[T any] struct { @@ -48,6 +63,14 @@ func SetPipelineOptions(clOpts *ClientOptions, plOpts *runtime.PipelineOptions) clOpts.pipelineOptions = plOpts } +func GetAudience(clOpts *ClientOptions) string { + if clOpts == nil || clOpts.Audience == nil { + return shared.TokenScope + } else { + return strings.TrimRight(*clOpts.Audience, "/") + "/.default" + } +} + func NewServiceClient(serviceURL string, azClient *azcore.Client, sharedKey *exported.SharedKeyCredential, options *ClientOptions) *Client[generated.ServiceClient] { return &Client[generated.ServiceClient]{ inner: generated.NewServiceClient(serviceURL, azClient), diff --git a/sdk/storage/azfile/service/client.go b/sdk/storage/azfile/service/client.go index aec7d058169c..1fd1f819313e 100644 --- a/sdk/storage/azfile/service/client.go +++ b/sdk/storage/azfile/service/client.go @@ -38,7 +38,8 @@ type Client base.Client[generated.ServiceClient] // This constructor exists to allow the construction of a share.Client that has token credential authentication. // Also note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/service/client_test.go b/sdk/storage/azfile/service/client_test.go index 9f0521dd6e0f..7a6c0c2b3481 100644 --- a/sdk/storage/azfile/service/client_test.go +++ b/sdk/storage/azfile/service/client_test.go @@ -629,3 +629,38 @@ func (s *ServiceRecordedTestsSuite) TestPremiumAccountListShares() { } } } + +func (s *ServiceRecordedTestsSuite) TestServiceClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + // create service client using token credential + options := &service.ClientOptions{ + FileRequestIntent: to.Ptr(service.ShareTokenIntentBackup), + Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + svcClientAudience, err := service.NewClient("https://"+accountName+".file.core.windows.net/", cred, options) + _require.NoError(err) + + dirClientAudience := svcClientAudience.NewShareClient(shareName).NewDirectoryClient(testcommon.GenerateDirectoryName(testName)) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = dirClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} diff --git a/sdk/storage/azfile/share/client.go b/sdk/storage/azfile/share/client.go index 466774c548dc..db30b3f48c16 100644 --- a/sdk/storage/azfile/share/client.go +++ b/sdk/storage/azfile/share/client.go @@ -37,7 +37,8 @@ type Client base.Client[generated.ShareClient] // Note that the only share-level operations that support token credential authentication are CreatePermission and GetPermission. // Also note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(shareURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/share/client_test.go b/sdk/storage/azfile/share/client_test.go index 9d86d5d9a46e..b75107dff41f 100644 --- a/sdk/storage/azfile/share/client_test.go +++ b/sdk/storage/azfile/share/client_test.go @@ -1627,3 +1627,108 @@ func (s *ShareRecordedTestsSuite) TestPremiumShareBandwidth() { _require.NotNil(response.NextAllowedQuotaDowngradeTime) _require.Greater(*response.ProvisionedBandwidthMiBps, (int32)(0)) } + +func (s *ShareRecordedTestsSuite) TestShareClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + options := &share.ClientOptions{ + FileRequestIntent: to.Ptr(share.TokenIntentBackup), + Audience: to.Ptr("https://storage.azure.com/"), + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) + _require.NoError(err) + + // Create a permission and check that it's not empty. + createResp, err := shareClientAudience.CreatePermission(context.Background(), testcommon.SampleSDDL, nil) + _require.NoError(err) + _require.NotNil(createResp.FilePermissionKey) + _require.NotEmpty(*createResp.FilePermissionKey) + + getResp, err := shareClientAudience.GetPermission(context.Background(), *createResp.FilePermissionKey, nil) + _require.NoError(err) + _require.NotNil(getResp.Permission) + _require.NotEmpty(*getResp.Permission) +} + +func (s *ShareRecordedTestsSuite) TestShareClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + options := &share.ClientOptions{ + FileRequestIntent: to.Ptr(share.TokenIntentBackup), + Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) + _require.NoError(err) + + // Create a permission and check that it's not empty. + createResp, err := shareClientAudience.CreatePermission(context.Background(), testcommon.SampleSDDL, nil) + _require.NoError(err) + _require.NotNil(createResp.FilePermissionKey) + _require.NotEmpty(*createResp.FilePermissionKey) + + getResp, err := shareClientAudience.GetPermission(context.Background(), *createResp.FilePermissionKey, nil) + _require.NoError(err) + _require.NotNil(getResp.Permission) + _require.NotEmpty(*getResp.Permission) +} + +func (s *ShareRecordedTestsSuite) TestShareClientAudienceNegative() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + options := &share.ClientOptions{ + FileRequestIntent: to.Ptr(share.TokenIntentBackup), + Audience: to.Ptr("https://badaudience.file.core.windows.net"), + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) + _require.NoError(err) + + // Create a permission and check that it's not empty. + _, err = shareClientAudience.CreatePermission(context.Background(), testcommon.SampleSDDL, nil) + _require.Error(err) + testcommon.ValidateFileErrorCode(_require, err, fileerror.AuthenticationFailed) +} From d83b052c3f1eff420bc636acc3231aa093cdae21 Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Fri, 29 Dec 2023 15:59:20 +0530 Subject: [PATCH 4/5] azfile: Readme and code generator update (#22181) --- sdk/storage/azfile/README.md | 2 +- .../azfile/internal/generated/autorest.md | 3 +- .../azfile/internal/generated/models.go | 14 +- .../azfile/internal/generated/zz_constants.go | 3 +- .../internal/generated/zz_directory_client.go | 427 ++++---- .../internal/generated/zz_file_client.go | 929 +++++++++--------- .../azfile/internal/generated/zz_models.go | 722 +------------- .../internal/generated/zz_models_serde.go | 69 +- .../azfile/internal/generated/zz_options.go | 852 ++++++++++++++++ .../internal/generated/zz_response_types.go | 83 +- .../internal/generated/zz_service_client.go | 25 +- .../internal/generated/zz_share_client.go | 568 ++++++----- .../internal/generated/zz_time_rfc1123.go | 23 +- .../internal/generated/zz_time_rfc3339.go | 35 +- .../internal/generated/zz_xml_helper.go | 26 +- 15 files changed, 2034 insertions(+), 1747 deletions(-) create mode 100644 sdk/storage/azfile/internal/generated/zz_options.go diff --git a/sdk/storage/azfile/README.md b/sdk/storage/azfile/README.md index 9d543493bf30..67e9d5c360ec 100644 --- a/sdk/storage/azfile/README.md +++ b/sdk/storage/azfile/README.md @@ -1,6 +1,6 @@ # Azure File Storage SDK for Go -> Service Version: 2022-11-02 +> Service Version: 2023-11-03 Azure File Shares offers fully managed file shares in the cloud that are accessible via the industry standard [Server Message Block (SMB) protocol](https://docs.microsoft.com/windows/desktop/FileIO/microsoft-smb-protocol-and-cifs-protocol-overview). diff --git a/sdk/storage/azfile/internal/generated/autorest.md b/sdk/storage/azfile/internal/generated/autorest.md index 9572da0256e2..f887159b7f0b 100644 --- a/sdk/storage/azfile/internal/generated/autorest.md +++ b/sdk/storage/azfile/internal/generated/autorest.md @@ -19,7 +19,7 @@ modelerfour: seal-single-value-enum-by-default: true lenient-model-deduplication: true export-clients: true -use: "@autorest/go@4.0.0-preview.49" +use: "@autorest/go@4.0.0-preview.61" ``` ### Updating service version to 2023-11-03 @@ -160,6 +160,7 @@ directive: - zz_directory_client.go - zz_file_client.go - zz_models.go + - zz_options.go where: $ transform: >- return $. diff --git a/sdk/storage/azfile/internal/generated/models.go b/sdk/storage/azfile/internal/generated/models.go index 3aeb9ae89d49..36a671cc6a86 100644 --- a/sdk/storage/azfile/internal/generated/models.go +++ b/sdk/storage/azfile/internal/generated/models.go @@ -38,12 +38,12 @@ func (h Handle) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias Handle aux := &struct { *alias - LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` - OpenTime *timeRFC1123 `xml:"OpenTime"` + LastReconnectTime *dateTimeRFC1123 `xml:"LastReconnectTime"` + OpenTime *dateTimeRFC1123 `xml:"OpenTime"` }{ alias: (*alias)(&h), - LastReconnectTime: (*timeRFC1123)(h.LastReconnectTime), - OpenTime: (*timeRFC1123)(h.OpenTime), + LastReconnectTime: (*dateTimeRFC1123)(h.LastReconnectTime), + OpenTime: (*dateTimeRFC1123)(h.OpenTime), } return enc.EncodeElement(aux, start) } @@ -53,9 +53,9 @@ func (h *Handle) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias Handle aux := &struct { *alias - Path *StringEncoded `xml:"Path"` - LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` - OpenTime *timeRFC1123 `xml:"OpenTime"` + Path *StringEncoded `xml:"Path"` + LastReconnectTime *dateTimeRFC1123 `xml:"LastReconnectTime"` + OpenTime *dateTimeRFC1123 `xml:"OpenTime"` }{ alias: (*alias)(h), } diff --git a/sdk/storage/azfile/internal/generated/zz_constants.go b/sdk/storage/azfile/internal/generated/zz_constants.go index 9df8784a97a1..edbc1a5c1c74 100644 --- a/sdk/storage/azfile/internal/generated/zz_constants.go +++ b/sdk/storage/azfile/internal/generated/zz_constants.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated diff --git a/sdk/storage/azfile/internal/generated/zz_directory_client.go b/sdk/storage/azfile/internal/generated/zz_directory_client.go index 5a13781a835b..41d3367a1dd5 100644 --- a/sdk/storage/azfile/internal/generated/zz_directory_client.go +++ b/sdk/storage/azfile/internal/generated/zz_directory_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -38,18 +37,21 @@ type DirectoryClient struct { // Generated from API version 2023-11-03 // - options - DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. func (client *DirectoryClient) Create(ctx context.Context, options *DirectoryClientCreateOptions) (DirectoryClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, options) if err != nil { return DirectoryClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return DirectoryClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -103,22 +105,6 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, options // createHandleResponse handles the Create response. func (client *DirectoryClient) createHandleResponse(resp *http.Response) (DirectoryClientCreateResponse, error) { result := DirectoryClientCreateResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientCreateResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -126,19 +112,19 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientCreateResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientCreateResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -146,6 +132,9 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -153,18 +142,31 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientCreateResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientCreateResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -175,18 +177,21 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct // Generated from API version 2023-11-03 // - options - DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. func (client *DirectoryClient) Delete(ctx context.Context, options *DirectoryClientDeleteOptions) (DirectoryClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, options) if err != nil { return DirectoryClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return DirectoryClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -215,12 +220,6 @@ func (client *DirectoryClient) deleteCreateRequest(ctx context.Context, options // deleteHandleResponse handles the Delete response. func (client *DirectoryClient) deleteHandleResponse(resp *http.Response) (DirectoryClientDeleteResponse, error) { result := DirectoryClientDeleteResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -228,6 +227,12 @@ func (client *DirectoryClient) deleteHandleResponse(resp *http.Response) (Direct } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -240,18 +245,21 @@ func (client *DirectoryClient) deleteHandleResponse(resp *http.Response) (Direct // - options - DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles // method. func (client *DirectoryClient) ForceCloseHandles(ctx context.Context, handleID string, options *DirectoryClientForceCloseHandlesOptions) (DirectoryClientForceCloseHandlesResponse, error) { + var err error req, err := client.forceCloseHandlesCreateRequest(ctx, handleID, options) if err != nil { return DirectoryClientForceCloseHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientForceCloseHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientForceCloseHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientForceCloseHandlesResponse{}, err } - return client.forceCloseHandlesHandleResponse(resp) + resp, err := client.forceCloseHandlesHandleResponse(httpResp) + return resp, err } // forceCloseHandlesCreateRequest creates the ForceCloseHandles request. @@ -290,12 +298,6 @@ func (client *DirectoryClient) forceCloseHandlesCreateRequest(ctx context.Contex // forceCloseHandlesHandleResponse handles the ForceCloseHandles response. func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Response) (DirectoryClientForceCloseHandlesResponse, error) { result := DirectoryClientForceCloseHandlesResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -322,6 +324,12 @@ func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Respon } result.NumberOfHandlesFailedToClose = &numberOfHandlesFailedToClose } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -333,18 +341,21 @@ func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Respon // Generated from API version 2023-11-03 // - options - DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. func (client *DirectoryClient) GetProperties(ctx context.Context, options *DirectoryClientGetPropertiesOptions) (DirectoryClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -376,30 +387,6 @@ func (client *DirectoryClient) getPropertiesCreateRequest(ctx context.Context, o // getPropertiesHandleResponse handles the GetProperties response. func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) (DirectoryClientGetPropertiesResponse, error) { result := DirectoryClientGetPropertiesResponse{} - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientGetPropertiesResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -407,16 +394,19 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) } result.Date = &date } - if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientGetPropertiesResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientGetPropertiesResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -424,6 +414,9 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -431,21 +424,39 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientGetPropertiesResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -505,12 +516,6 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp if val := resp.Header.Get("Content-Type"); val != "" { result.ContentType = &val } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -518,6 +523,12 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsXML(resp, &result.ListFilesAndDirectoriesSegmentResponse); err != nil { return DirectoryClientListFilesAndDirectoriesSegmentResponse{}, err } @@ -530,18 +541,21 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp // Generated from API version 2023-11-03 // - options - DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. func (client *DirectoryClient) ListHandles(ctx context.Context, options *DirectoryClientListHandlesOptions) (DirectoryClientListHandlesResponse, error) { + var err error req, err := client.listHandlesCreateRequest(ctx, options) if err != nil { return DirectoryClientListHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientListHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientListHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientListHandlesResponse{}, err } - return client.listHandlesHandleResponse(resp) + resp, err := client.listHandlesHandleResponse(httpResp) + return resp, err } // listHandlesCreateRequest creates the ListHandles request. @@ -585,12 +599,6 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D if val := resp.Header.Get("Content-Type"); val != "" { result.ContentType = &val } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -598,6 +606,12 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsXML(resp, &result.ListHandlesResponse); err != nil { return DirectoryClientListHandlesResponse{}, err } @@ -616,18 +630,21 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D // method. // - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. func (client *DirectoryClient) Rename(ctx context.Context, renameSource string, options *DirectoryClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo) (DirectoryClientRenameResponse, error) { + var err error req, err := client.renameCreateRequest(ctx, renameSource, options, sourceLeaseAccessConditions, destinationLeaseAccessConditions, copyFileSMBInfo) if err != nil { return DirectoryClientRenameResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientRenameResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientRenameResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientRenameResponse{}, err } - return client.renameHandleResponse(resp) + resp, err := client.renameHandleResponse(httpResp) + return resp, err } // renameCreateRequest creates the Rename request. @@ -698,22 +715,6 @@ func (client *DirectoryClient) renameCreateRequest(ctx context.Context, renameSo // renameHandleResponse handles the Rename response. func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (DirectoryClientRenameResponse, error) { result := DirectoryClientRenameResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientRenameResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -721,19 +722,19 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientRenameResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -741,6 +742,9 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -748,18 +752,31 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientRenameResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -770,18 +787,21 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct // Generated from API version 2023-11-03 // - options - DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. func (client *DirectoryClient) SetMetadata(ctx context.Context, options *DirectoryClientSetMetadataOptions) (DirectoryClientSetMetadataResponse, error) { + var err error req, err := client.setMetadataCreateRequest(ctx, options) if err != nil { return DirectoryClientSetMetadataResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientSetMetadataResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientSetMetadataResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientSetMetadataResponse{}, err } - return client.setMetadataHandleResponse(resp) + resp, err := client.setMetadataHandleResponse(httpResp) + return resp, err } // setMetadataCreateRequest creates the SetMetadata request. @@ -818,15 +838,6 @@ func (client *DirectoryClient) setMetadataCreateRequest(ctx context.Context, opt // setMetadataHandleResponse handles the SetMetadata response. func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (DirectoryClientSetMetadataResponse, error) { result := DirectoryClientSetMetadataResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -834,6 +845,9 @@ func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (D } result.Date = &date } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) if err != nil { @@ -841,6 +855,12 @@ func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (D } result.IsServerEncrypted = &isServerEncrypted } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -850,18 +870,21 @@ func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (D // Generated from API version 2023-11-03 // - options - DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. func (client *DirectoryClient) SetProperties(ctx context.Context, options *DirectoryClientSetPropertiesOptions) (DirectoryClientSetPropertiesResponse, error) { + var err error req, err := client.setPropertiesCreateRequest(ctx, options) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientSetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientSetPropertiesResponse{}, err } - return client.setPropertiesHandleResponse(resp) + resp, err := client.setPropertiesHandleResponse(httpResp) + return resp, err } // setPropertiesCreateRequest creates the SetProperties request. @@ -909,22 +932,6 @@ func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, o // setPropertiesHandleResponse handles the SetProperties response. func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) (DirectoryClientSetPropertiesResponse, error) { result := DirectoryClientSetPropertiesResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientSetPropertiesResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -932,19 +939,19 @@ func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientSetPropertiesResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientSetPropertiesResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -952,6 +959,9 @@ func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -959,18 +969,31 @@ func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientSetPropertiesResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_file_client.go b/sdk/storage/azfile/internal/generated/zz_file_client.go index be104c8e1aa0..e8ce03fd2d10 100644 --- a/sdk/storage/azfile/internal/generated/zz_file_client.go +++ b/sdk/storage/azfile/internal/generated/zz_file_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -41,18 +40,21 @@ type FileClient struct { // - options - FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) AbortCopy(ctx context.Context, copyID string, options *FileClientAbortCopyOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientAbortCopyResponse, error) { + var err error req, err := client.abortCopyCreateRequest(ctx, copyID, options, leaseAccessConditions) if err != nil { return FileClientAbortCopyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientAbortCopyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return FileClientAbortCopyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return FileClientAbortCopyResponse{}, err } - return client.abortCopyHandleResponse(resp) + resp, err := client.abortCopyHandleResponse(httpResp) + return resp, err } // abortCopyCreateRequest creates the AbortCopy request. @@ -86,12 +88,6 @@ func (client *FileClient) abortCopyCreateRequest(ctx context.Context, copyID str // abortCopyHandleResponse handles the AbortCopy response. func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClientAbortCopyResponse, error) { result := FileClientAbortCopyResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -99,6 +95,12 @@ func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClie } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -111,18 +113,21 @@ func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClie // renew or change. // - options - FileClientAcquireLeaseOptions contains the optional parameters for the FileClient.AcquireLease method. func (client *FileClient) AcquireLease(ctx context.Context, duration int32, options *FileClientAcquireLeaseOptions) (FileClientAcquireLeaseResponse, error) { + var err error req, err := client.acquireLeaseCreateRequest(ctx, duration, options) if err != nil { return FileClientAcquireLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientAcquireLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientAcquireLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientAcquireLeaseResponse{}, err } - return client.acquireLeaseHandleResponse(resp) + resp, err := client.acquireLeaseHandleResponse(httpResp) + return resp, err } // acquireLeaseCreateRequest creates the AcquireLease request. @@ -159,6 +164,16 @@ func (client *FileClient) acquireLeaseCreateRequest(ctx context.Context, duratio // acquireLeaseHandleResponse handles the AcquireLease response. func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileClientAcquireLeaseResponse, error) { result := FileClientAcquireLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientAcquireLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -172,22 +187,12 @@ func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileC if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientAcquireLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -198,18 +203,21 @@ func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileC // - options - FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) BreakLease(ctx context.Context, options *FileClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientBreakLeaseResponse, error) { + var err error req, err := client.breakLeaseCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientBreakLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientBreakLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return FileClientBreakLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return FileClientBreakLeaseResponse{}, err } - return client.breakLeaseHandleResponse(resp) + resp, err := client.breakLeaseHandleResponse(httpResp) + return resp, err } // breakLeaseCreateRequest creates the BreakLease request. @@ -245,6 +253,16 @@ func (client *FileClient) breakLeaseCreateRequest(ctx context.Context, options * // breakLeaseHandleResponse handles the BreakLease response. func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileClientBreakLeaseResponse, error) { result := FileClientBreakLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientBreakLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -258,22 +276,12 @@ func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileCli if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientBreakLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -284,18 +292,21 @@ func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileCli // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. func (client *FileClient) ChangeLease(ctx context.Context, leaseID string, options *FileClientChangeLeaseOptions) (FileClientChangeLeaseResponse, error) { + var err error req, err := client.changeLeaseCreateRequest(ctx, leaseID, options) if err != nil { return FileClientChangeLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientChangeLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientChangeLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientChangeLeaseResponse{}, err } - return client.changeLeaseHandleResponse(resp) + resp, err := client.changeLeaseHandleResponse(httpResp) + return resp, err } // changeLeaseCreateRequest creates the ChangeLease request. @@ -332,6 +343,16 @@ func (client *FileClient) changeLeaseCreateRequest(ctx context.Context, leaseID // changeLeaseHandleResponse handles the ChangeLease response. func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileClientChangeLeaseResponse, error) { result := FileClientChangeLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientChangeLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -345,22 +366,12 @@ func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileCl if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientChangeLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -373,18 +384,21 @@ func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileCl // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Create(ctx context.Context, fileContentLength int64, options *FileClientCreateOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, fileContentLength, options, shareFileHTTPHeaders, leaseAccessConditions) if err != nil { return FileClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -460,22 +474,6 @@ func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLe // createHandleResponse handles the Create response. func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientCreateResponse, error) { result := FileClientCreateResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientCreateResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -483,19 +481,19 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return FileClientCreateResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientCreateResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -503,6 +501,9 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -510,18 +511,31 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return FileClientCreateResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientCreateResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -533,18 +547,21 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC // - options - FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Delete(ctx context.Context, options *FileClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return FileClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return FileClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -575,12 +592,6 @@ func (client *FileClient) deleteCreateRequest(ctx context.Context, options *File // deleteHandleResponse handles the Delete response. func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientDeleteResponse, error) { result := FileClientDeleteResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -588,6 +599,12 @@ func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientD } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -598,18 +615,21 @@ func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientD // - options - FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Download(ctx context.Context, options *FileClientDownloadOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDownloadResponse, error) { + var err error req, err := client.downloadCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientDownloadResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientDownloadResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusPartialContent) { - return FileClientDownloadResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusPartialContent) { + err = runtime.NewResponseError(httpResp) + return FileClientDownloadResponse{}, err } - return client.downloadHandleResponse(resp) + resp, err := client.downloadHandleResponse(httpResp) + return resp, err } // downloadCreateRequest creates the Download request. @@ -647,20 +667,20 @@ func (client *FileClient) downloadCreateRequest(ctx context.Context, options *Fi // downloadHandleResponse handles the Download response. func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClientDownloadResponse, error) { result := FileClientDownloadResponse{Body: resp.Body} - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientDownloadResponse{}, err - } - result.LastModified = &lastModified + if val := resp.Header.Get("Accept-Ranges"); val != "" { + result.AcceptRanges = &val } - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } + if val := resp.Header.Get("Cache-Control"); val != "" { + result.CacheControl = &val + } + if val := resp.Header.Get("Content-Disposition"); val != "" { + result.ContentDisposition = &val + } + if val := resp.Header.Get("Content-Encoding"); val != "" { + result.ContentEncoding = &val + } + if val := resp.Header.Get("Content-Language"); val != "" { + result.ContentLanguage = &val } if val := resp.Header.Get("Content-Length"); val != "" { contentLength, err := strconv.ParseInt(val, 10, 64) @@ -669,15 +689,6 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.ContentLength = &contentLength } - if val := resp.Header.Get("Content-Type"); val != "" { - result.ContentType = &val - } - if val := resp.Header.Get("Content-Range"); val != "" { - result.ContentRange = &val - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { @@ -685,33 +696,11 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("Content-Encoding"); val != "" { - result.ContentEncoding = &val - } - if val := resp.Header.Get("Cache-Control"); val != "" { - result.CacheControl = &val - } - if val := resp.Header.Get("Content-Disposition"); val != "" { - result.ContentDisposition = &val - } - if val := resp.Header.Get("Content-Language"); val != "" { - result.ContentLanguage = &val - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } - if val := resp.Header.Get("Accept-Ranges"); val != "" { - result.AcceptRanges = &val + if val := resp.Header.Get("Content-Range"); val != "" { + result.ContentRange = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientDownloadResponse{}, err - } - result.Date = &date + if val := resp.Header.Get("Content-Type"); val != "" { + result.ContentType = &val } if val := resp.Header.Get("x-ms-copy-completion-time"); val != "" { copyCompletionTime, err := time.Parse(time.RFC1123, val) @@ -720,9 +709,6 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.CopyCompletionTime = ©CompletionTime } - if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { - result.CopyStatusDescription = &val - } if val := resp.Header.Get("x-ms-copy-id"); val != "" { result.CopyID = &val } @@ -735,22 +721,35 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien if val := resp.Header.Get("x-ms-copy-status"); val != "" { result.CopyStatus = (*CopyStatusType)(&val) } - if val := resp.Header.Get("x-ms-content-md5"); val != "" { - fileContentMD5, err := base64.StdEncoding.DecodeString(val) + if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { + result.CopyStatusDescription = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientDownloadResponse{}, err } - result.FileContentMD5 = fileContentMD5 + result.Date = &date } - if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("x-ms-file-attributes"); val != "" { + result.FileAttributes = &val + } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) if err != nil { return FileClientDownloadResponse{}, err } - result.IsServerEncrypted = &isServerEncrypted + result.FileChangeTime = &fileChangeTime } - if val := resp.Header.Get("x-ms-file-attributes"); val != "" { - result.FileAttributes = &val + if val := resp.Header.Get("x-ms-content-md5"); val != "" { + fileContentMD5, err := base64.StdEncoding.DecodeString(val) + if err != nil { + return FileClientDownloadResponse{}, err + } + result.FileContentMD5 = fileContentMD5 } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) @@ -759,6 +758,9 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -766,21 +768,25 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) - if err != nil { - return FileClientDownloadResponse{}, err - } - result.FileChangeTime = &fileChangeTime + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val } if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { result.FilePermissionKey = &val } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) + if err != nil { + return FileClientDownloadResponse{}, err + } + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientDownloadResponse{}, err + } + result.LastModified = &lastModified } if val := resp.Header.Get("x-ms-lease-duration"); val != "" { result.LeaseDuration = (*LeaseDurationType)(&val) @@ -791,6 +797,20 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien if val := resp.Header.Get("x-ms-lease-status"); val != "" { result.LeaseStatus = (*LeaseStatusType)(&val) } + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -802,18 +822,21 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien // all handles. // - options - FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. func (client *FileClient) ForceCloseHandles(ctx context.Context, handleID string, options *FileClientForceCloseHandlesOptions) (FileClientForceCloseHandlesResponse, error) { + var err error req, err := client.forceCloseHandlesCreateRequest(ctx, handleID, options) if err != nil { return FileClientForceCloseHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientForceCloseHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientForceCloseHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientForceCloseHandlesResponse{}, err } - return client.forceCloseHandlesHandleResponse(resp) + resp, err := client.forceCloseHandlesHandleResponse(httpResp) + return resp, err } // forceCloseHandlesCreateRequest creates the ForceCloseHandles request. @@ -849,12 +872,6 @@ func (client *FileClient) forceCloseHandlesCreateRequest(ctx context.Context, ha // forceCloseHandlesHandleResponse handles the ForceCloseHandles response. func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) (FileClientForceCloseHandlesResponse, error) { result := FileClientForceCloseHandlesResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -881,6 +898,12 @@ func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) ( } result.NumberOfHandlesFailedToClose = &numberOfHandlesFailedToClose } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -892,18 +915,21 @@ func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) ( // - options - FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetProperties(ctx context.Context, options *FileClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -937,23 +963,17 @@ func (client *FileClient) getPropertiesCreateRequest(ctx context.Context, option // getPropertiesHandleResponse handles the GetProperties response. func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (FileClientGetPropertiesResponse, error) { result := FileClientGetPropertiesResponse{} - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientGetPropertiesResponse{}, err - } - result.LastModified = &lastModified + if val := resp.Header.Get("Cache-Control"); val != "" { + result.CacheControl = &val } - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } + if val := resp.Header.Get("Content-Disposition"); val != "" { + result.ContentDisposition = &val } - if val := resp.Header.Get("x-ms-type"); val != "" { - result.FileType = &val + if val := resp.Header.Get("Content-Encoding"); val != "" { + result.ContentEncoding = &val + } + if val := resp.Header.Get("Content-Language"); val != "" { + result.ContentLanguage = &val } if val := resp.Header.Get("Content-Length"); val != "" { contentLength, err := strconv.ParseInt(val, 10, 64) @@ -962,12 +982,6 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.ContentLength = &contentLength } - if val := resp.Header.Get("Content-Type"); val != "" { - result.ContentType = &val - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { @@ -975,30 +989,8 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("Content-Encoding"); val != "" { - result.ContentEncoding = &val - } - if val := resp.Header.Get("Cache-Control"); val != "" { - result.CacheControl = &val - } - if val := resp.Header.Get("Content-Disposition"); val != "" { - result.ContentDisposition = &val - } - if val := resp.Header.Get("Content-Language"); val != "" { - result.ContentLanguage = &val - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientGetPropertiesResponse{}, err - } - result.Date = &date + if val := resp.Header.Get("Content-Type"); val != "" { + result.ContentType = &val } if val := resp.Header.Get("x-ms-copy-completion-time"); val != "" { copyCompletionTime, err := time.Parse(time.RFC1123, val) @@ -1007,9 +999,6 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.CopyCompletionTime = ©CompletionTime } - if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { - result.CopyStatusDescription = &val - } if val := resp.Header.Get("x-ms-copy-id"); val != "" { result.CopyID = &val } @@ -1022,16 +1011,29 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File if val := resp.Header.Get("x-ms-copy-status"); val != "" { result.CopyStatus = (*CopyStatusType)(&val) } - if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) + if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { + result.CopyStatusDescription = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientGetPropertiesResponse{}, err } - result.IsServerEncrypted = &isServerEncrypted + result.Date = &date + } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientGetPropertiesResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1039,6 +1041,9 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1046,21 +1051,28 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) - if err != nil { - return FileClientGetPropertiesResponse{}, err - } - result.FileChangeTime = &fileChangeTime + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val } if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { result.FilePermissionKey = &val } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("x-ms-type"); val != "" { + result.FileType = &val } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) + if err != nil { + return FileClientGetPropertiesResponse{}, err + } + result.IsServerEncrypted = &isServerEncrypted + } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientGetPropertiesResponse{}, err + } + result.LastModified = &lastModified } if val := resp.Header.Get("x-ms-lease-duration"); val != "" { result.LeaseDuration = (*LeaseDurationType)(&val) @@ -1071,6 +1083,20 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File if val := resp.Header.Get("x-ms-lease-status"); val != "" { result.LeaseStatus = (*LeaseStatusType)(&val) } + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -1081,18 +1107,21 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File // - options - FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetRangeList(ctx context.Context, options *FileClientGetRangeListOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetRangeListResponse, error) { + var err error req, err := client.getRangeListCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientGetRangeListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientGetRangeListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientGetRangeListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientGetRangeListResponse{}, err } - return client.getRangeListHandleResponse(resp) + resp, err := client.getRangeListHandleResponse(httpResp) + return resp, err } // getRangeListCreateRequest creates the GetRangeList request. @@ -1133,12 +1162,12 @@ func (client *FileClient) getRangeListCreateRequest(ctx context.Context, options // getRangeListHandleResponse handles the GetRangeList response. func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileClientGetRangeListResponse, error) { result := FileClientGetRangeListResponse{} - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientGetRangeListResponse{}, err } - result.LastModified = &lastModified + result.Date = &date } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) @@ -1150,19 +1179,19 @@ func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileC } result.FileContentLength = &fileContentLength } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientGetRangeListResponse{}, err + } + result.LastModified = &lastModified + } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientGetRangeListResponse{}, err - } - result.Date = &date - } if err := runtime.UnmarshalAsXML(resp, &result.ShareFileRangeList); err != nil { return FileClientGetRangeListResponse{}, err } @@ -1175,18 +1204,21 @@ func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileC // Generated from API version 2023-11-03 // - options - FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. func (client *FileClient) ListHandles(ctx context.Context, options *FileClientListHandlesOptions) (FileClientListHandlesResponse, error) { + var err error req, err := client.listHandlesCreateRequest(ctx, options) if err != nil { return FileClientListHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientListHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientListHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientListHandlesResponse{}, err } - return client.listHandlesHandleResponse(resp) + resp, err := client.listHandlesHandleResponse(httpResp) + return resp, err } // listHandlesCreateRequest creates the ListHandles request. @@ -1227,12 +1259,6 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl if val := resp.Header.Get("Content-Type"); val != "" { result.ContentType = &val } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1240,6 +1266,12 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsXML(resp, &result.ListHandlesResponse); err != nil { return FileClientListHandlesResponse{}, err } @@ -1253,18 +1285,21 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. func (client *FileClient) ReleaseLease(ctx context.Context, leaseID string, options *FileClientReleaseLeaseOptions) (FileClientReleaseLeaseResponse, error) { + var err error req, err := client.releaseLeaseCreateRequest(ctx, leaseID, options) if err != nil { return FileClientReleaseLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientReleaseLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientReleaseLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientReleaseLeaseResponse{}, err } - return client.releaseLeaseHandleResponse(resp) + resp, err := client.releaseLeaseHandleResponse(httpResp) + return resp, err } // releaseLeaseCreateRequest creates the ReleaseLease request. @@ -1298,6 +1333,16 @@ func (client *FileClient) releaseLeaseCreateRequest(ctx context.Context, leaseID // releaseLeaseHandleResponse handles the ReleaseLease response. func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileClientReleaseLeaseResponse, error) { result := FileClientReleaseLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientReleaseLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1308,22 +1353,12 @@ func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileC } result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientReleaseLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -1340,18 +1375,21 @@ func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileC // - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. func (client *FileClient) Rename(ctx context.Context, renameSource string, options *FileClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo, shareFileHTTPHeaders *ShareFileHTTPHeaders) (FileClientRenameResponse, error) { + var err error req, err := client.renameCreateRequest(ctx, renameSource, options, sourceLeaseAccessConditions, destinationLeaseAccessConditions, copyFileSMBInfo, shareFileHTTPHeaders) if err != nil { return FileClientRenameResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientRenameResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientRenameResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientRenameResponse{}, err } - return client.renameHandleResponse(resp) + resp, err := client.renameHandleResponse(httpResp) + return resp, err } // renameCreateRequest creates the Rename request. @@ -1424,22 +1462,6 @@ func (client *FileClient) renameCreateRequest(ctx context.Context, renameSource // renameHandleResponse handles the Rename response. func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientRenameResponse, error) { result := FileClientRenameResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientRenameResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1447,19 +1469,19 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return FileClientRenameResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1467,6 +1489,9 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1474,18 +1499,31 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return FileClientRenameResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -1498,18 +1536,21 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) SetHTTPHeaders(ctx context.Context, options *FileClientSetHTTPHeadersOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientSetHTTPHeadersResponse, error) { + var err error req, err := client.setHTTPHeadersCreateRequest(ctx, options, shareFileHTTPHeaders, leaseAccessConditions) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientSetHTTPHeadersResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientSetHTTPHeadersResponse{}, err } - return client.setHTTPHeadersHandleResponse(resp) + resp, err := client.setHTTPHeadersHandleResponse(httpResp) + return resp, err } // setHTTPHeadersCreateRequest creates the SetHTTPHeaders request. @@ -1580,22 +1621,6 @@ func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, optio // setHTTPHeadersHandleResponse handles the SetHTTPHeaders response. func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (FileClientSetHTTPHeadersResponse, error) { result := FileClientSetHTTPHeadersResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientSetHTTPHeadersResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1603,19 +1628,19 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return FileClientSetHTTPHeadersResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientSetHTTPHeadersResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1623,6 +1648,9 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1630,18 +1658,31 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientSetHTTPHeadersResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -1653,18 +1694,21 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil // - options - FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) SetMetadata(ctx context.Context, options *FileClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientSetMetadataResponse, error) { + var err error req, err := client.setMetadataCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientSetMetadataResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientSetMetadataResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientSetMetadataResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientSetMetadataResponse{}, err } - return client.setMetadataHandleResponse(resp) + resp, err := client.setMetadataHandleResponse(httpResp) + return resp, err } // setMetadataCreateRequest creates the SetMetadata request. @@ -1703,15 +1747,6 @@ func (client *FileClient) setMetadataCreateRequest(ctx context.Context, options // setMetadataHandleResponse handles the SetMetadata response. func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileClientSetMetadataResponse, error) { result := FileClientSetMetadataResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1719,6 +1754,9 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl } result.Date = &date } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) if err != nil { @@ -1733,6 +1771,12 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl } result.LastModified = &lastModified } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -1750,18 +1794,21 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl // - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) StartCopy(ctx context.Context, copySource string, options *FileClientStartCopyOptions, copyFileSMBInfo *CopyFileSMBInfo, leaseAccessConditions *LeaseAccessConditions) (FileClientStartCopyResponse, error) { + var err error req, err := client.startCopyCreateRequest(ctx, copySource, options, copyFileSMBInfo, leaseAccessConditions) if err != nil { return FileClientStartCopyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientStartCopyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return FileClientStartCopyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return FileClientStartCopyResponse{}, err } - return client.startCopyHandleResponse(resp) + resp, err := client.startCopyHandleResponse(httpResp) + return resp, err } // startCopyCreateRequest creates the StartCopy request. @@ -1830,6 +1877,19 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource // startCopyHandleResponse handles the StartCopy response. func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClientStartCopyResponse, error) { result := FileClientStartCopyResponse{} + if val := resp.Header.Get("x-ms-copy-id"); val != "" { + result.CopyID = &val + } + if val := resp.Header.Get("x-ms-copy-status"); val != "" { + result.CopyStatus = (*CopyStatusType)(&val) + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientStartCopyResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1846,19 +1906,6 @@ func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClie if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientStartCopyResponse{}, err - } - result.Date = &date - } - if val := resp.Header.Get("x-ms-copy-id"); val != "" { - result.CopyID = &val - } - if val := resp.Header.Get("x-ms-copy-status"); val != "" { - result.CopyStatus = (*CopyStatusType)(&val) - } return result, nil } @@ -1882,18 +1929,21 @@ func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClie // - options - FileClientUploadRangeOptions contains the optional parameters for the FileClient.UploadRange method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) UploadRange(ctx context.Context, rangeParam string, fileRangeWrite FileRangeWriteType, contentLength int64, optionalbody io.ReadSeekCloser, options *FileClientUploadRangeOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientUploadRangeResponse, error) { + var err error req, err := client.uploadRangeCreateRequest(ctx, rangeParam, fileRangeWrite, contentLength, optionalbody, options, leaseAccessConditions) if err != nil { return FileClientUploadRangeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientUploadRangeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientUploadRangeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientUploadRangeResponse{}, err } - return client.uploadRangeHandleResponse(resp) + resp, err := client.uploadRangeHandleResponse(httpResp) + return resp, err } // uploadRangeCreateRequest creates the UploadRange request. @@ -1937,16 +1987,6 @@ func (client *FileClient) uploadRangeCreateRequest(ctx context.Context, rangePar // uploadRangeHandleResponse handles the UploadRange response. func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileClientUploadRangeResponse, error) { result := FileClientUploadRangeResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientUploadRangeResponse{}, err - } - result.LastModified = &lastModified - } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { @@ -1954,12 +1994,6 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl } result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1967,6 +2001,16 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl } result.Date = &date } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientUploadRangeResponse{}, err + } + result.FileLastWriteTime = &fileLastWriteTime + } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) if err != nil { @@ -1974,12 +2018,18 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl } result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { - fileLastWriteTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientUploadRangeResponse{}, err } - result.FileLastWriteTime = &fileLastWriteTime + result.LastModified = &lastModified + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -2002,18 +2052,21 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl // method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) UploadRangeFromURL(ctx context.Context, rangeParam string, copySource string, contentLength int64, options *FileClientUploadRangeFromURLOptions, sourceModifiedAccessConditions *SourceModifiedAccessConditions, leaseAccessConditions *LeaseAccessConditions) (FileClientUploadRangeFromURLResponse, error) { + var err error req, err := client.uploadRangeFromURLCreateRequest(ctx, rangeParam, copySource, contentLength, options, sourceModifiedAccessConditions, leaseAccessConditions) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientUploadRangeFromURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientUploadRangeFromURLResponse{}, err } - return client.uploadRangeFromURLHandleResponse(resp) + resp, err := client.uploadRangeFromURLHandleResponse(httpResp) + return resp, err } // uploadRangeFromURLCreateRequest creates the UploadRangeFromURL request. @@ -2070,35 +2123,29 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r // uploadRangeFromURLHandleResponse handles the UploadRangeFromURL response. func (client *FileClient) uploadRangeFromURLHandleResponse(resp *http.Response) (FileClientUploadRangeFromURLResponse, error) { result := FileClientUploadRangeFromURLResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("Content-MD5"); val != "" { + contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.LastModified = &lastModified + result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("x-ms-content-crc64"); val != "" { - xMSContentCRC64, err := base64.StdEncoding.DecodeString(val) + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.XMSContentCRC64 = xMSContentCRC64 - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val + result.Date = &date } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.Date = &date + result.FileLastWriteTime = &fileLastWriteTime } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) @@ -2107,19 +2154,25 @@ func (client *FileClient) uploadRangeFromURLHandleResponse(resp *http.Response) } result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { - fileLastWriteTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.FileLastWriteTime = &fileLastWriteTime + result.LastModified = &lastModified } - if val := resp.Header.Get("Content-MD5"); val != "" { - contentMD5, err := base64.StdEncoding.DecodeString(val) + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("x-ms-content-crc64"); val != "" { + xMSContentCRC64, err := base64.StdEncoding.DecodeString(val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.ContentMD5 = contentMD5 + result.XMSContentCRC64 = xMSContentCRC64 } return result, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_models.go b/sdk/storage/azfile/internal/generated/zz_models.go index 10aace210fe4..448879f6564c 100644 --- a/sdk/storage/azfile/internal/generated/zz_models.go +++ b/sdk/storage/azfile/internal/generated/zz_models.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -34,30 +33,6 @@ type ClearRange struct { Start *int64 `xml:"Start"` } -// CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. -type CopyFileSMBInfo struct { - // Specifies either the option to copy file attributes from a source file(source) to a target file or a list of attributes - // to set on a target file. - FileAttributes *string - // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in - // ISO 8601 format to set as last write time on a target file. - FileChangeTime *string - // Specifies either the option to copy file creation time from a source file(source) to a target file or a time value in ISO - // 8601 format to set as creation time on a target file. - FileCreationTime *string - // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in - // ISO 8601 format to set as last write time on a target file. - FileLastWriteTime *string - // Specifies the option to copy file security descriptor from source file or to set it using the value which is defined by - // the header value of x-ms-file-permission or x-ms-file-permission-key. - FilePermissionCopyMode *PermissionCopyModeType - // Specifies the option to overwrite the target file if it already exists and has read-only attribute set. - IgnoreReadOnly *bool - // Specifies the option to set archive attribute on a target file. True means archive attribute will be set on a target file - // despite attribute overrides or a source file state. - SetArchiveAttribute *bool -} - // 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 @@ -83,16 +58,6 @@ type CORSRule struct { MaxAgeInSeconds *int32 `xml:"MaxAgeInSeconds"` } -// DestinationLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. -type DestinationLeaseAccessConditions struct { - // Required if the destination file has an active infinite lease. The lease ID specified for this header must match the lease - // ID of the destination file. If the request does not include the lease ID or - // it is not valid, the operation fails with status code 412 (Precondition Failed). If this header is specified and the destination - // file does not currently have an active lease, the operation will also - // fail with status code 412 (Precondition Failed). - DestinationLeaseID *string -} - // Directory - A listed directory item. type Directory struct { // REQUIRED @@ -105,167 +70,6 @@ type Directory struct { Properties *FileProperty `xml:"Properties"` } -// DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. -type DirectoryClientCreateOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. -type DirectoryClientDeleteOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles method. -type DirectoryClientForceCloseHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. - Recursive *bool - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. -type DirectoryClientGetPropertiesOptions struct { - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientListFilesAndDirectoriesSegmentOptions contains the optional parameters for the DirectoryClient.NewListFilesAndDirectoriesSegmentPager -// method. -type DirectoryClientListFilesAndDirectoriesSegmentOptions struct { - // Include this parameter to specify one or more datasets to include in the response. - Include []ListFilesIncludeType - // Include extended information. - IncludeExtendedInfo *bool - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // Filters the results to return only entries whose name begins with the specified prefix. - Prefix *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. -type DirectoryClientListHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. - Recursive *bool - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. -type DirectoryClientRenameOptions struct { - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. - // If true, the rename will succeed, otherwise, a previous file at the - // destination with the ReadOnly attribute set will cause the rename to fail. - IgnoreReadOnly *bool - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. - // If true, the rename will succeed and will overwrite the destination file. If - // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided - // and the destination file doesn’t exist, the rename will succeed. Note: - // This value does not override the x-ms-file-copy-ignore-read-only header value. - ReplaceIfExists *bool - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. -type DirectoryClientSetMetadataOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. -type DirectoryClientSetPropertiesOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - // File - A listed file item. type File struct { // REQUIRED @@ -278,268 +82,6 @@ type File struct { PermissionKey *string `xml:"PermissionKey"` } -// FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. -type FileClientAbortCopyOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientAcquireLeaseOptions contains the optional parameters for the FileClient.AcquireLease method. -type FileClientAcquireLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. -type FileClientBreakLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. -type FileClientChangeLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientCreateOptions contains the optional parameters for the FileClient.Create method. -type FileClientCreateOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. -type FileClientDeleteOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. -type FileClientDownloadOptions struct { - // Return file data only from the specified byte range. - Range *string - // When this header is set to true and specified together with the Range header, the service returns the MD5 hash for the - // range, as long as the range is less than or equal to 4 MB in size. - RangeGetContentMD5 *bool - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. -type FileClientForceCloseHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. -type FileClientGetPropertiesOptions struct { - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. -type FileClientGetRangeListOptions struct { - // The previous snapshot parameter is an opaque DateTime value that, when present, specifies the previous snapshot. - Prevsharesnapshot *string - // Specifies the range of bytes over which to list ranges, inclusively. - Range *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. -type FileClientListHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. -type FileClientReleaseLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. -type FileClientRenameOptions struct { - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. - // If true, the rename will succeed, otherwise, a previous file at the - // destination with the ReadOnly attribute set will cause the rename to fail. - IgnoreReadOnly *bool - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. - // If true, the rename will succeed and will overwrite the destination file. If - // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided - // and the destination file doesn’t exist, the rename will succeed. Note: - // This value does not override the x-ms-file-copy-ignore-read-only header value. - ReplaceIfExists *bool - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. -type FileClientSetHTTPHeadersOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Resizes a file to the specified size. If the specified byte value is less than the current size of the file, then all ranges - // above the specified byte value are cleared. - FileContentLength *int64 - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. -type FileClientSetMetadataOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientStartCopyOptions contains the optional parameters for the FileClient.StartCopy method. -type FileClientStartCopyOptions struct { - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientUploadRangeFromURLOptions contains the optional parameters for the FileClient.UploadRangeFromURL method. -type FileClientUploadRangeFromURLOptions struct { - // Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. - CopySourceAuthorization *string - // If the file last write time should be preserved or overwritten - FileLastWrittenMode *FileLastWrittenMode - // Specify the crc64 calculated for the range of bytes that must be read from the copy source. - SourceContentCRC64 []byte - // Bytes of source data in the specified range. - SourceRange *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientUploadRangeOptions contains the optional parameters for the FileClient.UploadRange method. -type FileClientUploadRangeOptions struct { - // An MD5 hash of the content. This hash is used to verify the integrity of the data during transport. When the Content-MD5 - // header is specified, the File service compares the hash of the content that has - // arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 - // (Bad Request). - ContentMD5 []byte - // If the file last write time should be preserved or overwritten - FileLastWrittenMode *FileLastWrittenMode - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - // FileProperty - File properties. type FileProperty struct { // REQUIRED; Content length of the file. This value may not be up-to-date since an SMB client may have modified the file locally. @@ -600,12 +142,6 @@ type Handle struct { ParentID *string `xml:"ParentId"` } -// LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. -type LeaseAccessConditions struct { - // If specified, the operation only succeeds if the resource's lease is active and matches this ID. - LeaseID *string -} - // ListFilesAndDirectoriesSegmentResponse - An enumeration of directories and files. type ListFilesAndDirectoriesSegmentResponse struct { // REQUIRED @@ -690,40 +226,6 @@ type SMBSettings struct { Multichannel *SMBMultichannel `xml:"Multichannel"` } -// ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. -type ServiceClientGetPropertiesOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ServiceClientListSharesSegmentOptions contains the optional parameters for the ServiceClient.NewListSharesSegmentPager -// method. -type ServiceClientListSharesSegmentOptions struct { - // Include this parameter to specify one or more datasets to include in the response. - Include []ListSharesIncludeType - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // Filters the results to return only entries whose name begins with the specified prefix. - Prefix *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. -type ServiceClientSetPropertiesOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - // Share - A listed Azure Storage share item. type Share struct { // REQUIRED @@ -739,214 +241,6 @@ type Share struct { Version *string `xml:"Version"` } -// ShareClientAcquireLeaseOptions contains the optional parameters for the ShareClient.AcquireLease method. -type ShareClientAcquireLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. -type ShareClientBreakLeaseOptions struct { - // For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. This - // break period is only used if it is shorter than the time remaining on the - // lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - // expired, but the lease may be held for longer than the break period. If this - // header does not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, - // and an infinite lease breaks immediately. - BreakPeriod *int32 - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. -type ShareClientChangeLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. -type ShareClientCreateOptions struct { - // Specifies the access tier of the share. - AccessTier *ShareAccessTier - // Protocols to enable on the share. - EnabledProtocols *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // Specifies the maximum size of the share, in gigabytes. - Quota *int32 - // Root squash to set on the share. Only valid for NFS shares. - RootSquash *ShareRootSquash - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. -type ShareClientCreatePermissionOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. -type ShareClientCreateSnapshotOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. -type ShareClientDeleteOptions struct { - // Specifies the option include to delete the base share and all of its snapshots. - DeleteSnapshots *DeleteSnapshotsOptionType - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. -type ShareClientGetAccessPolicyOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. -type ShareClientGetPermissionOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. -type ShareClientGetPropertiesOptions struct { - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. -type ShareClientGetStatisticsOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. -type ShareClientReleaseLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. -type ShareClientRenewLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. -type ShareClientRestoreOptions struct { - // Specifies the name of the previously-deleted share. - DeletedShareName *string - // Specifies the version of the previously-deleted share. - DeletedShareVersion *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. -type ShareClientSetAccessPolicyOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. -type ShareClientSetMetadataOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. -type ShareClientSetPropertiesOptions struct { - // Specifies the access tier of the share. - AccessTier *ShareAccessTier - // Specifies the maximum size of the share, in gigabytes. - Quota *int32 - // Root squash to set on the share. Only valid for NFS shares. - RootSquash *ShareRootSquash - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. -type ShareFileHTTPHeaders struct { - // Sets the file's cache control. The File service stores this value but does not use or modify it. - CacheControl *string - // Sets the file's Content-Disposition header. - ContentDisposition *string - // Specifies which content encodings have been applied to the file. - ContentEncoding *string - // Specifies the natural languages used by this resource. - ContentLanguage *string - // Sets the file's MD5 hash. - ContentMD5 []byte - // Sets the MIME content type of the file. The default type is 'application/octet-stream'. - ContentType *string -} - // ShareFileRangeList - The list of file ranges type ShareFileRangeList struct { ClearRanges []*ClearRange `xml:"ClearRange"` @@ -1014,20 +308,6 @@ type SMBMultichannel struct { Enabled *bool `xml:"Enabled"` } -// SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. -type SourceLeaseAccessConditions struct { - // Required if the source file has an active infinite lease. - SourceLeaseID *string -} - -// SourceModifiedAccessConditions contains a group of parameters for the FileClient.UploadRangeFromURL method. -type SourceModifiedAccessConditions struct { - // Specify the crc64 value to operate only on range with a matching crc64 checksum. - SourceIfMatchCRC64 []byte - // Specify the crc64 value to operate only on range without a matching crc64 checksum. - SourceIfNoneMatchCRC64 []byte -} - type StorageError struct { Message *string } diff --git a/sdk/storage/azfile/internal/generated/zz_models_serde.go b/sdk/storage/azfile/internal/generated/zz_models_serde.go index 94664adc2280..91a56c2eb3dc 100644 --- a/sdk/storage/azfile/internal/generated/zz_models_serde.go +++ b/sdk/storage/azfile/internal/generated/zz_models_serde.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -23,12 +22,12 @@ func (a AccessPolicy) MarshalXML(enc *xml.Encoder, start xml.StartElement) error type alias AccessPolicy aux := &struct { *alias - Expiry *timeRFC3339 `xml:"Expiry"` - Start *timeRFC3339 `xml:"Start"` + Expiry *dateTimeRFC3339 `xml:"Expiry"` + Start *dateTimeRFC3339 `xml:"Start"` }{ alias: (*alias)(&a), - Expiry: (*timeRFC3339)(a.Expiry), - Start: (*timeRFC3339)(a.Start), + Expiry: (*dateTimeRFC3339)(a.Expiry), + Start: (*dateTimeRFC3339)(a.Start), } return enc.EncodeElement(aux, start) } @@ -38,8 +37,8 @@ func (a *AccessPolicy) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) er type alias AccessPolicy aux := &struct { *alias - Expiry *timeRFC3339 `xml:"Expiry"` - Start *timeRFC3339 `xml:"Start"` + Expiry *dateTimeRFC3339 `xml:"Expiry"` + Start *dateTimeRFC3339 `xml:"Start"` }{ alias: (*alias)(a), } @@ -56,18 +55,18 @@ func (f FileProperty) MarshalXML(enc *xml.Encoder, start xml.StartElement) error type alias FileProperty aux := &struct { *alias - ChangeTime *timeRFC3339 `xml:"ChangeTime"` - CreationTime *timeRFC3339 `xml:"CreationTime"` - LastAccessTime *timeRFC3339 `xml:"LastAccessTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - LastWriteTime *timeRFC3339 `xml:"LastWriteTime"` + ChangeTime *dateTimeRFC3339 `xml:"ChangeTime"` + CreationTime *dateTimeRFC3339 `xml:"CreationTime"` + LastAccessTime *dateTimeRFC3339 `xml:"LastAccessTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + LastWriteTime *dateTimeRFC3339 `xml:"LastWriteTime"` }{ alias: (*alias)(&f), - ChangeTime: (*timeRFC3339)(f.ChangeTime), - CreationTime: (*timeRFC3339)(f.CreationTime), - LastAccessTime: (*timeRFC3339)(f.LastAccessTime), - LastModified: (*timeRFC1123)(f.LastModified), - LastWriteTime: (*timeRFC3339)(f.LastWriteTime), + ChangeTime: (*dateTimeRFC3339)(f.ChangeTime), + CreationTime: (*dateTimeRFC3339)(f.CreationTime), + LastAccessTime: (*dateTimeRFC3339)(f.LastAccessTime), + LastModified: (*dateTimeRFC1123)(f.LastModified), + LastWriteTime: (*dateTimeRFC3339)(f.LastWriteTime), } return enc.EncodeElement(aux, start) } @@ -77,11 +76,11 @@ func (f *FileProperty) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) er type alias FileProperty aux := &struct { *alias - ChangeTime *timeRFC3339 `xml:"ChangeTime"` - CreationTime *timeRFC3339 `xml:"CreationTime"` - LastAccessTime *timeRFC3339 `xml:"LastAccessTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - LastWriteTime *timeRFC3339 `xml:"LastWriteTime"` + ChangeTime *dateTimeRFC3339 `xml:"ChangeTime"` + CreationTime *dateTimeRFC3339 `xml:"CreationTime"` + LastAccessTime *dateTimeRFC3339 `xml:"LastAccessTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + LastWriteTime *dateTimeRFC3339 `xml:"LastWriteTime"` }{ alias: (*alias)(f), } @@ -212,16 +211,16 @@ func (s ShareProperties) MarshalXML(enc *xml.Encoder, start xml.StartElement) er type alias ShareProperties aux := &struct { *alias - AccessTierChangeTime *timeRFC1123 `xml:"AccessTierChangeTime"` - DeletedTime *timeRFC1123 `xml:"DeletedTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - NextAllowedQuotaDowngradeTime *timeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` + AccessTierChangeTime *dateTimeRFC1123 `xml:"AccessTierChangeTime"` + DeletedTime *dateTimeRFC1123 `xml:"DeletedTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + NextAllowedQuotaDowngradeTime *dateTimeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` }{ alias: (*alias)(&s), - AccessTierChangeTime: (*timeRFC1123)(s.AccessTierChangeTime), - DeletedTime: (*timeRFC1123)(s.DeletedTime), - LastModified: (*timeRFC1123)(s.LastModified), - NextAllowedQuotaDowngradeTime: (*timeRFC1123)(s.NextAllowedQuotaDowngradeTime), + AccessTierChangeTime: (*dateTimeRFC1123)(s.AccessTierChangeTime), + DeletedTime: (*dateTimeRFC1123)(s.DeletedTime), + LastModified: (*dateTimeRFC1123)(s.LastModified), + NextAllowedQuotaDowngradeTime: (*dateTimeRFC1123)(s.NextAllowedQuotaDowngradeTime), } return enc.EncodeElement(aux, start) } @@ -231,10 +230,10 @@ func (s *ShareProperties) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) type alias ShareProperties aux := &struct { *alias - AccessTierChangeTime *timeRFC1123 `xml:"AccessTierChangeTime"` - DeletedTime *timeRFC1123 `xml:"DeletedTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - NextAllowedQuotaDowngradeTime *timeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` + AccessTierChangeTime *dateTimeRFC1123 `xml:"AccessTierChangeTime"` + DeletedTime *dateTimeRFC1123 `xml:"DeletedTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + NextAllowedQuotaDowngradeTime *dateTimeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` }{ alias: (*alias)(s), } diff --git a/sdk/storage/azfile/internal/generated/zz_options.go b/sdk/storage/azfile/internal/generated/zz_options.go new file mode 100644 index 000000000000..5c1c92079d19 --- /dev/null +++ b/sdk/storage/azfile/internal/generated/zz_options.go @@ -0,0 +1,852 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package generated + +// CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. +type CopyFileSMBInfo struct { + // Specifies either the option to copy file attributes from a source file(source) to a target file or a list of attributes + // to set on a target file. + FileAttributes *string + + // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in + // ISO 8601 format to set as last write time on a target file. + FileChangeTime *string + + // Specifies either the option to copy file creation time from a source file(source) to a target file or a time value in ISO + // 8601 format to set as creation time on a target file. + FileCreationTime *string + + // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in + // ISO 8601 format to set as last write time on a target file. + FileLastWriteTime *string + + // Specifies the option to copy file security descriptor from source file or to set it using the value which is defined by + // the header value of x-ms-file-permission or x-ms-file-permission-key. + FilePermissionCopyMode *PermissionCopyModeType + + // Specifies the option to overwrite the target file if it already exists and has read-only attribute set. + IgnoreReadOnly *bool + + // Specifies the option to set archive attribute on a target file. True means archive attribute will be set on a target file + // despite attribute overrides or a source file state. + SetArchiveAttribute *bool +} + +// DestinationLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. +type DestinationLeaseAccessConditions struct { + // Required if the destination file has an active infinite lease. The lease ID specified for this header must match the lease + // ID of the destination file. If the request does not include the lease ID or + // it is not valid, the operation fails with status code 412 (Precondition Failed). If this header is specified and the destination + // file does not currently have an active lease, the operation will also + // fail with status code 412 (Precondition Failed). + DestinationLeaseID *string +} + +// DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. +type DirectoryClientCreateOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. +type DirectoryClientDeleteOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles method. +type DirectoryClientForceCloseHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. + Recursive *bool + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. +type DirectoryClientGetPropertiesOptions struct { + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientListFilesAndDirectoriesSegmentOptions contains the optional parameters for the DirectoryClient.NewListFilesAndDirectoriesSegmentPager +// method. +type DirectoryClientListFilesAndDirectoriesSegmentOptions struct { + // Include this parameter to specify one or more datasets to include in the response. + Include []ListFilesIncludeType + + // Include extended information. + IncludeExtendedInfo *bool + + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // Filters the results to return only entries whose name begins with the specified prefix. + Prefix *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. +type DirectoryClientListHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. + Recursive *bool + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. +type DirectoryClientRenameOptions struct { + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. + // If true, the rename will succeed, otherwise, a previous file at the + // destination with the ReadOnly attribute set will cause the rename to fail. + IgnoreReadOnly *bool + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. + // If true, the rename will succeed and will overwrite the destination file. If + // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided + // and the destination file doesn’t exist, the rename will succeed. Note: + // This value does not override the x-ms-file-copy-ignore-read-only header value. + ReplaceIfExists *bool + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. +type DirectoryClientSetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. +type DirectoryClientSetPropertiesOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. +type FileClientAbortCopyOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientAcquireLeaseOptions contains the optional parameters for the FileClient.AcquireLease method. +type FileClientAcquireLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. +type FileClientBreakLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. +type FileClientChangeLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientCreateOptions contains the optional parameters for the FileClient.Create method. +type FileClientCreateOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. +type FileClientDeleteOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. +type FileClientDownloadOptions struct { + // Return file data only from the specified byte range. + Range *string + + // When this header is set to true and specified together with the Range header, the service returns the MD5 hash for the + // range, as long as the range is less than or equal to 4 MB in size. + RangeGetContentMD5 *bool + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. +type FileClientForceCloseHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. +type FileClientGetPropertiesOptions struct { + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. +type FileClientGetRangeListOptions struct { + // The previous snapshot parameter is an opaque DateTime value that, when present, specifies the previous snapshot. + Prevsharesnapshot *string + + // Specifies the range of bytes over which to list ranges, inclusively. + Range *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. +type FileClientListHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. +type FileClientReleaseLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. +type FileClientRenameOptions struct { + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. + // If true, the rename will succeed, otherwise, a previous file at the + // destination with the ReadOnly attribute set will cause the rename to fail. + IgnoreReadOnly *bool + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. + // If true, the rename will succeed and will overwrite the destination file. If + // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided + // and the destination file doesn’t exist, the rename will succeed. Note: + // This value does not override the x-ms-file-copy-ignore-read-only header value. + ReplaceIfExists *bool + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. +type FileClientSetHTTPHeadersOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Resizes a file to the specified size. If the specified byte value is less than the current size of the file, then all ranges + // above the specified byte value are cleared. + FileContentLength *int64 + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. +type FileClientSetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientStartCopyOptions contains the optional parameters for the FileClient.StartCopy method. +type FileClientStartCopyOptions struct { + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientUploadRangeFromURLOptions contains the optional parameters for the FileClient.UploadRangeFromURL method. +type FileClientUploadRangeFromURLOptions struct { + // Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. + CopySourceAuthorization *string + + // If the file last write time should be preserved or overwritten + FileLastWrittenMode *FileLastWrittenMode + + // Specify the crc64 calculated for the range of bytes that must be read from the copy source. + SourceContentCRC64 []byte + + // Bytes of source data in the specified range. + SourceRange *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientUploadRangeOptions contains the optional parameters for the FileClient.UploadRange method. +type FileClientUploadRangeOptions struct { + // An MD5 hash of the content. This hash is used to verify the integrity of the data during transport. When the Content-MD5 + // header is specified, the File service compares the hash of the content that has + // arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 + // (Bad Request). + ContentMD5 []byte + + // If the file last write time should be preserved or overwritten + FileLastWrittenMode *FileLastWrittenMode + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. +type LeaseAccessConditions struct { + // If specified, the operation only succeeds if the resource's lease is active and matches this ID. + LeaseID *string +} + +// ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. +type ServiceClientGetPropertiesOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ServiceClientListSharesSegmentOptions contains the optional parameters for the ServiceClient.NewListSharesSegmentPager +// method. +type ServiceClientListSharesSegmentOptions struct { + // Include this parameter to specify one or more datasets to include in the response. + Include []ListSharesIncludeType + + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // Filters the results to return only entries whose name begins with the specified prefix. + Prefix *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. +type ServiceClientSetPropertiesOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientAcquireLeaseOptions contains the optional parameters for the ShareClient.AcquireLease method. +type ShareClientAcquireLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. +type ShareClientBreakLeaseOptions struct { + // For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. This + // break period is only used if it is shorter than the time remaining on the + // lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has + // expired, but the lease may be held for longer than the break period. If this + // header does not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, + // and an infinite lease breaks immediately. + BreakPeriod *int32 + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. +type ShareClientChangeLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. +type ShareClientCreateOptions struct { + // Specifies the access tier of the share. + AccessTier *ShareAccessTier + + // Protocols to enable on the share. + EnabledProtocols *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // Specifies the maximum size of the share, in gigabytes. + Quota *int32 + + // Root squash to set on the share. Only valid for NFS shares. + RootSquash *ShareRootSquash + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. +type ShareClientCreatePermissionOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. +type ShareClientCreateSnapshotOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. +type ShareClientDeleteOptions struct { + // Specifies the option include to delete the base share and all of its snapshots. + DeleteSnapshots *DeleteSnapshotsOptionType + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. +type ShareClientGetAccessPolicyOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. +type ShareClientGetPermissionOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. +type ShareClientGetPropertiesOptions struct { + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. +type ShareClientGetStatisticsOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. +type ShareClientReleaseLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. +type ShareClientRenewLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. +type ShareClientRestoreOptions struct { + // Specifies the name of the previously-deleted share. + DeletedShareName *string + + // Specifies the version of the previously-deleted share. + DeletedShareVersion *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. +type ShareClientSetAccessPolicyOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. +type ShareClientSetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. +type ShareClientSetPropertiesOptions struct { + // Specifies the access tier of the share. + AccessTier *ShareAccessTier + + // Specifies the maximum size of the share, in gigabytes. + Quota *int32 + + // Root squash to set on the share. Only valid for NFS shares. + RootSquash *ShareRootSquash + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. +type ShareFileHTTPHeaders struct { + // Sets the file's cache control. The File service stores this value but does not use or modify it. + CacheControl *string + + // Sets the file's Content-Disposition header. + ContentDisposition *string + + // Specifies which content encodings have been applied to the file. + ContentEncoding *string + + // Specifies the natural languages used by this resource. + ContentLanguage *string + + // Sets the file's MD5 hash. + ContentMD5 []byte + + // Sets the MIME content type of the file. The default type is 'application/octet-stream'. + ContentType *string +} + +// SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. +type SourceLeaseAccessConditions struct { + // Required if the source file has an active infinite lease. + SourceLeaseID *string +} + +// SourceModifiedAccessConditions contains a group of parameters for the FileClient.UploadRangeFromURL method. +type SourceModifiedAccessConditions struct { + // Specify the crc64 value to operate only on range with a matching crc64 checksum. + SourceIfMatchCRC64 []byte + + // Specify the crc64 value to operate only on range without a matching crc64 checksum. + SourceIfNoneMatchCRC64 []byte +} diff --git a/sdk/storage/azfile/internal/generated/zz_response_types.go b/sdk/storage/azfile/internal/generated/zz_response_types.go index b94bd5e6fae4..69709e4aaabf 100644 --- a/sdk/storage/azfile/internal/generated/zz_response_types.go +++ b/sdk/storage/azfile/internal/generated/zz_response_types.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -137,34 +136,38 @@ type DirectoryClientGetPropertiesResponse struct { // DirectoryClientListFilesAndDirectoriesSegmentResponse contains the response from method DirectoryClient.NewListFilesAndDirectoriesSegmentPager. type DirectoryClientListFilesAndDirectoriesSegmentResponse struct { + // An enumeration of directories and files. ListFilesAndDirectoriesSegmentResponse + // ContentType contains the information returned from the Content-Type header response. - ContentType *string `xml:"ContentType"` + ContentType *string // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // DirectoryClientListHandlesResponse contains the response from method DirectoryClient.ListHandles. type DirectoryClientListHandlesResponse struct { + // An enumeration of handles. ListHandlesResponse + // ContentType contains the information returned from the Content-Type header response. - ContentType *string `xml:"ContentType"` + ContentType *string // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // DirectoryClientRenameResponse contains the response from method DirectoryClient.Rename. @@ -631,40 +634,44 @@ type FileClientGetPropertiesResponse struct { // FileClientGetRangeListResponse contains the response from method FileClient.GetRangeList. type FileClientGetRangeListResponse struct { + // The list of file ranges ShareFileRangeList + // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *azcore.ETag `xml:"ETag"` + ETag *azcore.ETag // FileContentLength contains the information returned from the x-ms-content-length header response. - FileContentLength *int64 `xml:"FileContentLength"` + FileContentLength *int64 // LastModified contains the information returned from the Last-Modified header response. - LastModified *time.Time `xml:"LastModified"` + LastModified *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // FileClientListHandlesResponse contains the response from method FileClient.ListHandles. type FileClientListHandlesResponse struct { + // An enumeration of handles. ListHandlesResponse + // ContentType contains the information returned from the Content-Type header response. - ContentType *string `xml:"ContentType"` + ContentType *string // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // FileClientReleaseLeaseResponse contains the response from method FileClient.ReleaseLease. @@ -876,22 +883,26 @@ type FileClientUploadRangeResponse struct { // ServiceClientGetPropertiesResponse contains the response from method ServiceClient.GetProperties. type ServiceClientGetPropertiesResponse struct { + // Storage service properties. StorageServiceProperties + // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ServiceClientListSharesSegmentResponse contains the response from method ServiceClient.NewListSharesSegmentPager. type ServiceClientListSharesSegmentResponse struct { + // An enumeration of shares. ListSharesResponse + // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ServiceClientSetPropertiesResponse contains the response from method ServiceClient.SetProperties. @@ -1047,27 +1058,29 @@ type ShareClientDeleteResponse struct { // ShareClientGetAccessPolicyResponse contains the response from method ShareClient.GetAccessPolicy. type ShareClientGetAccessPolicyResponse struct { // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *azcore.ETag `xml:"ETag"` + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. - LastModified *time.Time `xml:"LastModified"` + LastModified *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // A collection of signed identifiers. SignedIdentifiers []*SignedIdentifier `xml:"SignedIdentifier"` // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ShareClientGetPermissionResponse contains the response from method ShareClient.GetPermission. type ShareClientGetPermissionResponse struct { + // A permission (a security descriptor) at the share level. SharePermission + // Date contains the information returned from the Date header response. Date *time.Time @@ -1144,21 +1157,23 @@ type ShareClientGetPropertiesResponse struct { // ShareClientGetStatisticsResponse contains the response from method ShareClient.GetStatistics. type ShareClientGetStatisticsResponse struct { + // Stats for the share. ShareStats + // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *azcore.ETag `xml:"ETag"` + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. - LastModified *time.Time `xml:"LastModified"` + LastModified *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ShareClientReleaseLeaseResponse contains the response from method ShareClient.ReleaseLease. diff --git a/sdk/storage/azfile/internal/generated/zz_service_client.go b/sdk/storage/azfile/internal/generated/zz_service_client.go index fc0cf80a4f2c..436dc845336e 100644 --- a/sdk/storage/azfile/internal/generated/zz_service_client.go +++ b/sdk/storage/azfile/internal/generated/zz_service_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -34,18 +33,21 @@ type ServiceClient struct { // Generated from API version 2023-11-03 // - options - ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. func (client *ServiceClient) GetProperties(ctx context.Context, options *ServiceClientGetPropertiesOptions) (ServiceClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options) if err != nil { return ServiceClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ServiceClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -140,18 +142,21 @@ func (client *ServiceClient) ListSharesSegmentHandleResponse(resp *http.Response // - storageServiceProperties - The StorageService properties. // - options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. func (client *ServiceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { + var err error req, err := client.setPropertiesCreateRequest(ctx, storageServiceProperties, options) if err != nil { return ServiceClientSetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceClientSetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ServiceClientSetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ServiceClientSetPropertiesResponse{}, err } - return client.setPropertiesHandleResponse(resp) + resp, err := client.setPropertiesHandleResponse(httpResp) + return resp, err } // setPropertiesCreateRequest creates the SetProperties request. diff --git a/sdk/storage/azfile/internal/generated/zz_share_client.go b/sdk/storage/azfile/internal/generated/zz_share_client.go index 83a3092cd292..9ef788133d07 100644 --- a/sdk/storage/azfile/internal/generated/zz_share_client.go +++ b/sdk/storage/azfile/internal/generated/zz_share_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -40,18 +39,21 @@ type ShareClient struct { // renew or change. // - options - ShareClientAcquireLeaseOptions contains the optional parameters for the ShareClient.AcquireLease method. func (client *ShareClient) AcquireLease(ctx context.Context, duration int32, options *ShareClientAcquireLeaseOptions) (ShareClientAcquireLeaseResponse, error) { + var err error req, err := client.acquireLeaseCreateRequest(ctx, duration, options) if err != nil { return ShareClientAcquireLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientAcquireLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientAcquireLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientAcquireLeaseResponse{}, err } - return client.acquireLeaseHandleResponse(resp) + resp, err := client.acquireLeaseHandleResponse(httpResp) + return resp, err } // acquireLeaseCreateRequest creates the AcquireLease request. @@ -86,6 +88,16 @@ func (client *ShareClient) acquireLeaseCreateRequest(ctx context.Context, durati // acquireLeaseHandleResponse handles the AcquireLease response. func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (ShareClientAcquireLeaseResponse, error) { result := ShareClientAcquireLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientAcquireLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -99,22 +111,12 @@ func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (Shar if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientAcquireLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -126,18 +128,21 @@ func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (Shar // - options - ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) BreakLease(ctx context.Context, options *ShareClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientBreakLeaseResponse, error) { + var err error req, err := client.breakLeaseCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientBreakLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientBreakLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ShareClientBreakLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ShareClientBreakLeaseResponse{}, err } - return client.breakLeaseHandleResponse(resp) + resp, err := client.breakLeaseHandleResponse(httpResp) + return resp, err } // breakLeaseCreateRequest creates the BreakLease request. @@ -174,6 +179,16 @@ func (client *ShareClient) breakLeaseCreateRequest(ctx context.Context, options // breakLeaseHandleResponse handles the BreakLease response. func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareClientBreakLeaseResponse, error) { result := ShareClientBreakLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientBreakLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -184,6 +199,9 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC } result.LastModified = &lastModified } + if val := resp.Header.Get("x-ms-lease-id"); val != "" { + result.LeaseID = &val + } if val := resp.Header.Get("x-ms-lease-time"); val != "" { leaseTime32, err := strconv.ParseInt(val, 10, 32) leaseTime := int32(leaseTime32) @@ -192,25 +210,12 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC } result.LeaseTime = &leaseTime } - if val := resp.Header.Get("x-ms-lease-id"); val != "" { - result.LeaseID = &val - } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientBreakLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -222,18 +227,21 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. func (client *ShareClient) ChangeLease(ctx context.Context, leaseID string, options *ShareClientChangeLeaseOptions) (ShareClientChangeLeaseResponse, error) { + var err error req, err := client.changeLeaseCreateRequest(ctx, leaseID, options) if err != nil { return ShareClientChangeLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientChangeLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientChangeLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientChangeLeaseResponse{}, err } - return client.changeLeaseHandleResponse(resp) + resp, err := client.changeLeaseHandleResponse(httpResp) + return resp, err } // changeLeaseCreateRequest creates the ChangeLease request. @@ -268,6 +276,16 @@ func (client *ShareClient) changeLeaseCreateRequest(ctx context.Context, leaseID // changeLeaseHandleResponse handles the ChangeLease response. func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (ShareClientChangeLeaseResponse, error) { result := ShareClientChangeLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientChangeLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -281,22 +299,12 @@ func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (Share if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientChangeLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -307,18 +315,21 @@ func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (Share // Generated from API version 2023-11-03 // - options - ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. func (client *ShareClient) Create(ctx context.Context, options *ShareClientCreateOptions) (ShareClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, options) if err != nil { return ShareClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -360,6 +371,13 @@ func (client *ShareClient) createCreateRequest(ctx context.Context, options *Sha // createHandleResponse handles the Create response. func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClientCreateResponse, error) { result := ShareClientCreateResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientCreateResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -376,13 +394,6 @@ func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClien if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientCreateResponse{}, err - } - result.Date = &date - } return result, nil } @@ -393,18 +404,21 @@ func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClien // - sharePermission - A permission (a security descriptor) at the share level. // - options - ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. func (client *ShareClient) CreatePermission(ctx context.Context, sharePermission SharePermission, options *ShareClientCreatePermissionOptions) (ShareClientCreatePermissionResponse, error) { + var err error req, err := client.createPermissionCreateRequest(ctx, sharePermission, options) if err != nil { return ShareClientCreatePermissionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreatePermissionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientCreatePermissionResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientCreatePermissionResponse{}, err } - return client.createPermissionHandleResponse(resp) + resp, err := client.createPermissionHandleResponse(httpResp) + return resp, err } // createPermissionCreateRequest creates the CreatePermission request. @@ -434,12 +448,6 @@ func (client *ShareClient) createPermissionCreateRequest(ctx context.Context, sh // createPermissionHandleResponse handles the CreatePermission response. func (client *ShareClient) createPermissionHandleResponse(resp *http.Response) (ShareClientCreatePermissionResponse, error) { result := ShareClientCreatePermissionResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -450,6 +458,12 @@ func (client *ShareClient) createPermissionHandleResponse(resp *http.Response) ( if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { result.FilePermissionKey = &val } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -459,18 +473,21 @@ func (client *ShareClient) createPermissionHandleResponse(resp *http.Response) ( // Generated from API version 2023-11-03 // - options - ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. func (client *ShareClient) CreateSnapshot(ctx context.Context, options *ShareClientCreateSnapshotOptions) (ShareClientCreateSnapshotResponse, error) { + var err error req, err := client.createSnapshotCreateRequest(ctx, options) if err != nil { return ShareClientCreateSnapshotResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreateSnapshotResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientCreateSnapshotResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientCreateSnapshotResponse{}, err } - return client.createSnapshotHandleResponse(resp) + resp, err := client.createSnapshotHandleResponse(httpResp) + return resp, err } // createSnapshotCreateRequest creates the CreateSnapshot request. @@ -501,8 +518,12 @@ func (client *ShareClient) createSnapshotCreateRequest(ctx context.Context, opti // createSnapshotHandleResponse handles the CreateSnapshot response. func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (ShareClientCreateSnapshotResponse, error) { result := ShareClientCreateSnapshotResponse{} - if val := resp.Header.Get("x-ms-snapshot"); val != "" { - result.Snapshot = &val + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientCreateSnapshotResponse{}, err + } + result.Date = &date } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) @@ -517,16 +538,12 @@ func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (Sh if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } + if val := resp.Header.Get("x-ms-snapshot"); val != "" { + result.Snapshot = &val + } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientCreateSnapshotResponse{}, err - } - result.Date = &date - } return result, nil } @@ -538,18 +555,21 @@ func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (Sh // - options - ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) Delete(ctx context.Context, options *ShareClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ShareClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ShareClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -581,12 +601,6 @@ func (client *ShareClient) deleteCreateRequest(ctx context.Context, options *Sha // deleteHandleResponse handles the Delete response. func (client *ShareClient) deleteHandleResponse(resp *http.Response) (ShareClientDeleteResponse, error) { result := ShareClientDeleteResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -594,6 +608,12 @@ func (client *ShareClient) deleteHandleResponse(resp *http.Response) (ShareClien } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -604,18 +624,21 @@ func (client *ShareClient) deleteHandleResponse(resp *http.Response) (ShareClien // - options - ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetAccessPolicy(ctx context.Context, options *ShareClientGetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetAccessPolicyResponse, error) { + var err error req, err := client.getAccessPolicyCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientGetAccessPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetAccessPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetAccessPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetAccessPolicyResponse{}, err } - return client.getAccessPolicyHandleResponse(resp) + resp, err := client.getAccessPolicyHandleResponse(httpResp) + return resp, err } // getAccessPolicyCreateRequest creates the GetAccessPolicy request. @@ -642,6 +665,13 @@ func (client *ShareClient) getAccessPolicyCreateRequest(ctx context.Context, opt // getAccessPolicyHandleResponse handles the GetAccessPolicy response. func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (ShareClientGetAccessPolicyResponse, error) { result := ShareClientGetAccessPolicyResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientGetAccessPolicyResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -658,13 +688,6 @@ func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (S if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientGetAccessPolicyResponse{}, err - } - result.Date = &date - } if err := runtime.UnmarshalAsXML(resp, &result); err != nil { return ShareClientGetAccessPolicyResponse{}, err } @@ -678,18 +701,21 @@ func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (S // - filePermissionKey - Key of the permission to be set for the directory/file. // - options - ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. func (client *ShareClient) GetPermission(ctx context.Context, filePermissionKey string, options *ShareClientGetPermissionOptions) (ShareClientGetPermissionResponse, error) { + var err error req, err := client.getPermissionCreateRequest(ctx, filePermissionKey, options) if err != nil { return ShareClientGetPermissionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetPermissionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetPermissionResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetPermissionResponse{}, err } - return client.getPermissionHandleResponse(resp) + resp, err := client.getPermissionHandleResponse(httpResp) + return resp, err } // getPermissionCreateRequest creates the GetPermission request. @@ -717,12 +743,6 @@ func (client *ShareClient) getPermissionCreateRequest(ctx context.Context, fileP // getPermissionHandleResponse handles the GetPermission response. func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (ShareClientGetPermissionResponse, error) { result := ShareClientGetPermissionResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -730,6 +750,12 @@ func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (Sha } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsJSON(resp, &result.SharePermission); err != nil { return ShareClientGetPermissionResponse{}, err } @@ -744,18 +770,21 @@ func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (Sha // - options - ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetProperties(ctx context.Context, options *ShareClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -784,29 +813,18 @@ func (client *ShareClient) getPropertiesCreateRequest(ctx context.Context, optio // getPropertiesHandleResponse handles the GetProperties response. func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (ShareClientGetPropertiesResponse, error) { result := ShareClientGetPropertiesResponse{} - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) + if val := resp.Header.Get("x-ms-access-tier"); val != "" { + result.AccessTier = &val } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-access-tier-change-time"); val != "" { + accessTierChangeTime, err := time.Parse(time.RFC1123, val) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val + result.AccessTierChangeTime = &accessTierChangeTime } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val + if val := resp.Header.Get("x-ms-access-tier-transition-state"); val != "" { + result.AccessTierTransitionState = &val } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) @@ -815,29 +833,50 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha } result.Date = &date } - if val := resp.Header.Get("x-ms-share-quota"); val != "" { - quota32, err := strconv.ParseInt(val, 10, 32) - quota := int32(quota32) + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("x-ms-enabled-protocols"); val != "" { + result.EnabledProtocols = &val + } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.Quota = "a + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-share-provisioned-iops"); val != "" { - provisionedIops32, err := strconv.ParseInt(val, 10, 32) - provisionedIops := int32(provisionedIops32) + if val := resp.Header.Get("x-ms-lease-duration"); val != "" { + result.LeaseDuration = (*LeaseDurationType)(&val) + } + if val := resp.Header.Get("x-ms-lease-state"); val != "" { + result.LeaseState = (*LeaseStateType)(&val) + } + if val := resp.Header.Get("x-ms-lease-status"); val != "" { + result.LeaseStatus = (*LeaseStatusType)(&val) + } + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } + } + if val := resp.Header.Get("x-ms-share-next-allowed-quota-downgrade-time"); val != "" { + nextAllowedQuotaDowngradeTime, err := time.Parse(time.RFC1123, val) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.ProvisionedIops = &provisionedIops + result.NextAllowedQuotaDowngradeTime = &nextAllowedQuotaDowngradeTime } - if val := resp.Header.Get("x-ms-share-provisioned-ingress-mbps"); val != "" { - provisionedIngressMBps32, err := strconv.ParseInt(val, 10, 32) - provisionedIngressMBps := int32(provisionedIngressMBps32) + if val := resp.Header.Get("x-ms-share-provisioned-bandwidth-mibps"); val != "" { + provisionedBandwidthMiBps32, err := strconv.ParseInt(val, 10, 32) + provisionedBandwidthMiBps := int32(provisionedBandwidthMiBps32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.ProvisionedIngressMBps = &provisionedIngressMBps + result.ProvisionedBandwidthMiBps = &provisionedBandwidthMiBps } if val := resp.Header.Get("x-ms-share-provisioned-egress-mbps"); val != "" { provisionedEgressMBps32, err := strconv.ParseInt(val, 10, 32) @@ -847,49 +886,39 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha } result.ProvisionedEgressMBps = &provisionedEgressMBps } - if val := resp.Header.Get("x-ms-share-next-allowed-quota-downgrade-time"); val != "" { - nextAllowedQuotaDowngradeTime, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-share-provisioned-ingress-mbps"); val != "" { + provisionedIngressMBps32, err := strconv.ParseInt(val, 10, 32) + provisionedIngressMBps := int32(provisionedIngressMBps32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.NextAllowedQuotaDowngradeTime = &nextAllowedQuotaDowngradeTime + result.ProvisionedIngressMBps = &provisionedIngressMBps } - if val := resp.Header.Get("x-ms-share-provisioned-bandwidth-mibps"); val != "" { - provisionedBandwidthMiBps32, err := strconv.ParseInt(val, 10, 32) - provisionedBandwidthMiBps := int32(provisionedBandwidthMiBps32) + if val := resp.Header.Get("x-ms-share-provisioned-iops"); val != "" { + provisionedIops32, err := strconv.ParseInt(val, 10, 32) + provisionedIops := int32(provisionedIops32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.ProvisionedBandwidthMiBps = &provisionedBandwidthMiBps - } - if val := resp.Header.Get("x-ms-lease-duration"); val != "" { - result.LeaseDuration = (*LeaseDurationType)(&val) - } - if val := resp.Header.Get("x-ms-lease-state"); val != "" { - result.LeaseState = (*LeaseStateType)(&val) - } - if val := resp.Header.Get("x-ms-lease-status"); val != "" { - result.LeaseStatus = (*LeaseStatusType)(&val) - } - if val := resp.Header.Get("x-ms-access-tier"); val != "" { - result.AccessTier = &val + result.ProvisionedIops = &provisionedIops } - if val := resp.Header.Get("x-ms-access-tier-change-time"); val != "" { - accessTierChangeTime, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-share-quota"); val != "" { + quota32, err := strconv.ParseInt(val, 10, 32) + quota := int32(quota32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.AccessTierChangeTime = &accessTierChangeTime - } - if val := resp.Header.Get("x-ms-access-tier-transition-state"); val != "" { - result.AccessTierTransitionState = &val + result.Quota = "a } - if val := resp.Header.Get("x-ms-enabled-protocols"); val != "" { - result.EnabledProtocols = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val } if val := resp.Header.Get("x-ms-root-squash"); val != "" { result.RootSquash = (*ShareRootSquash)(&val) } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -900,18 +929,21 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha // - options - ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetStatistics(ctx context.Context, options *ShareClientGetStatisticsOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetStatisticsResponse, error) { + var err error req, err := client.getStatisticsCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientGetStatisticsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetStatisticsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetStatisticsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetStatisticsResponse{}, err } - return client.getStatisticsHandleResponse(resp) + resp, err := client.getStatisticsHandleResponse(httpResp) + return resp, err } // getStatisticsCreateRequest creates the GetStatistics request. @@ -938,6 +970,13 @@ func (client *ShareClient) getStatisticsCreateRequest(ctx context.Context, optio // getStatisticsHandleResponse handles the GetStatistics response. func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (ShareClientGetStatisticsResponse, error) { result := ShareClientGetStatisticsResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientGetStatisticsResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -954,13 +993,6 @@ func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (Sha if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientGetStatisticsResponse{}, err - } - result.Date = &date - } if err := runtime.UnmarshalAsXML(resp, &result.ShareStats); err != nil { return ShareClientGetStatisticsResponse{}, err } @@ -975,18 +1007,21 @@ func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (Sha // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. func (client *ShareClient) ReleaseLease(ctx context.Context, leaseID string, options *ShareClientReleaseLeaseOptions) (ShareClientReleaseLeaseResponse, error) { + var err error req, err := client.releaseLeaseCreateRequest(ctx, leaseID, options) if err != nil { return ShareClientReleaseLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientReleaseLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientReleaseLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientReleaseLeaseResponse{}, err } - return client.releaseLeaseHandleResponse(resp) + resp, err := client.releaseLeaseHandleResponse(httpResp) + return resp, err } // releaseLeaseCreateRequest creates the ReleaseLease request. @@ -1018,6 +1053,16 @@ func (client *ShareClient) releaseLeaseCreateRequest(ctx context.Context, leaseI // releaseLeaseHandleResponse handles the ReleaseLease response. func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (ShareClientReleaseLeaseResponse, error) { result := ShareClientReleaseLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientReleaseLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1028,22 +1073,12 @@ func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (Shar } result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientReleaseLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -1055,18 +1090,21 @@ func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (Shar // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. func (client *ShareClient) RenewLease(ctx context.Context, leaseID string, options *ShareClientRenewLeaseOptions) (ShareClientRenewLeaseResponse, error) { + var err error req, err := client.renewLeaseCreateRequest(ctx, leaseID, options) if err != nil { return ShareClientRenewLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientRenewLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientRenewLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientRenewLeaseResponse{}, err } - return client.renewLeaseHandleResponse(resp) + resp, err := client.renewLeaseHandleResponse(httpResp) + return resp, err } // renewLeaseCreateRequest creates the RenewLease request. @@ -1098,6 +1136,16 @@ func (client *ShareClient) renewLeaseCreateRequest(ctx context.Context, leaseID // renewLeaseHandleResponse handles the RenewLease response. func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareClientRenewLeaseResponse, error) { result := ShareClientRenewLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientRenewLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1111,22 +1159,12 @@ func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareC if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientRenewLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -1136,18 +1174,21 @@ func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareC // Generated from API version 2023-11-03 // - options - ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. func (client *ShareClient) Restore(ctx context.Context, options *ShareClientRestoreOptions) (ShareClientRestoreResponse, error) { + var err error req, err := client.restoreCreateRequest(ctx, options) if err != nil { return ShareClientRestoreResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientRestoreResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientRestoreResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientRestoreResponse{}, err } - return client.restoreHandleResponse(resp) + resp, err := client.restoreHandleResponse(httpResp) + return resp, err } // restoreCreateRequest creates the Restore request. @@ -1180,6 +1221,16 @@ func (client *ShareClient) restoreCreateRequest(ctx context.Context, options *Sh // restoreHandleResponse handles the Restore response. func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClientRestoreResponse, error) { result := ShareClientRestoreResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientRestoreResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1193,19 +1244,9 @@ func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClie if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientRestoreResponse{}, err - } - result.Date = &date - } return result, nil } @@ -1217,18 +1258,21 @@ func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClie // - options - ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetAccessPolicy(ctx context.Context, shareACL []*SignedIdentifier, options *ShareClientSetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetAccessPolicyResponse, error) { + var err error req, err := client.setAccessPolicyCreateRequest(ctx, shareACL, options, leaseAccessConditions) if err != nil { return ShareClientSetAccessPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetAccessPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientSetAccessPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientSetAccessPolicyResponse{}, err } - return client.setAccessPolicyHandleResponse(resp) + resp, err := client.setAccessPolicyHandleResponse(httpResp) + return resp, err } // setAccessPolicyCreateRequest creates the SetAccessPolicy request. @@ -1262,6 +1306,13 @@ func (client *ShareClient) setAccessPolicyCreateRequest(ctx context.Context, sha // setAccessPolicyHandleResponse handles the SetAccessPolicy response. func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (ShareClientSetAccessPolicyResponse, error) { result := ShareClientSetAccessPolicyResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientSetAccessPolicyResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1278,13 +1329,6 @@ func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (S if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientSetAccessPolicyResponse{}, err - } - result.Date = &date - } return result, nil } @@ -1295,18 +1339,21 @@ func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (S // - options - ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetMetadata(ctx context.Context, options *ShareClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetMetadataResponse, error) { + var err error req, err := client.setMetadataCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientSetMetadataResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetMetadataResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientSetMetadataResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientSetMetadataResponse{}, err } - return client.setMetadataHandleResponse(resp) + resp, err := client.setMetadataHandleResponse(httpResp) + return resp, err } // setMetadataCreateRequest creates the SetMetadata request. @@ -1340,6 +1387,13 @@ func (client *ShareClient) setMetadataCreateRequest(ctx context.Context, options // setMetadataHandleResponse handles the SetMetadata response. func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (ShareClientSetMetadataResponse, error) { result := ShareClientSetMetadataResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientSetMetadataResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1356,13 +1410,6 @@ func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (Share if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientSetMetadataResponse{}, err - } - result.Date = &date - } return result, nil } @@ -1373,18 +1420,21 @@ func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (Share // - options - ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetProperties(ctx context.Context, options *ShareClientSetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetPropertiesResponse, error) { + var err error req, err := client.setPropertiesCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientSetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientSetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientSetPropertiesResponse{}, err } - return client.setPropertiesHandleResponse(resp) + resp, err := client.setPropertiesHandleResponse(httpResp) + return resp, err } // setPropertiesCreateRequest creates the SetProperties request. @@ -1420,6 +1470,13 @@ func (client *ShareClient) setPropertiesCreateRequest(ctx context.Context, optio // setPropertiesHandleResponse handles the SetProperties response. func (client *ShareClient) setPropertiesHandleResponse(resp *http.Response) (ShareClientSetPropertiesResponse, error) { result := ShareClientSetPropertiesResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientSetPropertiesResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1436,12 +1493,5 @@ func (client *ShareClient) setPropertiesHandleResponse(resp *http.Response) (Sha if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientSetPropertiesResponse{}, err - } - result.Date = &date - } return result, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go b/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go index 4b4d51aa3994..586650329724 100644 --- a/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go +++ b/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -15,29 +14,29 @@ import ( ) const ( - rfc1123JSON = `"` + time.RFC1123 + `"` + dateTimeRFC1123JSON = `"` + time.RFC1123 + `"` ) -type timeRFC1123 time.Time +type dateTimeRFC1123 time.Time -func (t timeRFC1123) MarshalJSON() ([]byte, error) { - b := []byte(time.Time(t).Format(rfc1123JSON)) +func (t dateTimeRFC1123) MarshalJSON() ([]byte, error) { + b := []byte(time.Time(t).Format(dateTimeRFC1123JSON)) return b, nil } -func (t timeRFC1123) MarshalText() ([]byte, error) { +func (t dateTimeRFC1123) MarshalText() ([]byte, error) { b := []byte(time.Time(t).Format(time.RFC1123)) return b, nil } -func (t *timeRFC1123) UnmarshalJSON(data []byte) error { - p, err := time.Parse(rfc1123JSON, strings.ToUpper(string(data))) - *t = timeRFC1123(p) +func (t *dateTimeRFC1123) UnmarshalJSON(data []byte) error { + p, err := time.Parse(dateTimeRFC1123JSON, strings.ToUpper(string(data))) + *t = dateTimeRFC1123(p) return err } -func (t *timeRFC1123) UnmarshalText(data []byte) error { +func (t *dateTimeRFC1123) UnmarshalText(data []byte) error { p, err := time.Parse(time.RFC1123, string(data)) - *t = timeRFC1123(p) + *t = dateTimeRFC1123(p) return err } diff --git a/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go b/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go index 1ce9d621164e..82b370133fac 100644 --- a/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go +++ b/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -15,45 +14,45 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } diff --git a/sdk/storage/azfile/internal/generated/zz_xml_helper.go b/sdk/storage/azfile/internal/generated/zz_xml_helper.go index 144ea18e1aba..1bd0e4de05a8 100644 --- a/sdk/storage/azfile/internal/generated/zz_xml_helper.go +++ b/sdk/storage/azfile/internal/generated/zz_xml_helper.go @@ -3,14 +3,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated import ( "encoding/xml" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "io" "strings" ) @@ -19,22 +21,32 @@ type additionalProperties map[string]*string // UnmarshalXML implements the xml.Unmarshaler interface for additionalProperties. func (ap *additionalProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { tokName := "" - for t, err := d.Token(); err == nil; t, err = d.Token() { + tokValue := "" + for { + t, err := d.Token() + if errors.Is(err, io.EOF) { + break + } else if err != nil { + return err + } switch tt := t.(type) { case xml.StartElement: tokName = strings.ToLower(tt.Name.Local) - break + tokValue = "" case xml.CharData: + if tokName == "" { + continue + } + tokValue = string(tt) + case xml.EndElement: if tokName == "" { continue } if *ap == nil { *ap = additionalProperties{} } - s := string(tt) - (*ap)[tokName] = &s + (*ap)[tokName] = to.Ptr(tokValue) tokName = "" - break } } return nil From 831638700cd91ec5196b7fe89987f231ff40c2fe Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Wed, 3 Jan 2024 13:16:00 +0530 Subject: [PATCH 5/5] Updating type of audience field (#22200) --- sdk/storage/azfile/directory/client_test.go | 6 +++--- sdk/storage/azfile/file/client_test.go | 6 +++--- sdk/storage/azfile/internal/base/clients.go | 6 +++--- sdk/storage/azfile/service/client_test.go | 2 +- sdk/storage/azfile/share/client_test.go | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/sdk/storage/azfile/directory/client_test.go b/sdk/storage/azfile/directory/client_test.go index 6f952fe7aae2..c2b7dc12df25 100644 --- a/sdk/storage/azfile/directory/client_test.go +++ b/sdk/storage/azfile/directory/client_test.go @@ -2287,7 +2287,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirectoryClientDefaultAudience() { options := &directory.ClientOptions{ FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), - Audience: to.Ptr("https://storage.azure.com/"), + Audience: "https://storage.azure.com/", } testcommon.SetClientOptions(d.T(), &options.ClientOptions) dirClientAudience, err := directory.NewClient(dirURL, cred, options) @@ -2322,7 +2322,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirectoryClientCustomAudience() { options := &directory.ClientOptions{ FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(d.T(), &options.ClientOptions) dirClientAudience, err := directory.NewClient(dirURL, cred, options) @@ -2357,7 +2357,7 @@ func (d *DirectoryRecordedTestsSuite) TestDirectoryAudienceNegative() { options := &directory.ClientOptions{ FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), - Audience: to.Ptr("https://badaudience.file.core.windows.net"), + Audience: "https://badaudience.file.core.windows.net", } testcommon.SetClientOptions(d.T(), &options.ClientOptions) dirClientAudience, err := directory.NewClient(dirURL, cred, options) diff --git a/sdk/storage/azfile/file/client_test.go b/sdk/storage/azfile/file/client_test.go index f7aa36c5ab7a..c98c4d04ef6b 100644 --- a/sdk/storage/azfile/file/client_test.go +++ b/sdk/storage/azfile/file/client_test.go @@ -4543,7 +4543,7 @@ func (f *FileRecordedTestsSuite) TestFileClientDefaultAudience() { options := &file.ClientOptions{ FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), - Audience: to.Ptr("https://storage.azure.com/"), + Audience: "https://storage.azure.com/", } testcommon.SetClientOptions(f.T(), &options.ClientOptions) fileClientAudience, err := file.NewClient(fileURL, cred, options) @@ -4578,7 +4578,7 @@ func (f *FileRecordedTestsSuite) TestFileClientCustomAudience() { options := &file.ClientOptions{ FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(f.T(), &options.ClientOptions) fileClientAudience, err := file.NewClient(fileURL, cred, options) @@ -4613,7 +4613,7 @@ func (f *FileRecordedTestsSuite) TestFileClientAudienceNegative() { options := &file.ClientOptions{ FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), - Audience: to.Ptr("https://badaudience.file.core.windows.net"), + Audience: "https://badaudience.file.core.windows.net", } testcommon.SetClientOptions(f.T(), &options.ClientOptions) fileClientAudience, err := file.NewClient(fileURL, cred, options) diff --git a/sdk/storage/azfile/internal/base/clients.go b/sdk/storage/azfile/internal/base/clients.go index 8d081a73c4b9..e39baf006011 100644 --- a/sdk/storage/azfile/internal/base/clients.go +++ b/sdk/storage/azfile/internal/base/clients.go @@ -32,7 +32,7 @@ type ClientOptions struct { // Audience to use when requesting tokens for Azure Active Directory authentication. // Only has an effect when credential is of type TokenCredential. The value could be // https://storage.azure.com/ (default) or https://.file.core.windows.net. - Audience *string + Audience string pipelineOptions *runtime.PipelineOptions } @@ -64,10 +64,10 @@ func SetPipelineOptions(clOpts *ClientOptions, plOpts *runtime.PipelineOptions) } func GetAudience(clOpts *ClientOptions) string { - if clOpts == nil || clOpts.Audience == nil { + if clOpts == nil || len(strings.TrimSpace(clOpts.Audience)) == 0 { return shared.TokenScope } else { - return strings.TrimRight(*clOpts.Audience, "/") + "/.default" + return strings.TrimRight(clOpts.Audience, "/") + "/.default" } } diff --git a/sdk/storage/azfile/service/client_test.go b/sdk/storage/azfile/service/client_test.go index 7a6c0c2b3481..0d83e8556f30 100644 --- a/sdk/storage/azfile/service/client_test.go +++ b/sdk/storage/azfile/service/client_test.go @@ -650,7 +650,7 @@ func (s *ServiceRecordedTestsSuite) TestServiceClientCustomAudience() { // create service client using token credential options := &service.ClientOptions{ FileRequestIntent: to.Ptr(service.ShareTokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) svcClientAudience, err := service.NewClient("https://"+accountName+".file.core.windows.net/", cred, options) diff --git a/sdk/storage/azfile/share/client_test.go b/sdk/storage/azfile/share/client_test.go index b75107dff41f..a5dc7fb74d4e 100644 --- a/sdk/storage/azfile/share/client_test.go +++ b/sdk/storage/azfile/share/client_test.go @@ -1647,7 +1647,7 @@ func (s *ShareRecordedTestsSuite) TestShareClientDefaultAudience() { options := &share.ClientOptions{ FileRequestIntent: to.Ptr(share.TokenIntentBackup), - Audience: to.Ptr("https://storage.azure.com/"), + Audience: "https://storage.azure.com/", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) @@ -1684,7 +1684,7 @@ func (s *ShareRecordedTestsSuite) TestShareClientCustomAudience() { options := &share.ClientOptions{ FileRequestIntent: to.Ptr(share.TokenIntentBackup), - Audience: to.Ptr("https://" + accountName + ".file.core.windows.net"), + Audience: "https://" + accountName + ".file.core.windows.net", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) @@ -1721,7 +1721,7 @@ func (s *ShareRecordedTestsSuite) TestShareClientAudienceNegative() { options := &share.ClientOptions{ FileRequestIntent: to.Ptr(share.TokenIntentBackup), - Audience: to.Ptr("https://badaudience.file.core.windows.net"), + Audience: "https://badaudience.file.core.windows.net", } testcommon.SetClientOptions(s.T(), &options.ClientOptions) shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options)