-
Notifications
You must be signed in to change notification settings - Fork 3.3k
move config into kwargs #7734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move config into kwargs #7734
Changes from 1 commit
dd69576
be32df4
65e5f6a
9e54a6d
e0a66b5
bc50ec9
4809fad
11a5ec2
f3a0790
bdec916
60e1ba2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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. | ||
| :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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
|
@@ -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) | ||
|
bryevdv marked this conversation as resolved.
|
||
|
|
||
| def __enter__(self): | ||
| self._pipeline.__enter__() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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. | ||
|
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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Transpost
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
| :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 | ||
|
|
@@ -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) | ||
|
bryevdv marked this conversation as resolved.
|
||
|
|
||
| async def __aenter__(self): | ||
| await self._pipeline.__aenter__() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.