Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 9 additions & 17 deletions sdk/core/azure-core/azure/core/pipeline_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# --------------------------------------------------------------------------

import logging
from .configuration import Configuration
from .pipeline import Pipeline
from .pipeline.transport.base import PipelineClientBase
from .pipeline.policies import ContentDecodePolicy
Expand Down Expand Up @@ -59,20 +60,13 @@ class PipelineClient(PipelineClientBase):
Builds a Pipeline client.

:param str base_url: URL for the request.
:param config: Service configuration. This is a required parameter.
:type config: ~azure.core.Configuration
:param kwargs: keyword arguments
:keyword Configuration config: If omitted, it will be used by the PipelineClient.
Comment thread
xiangyan99 marked this conversation as resolved.
Outdated
:keyword Pipeline pipeline: If omitted, a Pipeline object is created and returned.
:keyword list[policy] policies: If omitted, the standard policies of the configuration object is used.
:keyword HttpTranpost transport: If omitted, RequestsTransport is used for synchronous transport.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpTranpost -> HttpTranport

:return: A pipeline object.
:rtype: ~azure.core.pipeline.Pipeline

**Keyword arguments:**

*pipeline* - A Pipeline object. If omitted, a Pipeline object is created and returned.

*policies* - A list of policies object. If omitted, the standard policies of the configuration object is used.

*transport* - The HTTP Transport instance. If omitted, RequestsTransport is used for synchronous transport.


.. admonition:: Example:

.. literalinclude:: ../examples/test_example_sync.py
Expand All @@ -83,16 +77,14 @@ class PipelineClient(PipelineClientBase):
:caption: Builds the pipeline client.
"""

def __init__(self, base_url, config, **kwargs):
def __init__(self, base_url, **kwargs):
super(PipelineClient, self).__init__(base_url)
if config is None:
raise ValueError("Config is a required parameter")
self._config = config
self._config = kwargs.get("config", None) or Configuration(**kwargs)
self._base_url = base_url
if kwargs.get("pipeline"):
self._pipeline = kwargs["pipeline"]
else:
self._pipeline = self._build_pipeline(config, **kwargs)
self._pipeline = self._build_pipeline(self._config, **kwargs)
Comment thread
bryevdv marked this conversation as resolved.

def __enter__(self):
self._pipeline.__enter__()
Expand Down
24 changes: 8 additions & 16 deletions sdk/core/azure-core/azure/core/pipeline_client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# --------------------------------------------------------------------------

import logging
from .configuration import Configuration
from .pipeline import AsyncPipeline
from .pipeline.transport.base import PipelineClientBase
from .pipeline.policies import ContentDecodePolicy
Expand Down Expand Up @@ -58,20 +59,13 @@ class AsyncPipelineClient(PipelineClientBase):
Builds an AsyncPipeline client.

:param str base_url: URL for the request.
:param config: Service configuration. This is a required parameter.
:type config: ~azure.core.Configuration
:param kwargs: keyword arguments.
:keyword Configuration config: If omitted, it will be used by the PipelineClient.
Comment thread
xiangyan99 marked this conversation as resolved.
Outdated
:keyword Pipeline pipeline: If omitted, a Pipeline object is created and returned.
:keyword list[policy] policies: If omitted, the standard policies of the configuration object is used.
:keyword HttpTranpost transport: If omitted, RequestsTransport is used for synchronous transport.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transpost

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
Thanks.

:return: An async pipeline object.
:rtype: ~azure.core.pipeline.AsyncPipeline

**Keyword arguments:**

*pipeline* - A Pipeline object. If omitted, an AsyncPipeline is created and returned.

*policies* - A list of policies object. If omitted, the standard policies of the configuration object is used.

*transport* - The HTTP Transport instance. If omitted, AioHttpTransport is use for asynchronous transport.

.. admonition:: Example:

.. literalinclude:: ../examples/test_example_async.py
Expand All @@ -82,16 +76,14 @@ class AsyncPipelineClient(PipelineClientBase):
:caption: Builds the async pipeline client.
"""

def __init__(self, base_url, config, **kwargs):
def __init__(self, base_url, **kwargs):
super(AsyncPipelineClient, self).__init__(base_url)
if config is None:
raise ValueError("Config is a required parameter")
self._config = config
self._config = kwargs.get("config", None) or Configuration(**kwargs)
self._base_url = base_url
if kwargs.get("pipeline"):
self._pipeline = kwargs["pipeline"]
else:
self._pipeline = self._build_pipeline(config, **kwargs)
self._pipeline = self._build_pipeline(self._config, **kwargs)
Comment thread
bryevdv marked this conversation as resolved.

async def __aenter__(self):
await self._pipeline.__aenter__()
Expand Down