async def sample_list_translations_async():
    import os
    # [START list_translations_async]
    from azure.core.credentials import AzureKeyCredential
    from azure.ai.translation.document.aio import DocumentTranslationClient

    endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"]
    key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"]

    client = DocumentTranslationClient(endpoint, AzureKeyCredential(key))
    async with client:
        operations = client.list_translation_statuses(
        )  # type: AsyncItemPaged[TranslationStatus]

        async for operation in operations:
            print(f"ID: {operation.id}")
            print(f"Status: {operation.status}")
            print(f"Created on: {operation.created_on}")
            print(f"Last updated on: {operation.last_updated_on}")
            print(
                f"Total number of operations on documents: {operation.documents_total_count}"
            )
            print(
                f"Total number of characters charged: {operation.total_characters_charged}"
            )

            print("\nOf total documents...")
            print(f"{operation.documents_failed_count} failed")
            print(f"{operation.documents_succeeded_count} succeeded")
            print(f"{operation.documents_canceled_count} canceled\n")
async def sample_list_translations_with_filters_async():
    # import libraries
    from azure.core.credentials import AzureKeyCredential
    from azure.ai.translation.document.aio import DocumentTranslationClient

    from datetime import datetime

    # obtain client secrets
    endpoint = os.environ["AZURE_DOCUMENT_TRANSLATION_ENDPOINT"]
    key = os.environ["AZURE_DOCUMENT_TRANSLATION_KEY"]

    # authorize client
    client = DocumentTranslationClient(endpoint, AzureKeyCredential(key))
    async with client:
        # set your filters
        '''
            Note:
                these are just sample values for the filters!
                please comment/uncomment/change what you are interested in using.
        '''
        start = datetime(2021, 4, 12)
        end = datetime(2021, 4, 14)
        statuses = ["Canceled", "Failed"]
        order_by = ["created_on desc"]
        results_per_page = 2
        skip = 3

        # list translation operations
        submitted_translations = client.list_translation_statuses(
            # filters
            statuses=statuses,
            created_after=start,
            created_before=end,
            # ordering
            order_by=order_by,
            # paging
            skip=skip,
            results_per_page=results_per_page
        ).by_page()

        # check statuses
        async for page in submitted_translations:
            async for translation in page:
                display_translation_info(translation)