Skip to content

Commit c3e8ebc

Browse files
support customize operation
1 parent d099078 commit c3e8ebc

6 files changed

Lines changed: 260 additions & 0 deletions

File tree

sdk/metricsadvisor/azure-ai-metricsadvisor/src/main/java/com/azure/ai/metricsadvisor/MetricsAdvisorAsyncClient.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package com.azure.ai.metricsadvisor;
55

66
import com.azure.ai.metricsadvisor.implementation.MetricsAdvisorClientImpl;
7+
import com.azure.ai.metricsadvisor.models.ListDataFeedOptions;
78
import com.azure.core.annotation.Generated;
89
import com.azure.core.annotation.ReturnType;
910
import com.azure.core.annotation.ServiceClient;
@@ -16,6 +17,7 @@
1617
import com.azure.core.http.rest.RequestOptions;
1718
import com.azure.core.http.rest.Response;
1819
import com.azure.core.util.BinaryData;
20+
import com.azure.core.util.Context;
1921
import reactor.core.publisher.Mono;
2022

2123
/** Initializes a new instance of the asynchronous MetricsAdvisorClient type. */
@@ -2519,4 +2521,37 @@ public PagedFlux<BinaryData> getEnrichmentStatusByMetric(
25192521
String metricId, BinaryData body, RequestOptions requestOptions) {
25202522
return this.serviceClient.getEnrichmentStatusByMetricAsync(metricId, body, requestOptions);
25212523
}
2524+
2525+
/**
2526+
* List information of all data feeds on the metrics advisor account.
2527+
*
2528+
* @param listDataFeedOptions The configurable {@link ListDataFeedOptions options} to pass for filtering the output result.
2529+
*
2530+
* @return A {@link PagedFlux} containing information of all the data feeds in the account.
2531+
*/
2532+
@ServiceMethod(returns = ReturnType.COLLECTION)
2533+
public PagedFlux<BinaryData> listDataFeeds(ListDataFeedOptions listDataFeedOptions) {
2534+
return listDataFeeds(listDataFeedOptions, Context.NONE);
2535+
}
2536+
2537+
PagedFlux<BinaryData> listDataFeeds(ListDataFeedOptions listDataFeedOptions, Context context) {
2538+
RequestOptions requestOptions = new RequestOptions().setContext(context);
2539+
if (listDataFeedOptions != null) {
2540+
if (listDataFeedOptions.getSkip() != null) {
2541+
requestOptions.addQueryParam("$skip", listDataFeedOptions.getSkip().toString());
2542+
}
2543+
if (listDataFeedOptions.getMaxPageSize() != null) {
2544+
requestOptions.addQueryParam("$maxpagesize", listDataFeedOptions.getMaxPageSize().toString());
2545+
}
2546+
if (listDataFeedOptions.getListDataFeedFilter() != null) {
2547+
if (listDataFeedOptions.getListDataFeedFilter().getName() != null) {
2548+
requestOptions.addQueryParam("dataFeedName", listDataFeedOptions.getListDataFeedFilter().getName());
2549+
}
2550+
if (listDataFeedOptions.getListDataFeedFilter().getCreator() != null) {
2551+
requestOptions.addQueryParam("creator", listDataFeedOptions.getListDataFeedFilter().getCreator());
2552+
}
2553+
}
2554+
}
2555+
return this.listDataFeeds(requestOptions);
2556+
}
25222557
}

sdk/metricsadvisor/azure-ai-metricsadvisor/src/main/java/com/azure/ai/metricsadvisor/MetricsAdvisorClient.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Code generated by Microsoft (R) AutoRest Code Generator.
44
package com.azure.ai.metricsadvisor;
55

6+
import com.azure.ai.metricsadvisor.models.ListDataFeedOptions;
67
import com.azure.core.annotation.Generated;
78
import com.azure.core.annotation.ReturnType;
89
import com.azure.core.annotation.ServiceClient;
@@ -15,6 +16,7 @@
1516
import com.azure.core.http.rest.RequestOptions;
1617
import com.azure.core.http.rest.Response;
1718
import com.azure.core.util.BinaryData;
19+
import com.azure.core.util.Context;
1820

