Skip to content

Commit

Permalink
Generate Code for AzQueue (#19729)
Browse files Browse the repository at this point in the history
* first generation

* removed queuename from url param

* fixed georep

* removed pagination

* move to internal

* last generation
  • Loading branch information
tasherif-msft authored Dec 28, 2022
1 parent 575bc88 commit 3228b2c
Show file tree
Hide file tree
Showing 14 changed files with 2,501 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sdk/storage/azqueue/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/azqueue

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/azqueue/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=
70 changes: 70 additions & 0 deletions sdk/storage/azqueue/internal/generated/autorest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Code Generation - Azure Queue 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.QueueStorage/preview/2018-03-28/queue.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]"
```
### Remove QueueName from parameter list since it is not needed
``` yaml
directive:
- from: swagger-document
where: $["x-ms-paths"]
transform: >
for (const property in $)
{
if (property.includes('/{queueName}/messages/{messageid}'))
{
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/QueueName") && false == param['$ref'].endsWith("#/parameters/MessageId"))});
}
else if (property.includes('/{queueName}'))
{
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/QueueName"))});
}
}
```
### Fix GeoReplication
``` yaml
directive:
- from: swagger-document
where: $.definitions
transform: >
delete $.GeoReplication.properties.Status["x-ms-enum"];
$.GeoReplication.properties.Status["x-ms-enum"] = {
"name": "QueueGeoReplicationStatus",
"modelAsString": false
};
```
### Remove pager method (since we implement it ourselves on the client layer) and export various generated methods in service client to utilize them in higher layers
``` yaml
directive:
- from: zz_service_client.go
where: $
transform: >-
return $.
replace(/func \(client \*ServiceClient\) NewListQueuesSegmentPager\(.+\/\/ listQueuesSegmentCreateRequest creates the ListQueuesSegment request/s, `// ListQueuesSegmentCreateRequest creates the ListQueuesFlatSegment ListQueuesSegment`).
replace(/\(client \*ServiceClient\) listQueuesSegmentCreateRequest\(/, `(client *ServiceClient) ListQueuesSegmentCreateRequest(`).
replace(/\(client \*ServiceClient\) listQueuesSegmentHandleResponse\(/, `(client *ServiceClient) ListQueuesSegmentHandleResponse(`);
```
155 changes: 155 additions & 0 deletions sdk/storage/azqueue/internal/generated/zz_constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3228b2c

Please sign in to comment.