Skip to content

Commit 7a9dad7

Browse files
author
Rakshith Bhyravabhotla
authored
Rename Visualization attribute (Azure#20196)
* Rename Visualization attribute * lint
1 parent 2d497d8 commit 7a9dad7

File tree

7 files changed

+82
-29
lines changed

7 files changed

+82
-29
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88

99
- Rename `batch_query` to `query_batch`.
1010
- Rename `LogsBatchQueryRequest` to `LogsBatchQuery`.
11+
- `include_render` is now renamed to `include_visualization` in the query API.
12+
- `LogsQueryResult` and `LogsBatchQueryResult` now return `visualization` instead of `render`.
1113

1214
### Bugs Fixed
1315

16+
- `include_statistics` and `include_visualization` args can now work together.
17+
1418
### Other Changes
1519

1620
## 1.0.0b3 (2021-08-09)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ LogsQueryResult / LogsBatchQueryResult
223223
|---id (this exists in `LogsBatchQueryResult` object only)
224224
|---status (this exists in `LogsBatchQueryResult` object only)
225225
|---statistics
226-
|---render
226+
|---visualization
227227
|---error
228228
|---tables (list of `LogsQueryResultTable` objects)
229229
|---name

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def query(self, workspace_id, query, duration=None, **kwargs):
7474
:keyword int server_timeout: the server timeout in seconds. The default timeout is 3 minutes,
7575
and the maximum timeout is 10 minutes.
7676
:keyword bool include_statistics: To get information about query statistics.
77-
:keyword bool include_render: In the query language, it is possible to specify different render options.
78-
By default, the API does not return information regarding the type of visualization to show.
79-
If your client requires this information, specify the preference
77+
:keyword bool include_visualization: In the query language, it is possible to specify different
78+
visualization options. By default, the API does not return information regarding the type of
79+
visualization to show. If your client requires this information, specify the preference
8080
:keyword additional_workspaces: A list of workspaces that are included in the query.
8181
These can be qualified workspace names, workspace Ids, or Azure resource Ids.
8282
:paramtype additional_workspaces: list[str]
@@ -97,7 +97,7 @@ def query(self, workspace_id, query, duration=None, **kwargs):
9797
end = kwargs.pop('end_time', None)
9898
timespan = construct_iso8601(start, end, duration)
9999
include_statistics = kwargs.pop("include_statistics", False)
100-
include_render = kwargs.pop("include_render", False)
100+
include_visualization = kwargs.pop("include_visualization", False)
101101
server_timeout = kwargs.pop("server_timeout", None)
102102
workspaces = kwargs.pop("additional_workspaces", None)
103103

@@ -106,11 +106,11 @@ def query(self, workspace_id, query, duration=None, **kwargs):
106106
prefer += "wait=" + str(server_timeout)
107107
if include_statistics:
108108
if len(prefer) > 0:
109-
prefer += " "
109+
prefer += ","
110110
prefer += "include-statistics=true"
111-
if include_render:
111+
if include_visualization:
112112
if len(prefer) > 0:
113-
prefer += " "
113+
prefer += ","
114114
prefer += "include-render=true"
115115

116116
body = LogsQueryBody(

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ class LogsQueryResult(object):
7272
:ivar statistics: This will include a statistics property in the response that describes various
7373
performance statistics such as query execution time and resource usage.
7474
:vartype statistics: object
75-
:ivar render: This will include a render property in the response that specifies the type of
75+
:ivar visualization: This will include a visualization property in the response that specifies the type of
7676
visualization selected by the query and any properties for that visualization.
77-
:vartype render: object
77+
:vartype visualization: object
7878
:ivar error: Any error info.
7979
:vartype error: object
8080
"""
8181
def __init__(self, **kwargs):
8282
# type: (Any) -> None
8383
self.tables = kwargs.get("tables", None)
8484
self.statistics = kwargs.get("statistics", None)
85-
self.render = kwargs.get("render", None)
85+
self.visualization = kwargs.get("visualization", None)
8686
self.error = kwargs.get("error", None)
8787

8888
@classmethod
@@ -99,7 +99,7 @@ def _from_generated(cls, generated):
9999
return cls(
100100
tables=tables,
101101
statistics=generated.statistics,
102-
render=generated.render,
102+
visualization=generated.render,
103103
error=generated.error
104104
)
105105

@@ -173,27 +173,28 @@ class LogsBatchQuery(object):
173173
:keyword int server_timeout: the server timeout. The default timeout is 3 minutes,
174174
and the maximum timeout is 10 minutes.
175175
:keyword bool include_statistics: To get information about query statistics.
176-
:keyword bool include_render: In the query language, it is possible to specify different render options.
177-
By default, the API does not return information regarding the type of visualization to show.
176+
:keyword bool include_visualization: In the query language, it is possible to specify different
177+
visualization options. By default, the API does not return information regarding the type of
178+
visualization to show.
178179
:keyword headers: Dictionary of :code:`<string>`.
179180
:paramtype headers: dict[str, str]
180181
"""
181182

182183
def __init__(self, query, workspace_id, duration=None, **kwargs): #pylint: disable=super-init-not-called
183184
# type: (str, str, Optional[str], Any) -> None
184185
include_statistics = kwargs.pop("include_statistics", False)
185-
include_render = kwargs.pop("include_render", False)
186+
include_visualization = kwargs.pop("include_visualization", False)
186187
server_timeout = kwargs.pop("server_timeout", None)
187188
prefer = ""
188189
if server_timeout:
189190
prefer += "wait=" + str(server_timeout)
190191
if include_statistics:
191192
if len(prefer) > 0:
192-
prefer += " "
193+
prefer += ","
193194
prefer += "include-statistics=true"
194-
if include_render:
195+
if include_visualization:
195196
if len(prefer) > 0:
196-
prefer += " "
197+
prefer += ","
197198
prefer += "include-render=true"
198199

199200
headers = kwargs.get("headers", None)
@@ -232,9 +233,9 @@ class LogsBatchQueryResult(object):
232233
:ivar statistics: This will include a statistics property in the response that describes various
233234
performance statistics such as query execution time and resource usage.
234235
:vartype statistics: object
235-
:ivar render: This will include a render property in the response that specifies the type of
236+
:ivar visualization: This will include a visualization property in the response that specifies the type of
236237
visualization selected by the query and any properties for that visualization.
237-
:vartype render: object
238+
:vartype visualization: object
238239
:ivar error: Any error info.
239240
:vartype error: object
240241
"""
@@ -247,7 +248,7 @@ def __init__(
247248
self.tables = kwargs.get('tables', None)
248249
self.error = kwargs.get('error', None)
249250
self.statistics = kwargs.get('statistics', None)
250-
self.render = kwargs.get('render', None)
251+
self.visualization = kwargs.get('visualization', None)
251252

252253
@classmethod
253254
def _from_generated(cls, generated):
@@ -265,7 +266,7 @@ def _from_generated(cls, generated):
265266
status=generated.status,
266267
tables=tables,
267268
statistics=generated.body.statistics,
268-
render=generated.body.render,
269+
visualization=generated.body.render,
269270
error=generated.body.error
270271
)
271272

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ async def query(
6767
:keyword int server_timeout: the server timeout. The default timeout is 3 minutes,
6868
and the maximum timeout is 10 minutes.
6969
:keyword bool include_statistics: To get information about query statistics.
70-
:keyword bool include_render: In the query language, it is possible to specify different render options.
71-
By default, the API does not return information regarding the type of visualization to show.
72-
If your client requires this information, specify the preference
70+
:keyword bool include_visualization: In the query language, it is possible to specify different
71+
visualization options. By default, the API does not return information regarding the type of
72+
visualization to show. If your client requires this information, specify the preference
7373
:keyword additional_workspaces: A list of workspaces that are included in the query.
7474
These can be qualified workspace names, workspsce Ids or Azure resource Ids.
7575
:paramtype additional_workspaces: list[str]
@@ -81,7 +81,7 @@ async def query(
8181
end = kwargs.pop('end_time', None)
8282
timespan = construct_iso8601(start, end, duration)
8383
include_statistics = kwargs.pop("include_statistics", False)
84-
include_render = kwargs.pop("include_render", False)
84+
include_visualization = kwargs.pop("include_visualization", False)
8585
server_timeout = kwargs.pop("server_timeout", None)
8686
additional_workspaces = kwargs.pop("additional_workspaces", None)
8787

@@ -90,11 +90,11 @@ async def query(
9090
prefer += "wait=" + str(server_timeout)
9191
if include_statistics:
9292
if len(prefer) > 0:
93-
prefer += ";"
93+
prefer += ","
9494
prefer += "include-statistics=true"
95-
if include_render:
95+
if include_visualization:
9696
if len(prefer) > 0:
97-
prefer += ";"
97+
prefer += ","
9898
prefer += "include-render=true"
9999

100100
body = LogsQueryBody(

sdk/monitor/azure-monitor-query/tests/async/test_logs_client_async.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,28 @@ async def test_logs_query_batch_additional_workspaces():
114114

115115
for resp in response:
116116
assert len(resp.tables[0].rows) == 2
117+
118+
@pytest.mark.live_test_only
119+
@pytest.mark.asyncio
120+
async def test_logs_single_query_with_render():
121+
credential = _credential()
122+
client = LogsQueryClient(credential)
123+
query = """AppRequests"""
124+
125+
# returns LogsQueryResult
126+
response = await client.query(os.environ['LOG_WORKSPACE_ID'], query, include_visualization=True)
127+
128+
assert response.visualization is not None
129+
130+
@pytest.mark.live_test_only
131+
@pytest.mark.asyncio
132+
async def test_logs_single_query_with_render_and_stats():
133+
credential = _credential()
134+
client = LogsQueryClient(credential)
135+
query = """AppRequests"""
136+
137+
# returns LogsQueryResult
138+
response = await client.query(os.environ['LOG_WORKSPACE_ID'], query, include_visualization=True, include_statistics=True)
139+
140+
assert response.visualization is not None
141+
assert response.statistics is not None

sdk/monitor/azure-monitor-query/tests/test_logs_client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,29 @@ def test_logs_single_query_with_statistics():
9797

9898
assert response.statistics is not None
9999

100+
@pytest.mark.live_test_only
101+
def test_logs_single_query_with_render():
102+
credential = _credential()
103+
client = LogsQueryClient(credential)
104+
query = """AppRequests"""
105+
106+
# returns LogsQueryResult
107+
response = client.query(os.environ['LOG_WORKSPACE_ID'], query, include_visualization=True)
108+
109+
assert response.visualization is not None
110+
111+
@pytest.mark.live_test_only
112+
def test_logs_single_query_with_render_and_stats():
113+
credential = _credential()
114+
client = LogsQueryClient(credential)
115+
query = """AppRequests"""
116+
117+
# returns LogsQueryResult
118+
response = client.query(os.environ['LOG_WORKSPACE_ID'], query, include_visualization=True, include_statistics=True)
119+
120+
assert response.visualization is not None
121+
assert response.statistics is not None
122+
100123
@pytest.mark.live_test_only
101124
def test_logs_query_batch_with_statistics_in_some():
102125
client = LogsQueryClient(_credential())

0 commit comments

Comments
 (0)