forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeGen from PR 11826 in Azure/azure-rest-api-specs
Fix errors in various of readme files encountered in the recent go SDK release (Azure#11826) * Fix an issue on windows * Fix cdn * Fix cognitiveservices/customVision * Fix cognitiveservices/personalizer * Fix cognitiveservices/translatorText * Fix data plane digitaltwins * Remove problematic tag from release - no impact on sdk, this has never been released * amend Fix cognitiveservices/translatorText * Fix imds * Fix migrate readme that are mistakenly damaged in Azure#10305 * add one api-version back * Fix digtaltwins data plane again * Fix hybridnetwork * Fix streamanlytics * Revert some changes of digitaltwins * Revert imds * Fix migrate * Fix migrate again
- Loading branch information
SDKAuto
committed
Nov 27, 2020
1 parent
e1f2009
commit 36be78e
Showing
9 changed files
with
3,073 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...azure-cognitiveservices-translatortext/azure/cognitiveservices/translatortext/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._configuration import TranslatorTextClientConfiguration | ||
from ._translator_text_client import TranslatorTextClient | ||
__all__ = ['TranslatorTextClient', 'TranslatorTextClientConfiguration'] | ||
|
||
from .version import VERSION | ||
|
||
__version__ = VERSION | ||
|
46 changes: 46 additions & 0 deletions
46
...cognitiveservices-translatortext/azure/cognitiveservices/translatortext/_configuration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from msrest import Configuration | ||
|
||
from .version import VERSION | ||
|
||
|
||
class TranslatorTextClientConfiguration(Configuration): | ||
"""Configuration for TranslatorTextClient | ||
Note that all parameters used to create this instance are saved as instance | ||
attributes. | ||
:param endpoint: Supported Cognitive Services endpoints | ||
:type endpoint: str | ||
:param credentials: Subscription credentials which uniquely identify | ||
client subscription. | ||
:type credentials: None | ||
""" | ||
|
||
def __init__( | ||
self, endpoint, credentials): | ||
|
||
if endpoint is None: | ||
raise ValueError("Parameter 'endpoint' must not be None.") | ||
if credentials is None: | ||
raise ValueError("Parameter 'credentials' must not be None.") | ||
base_url = '{Endpoint}' | ||
|
||
super(TranslatorTextClientConfiguration, self).__init__(base_url) | ||
|
||
# Starting Autorest.Python 4.0.64, make connection pool activated by default | ||
self.keep_alive = True | ||
|
||
self.add_user_agent('azure-cognitiveservices-translatortext/{}'.format(VERSION)) | ||
|
||
self.endpoint = endpoint | ||
self.credentials = credentials |
111 changes: 111 additions & 0 deletions
111
...services-translatortext/azure/cognitiveservices/translatortext/_translator_text_client.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from msrest.service_client import SDKClient | ||
from msrest import Serializer, Deserializer | ||
|
||
from ._configuration import TranslatorTextClientConfiguration | ||
from .operations import TranslatorOperations | ||
from . import models | ||
|
||
|
||
class TranslatorTextClient(SDKClient): | ||
"""# Introduction | ||
The Microsoft Translator Text API provides a JSON-based Web API. It provides: | ||
* Translation between any supported languages to any other supported language. | ||
* Translation to multiple languages in one request. | ||
* Transliteration to convert text from one script to another script of the same language. | ||
* Language detection, translation, and transliteration in one request. | ||
* Dictionary to lookup alternative translations of a term, to find back-translations and examples showing terms used in context. | ||
* Rich language detection. | ||
# Base URLs | ||
The Translator Text API is available in the following clouds: | ||
| Description | Region | Base URL | | ||
| ------- | -------- | ------- | | ||
| Azure | Global | api.cognitive.microsofttranslator.com | | ||
| Azure | Europe | api-eur.cognitive.microsofttranslator.com | | ||
# Authentication | ||
Subscribe to the Translator Text API, part of Azure Cognitive Services, and use your subscription key from the Azure portal to authenticate. You can follow the steps in https://docs.microsoft.com/en-us/azure/cognitive-services/translator/translator-text-how-to-signup. | ||
The simplest way is to pass your Azure secret key to the Translator service using the http request header `Ocp-Apim-Subscription-Key`. | ||
If you prefer using a short-lived authentication, you may use your secret key to obtain an authorization token from the token service. In that case you pass the authorization token to the Translator service using the `Authorization` request header. To obtain an authorization token, make a `POST` request to the following URL: | ||
| Environment | Authentication service URL | | ||
| ---------- | ---------- | | ||
| Azure | `https://api.cognitive.microsoft.com/sts/v1.0/issueToken` | | ||
Here are example requests to obtain a token with a lifetime of 10 minutes, given a secret key: | ||
```python | ||
// Pass secret key using header | ||
curl --header 'Ocp-Apim-Subscription-Key: <your-key>' --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken' | ||
// Pass secret key using query string parameter | ||
curl --data "" 'https://api.cognitive.microsoft.com/sts/v1.0/issueToken?Subscription-Key=<your-key>' | ||
``` | ||
A successful request returns the encoded access token as plain text in the response body. The valid token is passed to the Translator service as a bearer token in the Authorization. | ||
``` | ||
Authorization: Bearer <Base64-access_token> | ||
``` | ||
An authentication token is valid for 10 minutes. The token should be re-used when making multiple calls to the Translator APIs. If you make requests to the Translator API over an extended period of time, you must request a new access token at regular intervals before the token expires, for instance every 9 minutes. | ||
To summarize, a client request to the Translator API will include one authorization header taken from the following table: | ||
| Headers | Description | | ||
| ---------- | ---------- | | ||
| Ocp-Apim-Subscription-key | Use with Cognitive Services subscription if you are passing your secret key. The value is the Azure secret key for your subscription to Translator Text API. | | ||
| Authorization | Use with Cognitive Services subscription if you are passing an authentication token. The value is the Bearer token: `Bearer <token>`. | | ||
## All-in-one subscription | ||
The last authentication option is to use a Cognitive Service’s all-in-one subscription. This allows you to use a single secret key to authenticate requests for multiple services. | ||
When you use an all-in-one secret key, you must include two authentication headers with your request. The first passes the secret key, the second specifies the region associated with your subscription. | ||
`Ocp-Api-Subscription-Key` `Ocp-Apim-Subscription-Region` | ||
If you pass the secret key in the query string with the parameter `Subscription-Key`, then you must specify the region with query parameter `Subscription-Region`. | ||
If you use a bearer token, you must obtain the token from the region endpoint: | ||
`https://<your-region>.api.cognitive.microsoft.com/sts/v1.0/issueToken`. | ||
Available regions are: `australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, and `westus2`. | ||
Region is required for the all-in-one Text API subscription. | ||
# Errors | ||
A standard error response is a JSON object with name/value pair named `error`. The value is also a JSON object with properties: | ||
* `code`: A server-defined error code. | ||
* `message`: A string giving a human-readable representation of the error. | ||
For example, a customer with a free trial subscription receives the following error once the free quota is exhausted: | ||
```json | ||
{ | ||
"error": { | ||
"code":403000, | ||
"message":"The subscription has exceeded its free quota." | ||
} | ||
} | ||
``` | ||
# Enter your subscription keys to try out Microsoft Translator. | ||
Select the `Authorize` button and enter your Microsoft Translator subscription key, OR your `all in one Cognitive Services` subscription key. If you are using the all in one Cognitive Services key you will need to also enter your subscription region. | ||
## Available regions are: | ||
`australiaeast`, `brazilsouth`, `canadacentral`, `centralindia`, `centraluseuap`, `eastasia`, `eastus`, `eastus2`, `japaneast`, `northeurope`, `southcentralus`, `southeastasia`, `uksouth`, `westcentralus`, `westeurope`, `westus`, `westus2`. | ||
:ivar config: Configuration for client. | ||
:vartype config: TranslatorTextClientConfiguration | ||
:ivar translator: Translator operations | ||
:vartype translator: azure.cognitiveservices.translatortext.operations.TranslatorOperations | ||
:param endpoint: Supported Cognitive Services endpoints | ||
:type endpoint: str | ||
:param credentials: Subscription credentials which uniquely identify | ||
client subscription. | ||
:type credentials: None | ||
""" | ||
|
||
def __init__( | ||
self, endpoint, credentials): | ||
|
||
self.config = TranslatorTextClientConfiguration(endpoint, credentials) | ||
super(TranslatorTextClient, self).__init__(self.config.credentials, self.config) | ||
|
||
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} | ||
self.api_version = '3.0' | ||
self._serialize = Serializer(client_models) | ||
self._deserialize = Deserializer(client_models) | ||
|
||
self.translator = TranslatorOperations( | ||
self._client, self.config, self._serialize, self._deserialize) |
124 changes: 124 additions & 0 deletions
124
...ognitiveservices-translatortext/azure/cognitiveservices/translatortext/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
try: | ||
from ._models_py3 import BreakSentenceResultItem | ||
from ._models_py3 import BreakSentenceTextInput | ||
from ._models_py3 import DetectResultItem | ||
from ._models_py3 import DetectTextInput | ||
from ._models_py3 import DictionaryExampleResultItem | ||
from ._models_py3 import DictionaryExampleResultItemExamplesItem | ||
from ._models_py3 import DictionaryExampleTextInput | ||
from ._models_py3 import DictionaryLookupResultItem | ||
from ._models_py3 import DictionaryLookupResultItemTranslationsItem | ||
from ._models_py3 import DictionaryLookupResultItemTranslationsItemBackTranslationsItem | ||
from ._models_py3 import DictionaryLookupTextInput | ||
from ._models_py3 import ErrorMessage, ErrorMessageException | ||
from ._models_py3 import ErrorMessageError | ||
from ._models_py3 import LanguagesResult | ||
from ._models_py3 import LanguagesResultDictionary | ||
from ._models_py3 import LanguagesResultDictionaryLanguageCode | ||
from ._models_py3 import LanguagesResultDictionaryLanguageCodeTranslationsItem | ||
from ._models_py3 import LanguagesResultTranslation | ||
from ._models_py3 import LanguagesResultTranslationLanguageCode | ||
from ._models_py3 import LanguagesResultTransliteration | ||
from ._models_py3 import LanguagesResultTransliterationLanguageCode | ||
from ._models_py3 import LanguagesResultTransliterationLanguageCodeScriptsItem | ||
from ._models_py3 import LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem | ||
from ._models_py3 import TranslateResultAllItem | ||
from ._models_py3 import TranslateResultAllItemDetectedLanguage | ||
from ._models_py3 import TranslateResultAllItemTranslationsItem | ||
from ._models_py3 import TranslateResultAllItemTranslationsItemAlignment | ||
from ._models_py3 import TranslateResultAllItemTranslationsItemSentLen | ||
from ._models_py3 import TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem | ||
from ._models_py3 import TranslateResultAllItemTranslationsItemSentLenTransSentLenItem | ||
from ._models_py3 import TranslateResultAllItemTranslationsItemTransliteration | ||
from ._models_py3 import TranslateResultItem | ||
from ._models_py3 import TranslateResultItemTranslationItem | ||
from ._models_py3 import TranslateTextInput | ||
from ._models_py3 import TransliterateResultItem | ||
from ._models_py3 import TransliterateTextInput | ||
except (SyntaxError, ImportError): | ||
from ._models import BreakSentenceResultItem | ||
from ._models import BreakSentenceTextInput | ||
from ._models import DetectResultItem | ||
from ._models import DetectTextInput | ||
from ._models import DictionaryExampleResultItem | ||
from ._models import DictionaryExampleResultItemExamplesItem | ||
from ._models import DictionaryExampleTextInput | ||
from ._models import DictionaryLookupResultItem | ||
from ._models import DictionaryLookupResultItemTranslationsItem | ||
from ._models import DictionaryLookupResultItemTranslationsItemBackTranslationsItem | ||
from ._models import DictionaryLookupTextInput | ||
from ._models import ErrorMessage, ErrorMessageException | ||
from ._models import ErrorMessageError | ||
from ._models import LanguagesResult | ||
from ._models import LanguagesResultDictionary | ||
from ._models import LanguagesResultDictionaryLanguageCode | ||
from ._models import LanguagesResultDictionaryLanguageCodeTranslationsItem | ||
from ._models import LanguagesResultTranslation | ||
from ._models import LanguagesResultTranslationLanguageCode | ||
from ._models import LanguagesResultTransliteration | ||
from ._models import LanguagesResultTransliterationLanguageCode | ||
from ._models import LanguagesResultTransliterationLanguageCodeScriptsItem | ||
from ._models import LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem | ||
from ._models import TranslateResultAllItem | ||
from ._models import TranslateResultAllItemDetectedLanguage | ||
from ._models import TranslateResultAllItemTranslationsItem | ||
from ._models import TranslateResultAllItemTranslationsItemAlignment | ||
from ._models import TranslateResultAllItemTranslationsItemSentLen | ||
from ._models import TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem | ||
from ._models import TranslateResultAllItemTranslationsItemSentLenTransSentLenItem | ||
from ._models import TranslateResultAllItemTranslationsItemTransliteration | ||
from ._models import TranslateResultItem | ||
from ._models import TranslateResultItemTranslationItem | ||
from ._models import TranslateTextInput | ||
from ._models import TransliterateResultItem | ||
from ._models import TransliterateTextInput | ||
|
||
__all__ = [ | ||
'BreakSentenceResultItem', | ||
'BreakSentenceTextInput', | ||
'DetectResultItem', | ||
'DetectTextInput', | ||
'DictionaryExampleResultItem', | ||
'DictionaryExampleResultItemExamplesItem', | ||
'DictionaryExampleTextInput', | ||
'DictionaryLookupResultItem', | ||
'DictionaryLookupResultItemTranslationsItem', | ||
'DictionaryLookupResultItemTranslationsItemBackTranslationsItem', | ||
'DictionaryLookupTextInput', | ||
'ErrorMessage', 'ErrorMessageException', | ||
'ErrorMessageError', | ||
'LanguagesResult', | ||
'LanguagesResultDictionary', | ||
'LanguagesResultDictionaryLanguageCode', | ||
'LanguagesResultDictionaryLanguageCodeTranslationsItem', | ||
'LanguagesResultTranslation', | ||
'LanguagesResultTranslationLanguageCode', | ||
'LanguagesResultTransliteration', | ||
'LanguagesResultTransliterationLanguageCode', | ||
'LanguagesResultTransliterationLanguageCodeScriptsItem', | ||
'LanguagesResultTransliterationLanguageCodeScriptsItemToScriptsItem', | ||
'TranslateResultAllItem', | ||
'TranslateResultAllItemDetectedLanguage', | ||
'TranslateResultAllItemTranslationsItem', | ||
'TranslateResultAllItemTranslationsItemAlignment', | ||
'TranslateResultAllItemTranslationsItemSentLen', | ||
'TranslateResultAllItemTranslationsItemSentLenSrcSentLenItem', | ||
'TranslateResultAllItemTranslationsItemSentLenTransSentLenItem', | ||
'TranslateResultAllItemTranslationsItemTransliteration', | ||
'TranslateResultItem', | ||
'TranslateResultItemTranslationItem', | ||
'TranslateTextInput', | ||
'TransliterateResultItem', | ||
'TransliterateTextInput', | ||
] |
Oops, something went wrong.