Skip to content
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

[translation] remove code for aad #17480

Merged
merged 2 commits into from
Mar 22, 2021
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,10 +4,12 @@
# Licensed under the MIT License.
# ------------------------------------

from typing import Union, Any, TYPE_CHECKING, List
from typing import Any, TYPE_CHECKING, List
from azure.core.tracing.decorator import distributed_trace
from azure.core.polling import LROPoller
from azure.core.polling.base_polling import LROBasePolling
from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline.policies import AzureKeyCredentialPolicy
from ._generated import BatchDocumentTranslationClient as _BatchDocumentTranslationClient
from ._generated.models import BatchStatusDetail as _BatchStatusDetail
from ._models import (
Expand All @@ -16,12 +18,12 @@
BatchDocumentInput,
FileFormat
)
from ._helpers import get_authentication_policy
from ._user_agent import USER_AGENT
from ._polling import TranslationPolling
if TYPE_CHECKING:
from azure.core.paging import ItemPaged
from azure.core.credentials import AzureKeyCredential, TokenCredential

COGNITIVE_KEY_HEADER = "Ocp-Apim-Subscription-Key"


class DocumentTranslationClient(object): # pylint: disable=r0205
Expand All @@ -30,19 +32,23 @@ class DocumentTranslationClient(object): # pylint: disable=r0205
"""

def __init__(self, endpoint, credential, **kwargs):
# type: (str, Union[AzureKeyCredential, TokenCredential], **Any) -> None
# type: (str, AzureKeyCredential, **Any) -> None
"""

:param str endpoint:
:param credential:
:type credential: Union[AzureKeyCredential, TokenCredential]
:type credential: AzureKeyCredential
:keyword str api_version:
"""
self._endpoint = endpoint
self._credential = credential
self._api_version = kwargs.pop('api_version', None)

authentication_policy = get_authentication_policy(credential)
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
authentication_policy = AzureKeyCredentialPolicy(
name=COGNITIVE_KEY_HEADER, credential=credential
)
self._client = _BatchDocumentTranslationClient(
endpoint=endpoint,
credential=credential, # type: ignore
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# Licensed under the MIT License.
# ------------------------------------

from typing import Union, Any, List, TYPE_CHECKING
from typing import Any, List
from azure.core.tracing.decorator_async import distributed_trace_async
from azure.core.tracing.decorator import distributed_trace
from azure.core.polling import AsyncLROPoller
from azure.core.polling.async_base_polling import AsyncLROBasePolling
from azure.core.async_paging import AsyncItemPaged
from azure.core.credentials import AzureKeyCredential
from azure.core.pipeline.policies import AzureKeyCredentialPolicy
from .._generated.aio import BatchDocumentTranslationClient as _BatchDocumentTranslationClient
from .._user_agent import USER_AGENT
from .._generated.models import (
Expand All @@ -21,11 +23,8 @@
FileFormat,
DocumentStatusDetail
)
from .._helpers import get_authentication_policy
from .._polling import TranslationPolling
if TYPE_CHECKING:
from azure.core.credentials_async import AsyncTokenCredential
from azure.core.credentials import AzureKeyCredential
COGNITIVE_KEY_HEADER = "Ocp-Apim-Subscription-Key"


class DocumentTranslationClient(object):
Expand All @@ -34,21 +33,25 @@ class DocumentTranslationClient(object):
"""

def __init__(
self, endpoint: str, credential: Union["AzureKeyCredential", "AsyncTokenCredential"], **kwargs: Any
self, endpoint: str, credential: "AzureKeyCredential", **kwargs: Any
) -> None:
"""

:param str endpoint:
:param credential:
:type credential: Union[AzureKeyCredential, AsyncTokenCredential]
:type credential: AzureKeyCredential
:keyword str api_version:
:rtype: None
"""
self._endpoint = endpoint
self._credential = credential
self._api_version = kwargs.pop('api_version', None)

authentication_policy = get_authentication_policy(credential)
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
authentication_policy = AzureKeyCredentialPolicy(
name=COGNITIVE_KEY_HEADER, credential=credential
)
self._client = _BatchDocumentTranslationClient(
endpoint=endpoint,
credential=credential, # type: ignore
Expand Down