-
Notifications
You must be signed in to change notification settings - Fork 911
Code generation for Azure Storage Files #19757
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9fba771
Init
souravgupta-msft 62e45d0
Reformat code
souravgupta-msft 0493788
Adding transforms
souravgupta-msft 9ddaf65
Adding transforms
souravgupta-msft 023f75a
Adding transforms
souravgupta-msft 51235e4
Typo
souravgupta-msft 340204f
Updating go version
souravgupta-msft 264812d
Converting to time.Time
souravgupta-msft b6f6c3f
Updating autorest version
souravgupta-msft 01c699d
Adding changelog and build.go files
souravgupta-msft 2045617
add license and CI file
jhendrixMSFT ae3062c
pin swagger to commit
jhendrixMSFT a8158fd
Remove transform for using default values
souravgupta-msft 87fe0b3
update dependencies and add doc.go
jhendrixMSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Release History | ||
|
||
## 0.1.0 (Unreleased) | ||
|
||
### Features Added | ||
|
||
### Breaking Changes | ||
|
||
### Bugs Fixed | ||
|
||
### Other Changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
trigger: | ||
branches: | ||
include: | ||
- main | ||
- feature/* | ||
- hotfix/* | ||
- release/* | ||
paths: | ||
include: | ||
- sdk/storage/azfile | ||
|
||
pr: | ||
branches: | ||
include: | ||
- main | ||
- feature/* | ||
- hotfix/* | ||
- release/* | ||
paths: | ||
include: | ||
- sdk/storage/azfile | ||
|
||
|
||
stages: | ||
- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml | ||
parameters: | ||
ServiceDirectory: 'storage/azfile' | ||
RunLiveTests: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 azfile provides access to Azure File storage. | ||
// For more information please see https://learn.microsoft.com/rest/api/storageservices/file-service-rest-api | ||
package azfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module github.com/Azure/azure-sdk-for-go/sdk/storage/azfile | ||
|
||
go 1.18 | ||
|
||
require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0 | ||
|
||
require ( | ||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 // indirect | ||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0 h1:VuHAcMq8pU1IWNT/m5yRaGqbK0BiQKHT8X4DTp9CHdI= | ||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.3.0/go.mod h1:tZoQYdDZNOiIjdSn0dVWVfl0NEPGOJqVLzSrcFk4Is0= | ||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1 h1:Oj853U9kG+RLTCQXpjvOnrv0WaZHxgmZz1TlLywgOPY= | ||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.1/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= | ||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= | ||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= | ||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | ||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Code Generation - Azure File SDK for Golang | ||
|
||
### Settings | ||
|
||
```yaml | ||
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/bbea558ac43d6ebec72455233c84b0158c89fcda/specification/storage/data-plane/Microsoft.FileStorage/preview/2020-10-02/file.json" | ||
credential-scope: "https://storage.azure.com/.default" | ||
output-folder: ../generated | ||
file-prefix: "zz_" | ||
openapi-type: "data-plane" | ||
verbose: true | ||
security: AzureKey | ||
modelerfour: | ||
group-parameters: false | ||
seal-single-value-enum-by-default: true | ||
lenient-model-deduplication: true | ||
export-clients: true | ||
use: "@autorest/[email protected]" | ||
``` | ||
|
||
### Don't include share name, directory, or file name in path - we have direct URIs | ||
|
||
``` yaml | ||
directive: | ||
- from: swagger-document | ||
where: $["x-ms-paths"] | ||
transform: > | ||
for (const property in $) | ||
{ | ||
if (property.includes('/{shareName}/{directory}/{fileName}')) | ||
{ | ||
$[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"))}); | ||
} | ||
else if (property.includes('/{shareName}/{directory}')) | ||
{ | ||
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName") && false == param['$ref'].endsWith("#/parameters/DirectoryPath"))}); | ||
} | ||
else if (property.includes('/{shareName}')) | ||
{ | ||
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName"))}); | ||
} | ||
} | ||
``` | ||
|
||
### Add Last-Modified to SetMetadata | ||
|
||
``` yaml | ||
directive: | ||
- from: swagger-document | ||
where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=metadata"] | ||
transform: > | ||
$.put.responses["200"].headers["Last-Modified"] = { | ||
"type": "string", | ||
"format": "date-time-rfc1123", | ||
"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." | ||
} | ||
``` | ||
|
||
### Add Content-MD5 to Put Range from URL | ||
|
||
``` yaml | ||
directive: | ||
- from: swagger-document | ||
where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=range&fromURL"] | ||
transform: > | ||
$.put.responses["201"].headers["Content-MD5"] = { | ||
"type": "string", | ||
"format": "byte", | ||
"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." | ||
} | ||
``` | ||
|
||
### ShareServiceProperties, ShareMetrics, ShareCorsRule, and ShareRetentionPolicy | ||
|
||
``` yaml | ||
directive: | ||
- rename-model: | ||
from: Metrics | ||
to: ShareMetrics | ||
- rename-model: | ||
from: CorsRule | ||
to: ShareCorsRule | ||
- rename-model: | ||
from: RetentionPolicy | ||
to: ShareRetentionPolicy | ||
- rename-model: | ||
from: StorageServiceProperties | ||
to: ShareServiceProperties | ||
|
||
- from: swagger-document | ||
where: $.definitions | ||
transform: > | ||
$.ShareMetrics.properties.IncludeAPIs["x-ms-client-name"] = "IncludeApis"; | ||
$.ShareServiceProperties.xml = {"name": "StorageServiceProperties"}; | ||
$.ShareCorsRule.xml = {"name": "CorsRule"}; | ||
- from: swagger-document | ||
where: $.parameters | ||
transform: > | ||
$.StorageServiceProperties.name = "ShareServiceProperties"; | ||
``` | ||
|
||
### Rename FileHttpHeaders to ShareFileHTTPHeaders and remove file prefix from properties | ||
souravgupta-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
``` yaml | ||
directive: | ||
- from: swagger-document | ||
where: $.parameters | ||
transform: > | ||
$.FileCacheControl["x-ms-parameter-grouping"].name = "share-file-http-headers"; | ||
$.FileCacheControl["x-ms-client-name"] = "cacheControl"; | ||
$.FileContentDisposition["x-ms-parameter-grouping"].name = "share-file-http-headers"; | ||
$.FileContentDisposition["x-ms-client-name"] = "contentDisposition"; | ||
$.FileContentEncoding["x-ms-parameter-grouping"].name = "share-file-http-headers"; | ||
$.FileContentEncoding["x-ms-client-name"] = "contentEncoding"; | ||
$.FileContentLanguage["x-ms-parameter-grouping"].name = "share-file-http-headers"; | ||
$.FileContentLanguage["x-ms-client-name"] = "contentLanguage"; | ||
$.FileContentMD5["x-ms-parameter-grouping"].name = "share-file-http-headers"; | ||
$.FileContentMD5["x-ms-client-name"] = "contentMd5"; | ||
$.FileContentType["x-ms-parameter-grouping"].name = "share-file-http-headers"; | ||
$.FileContentType["x-ms-client-name"] = "contentType"; | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//go:build go1.18 | ||
// +build go1.18 | ||
|
||
//go:generate autorest ./autorest.md | ||
//go:generate gofmt -w . | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
||
package generated |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.