-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[azquery] regenerate and clean up (#21965)
* update dependencies * autorest separate logs and metrics * upgrade code gen version * update utils_file * refactor autorest * update code generator * charles feedback
- Loading branch information
1 parent
bdda6a6
commit a2b542f
Showing
14 changed files
with
347 additions
and
363 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,25 +1,18 @@ | ||
## Go | ||
|
||
``` yaml | ||
title: MonitorQueryClient | ||
description: Azure Monitor Query Go Client | ||
generated-metadata: false | ||
|
||
title: Logs Query Client | ||
clear-output-folder: false | ||
export-clients: true | ||
go: true | ||
input-file: | ||
- https://github.com/Azure/azure-rest-api-specs/blob/72427ef3ff5875bd8409ef112ef5e6f3cf2b8795/specification/operationalinsights/data-plane/Microsoft.OperationalInsights/stable/2022-10-27/OperationalInsights.json | ||
- https://github.com/Azure/azure-rest-api-specs/blob/dba6ed1f03bda88ac6884c0a883246446cc72495/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json | ||
- https://github.com/Azure/azure-rest-api-specs/blob/dba6ed1f03bda88ac6884c0a883246446cc72495/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json | ||
- https://github.com/Azure/azure-rest-api-specs/blob/dba6ed1f03bda88ac6884c0a883246446cc72495/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/metricNamespaces_API.json | ||
license-header: MICROSOFT_MIT_NO_VERSION | ||
module: github.com/Azure/azure-sdk-for-go/sdk/monitor/azquery | ||
openapi-type: "data-plane" | ||
output-folder: ../azquery | ||
override-client-name: LogsClient | ||
security: "AADToken" | ||
use: "@autorest/[email protected].46" | ||
use: "@autorest/[email protected].60" | ||
version: "^3.0.0" | ||
|
||
directive: | ||
|
@@ -34,12 +27,8 @@ directive: | |
delete $["/{resourceId}/query?disambiguation_dummy"]; | ||
# delete extra operations | ||
- remove-operation: Metadata_Post | ||
- remove-operation: Metadata_Get | ||
- remove-operation: Query_Get | ||
- remove-operation: Query_ResourceGet | ||
- remove-operation: Query_ResourceExecuteXms | ||
- remove-operation: Query_ResourceGetXms | ||
|
||
# delete metadata models | ||
- remove-model: metadataResults | ||
|
@@ -54,7 +43,7 @@ directive: | |
- remove-model: metadataResource | ||
- remove-model: metadataPermissions | ||
|
||
# rename operations to generate into metrics and logs clients | ||
# rename log operations to generate into a separate logs client | ||
- rename-operation: | ||
from: Query_Execute | ||
to: Logs_QueryWorkspace | ||
|
@@ -64,35 +53,6 @@ directive: | |
- rename-operation: | ||
from: Query_ResourceExecute | ||
to: Logs_QueryResource | ||
- rename-operation: | ||
from: Metrics_List | ||
to: Metrics_QueryResource | ||
- rename-operation: | ||
from: MetricDefinitions_List | ||
to: Metrics_ListDefinitions | ||
- rename-operation: | ||
from: MetricNamespaces_List | ||
to: Metrics_ListNamespaces | ||
|
||
# rename some metrics fields | ||
- from: swagger-document | ||
where: $.definitions.Metric.properties.timeseries | ||
transform: $["x-ms-client-name"] = "TimeSeries" | ||
- from: swagger-document | ||
where: $.definitions.TimeSeriesElement.properties.metadatavalues | ||
transform: $["x-ms-client-name"] = "MetadataValues" | ||
- from: swagger-document | ||
where: $.definitions.Response.properties.resourceregion | ||
transform: $["x-ms-client-name"] = "ResourceRegion" | ||
- from: swagger-document | ||
where: $.parameters.MetricNamespaceParameter | ||
transform: $["x-ms-client-name"] = "MetricNamespace" | ||
- from: swagger-document | ||
where: $.parameters.MetricNamesParameter | ||
transform: $["x-ms-client-name"] = "MetricNames" | ||
- from: swagger-document | ||
where: $.parameters.OrderByParameter | ||
transform: $["x-ms-client-name"] = "OrderBy" | ||
|
||
# rename Body.Workspaces to Body.AdditionalWorkspaces | ||
- from: swagger-document | ||
|
@@ -124,7 +84,7 @@ directive: | |
- from: swagger-document | ||
where: $.parameters.PreferHeaderParameter | ||
transform: $["x-ms-client-name"] = "Options" | ||
- from: models.go | ||
- from: options.go | ||
where: $ | ||
transform: return $.replace(/Options \*string/g, "Options *LogsQueryOptions"); | ||
- from: logs_client.go | ||
|
@@ -181,26 +141,69 @@ directive: | |
where: $ | ||
transform: return $.replace(/const host = "(.*?)"/, ""); | ||
|
||
# change Table.Rows from type [][]interface{} to type []Row | ||
# change Table.Rows from type [][]byte to type []Row | ||
- from: models.go | ||
where: $ | ||
transform: return $.replace(/Rows \[\]\[\]byte/, "Rows []Row"); | ||
transform: return $.replace(/Rows \[\]\[\]\[\]byte/g, "Rows []Row"); | ||
|
||
# change type of timespan from *string to *TimeInterval | ||
- from: models.go | ||
- from: | ||
- models.go | ||
- options.go | ||
where: $ | ||
transform: return $.replace(/Timespan \*string/g, "Timespan *TimeInterval"); | ||
- from: metrics_client.go | ||
where: $ | ||
transform: return $.replace(/reqQP\.Set\(\"timespan\", \*options\.Timespan\)/g, "reqQP.Set(\"timespan\", string(*options.Timespan))"); | ||
``` | ||
``` yaml | ||
title: Metrics Query Client | ||
input-file: | ||
- https://github.com/Azure/azure-rest-api-specs/blob/dba6ed1f03bda88ac6884c0a883246446cc72495/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json | ||
- https://github.com/Azure/azure-rest-api-specs/blob/dba6ed1f03bda88ac6884c0a883246446cc72495/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json | ||
- https://github.com/Azure/azure-rest-api-specs/blob/dba6ed1f03bda88ac6884c0a883246446cc72495/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/metricNamespaces_API.json | ||
|
||
directive: | ||
# rename metric operations to generate as a separate metrics client | ||
- rename-operation: | ||
from: Metrics_List | ||
to: Metrics_QueryResource | ||
- rename-operation: | ||
from: MetricDefinitions_List | ||
to: Metrics_ListDefinitions | ||
- rename-operation: | ||
from: MetricNamespaces_List | ||
to: Metrics_ListNamespaces | ||
|
||
# rename some metrics fields | ||
- from: swagger-document | ||
where: $.definitions.Metric.properties.timeseries | ||
transform: $["x-ms-client-name"] = "TimeSeries" | ||
- from: swagger-document | ||
where: $.definitions.TimeSeriesElement.properties.metadatavalues | ||
transform: $["x-ms-client-name"] = "MetadataValues" | ||
- from: swagger-document | ||
where: $.definitions.Response.properties.resourceregion | ||
transform: $["x-ms-client-name"] = "ResourceRegion" | ||
- from: swagger-document | ||
where: $.parameters.MetricNamespaceParameter | ||
transform: $["x-ms-client-name"] = "MetricNamespace" | ||
- from: swagger-document | ||
where: $.parameters.MetricNamesParameter | ||
transform: $["x-ms-client-name"] = "MetricNames" | ||
- from: swagger-document | ||
where: $.parameters.OrderByParameter | ||
transform: $["x-ms-client-name"] = "OrderBy" | ||
|
||
# change type of MetricsClientQueryResourceOptions.Aggregation from *string to []*AggregationType | ||
- from: models.go | ||
- from: options.go | ||
where: $ | ||
transform: return $.replace(/Aggregation \*string/g, "Aggregation []*AggregationType"); | ||
- from: metrics_client.go | ||
where: $ | ||
transform: return $.replace(/\*options.Aggregation/g, "aggregationTypeToString(options.Aggregation)"); | ||
- from: swagger-document | ||
where: $.parameters.AggregationsParameter | ||
transform: $["description"] = "The list of aggregation types to retrieve" | ||
transform: $["description"] = "The list of aggregation types to retrieve" | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Oops, something went wrong.