Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Licensed under the MIT License.
# ------------------------------------
from enum import Enum
from azure.core.pipeline.policies import AzureKeyCredentialPolicy
from azure.core.pipeline.policies import AzureKeyCredentialPolicy, HttpLoggingPolicy
from azure.core.credentials import AzureKeyCredential
from ._generated import TextAnalyticsClient as _TextAnalyticsClient
from ._policies import TextAnalyticsResponseHookPolicy
Expand Down Expand Up @@ -39,13 +39,38 @@ def _authentication_policy(credential):

class TextAnalyticsClientBase(object):
def __init__(self, endpoint, credential, **kwargs):
http_logging_policy = HttpLoggingPolicy(**kwargs)
http_logging_policy.allowed_header_names.update(
{
"Operation-Location",
"apim-request-id",
"x-envoy-upstream-service-time",
"Strict-Transport-Security",
"x-content-type-options",
}
)
http_logging_policy.allowed_query_params.update(
{
"model-version",
"showStats",
"loggingOptOut",
"domain",
"stringIndexType",
"piiCategories",
"$top",
"$skip",
"opinionMining",
}
)

self._client = _TextAnalyticsClient(
endpoint=endpoint,
credential=credential,
api_version=kwargs.pop("api_version", DEFAULT_API_VERSION),
sdk_moniker=USER_AGENT,
authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)),
custom_hook_policy=kwargs.pop("custom_hook_policy", TextAnalyticsResponseHookPolicy(**kwargs)),
http_logging_policy=kwargs.pop("http_logging_policy", http_logging_policy),
**kwargs
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# ------------------------------------
from typing import Any
from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline.policies import AzureKeyCredentialPolicy
from azure.core.pipeline.policies import AzureKeyCredentialPolicy, HttpLoggingPolicy
from .._generated.aio import TextAnalyticsClient as _TextAnalyticsClient
from .._policies import TextAnalyticsResponseHookPolicy
from .._user_agent import USER_AGENT
Expand All @@ -30,13 +30,38 @@ def _authentication_policy(credential):

class AsyncTextAnalyticsClientBase(object):
def __init__(self, endpoint, credential, **kwargs):
http_logging_policy = HttpLoggingPolicy(**kwargs)
http_logging_policy.allowed_header_names.update(
{
"Operation-Location",
"apim-request-id",
"x-envoy-upstream-service-time",
"Strict-Transport-Security",
"x-content-type-options",
}
)
http_logging_policy.allowed_query_params.update(
{
"model-version",
"showStats",
"loggingOptOut",
"domain",
"stringIndexType",
"piiCategories",
"$top",
"$skip",
"opinionMining",
}
)

self._client = _TextAnalyticsClient(
endpoint=endpoint,
credential=credential,
api_version=kwargs.pop("api_version", DEFAULT_API_VERSION),
sdk_moniker=USER_AGENT,
authentication_policy=kwargs.pop("authentication_policy", _authentication_policy(credential)),
custom_hook_policy=kwargs.pop("custom_hook_policy", TextAnalyticsResponseHookPolicy(**kwargs)),
http_logging_policy=kwargs.pop("http_logging_policy", http_logging_policy),
**kwargs
)

Expand Down