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 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
11 changes: 11 additions & 0 deletions sdk/storage/azfile/CHANGELOG.md
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
21 changes: 21 additions & 0 deletions sdk/storage/azfile/LICENSE.txt
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
28 changes: 28 additions & 0 deletions sdk/storage/azfile/ci.yml
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
9 changes: 9 additions & 0 deletions sdk/storage/azfile/doc.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 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
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.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
)
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.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=
125 changes: 125 additions & 0 deletions sdk/storage/azfile/internal/generated/autorest.md
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

``` 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";
```
10 changes: 10 additions & 0 deletions sdk/storage/azfile/internal/generated/build.go
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
Loading