Skip to content

Commit 93decd7

Browse files
committed
regenerate
1 parent ad4424f commit 93decd7

18 files changed

+38
-53
lines changed

sdk/purview/azure-purview-scanning/azure/purview/scanning/_azure_purview_scanning_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def send_request(self, http_request, **kwargs):
7777
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
7878
if kwargs.pop("stream_response", False):
7979
return _StreamContextManager(
80-
client=self._client,
80+
client=self._client._pipeline,
8181
request=request_copy,
8282
)
8383
pipeline_response = self._client._pipeline.run(request_copy._internal_request, **kwargs)

sdk/purview/azure-purview-scanning/azure/purview/scanning/aio/_azure_purview_scanning_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncH
7474
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
7575
if kwargs.pop("stream_response", False):
7676
return _AsyncStreamContextManager(
77-
client=self._client,
77+
client=self._client._pipeline,
7878
request=request_copy,
7979
)
8080
pipeline_response = await self._client._pipeline.run(request_copy._internal_request, **kwargs)

sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest.py

+5-10
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,10 @@ def reason(self):
375375
def content(self):
376376
# type: (...) -> bytes
377377
"""Returns the response content in bytes"""
378-
raise NotImplementedError()
378+
try:
379+
return self._content
380+
except AttributeError:
381+
raise ResponseNotReadError()
379382

380383
@property
381384
def url(self):
@@ -491,22 +494,14 @@ def _validate_streaming_access(self):
491494

492495
class HttpResponse(_HttpResponseBase):
493496

494-
@property
495-
def content(self):
496-
# type: (...) -> bytes
497-
try:
498-
return self._content
499-
except AttributeError:
500-
raise ResponseNotReadError()
501-
502497
def close(self):
503498
# type: (...) -> None
504499
self.is_closed = True
505500
self._internal_response.internal_response.close()
506501

507502
def __exit__(self, *args):
508503
# type: (...) -> None
509-
self._internal_response.internal_response.__exit__(*args)
504+
self.close()
510505

511506
def read(self):
512507
# type: (...) -> bytes

sdk/purview/azure-purview-scanning/azure/purview/scanning/core/rest/_rest_py3.py

+17-27
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
Sequence[Tuple[str, FileType]]
7676
]
7777

