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.
[translation] update samples (Azure#17555)
* delete cancel translation job samples * rename files to fit hero scenarios * add samples for authenticating the client * updates for create translation job samples * updates for document status check samples * update samples for list jobs * updates for samples that use azure storage * updates for samples for glossaries * fix weird indent on sample headers * replace references to FR * remove glossary sample test prefix * update readme links to samples * comment out non-live links * review feedback * failed at job level won't have error code/message * missed a rename for translation glossary format -> file_format
- Loading branch information
1 parent
b6803a7
commit 19f9aba
Showing
23 changed files
with
1,036 additions
and
1,003 deletions.
There are no files selected for viewing
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
52 changes: 52 additions & 0 deletions
52
...slation/azure-ai-documenttranslation/samples/async_samples/sample_authentication_async.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,52 @@ | ||
# 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. | ||
# -------------------------------------------------------------------------- | ||
|
||
""" | ||
FILE: sample_authentication_async.py | ||
DESCRIPTION: | ||
This sample demonstrates how to authenticate to the Document Translation service. | ||
There is currently only one supported method of authentication: | ||
1) Use a Document Translation API key with AzureKeyCredential from azure.core.credentials | ||
Note: the endpoint must be formatted to use the custom domain name for your resource: | ||
https://<NAME-OF-YOUR-RESOURCE>.cognitiveservices.azure.com/ | ||
USAGE: | ||
python sample_authentication_async.py | ||
Set the environment variables with your own values before running the sample: | ||
1) AZURE_DOCUMENT_TRANSLATION_ENDPOINT - the endpoint to your Document Translation resource. | ||
2) AZURE_DOCUMENT_TRANSLATION_KEY - your Document Translation API key | ||
""" | ||
|
||
import os | ||
import asyncio | ||
|
||
|
||
async def sample_authentication_api_key_async(): | ||
from azure.core.credentials import AzureKeyCredential | ||
from azure.ai.documenttranslation.aio import DocumentTranslationClient | ||
|
||
endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"] | ||
key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"] | ||
|
||
document_translation_client = DocumentTranslationClient(endpoint, AzureKeyCredential(key)) | ||
|
||
# make calls with authenticated client | ||
async with document_translation_client: | ||
result = await document_translation_client.get_document_formats() | ||
|
||
|
||
async def main(): | ||
await sample_authentication_api_key_async() | ||
|
||
if __name__ == '__main__': | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(main()) |
113 changes: 0 additions & 113 deletions
113
...tion/azure-ai-documenttranslation/samples/async_samples/sample_batch_translation_async.py
This file was deleted.
Oops, something went wrong.
142 changes: 0 additions & 142 deletions
142
...-documenttranslation/samples/async_samples/sample_batch_translation_with_storage_async.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.