Skip to content

Commit a305fa9

Browse files
authored
[Monitor] Regen ingestion + query for next pylint (#33493)
Signed-off-by: Paul Van Eck <[email protected]>
1 parent 24a0313 commit a305fa9

File tree

18 files changed

+209
-125
lines changed

18 files changed

+209
-125
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Other Changes
1212

13+
* Bumped minimum dependency on `azure-core` to `>=1.28.0`.
14+
1315
## 1.0.3 (2023-11-07)
1416

1517
### Other Changes

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/_client.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from typing import Any, TYPE_CHECKING
1111

1212
from azure.core import PipelineClient
13+
from azure.core.pipeline import policies
1314
from azure.core.rest import HttpRequest, HttpResponse
1415

1516
from ._configuration import LogsIngestionClientConfiguration
@@ -37,13 +38,30 @@ class LogsIngestionClient(LogsIngestionClientOperationsMixin): # pylint: disabl
3738
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
3839
_endpoint = "{endpoint}"
3940
self._config = LogsIngestionClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)
40-
self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
41+
_policies = kwargs.pop("policies", None)
42+
if _policies is None:
43+
_policies = [
44+
policies.RequestIdPolicy(**kwargs),
45+
self._config.headers_policy,
46+
self._config.user_agent_policy,
47+
self._config.proxy_policy,
48+
policies.ContentDecodePolicy(**kwargs),
49+
self._config.redirect_policy,
50+
self._config.retry_policy,
51+
self._config.authentication_policy,
52+
self._config.custom_hook_policy,
53+
self._config.logging_policy,
54+
policies.DistributedTracingPolicy(**kwargs),
55+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
56+
self._config.http_logging_policy,
57+
]
58+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
4159

4260
self._serialize = Serializer()
4361
self._deserialize = Deserializer()
4462
self._serialize.client_side_validation = False
4563

46-
def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
64+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
4765
"""Runs the network request through the client's chained policies.
4866
4967
>>> from azure.core.rest import HttpRequest
@@ -67,7 +85,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
6785
}
6886

6987
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
70-
return self._client.send_request(request_copy, **kwargs)
88+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
7189

7290
def close(self) -> None:
7391
self._client.close()

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/_configuration.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from typing import Any, TYPE_CHECKING
1010

11-
from azure.core.configuration import Configuration
1211
from azure.core.pipeline import policies
1312

1413
if TYPE_CHECKING:
@@ -18,7 +17,7 @@
1817
VERSION = "unknown"
1918

2019

21-
class LogsIngestionClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes,name-too-long
20+
class LogsIngestionClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
2221
"""Configuration for LogsIngestionClient.
2322
2423
Note that all parameters used to create this instance are saved as instance
@@ -35,7 +34,6 @@ class LogsIngestionClientConfiguration(Configuration): # pylint: disable=too-ma
3534
"""
3635

3736
def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None:
38-
super(LogsIngestionClientConfiguration, self).__init__(**kwargs)
3937
api_version: str = kwargs.pop("api_version", "2023-01-01")
4038

4139
if endpoint is None:
@@ -48,6 +46,7 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any)
4846
self.api_version = api_version
4947
self.credential_scopes = kwargs.pop("credential_scopes", ["https://monitor.azure.com//.default"])
5048
kwargs.setdefault("sdk_moniker", "monitor-ingestion/{}".format(VERSION))
49+
self.polling_interval = kwargs.get("polling_interval", 30)
5150
self._configure(**kwargs)
5251

5352
def _configure(self, **kwargs: Any) -> None:
@@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None:
5655
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
5756
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
5857
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
59-
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6058
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
6159
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
60+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
6261
self.authentication_policy = kwargs.get("authentication_policy")
6362
if self.credential and not self.authentication_policy:
6463
self.authentication_policy = policies.BearerTokenCredentialPolicy(

sdk/monitor/azure-monitor-ingestion/azure/monitor/ingestion/_operations/_operations.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=too-many-lines
1+
# pylint: disable=too-many-lines,too-many-statements
22
# coding=utf-8
33
# --------------------------------------------------------------------------
44
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -89,7 +89,7 @@ def _upload( # pylint: disable=inconsistent-return-statements
8989
self,
9090
rule_id: str,
9191
stream: str,
92-
body: IO,
92+
body: IO[bytes],
9393
*,
9494
content_encoding: Optional[str] = None,
9595
content_type: str = "application/json",
@@ -102,7 +102,7 @@ def _upload( # pylint: disable=inconsistent-return-statements
102102
self,
103103
rule_id: str,
104104
stream: str,
105-
body: Union[List[JSON], IO],
105+
body: Union[List[JSON], IO[bytes]],
106106
*,
107107
content_encoding: Optional[str] = None,
108108
**kwargs: Any
@@ -116,8 +116,8 @@ def _upload( # pylint: disable=inconsistent-return-statements
116116
:param stream: The streamDeclaration name as defined in the Data Collection Rule. Required.
117117
:type stream: str
118118
:param body: An array of objects matching the schema defined by the provided stream. Is either
119-
a [JSON] type or a IO type. Required.
120-
:type body: list[JSON] or IO
119+
a [JSON] type or a IO[bytes] type. Required.
120+
:type body: list[JSON] or IO[bytes]
121121
:keyword content_encoding: gzip. Default value is None.
122122
:paramtype content_encoding: str
123123
:keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
@@ -149,7 +149,7 @@ def _upload( # pylint: disable=inconsistent-return-statements
149149
else:
150150
_json = body
151151

152-
request = build_logs_ingestion_upload_request(
152+
_request = build_logs_ingestion_upload_request(
153153
rule_id=rule_id,
154154
stream=stream,
155155
content_encoding=content_encoding,
@@ -163,11 +163,11 @@ def _upload( # pylint: disable=inconsistent-return-statements
163163
path_format_arguments = {
164164
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
165165
}
166-
request.url = self._client.format_url(request.url, **path_format_arguments)
166+
_request.url = self._client.format_url(_request.url, **path_format_arguments)
167167

168168
_stream = False
169169
pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access
170-
request, stream=_stream, **kwargs
170+
_request, stream=_stream, **kwargs
171171
)
172172

173173
response = pipeline_response.http_response
@@ -179,4 +179,4 @@ def _upload( # pylint: disable=inconsistent-return-statements
179179
raise HttpResponseError(response=response)
180180

181181
if cls:
182-
return cls(pipeline_response, None, {})
182+
return cls(pipeline_response, None, {}) # type: ignore

0 commit comments

Comments
 (0)