Skip to content

Commit

Permalink
move config into kwargs (#7734)
Browse files Browse the repository at this point in the history
* move config into kwargs

* use pop to avoid dup values for kw arguement 'config'

* update doc

* fix cosmos client

* pylint fix

* remove config

* fix typo

* Get latest master (#7770)

* increment key vault version (#7704)

* Update ep livetest according to storage-blob-b4 (#7725)

* Bug fix #6690 (#7738)

* Fix auto-headers for aiohttp (for real this time :)) (#7749)

* Fix auto-headers for aiohttp

* ChangeLog

* [AutoPR frontdoor/resource-manager] some fixes for frontdoor readme (#7714)

* Generated from e5fa469589e9cddf953d91122ebf61fc705ea8bb

renamed aggregation intervals

* Generated from 729f3420dad818c11e458aa67483039fd9b48778

Updated timeseriesType

* Generated from 9630e7a1f4c4c443797f8efa12d20bf1cf7a4dee

scorecard -> scoreboard

* Generated from 3a7dbc786a7789ef058736e2dfa8be0f7ab5f53d

network experiment resource state

* Packaging update of azure-mgmt-frontdoor

* changelog

* Fix requests asyncio if input data is async gen (#7743)

* Fix requests asyncio if input data is async gen

* ChangeLog

* Feedback

* Update HISTORY.md

* update user agent string (#7750)

* remove get_pending_certificate_signing_request (#7560)

* pylint fix

* update history.md
  • Loading branch information
xiangyan99 authored Oct 10, 2019
1 parent b25bd18 commit 520f11b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
24 changes: 8 additions & 16 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, the standard configuration is used.
: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 HttpTransport transport: If omitted, RequestsTransport is used for synchronous transport.
: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.pop("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)

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, the standard configuration is used.
: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 HttpTransport transport: If omitted, RequestsTransport is used for synchronous transport.
: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.pop("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)

async def __aenter__(self):
await self._pipeline.__aenter__()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __init__(
]

transport = kwargs.pop("transport", None)
self.pipeline_client = PipelineClient(url_connection, "empty-config", transport=transport, policies=policies)
self.pipeline_client = PipelineClient(base_url=url_connection, transport=transport, policies=policies)

# Query compatibility mode.
# Allows to specify compatibility mode used by client when making query requests. Should be removed when
Expand Down

0 comments on commit 520f11b

Please sign in to comment.