-
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 6 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 @@ | ||
module github.com/Azure/azure-sdk-for-go/sdk/storage/azfile | ||
|
||
go 1.19 | ||
|
||
require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 | ||
|
||
require ( | ||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // 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.2.0 h1:sVW/AFBTGyJxDaMYlq0ct3jUXTtj12tQ6zE2GZUgVQw= | ||
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= | ||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= | ||
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/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,171 @@ | ||
# 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/main/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"))}); | ||
} | ||
} | ||
``` | ||
|
||
### Use strings for dates in responses | ||
jhendrixMSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
``` yaml | ||
directive: | ||
- from: swagger-document | ||
where: $["x-ms-paths"]..responses..headers["x-ms-file-last-write-time"] | ||
transform: > | ||
$.format = "str"; | ||
- from: swagger-document | ||
where: $["x-ms-paths"]..responses..headers["x-ms-file-change-time"] | ||
transform: > | ||
$.format = "str"; | ||
- from: swagger-document | ||
where: $["x-ms-paths"]..responses..headers["x-ms-file-creation-time"] | ||
transform: > | ||
$.format = "str"; | ||
- from: swagger-document | ||
where: $.parameters.FileChangeTime | ||
transform: > | ||
$.format = "str"; | ||
``` | ||
|
||
### Change new SMB file parameters to use default values | ||
souravgupta-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
``` yaml | ||
directive: | ||
- from: swagger-document | ||
where: $.parameters.FileCreationTime | ||
transform: > | ||
$.format = "str"; | ||
$.default = "now"; | ||
- from: swagger-document | ||
where: $.parameters.FileLastWriteTime | ||
transform: > | ||
$.format = "str"; | ||
$.default = "now"; | ||
- from: swagger-document | ||
where: $.parameters.FileAttributes | ||
transform: > | ||
$.default = "none"; | ||
- from: swagger-document | ||
where: $.parameters.FilePermission | ||
transform: > | ||
$.default = "inherit"; | ||
``` | ||
|
||
### 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 | ||
jhendrixMSFT marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
``` 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"; | ||
``` |
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.