Skip to content

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 14 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
11 changes: 11 additions & 0 deletions sdk/storage/azfile/go.mod
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
)
12 changes: 12 additions & 0 deletions sdk/storage/azfile/go.sum
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=
171 changes: 171 additions & 0 deletions sdk/storage/azfile/internal/generated/autorest.md
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

``` 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

``` 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

``` 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

``` 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";
```
Loading