Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azfile: STG 91 code generation #22134

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions sdk/storage/azfile/file/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
18 changes: 17 additions & 1 deletion sdk/storage/azfile/internal/generated/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_"
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions sdk/storage/azfile/internal/generated/constants.go
Original file line number Diff line number Diff line change
@@ -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"
18 changes: 18 additions & 0 deletions sdk/storage/azfile/internal/generated/zz_constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions sdk/storage/azfile/internal/generated/zz_directory_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading