Skip to content
Prev Previous commit
Next Next commit
Updated policies
  • Loading branch information
annatisch committed Aug 28, 2019
commit c9ae86799d45917f44d01c8b92544e59818c4fe6
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

"""Document client class for the Azure Cosmos database service.
"""
import requests
import platform

import requests
import six
from azure.core import PipelineClient
from azure.core.pipeline.policies import (
Expand All @@ -50,6 +51,7 @@
from . import _session
from . import _utils
from .partition_key import _Undefined, _Empty
from .version import VERSION

# pylint: disable=protected-access

Expand Down Expand Up @@ -148,15 +150,19 @@ def __init__(
url = six.moves.urllib.parse.urlparse(host)
proxy = host if url.port else host + ":" + str(connection_policy.ProxyConfiguration.Port)
proxies = {url.scheme : proxy}
user_agent = "azsdk-python-cosmos/{} Python/{} ({})".format(
VERSION,
platform.python_version(),
platform.platform())

policies = [
HeadersPolicy(),
ProxyPolicy(proxies=proxies),
UserAgentPolicy(),
UserAgentPolicy(base_user_agent=user_agent),
ContentDecodePolicy(),
CustomHookPolicy(),
DistributedTracingPolicy(),
NetworkTraceLoggingPolicy(),
DistributedTracingPolicy()
]

self.pipeline_client = PipelineClient(url_connection, "empty-config", policies=policies)
Copy link
Member

@johanste johanste Aug 28, 2019

Choose a reason for hiding this comment

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

Do we still have the positional config parameter ("empty-config")in the PipelineClient?

Copy link
Member Author

@annatisch annatisch Aug 28, 2019

Choose a reason for hiding this comment

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

Yeah - I will submit a PR to at least make it optional - the current code doesn't seem to use it if policies is passed in explicitly
https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/azure/core/pipeline_client.py#L83

Copy link
Member Author

Choose a reason for hiding this comment

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

Expand Down