1921
/** Initializes a new instance of the synchronous MetricsAdvisorClient type. */
2022
@ServiceClient(builder = MetricsAdvisorClientBuilder.class)
@@ -2528,4 +2530,17 @@ public PagedIterable<BinaryData> getEnrichmentStatusByMetric(
25282530
String metricId, BinaryData body, RequestOptions requestOptions) {
25292531
return new PagedIterable<>(this.asyncClient.getEnrichmentStatusByMetric(metricId, body, requestOptions));
25302532
}
2533+
2534+
/**
2535+
* List information of all data feeds on the metrics advisor account with REST response.
2536+
*
2537+
* @param options The configurable {@link ListDataFeedOptions options} to pass for filtering the output result.
2538+
* @param context Additional context that is passed through the Http pipeline during the service call.
2539+
*
2540+
* @return A {@link PagedIterable} containing information of all the data feeds in the account.
2541+
*/
2542+
@ServiceMethod(returns = ReturnType.COLLECTION)
2543+
public PagedIterable<BinaryData> listDataFeeds(ListDataFeedOptions options, Context context) {
2544+
return new PagedIterable<>(this.asyncClient.listDataFeeds(options, context));
2545+
}
25312546
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.ai.metricsadvisor.models;
5+
6+
import com.azure.core.annotation.Fluent;
7+
8+
/**
9+
* Additional properties to filter result for data feed list operations.
10+
*/
11+
@Fluent
12+
public final class ListDataFeedFilter {
13+
private String dataFeedName;
14+
private String creator;
15+
16+
/**
17+
* Gets the data feed name.
18+
*
19+
* @return the data feed name.
20+
*/
21+
public String getName() {
22+
return this.dataFeedName;
23+
}
24+
25+
/**
26+
* Gets the creator of the data feed.
27+
*
28+
* @return the creator of the data feed.
29+
*/
30+
public String getCreator() {
31+
return this.creator;
32+
}
33+
34+
/**
35+
* Sets the name for the data feed.
36+
*
37+
* @param dataFeedName the name for the data feed.
38+
*
39+
* @return the updated {@code ListDataFeedFilter} value.
40+
*/
41+
public ListDataFeedFilter setName(String dataFeedName) {
42+
this.dataFeedName = dataFeedName;
43+
return this;
44+
}
45+
46+
/**
47+
* Set the creator of the data feed.
48+
*
49+
* @param creator the creator of the data feed.
50+
*
51+
* @return the updated {@code ListDataFeedFilter} value.
52+
*/
53+
public ListDataFeedFilter setCreator(final String creator) {
54+
this.creator = creator;
55+
return this;
56+
}
57+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.ai.metricsadvisor.models;
5+
6+
import com.azure.core.annotation.Fluent;
7+
8+
/**
9+
* Additional properties for filtering results on the listDataFeeds operation.
10+
*/
11+
@Fluent
12+
public final class ListDataFeedOptions {
13+
private ListDataFeedFilter listDataFeedFilter;
14+
private Integer maxPageSize;
15+
private Integer skip;
16+
17+
/**
18+
* Get the additional data feed filter options that can be passed for filtering the result of the data feeds
19+
* returned by the service
20+
*
21+
* @return The data feed filter options used for filtering the result of the data feeds
22+
* returned by the service
23+
*/
24+
public ListDataFeedFilter getListDataFeedFilter() {
25+
return listDataFeedFilter;
26+
}
27+
28+
/**
29+
* Set the additional data feed filter options that can be passed for filtering the result of listDataFeeds
30+
* operation.
31+
*
32+
* @param listDataFeedFilter the additional data feed filter options that can be passed for filtering the data feeds
33+
* returned by the service.
34+
*
35+
* @return the updated {@code ListDataFeedOptions} value.
36+
*/
37+
public ListDataFeedOptions setListDataFeedFilter(final ListDataFeedFilter listDataFeedFilter) {
38+
this.listDataFeedFilter = listDataFeedFilter;
39+
return this;
40+
}
41+
42+
/**
43+
* Gets limit indicating the number of items that will be included in a service returned page.
44+
*
45+
* @return The max page size value.
46+
*/
47+
public Integer getMaxPageSize() {
48+
return maxPageSize;
49+
}
50+
51+
/**
52+
* Sets limit indicating the number of items to be included in a service returned page.
53+
*
54+
* @param maxPageSize The max page size value.
55+
*
56+
* @return The ListDataFeedOptions object itself.
57+
*/
58+
public ListDataFeedOptions setMaxPageSize(Integer maxPageSize) {
59+
this.maxPageSize = maxPageSize;
60+
return this;
61+
}
62+
63+
/**
64+
* Gets the number of items in the queried collection that will be skipped and not included
65+
* in the returned result.
66+
*
67+
* @return The skip value.
68+
*/
69+
public Integer getSkip() {
70+
return skip;
71+
}
72+
73+
/**
74+
* Sets the number of items in the queried collection that are to be skipped and not included
75+
* in the returned result.
76+
*
77+
* @param skip The skip value.
78+
*
79+
* @return ListDataFeedOptions itself.
80+
*/
81+
public ListDataFeedOptions setSkip(final Integer skip) {
82+
this.skip = skip;
83+
return this;
84+
}
85+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
// Code generated by Microsoft (R) AutoRest Code Generator.
4+
5+
package com.azure.ai.metricsadvisor;
6+
7+
import com.azure.ai.metricsadvisor.models.ListDataFeedFilter;
8+
import com.azure.ai.metricsadvisor.models.ListDataFeedOptions;
9+
import com.azure.core.http.rest.PagedIterable;
10+
import com.azure.core.util.BinaryData;
11+
import com.azure.core.util.Context;
12+
import org.junit.jupiter.api.Assertions;
13+
import org.junit.jupiter.api.Test;
14+
15+
public final class ListAllDataFeedsTests extends com.azure.ai.metricsadvisor.MetricsAdvisorClientTestBase {
16+
@Test
17+
public void testListAllDataFeedsTests() {
18+
String name = "Sample - cost/revenue - city/category";
19+
PagedIterable<BinaryData> response = metricsAdvisorClient.listDataFeeds(new ListDataFeedOptions()
20+
.setListDataFeedFilter(new ListDataFeedFilter().setName(name)), Context.NONE);
21+
Assertions.assertEquals(200, response.iterableByPage().iterator().next().getStatusCode());
22+
Assertions.assertTrue(response.stream().anyMatch(d -> d.toString().contains(name)));
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"networkCallRecords" : [ {
3+
"Method" : "GET",
4+
"Uri" : "https://REDACTED.cognitiveservices.azure.com//metricsadvisor/v1.0/dataFeeds?dataFeedName=Sample%20-%20cost/revenue%20-%20city/category",
5+
"Headers" : {
6+
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.1 (17.0.1; Windows 11; 10.0)"
7+
},
8+
"Response" : {
9+
"x-request-id" : "68cc3bdb-4587-460b-8319-395bf1b15b00",
10+
"content-length" : "1318",
11+
"x-envoy-upstream-service-time" : "643",
12+
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
13+
"x-content-type-options" : "nosniff",
14+
"apim-request-id" : "68cc3bdb-4587-460b-8319-395bf1b15b00",
15+
"retry-after" : "0",
16+
"StatusCode" : "200",
17+
"Body" : "{\"value\":[{\"dataFeedId\":\"45092f2b-7e9f-474a-9b79-73c4138bba42\",\"dataFeedName\":\"Sample - cost/revenue - city/category\",\"metrics\":[{\"metricId\":\"c8bb138b-2adb-4fb0-bf88-9cb04dbd3c8e\",\"metricName\":\"cost\",\"metricDisplayName\":\"cost\",\"metricDescription\":\"\"},{\"metricId\":\"a1499841-adfc-443f-9a00-bcd26421661b\",\"metricName\":\"revenue\",\"metricDisplayName\":\"revenue\",\"metricDescription\":\"\"}],\"dimension\":[{\"dimensionName\":\"category\",\"dimensionDisplayName\":\"category\"},{\"dimensionName\":\"city\",\"dimensionDisplayName\":\"city\"}],\"dataStartFrom\":\"2020-01-01T00:00:00Z\",\"dataSourceType\":\"SqlServer\",\"timestampColumn\":\"timestamp\",\"startOffsetInSeconds\":86400,\"maxQueryPerMinute\":30.0,\"granularityName\":\"Daily\",\"allUpIdentification\":\"__SUM__\",\"needRollup\":\"NeedRollup\",\"fillMissingPointType\":\"SmartFilling\",\"fillMissingPointValue\":0.0,\"rollUpMethod\":\"Sum\",\"dataFeedDescription\":\"This is a sample data feed.\",\"stopRetryAfterInSeconds\":604800,\"minRetryIntervalInSeconds\":3600,\"maxConcurrency\":5,\"viewMode\":\"Private\",\"admins\":[\"09cc0fa8-7726-4f19-9216-8e9b0321cfa2\"],\"viewers\":[],\"creator\":\"09cc0fa8-7726-4f19-9216-8e9b0321cfa2\",\"status\":\"Active\",\"createdTime\":\"2022-03-14T05:13:40Z\",\"isAdmin\":true,\"actionLinkTemplate\":\"\",\"dataSourceParameter\":{\"query\":\"select * from your_table where timestamp = @StartTime\"},\"authenticationType\":\"Basic\"}]}",
18+
"Date" : "Mon, 14 Mar 2022 05:13:56 GMT",
19+
"Content-Type" : "application/json; charset=utf-8"
20+
},
21+
"Exception" : null
22+
}, {
23+
"Method" : "GET",
24+
"Uri" : "https://REDACTED.cognitiveservices.azure.com//metricsadvisor/v1.0/dataFeeds?dataFeedName=Sample%20-%20cost/revenue%20-%20city/category",
25+
"Headers" : {
26+
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.1 (17.0.1; Windows 11; 10.0)"
27+
},
28+
"Response" : {
29+
"x-request-id" : "6d9feaab-9de6-4019-875a-728a0d23c3b5",
30+
"content-length" : "1318",
31+
"x-envoy-upstream-service-time" : "499",
32+
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
33+
"x-content-type-options" : "nosniff",
34+
"apim-request-id" : "6d9feaab-9de6-4019-875a-728a0d23c3b5",
35+
"retry-after" : "0",
36+
"StatusCode" : "200",
37+
"Body" : "{\"value\":[{\"dataFeedId\":\"45092f2b-7e9f-474a-9b79-73c4138bba42\",\"dataFeedName\":\"Sample - cost/revenue - city/category\",\"metrics\":[{\"metricId\":\"c8bb138b-2adb-4fb0-bf88-9cb04dbd3c8e\",\"metricName\":\"cost\",\"metricDisplayName\":\"cost\",\"metricDescription\":\"\"},{\"metricId\":\"a1499841-adfc-443f-9a00-bcd26421661b\",\"metricName\":\"revenue\",\"metricDisplayName\":\"revenue\",\"metricDescription\":\"\"}],\"dimension\":[{\"dimensionName\":\"category\",\"dimensionDisplayName\":\"category\"},{\"dimensionName\":\"city\",\"dimensionDisplayName\":\"city\"}],\"dataStartFrom\":\"2020-01-01T00:00:00Z\",\"dataSourceType\":\"SqlServer\",\"timestampColumn\":\"timestamp\",\"startOffsetInSeconds\":86400,\"maxQueryPerMinute\":30.0,\"granularityName\":\"Daily\",\"allUpIdentification\":\"__SUM__\",\"needRollup\":\"NeedRollup\",\"fillMissingPointType\":\"SmartFilling\",\"fillMissingPointValue\":0.0,\"rollUpMethod\":\"Sum\",\"dataFeedDescription\":\"This is a sample data feed.\",\"stopRetryAfterInSeconds\":604800,\"minRetryIntervalInSeconds\":3600,\"maxConcurrency\":5,\"viewMode\":\"Private\",\"admins\":[\"09cc0fa8-7726-4f19-9216-8e9b0321cfa2\"],\"viewers\":[],\"creator\":\"09cc0fa8-7726-4f19-9216-8e9b0321cfa2\",\"status\":\"Active\",\"createdTime\":\"2022-03-14T05:13:40Z\",\"isAdmin\":true,\"actionLinkTemplate\":\"\",\"dataSourceParameter\":{\"query\":\"select * from your_table where timestamp = @StartTime\"},\"authenticationType\":\"Basic\"}]}",
38+
"Date" : "Mon, 14 Mar 2022 05:13:57 GMT",
39+
"Content-Type" : "application/json; charset=utf-8"
40+
},
41+
"Exception" : null
42+
} ],
43+
"variables" : [ ]
44+
}

0 commit comments

Comments
 (0)