Skip to content

Commit cce4b29

Browse files
author
Rakshith Bhyravabhotla
authored
Rename Query APIs (Azure#20830)
1 parent f2b2cea commit cce4b29

24 files changed

+56
-54
lines changed

sdk/monitor/azure-monitor-query/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
### Breaking Changes
1313

1414
- `LogsQueryResult` now iterates over the tables directly as a convinience.
15-
- `query` API now returns a union of `LogsQueryPartialResult` and `LogsQueryResult`.
15+
- `query` API in logs is renamed to `query_workspace`
16+
- `query` API in metrics is renamed to `query_resource`
17+
- `query_workspace` API now returns a union of `LogsQueryPartialResult` and `LogsQueryResult`.
1618
- `query_batch` API now returns a union of `LogsQueryPartialResult`, `LogsQueryError` and `LogsQueryResult`.
1719
- `metric_namespace` is renamed to `namespace` and is a keyword-only argument in `list_metric_definitions` API.
1820

sdk/monitor/azure-monitor-query/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ start_time=datetime(2021, 7, 2)
122122
end_time=datetime.now()
123123

124124
# returns LogsQueryResult
125-
response = client.query(
125+
response = client.query_workspace(
126126
os.environ['LOG_WORKSPACE_ID'],
127127
query,
128128
timespan=(start_time, end_time)
@@ -230,7 +230,7 @@ from azure.identity import DefaultAzureCredential
230230
credential = DefaultAzureCredential()
231231
client = LogsQueryClient(credential)
232232

233-
response = client.query(
233+
response = client.query_workspace(
234234
os.environ['LOG_WORKSPACE_ID'],
235235
"range x from 1 to 10000000000 step 1 | count",
236236
server_timeout=1,
@@ -250,7 +250,7 @@ The same logs query can be executed across multiple Log Analytics workspaces. In
250250
For example, the following query executes in three workspaces:
251251

252252
```python
253-
client.query(
253+
client.query_workspace(
254254
<workspace_id>,
255255
query,
256256
additional_workspaces=['<workspace 2>', '<workspace 3>']
@@ -282,7 +282,7 @@ client = MetricsQueryClient(credential)
282282
start_time = datetime(2021, 5, 25)
283283
duration = timedelta(days=1)
284284
metrics_uri = os.environ['METRICS_RESOURCE_URI']
285-
response = client.query(
285+
response = client.query_resource(
286286
metrics_uri,
287287
metric_names=["PublishSuccessCount"],
288288
timespan=(start_time, duration)
@@ -328,7 +328,7 @@ credential = DefaultAzureCredential()
328328
client = MetricsQueryClient(credential)
329329

330330
metrics_uri = os.environ['METRICS_RESOURCE_URI']
331-
response = client.query(
331+
response = client.query_resource(
332332
metrics_uri,
333333
metric_names=["MatchedEventCount"],
334334
aggregations=[MetricAggregationType.COUNT]

sdk/monitor/azure-monitor-query/azure/monitor/query/_logs_query_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, credential, **kwargs):
5858
self._query_op = self._client.query
5959

6060
@distributed_trace
61-
def query(self, workspace_id, query, **kwargs):
61+
def query_workspace(self, workspace_id, query, **kwargs):
6262
# type: (str, str, Any) -> Union[LogsQueryResult, LogsQueryPartialResult]
6363
"""Execute an Analytics query.
6464

sdk/monitor/azure-monitor-query/azure/monitor/query/_metrics_query_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def __init__(self, credential, **kwargs):
5656
self._definitions_op = self._client.metric_definitions
5757

5858
@distributed_trace
59-
def query(self, resource_uri, metric_names, **kwargs):
59+
def query_resource(self, resource_uri, metric_names, **kwargs):
6060
# type: (str, list, Optional[timedelta], Any) -> MetricsResult
6161
"""Lists the metric values for a resource.
6262

sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_logs_query_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
4242
self._query_op = self._client.query
4343

4444
@distributed_trace_async
45-
async def query(
45+
async def query_workspace(
4646
self,
4747
workspace_id: str,
4848
query: str,

sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
4848
self._definitions_op = self._client.metric_definitions
4949

5050
@distributed_trace_async
51-
async def query(
51+
async def query_resource(
5252
self, resource_uri: str, metric_names: List, **kwargs: Any
5353
) -> MetricsResult:
5454
"""Lists the metric values for a resource.

sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def logs_query():
2424

2525
# returns LogsQueryResult
2626
async with client:
27-
response = await client.query(os.environ['LOG_WORKSPACE_ID'], query, timespan=None)
27+
response = await client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=None)
2828

2929
if not response.tables:
3030
print("No results for the query")

sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def query_metrics():
1717

1818
metrics_uri = os.environ['METRICS_RESOURCE_URI']
1919
async with client:
20-
response = await client.query(
20+
response = await client.query_resource(
2121
metrics_uri,
2222
metric_names=["Ingress"],
2323
timespan=timedelta(hours=2),

sdk/monitor/azure-monitor-query/samples/sample_log_query_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
# returns LogsQueryResult
2323
try:
24-
response = client.query(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1))
24+
response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(days=1))
2525
if response.status == LogsQueryStatus.PARTIAL:
2626
# handle error here
2727
error = response.partial_error

sdk/monitor/azure-monitor-query/samples/sample_log_query_client_without_pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
summarize avgRequestDuration=avg(DurationMs) by bin(TimeGenerated, 10m), _ResourceId"""
1818

1919
# returns LogsQueryResult
20-
response = client.query(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(hours=1))
20+
response = client.query_workspace(os.environ['LOG_WORKSPACE_ID'], query, timespan=timedelta(hours=1))
2121

2222
if not response.tables:
2323
print("No results for the query")

0 commit comments

Comments
 (0)