Skip to content

Commit 5ac5d37

Browse files
Code generation for Azure Storage Files (#19757)
* Init * Adding transforms * Updating autorest version * Adding changelog and build.go files * add license and CI file * pin swagger to commit * update dependencies and add doc.go Co-authored-by: Joel Hendrix <[email protected]>
1 parent 794c96c commit 5ac5d37

19 files changed

+7455
-0
lines changed

sdk/storage/azfile/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Release History
2+
3+
## 0.1.0 (Unreleased)
4+
5+
### Features Added
6+
7+
### Breaking Changes
8+
9+
### Bugs Fixed
10+
11+
### Other Changes

sdk/storage/azfile/LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation. All rights reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

sdk/storage/azfile/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
trigger:
2+
branches:
3+
include:
4+
- main
5+
- feature/*
6+
- hotfix/*
7+
- release/*
8+
paths:
9+
include:
10+
- sdk/storage/azfile
11+
12+
pr:
13+
branches:
14+
include:
15+
- main
16+
- feature/*
17+
- hotfix/*
18+
- release/*
19+
paths:
20+
include:
21+
- sdk/storage/azfile
22+
23+
24+
stages:
25+
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml
26+
parameters:
27+
ServiceDirectory: 'storage/azfile'
28+
RunLiveTests: true

sdk/storage/azfile/doc.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
// Copyright (c) Microsoft Corporation. All rights reserved.
5+
// Licensed under the MIT License. See License.txt in the project root for license information.
6+
7+
// Package azfile provides access to Azure File storage.
8+
// For more information please see https://learn.microsoft.com/rest/api/storageservices/file-service-rest-api
9+
package azfile

sdk/storage/azfile/go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/Azure/azure-sdk-for-go/sdk/storage/azfile
2+
3+
go 1.18
4+
5+
require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0
6+
7+
require (
8+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 // indirect
9+
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect
10+
golang.org/x/text v0.3.7 // indirect
11+
)

sdk/storage/azfile/go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0 h1:VuHAcMq8pU1IWNT/m5yRaGqbK0BiQKHT8X4DTp9CHdI=
2+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0/go.mod h1:tZoQYdDZNOiIjdSn0dVWVfl0NEPGOJqVLzSrcFk4Is0=
3+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 h1:Oj853U9kG+RLTCQXpjvOnrv0WaZHxgmZz1TlLywgOPY=
4+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w=
5+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
6+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7+
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
8+
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
9+
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
10+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
11+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
12+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Code Generation - Azure File SDK for Golang
2+
3+
### Settings
4+
5+
```yaml
6+
go: true
7+
clear-output-folder: false
8+
version: "^3.0.0"
9+
license-header: MICROSOFT_MIT_NO_VERSION
10+
input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/bbea558ac43d6ebec72455233c84b0158c89fcda/specification/storage/data-plane/Microsoft.FileStorage/preview/2020-10-02/file.json"
11+
credential-scope: "https://storage.azure.com/.default"
12+
output-folder: ../generated
13+
file-prefix: "zz_"
14+
openapi-type: "data-plane"
15+
verbose: true
16+
security: AzureKey
17+
modelerfour:
18+
group-parameters: false
19+
seal-single-value-enum-by-default: true
20+
lenient-model-deduplication: true
21+
export-clients: true
22+
use: "@autorest/[email protected]"
23+
```
24+
25+
### Don't include share name, directory, or file name in path - we have direct URIs
26+
27+
``` yaml
28+
directive:
29+
- from: swagger-document
30+
where: $["x-ms-paths"]
31+
transform: >
32+
for (const property in $)
33+
{
34+
if (property.includes('/{shareName}/{directory}/{fileName}'))
35+
{
36+
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName") && false == param['$ref'].endsWith("#/parameters/DirectoryPath") && false == param['$ref'].endsWith("#/parameters/FilePath"))});
37+
}
38+
else if (property.includes('/{shareName}/{directory}'))
39+
{
40+
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName") && false == param['$ref'].endsWith("#/parameters/DirectoryPath"))});
41+
}
42+
else if (property.includes('/{shareName}'))
43+
{
44+
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName"))});
45+
}
46+
}
47+
```
48+
49+
### Add Last-Modified to SetMetadata
50+
51+
``` yaml
52+
directive:
53+
- from: swagger-document
54+
where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=metadata"]
55+
transform: >
56+
$.put.responses["200"].headers["Last-Modified"] = {
57+
"type": "string",
58+
"format": "date-time-rfc1123",
59+
"description": "Returns the date and time the file was last modified. Any operation that modifies the file, including an update of the file's metadata or properties, changes the last-modified time of the file."
60+
}
61+
```
62+
63+
### Add Content-MD5 to Put Range from URL
64+
65+
``` yaml
66+
directive:
67+
- from: swagger-document
68+
where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=range&fromURL"]
69+
transform: >
70+
$.put.responses["201"].headers["Content-MD5"] = {
71+
"type": "string",
72+
"format": "byte",
73+
"description": "This header is returned so that the client can check for message content integrity. The value of this header is computed by the File service; it is not necessarily the same value as may have been specified in the request headers."
74+
}
75+
```
76+
77+
### ShareServiceProperties, ShareMetrics, ShareCorsRule, and ShareRetentionPolicy
78+
79+
``` yaml
80+
directive:
81+
- rename-model:
82+
from: Metrics
83+
to: ShareMetrics
84+
- rename-model:
85+
from: CorsRule
86+
to: ShareCorsRule
87+
- rename-model:
88+
from: RetentionPolicy
89+
to: ShareRetentionPolicy
90+
- rename-model:
91+
from: StorageServiceProperties
92+
to: ShareServiceProperties
93+
94+
- from: swagger-document
95+
where: $.definitions
96+
transform: >
97+
$.ShareMetrics.properties.IncludeAPIs["x-ms-client-name"] = "IncludeApis";
98+
$.ShareServiceProperties.xml = {"name": "StorageServiceProperties"};
99+
$.ShareCorsRule.xml = {"name": "CorsRule"};
100+
- from: swagger-document
101+
where: $.parameters
102+
transform: >
103+
$.StorageServiceProperties.name = "ShareServiceProperties";
104+
```
105+
106+
### Rename FileHttpHeaders to ShareFileHTTPHeaders and remove file prefix from properties
107+
108+
``` yaml
109+
directive:
110+
- from: swagger-document
111+
where: $.parameters
112+
transform: >
113+
$.FileCacheControl["x-ms-parameter-grouping"].name = "share-file-http-headers";
114+
$.FileCacheControl["x-ms-client-name"] = "cacheControl";
115+
$.FileContentDisposition["x-ms-parameter-grouping"].name = "share-file-http-headers";
116+
$.FileContentDisposition["x-ms-client-name"] = "contentDisposition";
117+
$.FileContentEncoding["x-ms-parameter-grouping"].name = "share-file-http-headers";
118+
$.FileContentEncoding["x-ms-client-name"] = "contentEncoding";
119+
$.FileContentLanguage["x-ms-parameter-grouping"].name = "share-file-http-headers";
120+
$.FileContentLanguage["x-ms-client-name"] = "contentLanguage";
121+
$.FileContentMD5["x-ms-parameter-grouping"].name = "share-file-http-headers";
122+
$.FileContentMD5["x-ms-client-name"] = "contentMd5";
123+
$.FileContentType["x-ms-parameter-grouping"].name = "share-file-http-headers";
124+
$.FileContentType["x-ms-client-name"] = "contentType";
125+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build go1.18
2+
// +build go1.18
3+
4+
//go:generate autorest ./autorest.md
5+
//go:generate gofmt -w .
6+
7+
// Copyright (c) Microsoft Corporation. All rights reserved.
8+
// Licensed under the MIT License. See License.txt in the project root for license information.
9+
10+
package generated

0 commit comments

Comments
 (0)