a5410061cf | ||
---|---|---|
.. | ||
README.md | ||
blob.json |
README.md
Azure Blob Storage for Golang
Generation
cd swagger
autorest README.md --use=@microsoft.azure/autorest.go@v3.0.63
gofmt -w Go_BlobStorage/*
Settings
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-10-02/blob.json
go: true
output-folder: Go_BlobStorage
namespace: azblob
go-export-clients: false
enable-xml: true
file-prefix: zz_generated_
Remove ContainerName and BlobName from parameter list since they are not needed
directive:
- from: swagger-document
where: $["x-ms-paths"]
transform: >
for (const property in $)
{
if (property.includes('/{containerName}/{blob}'))
{
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ContainerName") && false == param['$ref'].endsWith("#/parameters/Blob"))});
}
else if (property.includes('/{containerName}'))
{
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ContainerName"))});
}
}
Set blob metadata to the right type
directive:
- from: swagger-document
where: $.definitions
transform: >
$["BlobMetadata"] = {
"type": "object",
"xml": {
"name": "Metadata"
},
"additionalProperties": {
"type": "string"
}
}
Generate immutability policy correctly
directive:
- from: swagger-document
where: $.parameters.ImmutabilityPolicyMode
transform: >
$.enum = [
"mutable",
"unlocked",
"locked"
]
directive:
- from: swagger-document
where: $["x-ms-paths"].*.*.responses.*.headers["x-ms-immutability-policy-mode"]
transform: >
$.enum = [
"mutable",
"unlocked",
"locked"
]
directive:
- from: swagger-document
where: $.definitions.BlobPropertiesInternal.properties.ImmutabilityPolicyMode
transform: >
$.enum = [
"mutable",
"unlocked",
"locked"
]
Add permissions to ListBlobsInclude
This does work, it's just not documented, or in the swagger unfortunately. Some directives jank it in.
These directives may need to be removed eventually, once these items are included.
For some reason, permissions gets added 3x, so a check for includes is added.
directive:
- from: swagger-document
where: $.parameters.ListBlobsInclude
transform: >
if (!$.items.enum.includes("permissions"))
$.items.enum.push("permissions")
directive:
- from: swagger-document
where: $.definitions.BlobPropertiesInternal
transform: >
$.properties["Owner"] = {
"type": "string"
};
$.properties["Group"] = {
"type": "string"
};
$.properties["Permissions"] = {
"type": "string"
};
$.properties["Acl"] = {
"type": "string"
};
ETags
Headers
directive:
- from: swagger-document
where: $["x-ms-paths"].*.*.responses.*.headers["ETag"]
transform: >
$.format = "etag"
Properties
directive:
- from: swagger-document
where: $.definitions.BlobPropertiesInternal.properties.Etag
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.definitions.ContainerProperties.properties.Etag
transform: >
$.format = "etag"
[Source]If*Match
directive:
- from: swagger-document
where: $.parameters.IfMatch
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.parameters.IfNoneMatch
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.parameters.SourceIfMatch
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.parameters.SourceIfNoneMatch
transform: >
$.format = "etag"
Remove BlobName & ContainerName parameters
directive:
- from: swagger-document
where: $["x-ms-paths"].*
transform: >
$.parameters = $.parameters.filter(x => x["$ref"] == undefined || !(x["$ref"] == "#/parameters/ContainerName" || x["$ref"] == "#/parameters/Blob"))
Remove Marker & MaxResults from GetPageRange & GetPageRangeDiff
directive:
- from: swagger-document
where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist"]["get"]
transform: >
$.parameters = $.parameters.filter(x => x["$ref"] == undefined || !(x["$ref"] == "#/parameters/Marker" || x["$ref"] == "#/parameters/MaxResults"))
directive:
- from: swagger-document
where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist&diff"]["get"]
transform: >
$.parameters = $.parameters.filter(x => x["$ref"] == undefined || !(x["$ref"] == "#/parameters/Marker" || x["$ref"] == "#/parameters/MaxResults"))