78-
from azure.core.pipeline import Pipeline
78+
from azure.core.pipeline import Pipeline, AsyncPipeline
7979
from azure.core.pipeline.transport import (
8080
HttpRequest as _PipelineTransportHttpRequest,
8181
)
@@ -214,7 +214,7 @@ def _parse_lines_from_text(text):
214214
class _StreamContextManagerBase:
215215
def __init__(
216216
self,
217-
client: Union[_PipelineClient, _AsyncPipelineClient],
217+
pipeline: Union[Pipeline, AsyncPipeline],
218218
request: "HttpRequest",
219219
**kwargs
220220
):
@@ -226,7 +226,7 @@ def __init__(
226226
227227
Heavily inspired from httpx, we want the same behavior for it to feel consistent for users
228228
"""
229-
self.client = client
229+
self.pipeline = pipeline
230230
self.request = request
231231
self.kwargs = kwargs
232232

@@ -237,7 +237,7 @@ def close(self):
237237
class _StreamContextManager(_StreamContextManagerBase):
238238
def __enter__(self) -> "HttpResponse":
239239
"""Actually make the call only when we enter. For sync stream_response calls"""
240-
pipeline_transport_response = self.client._pipeline.run(
240+
pipeline_transport_response = self.pipeline.run(
241241
self.request._internal_request,
242242
stream=True,
243243
**self.kwargs
@@ -258,12 +258,12 @@ def close(self):
258258
class _AsyncStreamContextManager(_StreamContextManagerBase):
259259
async def __aenter__(self) -> "AsyncHttpResponse":
260260
"""Actually make the call only when we enter. For async stream_response calls."""
261-
if not isinstance(self.client, _AsyncPipelineClient):
261+
if not isinstance(self.pipeline, AsyncPipeline):
262262
raise TypeError(
263-
"Only sync calls should enter here. If you mean to do a sync call, "
263+
"Only async calls should enter here. If you mean to do a sync call, "
264264
"make sure to use 'with' instead."
265265
)
266-
pipeline_transport_response = (await self.client._pipeline.run(
266+
pipeline_transport_response = (await self.pipeline.run(
267267
self.request._internal_request,
268268
stream=True,
269269
**self.kwargs
@@ -446,11 +446,6 @@ def reason(self) -> str:
446446
"""Returns the reason phrase for the response"""
447447
return self._internal_response.reason
448448

449-
@property
450-
def content(self) -> bytes:
451-
"""Returns the response content in bytes"""
452-
raise NotImplementedError()
453-
454449
@property
455450
def url(self) -> str:
456451
"""Returns the URL that resulted in this response"""
@@ -529,6 +524,14 @@ def raise_for_status(self) -> None:
529524
if self.status_code >= 400:
530525
raise HttpResponseError(response=self)
531526

527+
@property
528+
def content(self) -> bytes:
529+
"""Return the response's content in bytes."""
530+
try:
531+
return self._content
532+
except AttributeError:
533+
raise ResponseNotReadError()
534+
532535
def __repr__(self) -> str:
533536
content_type_str = (
534537
", Content-Type: {}".format(self.content_type) if self.content_type else ""
@@ -545,19 +548,12 @@ def _validate_streaming_access(self) -> None:
545548

546549
class HttpResponse(_HttpResponseBase):
547550

548-
@property
549-
def content(self):
550-
# type: (...) -> bytes
551-
try:
552-
return self._content
553-
except AttributeError:
554-
raise ResponseNotReadError()
555-
556551
def close(self) -> None:
557552
self.is_closed = True
558553
self._internal_response.internal_response.close()
559554

560555
def __exit__(self, *args) -> None:
556+
self.is_closed = True
561557
self._internal_response.internal_response.__exit__(*args)
562558

563559
def read(self) -> bytes:
@@ -619,13 +615,6 @@ def iter_raw(self, chunk_size: int = None) -> Iterator[bytes]:
619615

620616
class AsyncHttpResponse(_HttpResponseBase):
621617

622-
@property
623-
def content(self) -> bytes:
624-
try:
625-
return self._content
626-
except AttributeError:
627-
raise ResponseNotReadError()
628-
629618
async def _close_stream(self) -> None:
630619
self.is_stream_consumed = True
631620
await self.close()
@@ -686,6 +675,7 @@ async def close(self) -> None:
686675
await asyncio.sleep(0)
687676

688677
async def __aexit__(self, *args) -> None:
678+
self.is_closed = True
689679
await self._internal_response.internal_response.__aexit__(*args)
690680

691681

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/azure_key_vaults/_request_builders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def build_create_azure_key_vault_request(
104104

105105
# Construct headers
106106
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
107-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
108107
if content_type is not None:
109108
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
109+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
110110

111111
return HttpRequest(
112112
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/azure_key_vaults/_request_builders_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def build_create_azure_key_vault_request(
101101

102102
# Construct headers
103103
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
104-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
105104
if content_type is not None:
106105
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
106+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
107107

108108
return HttpRequest(
109109
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def build_create_or_update_request(
104104

105105
# Construct headers
106106
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
107-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
108107
if content_type is not None:
109108
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
109+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
110110

111111
return HttpRequest(
112112
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/classification_rules/_request_builders_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def build_create_or_update_request(
101101

102102
# Construct headers
103103
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
104-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
105104
if content_type is not None:
106105
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
106+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
107107

108108
return HttpRequest(
109109
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def build_create_or_update_request(
8989

9090
# Construct headers
9191
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
92-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9392
if content_type is not None:
9493
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
94+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9595

9696
return HttpRequest(
9797
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/data_sources/_request_builders_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def build_create_or_update_request(
8787

8888
# Construct headers
8989
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
90-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9190
if content_type is not None:
9291
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
92+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9393

9494
return HttpRequest(
9595
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def build_create_or_update_request(
112112

113113
# Construct headers
114114
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
115-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
116115
if content_type is not None:
117116
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
117+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
118118

119119
return HttpRequest(
120120
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/filters/_request_builders_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def build_create_or_update_request(
109109

110110
# Construct headers
111111
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
112-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
113112
if content_type is not None:
114113
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
114+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
115115

116116
return HttpRequest(
117117
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ def build_create_or_update_request(
104104

105105
# Construct headers
106106
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
107-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
108107
if content_type is not None:
109108
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
109+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
110110

111111
return HttpRequest(
112112
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scan_rulesets/_request_builders_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def build_create_or_update_request(
101101

102102
# Construct headers
103103
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
104-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
105104
if content_type is not None:
106105
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
106+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
107107

108108
return HttpRequest(
109109
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ def build_create_or_update_request(
8888

8989
# Construct headers
9090
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
91-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9291
if content_type is not None:
9392
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
93+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9494

9595
return HttpRequest(
9696
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/scans/_request_builders_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def build_create_or_update_request(
8686

8787
# Construct headers
8888
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
89-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9089
if content_type is not None:
9190
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
91+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
9292

9393
return HttpRequest(
9494
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ def build_create_trigger_request(
112112

113113
# Construct headers
114114
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
115-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
116115
if content_type is not None:
117116
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
117+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
118118

119119
return HttpRequest(
120120
method="PUT",

sdk/purview/azure-purview-scanning/azure/purview/scanning/rest/triggers/_request_builders_py3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def build_create_trigger_request(
109109

110110
# Construct headers
111111
header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any]
112-
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
113112
if content_type is not None:
114113
header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str')
114+
header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str')
115115

116116
return HttpRequest(
117117
method="PUT",

0 commit comments

Comments
 (0)