Skip to content
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
2 changes: 1 addition & 1 deletion sdk/monitor/azquery/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/monitor/azquery",
"Tag": "go/monitor/azquery_98fd781041"
"Tag": "go/monitor/azquery_123118d585"
Comment thread
chlowell marked this conversation as resolved.
}
13 changes: 12 additions & 1 deletion sdk/monitor/azquery/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,15 @@ directive:
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))");
transform: return $.replace(/reqQP\.Set\(\"timespan\", \*options\.Timespan\)/g, "reqQP.Set(\"timespan\", string(*options.Timespan))");

# change type of MetricsClientQueryResourceOptions.Aggregation from *string to []*AggregationType
- from: models.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"
10 changes: 10 additions & 0 deletions sdk/monitor/azquery/custom_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,13 @@ func NewBatchQueryRequest(workspaceID string, query string, timespan TimeInterva
Headers: optionsMap,
}
}

// aggregationTypeToString converts []*AggregationType to string, so the values can be sent
// in MetricsClient.QueryResource
func aggregationTypeToString(aggregations []*AggregationType) string {
var s []string
for _, aggregation := range aggregations {
s = append(s, string(*aggregation))
}
return strings.Join(s, ",")
}
2 changes: 1 addition & 1 deletion sdk/monitor/azquery/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func ExampleMetricsClient_QueryResource() {
Timespan: to.Ptr(azquery.NewTimeInterval(time.Date(2022, 12, 25, 0, 0, 0, 0, time.UTC), time.Date(2022, 12, 25, 12, 0, 0, 0, time.UTC))),
Interval: to.Ptr("PT1M"),
MetricNames: nil,
Aggregation: to.Ptr("Average,count"),
Aggregation: to.SliceOfPtrs(azquery.AggregationTypeAverage, azquery.AggregationTypeCount),
Top: to.Ptr[int32](3),
OrderBy: to.Ptr("Average asc"),
Filter: to.Ptr("BlobType eq '*'"),
Expand Down
2 changes: 1 addition & 1 deletion sdk/monitor/azquery/metrics_client.go

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

5 changes: 3 additions & 2 deletions sdk/monitor/azquery/metrics_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ func TestQueryResource_BasicQuerySuccess(t *testing.T) {
client := startMetricsTest(t)
timespan := azquery.TimeInterval("PT12H")
res, err := client.QueryResource(context.Background(), resourceURI,
&azquery.MetricsClientQueryResourceOptions{Timespan: to.Ptr(timespan),
&azquery.MetricsClientQueryResourceOptions{
Timespan: to.Ptr(timespan),
Interval: to.Ptr("PT1M"),
MetricNames: nil,
Aggregation: to.Ptr("Average,count"),
Aggregation: to.SliceOfPtrs(azquery.AggregationTypeAverage, azquery.AggregationTypeCount),
Top: nil,
OrderBy: to.Ptr("Average asc"),
Filter: nil,
Expand Down
4 changes: 2 additions & 2 deletions sdk/monitor/azquery/models.go

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