diff --git a/eng/ci_tools.txt b/eng/ci_tools.txt index 778e2d256aab..8c693ec8b715 100644 --- a/eng/ci_tools.txt +++ b/eng/ci_tools.txt @@ -20,6 +20,7 @@ beautifulsoup4==4.9.1 pkginfo==1.5.0.1 pip==20.3 black==21.6b0; python_version >= '3.6' +wrapt<=1.12.1; python_version == '2.7' # locking packages defined as deps from azure-sdk-tools or azure-devtools pytoml==0.1.21 diff --git a/eng/test_tools.txt b/eng/test_tools.txt index 3c37cd630556..e96c25a54af8 100644 --- a/eng/test_tools.txt +++ b/eng/test_tools.txt @@ -18,6 +18,7 @@ pytest-xdist==1.32.0 coverage==4.5.4 bandit==1.6.2 protobuf==3.17.3; python_version == '2.7' +wrapt<=1.12.1; python_version == '2.7' # locking packages defined as deps from azure-sdk-tools or azure-devtools pytoml==0.1.21 diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/conftest.py b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/conftest.py index 755d2a9305fa..b0503973b24b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/tests/conftest.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/tests/conftest.py @@ -11,5 +11,4 @@ # Ignore async tests for Python < 3.5 collect_ignore_glob = [] if sys.version_info < (3, 5): - collect_ignore_glob.append("*_async.py") - + collect_ignore_glob.append("*_async.py") \ No newline at end of file diff --git a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_shared/__init__.py b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_shared/__init__.py index 5b396cd202e8..755d2a9305fa 100644 --- a/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_shared/__init__.py +++ b/sdk/communication/azure-communication-callingserver/azure/communication/callingserver/_shared/__init__.py @@ -1,5 +1,15 @@ +# 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. # -------------------------------------------------------------------------- + +import sys + + +# Ignore async tests for Python < 3.5 +collect_ignore_glob = [] +if sys.version_info < (3, 5): + collect_ignore_glob.append("*_async.py") + diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection.test_create_add_remove_hangup_scenario.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection.test_create_add_remove_hangup_scenario.yaml deleted file mode 100644 index 037d9a260d7b..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection.test_create_add_remove_hangup_scenario.yaml +++ /dev/null @@ -1,227 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 21:28:16 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9fd7-5540-f4f5-343a0d002b3c"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 21:28:16 GMT - ms-cv: - - qvOTZ+mq70+vqksNLQ+D5w.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 42ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 21:28:17 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9fd7-572f-0e04-343a0d0033ce"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 21:28:16 GMT - ms-cv: - - aInwNGjk3Em4x5zCiLDqRg.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 44ms - status: - code: 201 - message: Created -- request: - body: '{"alternateCallerId": "sanitized", "targets": "sanitized", "source": "sanitized", - "callbackUri": "sanitized", "requestedMediaTypes": ["audio"], "requestedCallEvents": - ["participantsUpdated", "dtmfReceived"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '411' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "411f0b00-8e45-4c58-9dfb-b58847606d7f"}' - headers: - content-length: - - '59' - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 21:28:19 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 7ae446cf-6dae-4997-9cec-c3d9996d1cee - status: - code: 201 - message: Created -- request: - body: '{"participant": {"communicationUser": {"id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f68-6fd6-e57b-254822002248"}}, - "operationContext": "03e4b3d5-e50b-4957-97e3-15f3df772a2a"}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '189' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-8e45-4c58-9dfb-b58847606d7f/participants?api-version=2021-09-15-preview - response: - body: - string: '{"participantId": "0dd3ccdf-0754-4d23-b082-5052e5b66ea7"}' - headers: - content-length: - - '56' - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 21:28:29 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - e391ce75-1bad-4f66-b337-652e3fc11d31 - status: - code: 202 - message: Accepted -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: DELETE - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-8e45-4c58-9dfb-b58847606d7f/participants/0dd3ccdf-0754-4d23-b082-5052e5b66ea7?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Sun, 19 Sep 2021 21:28:39 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - e164c268-200c-49c6-ae16-0eff535cc95b - status: - code: 202 - message: Accepted -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-8e45-4c58-9dfb-b58847606d7f/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Sun, 19 Sep 2021 21:28:49 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - e80676cc-e297-4d19-95e8-60c1005cee43 - status: - code: 202 - message: Accepted -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection.test_create_play_cancel_hangup_scenario.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection.test_create_play_cancel_hangup_scenario.yaml deleted file mode 100644 index 17935c36f712..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection.test_create_play_cancel_hangup_scenario.yaml +++ /dev/null @@ -1,236 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 20:31:19 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9fa3-3266-9508-454822002be3"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 20:31:20 GMT - ms-cv: - - udp2YwR6q0SPCaSeRDk59A.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 60ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 20:31:20 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9fa3-339a-9508-454822002be4"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 20:31:20 GMT - ms-cv: - - /mxnYyadtEmLWX2C0zps3Q.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 73ms - status: - code: 201 - message: Created -- request: - body: '{"alternateCallerId": "sanitized", "targets": "sanitized", "source": "sanitized", - "callbackUri": "sanitized", "requestedMediaTypes": ["audio"], "requestedCallEvents": - ["participantsUpdated", "dtmfReceived"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '411' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "03000b80-8e99-43dc-bf93-192be30e9509"}' - headers: - content-length: - - '59' - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 20:31:21 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 5a04a6f6-517a-4131-baa6-a18806c466cb - status: - code: 201 - message: Created -- request: - body: '{"audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", "loop": - true, "operationContext": "", "audioFileId": "682ce87b-68b1-4983-9cd2-8a2387428998", - "callbackUri": "sanitized"}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '333' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/03000b80-8e99-43dc-bf93-192be30e9509/:playAudio?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "4e6441d3-928e-4ecf-9024-0219193f63d1", "status": "running", - "operationContext": ""}' - headers: - content-length: - - '184' - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 20:31:31 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - efae0053-a37e-4201-a222-3b2e536da1b0 - status: - code: 202 - message: Accepted -- request: - body: '{"operationContext": "aae5f563-f5e2-45eb-8160-6b751b1a510c"}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '60' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/03000b80-8e99-43dc-bf93-192be30e9509/:cancelAllMediaOperations?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "45c19042-96b9-40cc-9fd1-a179e708d925", "status": "completed", - "operationContext": "aae5f563-f5e2-45eb-8160-6b751b1a510c"}' - headers: - content-length: - - '133' - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 20:31:41 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 38d335e6-b633-4753-a17f-db1694ad243f - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/03000b80-8e99-43dc-bf93-192be30e9509/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Sun, 19 Sep 2021 20:31:51 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - b8eed645-3dfe-4f72-a506-f44b6cc75b9a - status: - code: 202 - message: Accepted -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection_async.test_create_add_remove_hangup_scenario_async.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection_async.test_create_add_remove_hangup_scenario_async.yaml deleted file mode 100644 index 3e2e6c07e4d2..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection_async.test_create_add_remove_hangup_scenario_async.yaml +++ /dev/null @@ -1,193 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 19:53:37 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f80-ad5a-0207-454822002049"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 19:53:37 GMT - ms-cv: - - vCVYQbJqNE2imgFfESQqpA.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 82ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 19:53:38 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f80-af4e-b1fb-343a0d002b05"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 19:53:37 GMT - ms-cv: - - 5VsS3sCFj0y+U4xLPlYgTg.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 45ms - status: - code: 201 - message: Created -- request: - body: '{"alternateCallerId": "sanitized", "targets": "sanitized", "source": "sanitized", - "callbackUri": "sanitized", "requestedMediaTypes": ["audio"], "requestedCallEvents": - ["participantsUpdated", "dtmfReceived"]}' - headers: - Accept: - - application/json - Content-Length: - - '411' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "411f0b00-7e5e-4c8e-9f67-b7a90ae2274d"}' - headers: - content-length: '59' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 19:53:39 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: c2f8659c-5982-4b36-883f-0b0aac53a8a6 - status: - code: 201 - message: Created - url: https://sanitized.communication.azure.com/calling/callConnections?api-version=2021-09-15-preview -- request: - body: '{"participant": {"communicationUser": {"id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f68-6fd6-e57b-254822002248"}}, - "operationContext": "15715806-3ac0-438d-8754-90a5ba073b20"}' - headers: - Accept: - - application/json - Content-Length: - - '189' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-7e5e-4c8e-9f67-b7a90ae2274d/participants?api-version=2021-09-15-preview - response: - body: - string: '{"participantId": "2d4ff34f-88a4-4efc-a103-6e6ffae5a042"}' - headers: - content-length: '56' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 19:53:49 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 44d1b443-d3f9-4c68-8357-5ddd4d19bd9d - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-7e5e-4c8e-9f67-b7a90ae2274d/participants?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: DELETE - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-7e5e-4c8e-9f67-b7a90ae2274d/participants/2d4ff34f-88a4-4efc-a103-6e6ffae5a042?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 19:54:00 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 5d4a29ed-1267-48bd-a204-d6d0aff78efb - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-7e5e-4c8e-9f67-b7a90ae2274d/participants/2d4ff34f-88a4-4efc-a103-6e6ffae5a042?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-7e5e-4c8e-9f67-b7a90ae2274d/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 19:54:10 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: d92b74bc-0849-44bc-b770-cc06aae55aea - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-7e5e-4c8e-9f67-b7a90ae2274d/:hangup?api-version=2021-09-15-preview -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection_async.test_create_play_cancel_hangup_scenario_async.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection_async.test_create_play_cancel_hangup_scenario_async.yaml deleted file mode 100644 index a50f139dfcfd..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_call_connection_async.test_create_play_cancel_hangup_scenario_async.yaml +++ /dev/null @@ -1,203 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 20:24:56 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f9d-5986-8170-254822001a34"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 20:24:56 GMT - ms-cv: - - aGPosBX/KEW2sq0HQMnYhA.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 131ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 20:24:57 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f9d-5afd-9406-454822001a09"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 20:24:56 GMT - ms-cv: - - v+9ovAkI0k2hUsn6UJKaPA.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 138ms - status: - code: 201 - message: Created -- request: - body: '{"alternateCallerId": "sanitized", "targets": "sanitized", "source": "sanitized", - "callbackUri": "sanitized", "requestedMediaTypes": ["audio"], "requestedCallEvents": - ["participantsUpdated", "dtmfReceived"]}' - headers: - Accept: - - application/json - Content-Length: - - '411' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "421f0b00-d5a3-49d8-a0e3-e172a00d8acb"}' - headers: - content-length: '59' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 20:24:57 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 9dc55f2f-3eb4-4ec2-987b-cc534aa41ce5 - status: - code: 201 - message: Created - url: https://sanitized.communication.azure.com/calling/callConnections?api-version=2021-09-15-preview -- request: - body: '{"audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", "loop": - true, "operationContext": "", "audioFileId": "63160841-124e-4996-97f8-47dc1bcda982", - "callbackUri": "sanitized"}' - headers: - Accept: - - application/json - Content-Length: - - '333' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-d5a3-49d8-a0e3-e172a00d8acb/:playAudio?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "020429d1-0612-431e-ad7c-4a488c90d429", "status": "running", - "operationContext": ""}' - headers: - content-length: '184' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 20:25:08 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 5ef0f954-cf3f-4356-a48c-66e24303418c - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-d5a3-49d8-a0e3-e172a00d8acb/:playAudio?api-version=2021-09-15-preview -- request: - body: '{"operationContext": "3044805c-1ea4-43bc-a854-afcae01cdaff"}' - headers: - Accept: - - application/json - Content-Length: - - '60' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-d5a3-49d8-a0e3-e172a00d8acb/:cancelAllMediaOperations?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "8028786d-8325-449f-bc33-cf6772839882", "status": "completed", - "operationContext": "3044805c-1ea4-43bc-a854-afcae01cdaff"}' - headers: - content-length: '133' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 20:25:18 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 2a13c57d-4896-47c4-bf6d-877628cd09e2 - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-d5a3-49d8-a0e3-e172a00d8acb/:cancelAllMediaOperations?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-d5a3-49d8-a0e3-e172a00d8acb/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 20:25:28 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 799ee960-c232-4a76-aa2b-38d0d614c65c - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-d5a3-49d8-a0e3-e172a00d8acb/:hangup?api-version=2021-09-15-preview -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream.yaml deleted file mode 100644 index 0501d745a455..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream.yaml +++ /dev/null @@ -1,55 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=0-4194303 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Thu, 30 Sep 2021 22:55:38 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "{\r\n \"resourceId\": \"ab12b0ea-85ea-4f83-b0b6-84d90209c7c4\",\r\n - \ \"callId\": \"ade1a5b4-1fed-4eb0-bece-2af03a20b178\",\r\n \"chunkDocumentId\": - \"0-wus-d3-008713a3abdb3f3ae4904369277244c5\",\r\n \"chunkIndex\": 0,\r\n - \ \"chunkStartTime\": \"2021-09-30T22:37:28.9321086Z\",\r\n \"chunkDuration\": - 7000.0,\r\n \"pauseResumeIntervals\": [],\r\n \"recordingInfo\": {\r\n \"contentType\": - \"mixed\",\r\n \"channelType\": \"audioVideo\",\r\n \"format\": \"mp4\",\r\n - \ \"audioConfiguration\": {\r\n \"sampleRate\": 16000,\r\n \"bitRate\": - 128000,\r\n \"channels\": 1\r\n },\r\n \"videoConfiguration\": - {\r\n \"longerSideLength\": 1920,\r\n \"shorterSideLength\": 1080,\r\n - \ \"framerate\": 8,\r\n \"bitRate\": 1000000\r\n }\r\n },\r\n - \ \"participants\": [\r\n {\r\n \"participantId\": \"8:acs:ab12b0ea-85ea-4f83-b0b6-84d90209c7c4_0000000c-d8bc-1176-2df4-343a0d0001bc\"\r\n - \ }\r\n ]\r\n}" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '836' - content-range: - - bytes 0-835/836 - content-type: - - application/octet-stream - date: - - Thu, 30 Sep 2021 22:55:38 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_on_chunks.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_on_chunks.yaml deleted file mode 100644 index 136438ab25fd..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_on_chunks.yaml +++ /dev/null @@ -1,137 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=0-399 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Thu, 30 Sep 2021 22:55:38 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "{\r\n \"resourceId\": \"ab12b0ea-85ea-4f83-b0b6-84d90209c7c4\",\r\n - \ \"callId\": \"ade1a5b4-1fed-4eb0-bece-2af03a20b178\",\r\n \"chunkDocumentId\": - \"0-wus-d3-008713a3abdb3f3ae4904369277244c5\",\r\n \"chunkIndex\": 0,\r\n - \ \"chunkStartTime\": \"2021-09-30T22:37:28.9321086Z\",\r\n \"chunkDuration\": - 7000.0,\r\n \"pauseResumeIntervals\": [],\r\n \"recordingInfo\": {\r\n \"contentType\": - \"mixed\",\r\n \"channelType\": \"audioVideo\",\r\n " - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '400' - content-range: - - bytes 0-399/836 - content-type: - - application/octet-stream - date: - - Thu, 30 Sep 2021 22:55:38 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=400-799 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Thu, 30 Sep 2021 22:55:39 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: " \"format\": \"mp4\",\r\n \"audioConfiguration\": {\r\n \"sampleRate\": - 16000,\r\n \"bitRate\": 128000,\r\n \"channels\": 1\r\n },\r\n - \ \"videoConfiguration\": {\r\n \"longerSideLength\": 1920,\r\n \"shorterSideLength\": - 1080,\r\n \"framerate\": 8,\r\n \"bitRate\": 1000000\r\n }\r\n - \ },\r\n \"participants\": [\r\n {\r\n \"participantId\": \"8:acs:ab12b0ea-85ea-4f83-b0b6-84d90209c7c4_0000000c-d8bc-11" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '400' - content-range: - - bytes 400-799/836 - content-type: - - application/octet-stream - date: - - Thu, 30 Sep 2021 22:55:39 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=800-835 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Thu, 30 Sep 2021 22:55:39 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "76-2df4-343a0d0001bc\"\r\n }\r\n ]\r\n}" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '36' - content-range: - - bytes 800-835/836 - content-type: - - application/octet-stream - date: - - Thu, 30 Sep 2021 22:55:39 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_on_chunks_parallel.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_on_chunks_parallel.yaml deleted file mode 100644 index 18afbd105573..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_on_chunks_parallel.yaml +++ /dev/null @@ -1,387 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=0-99 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:39 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "{\r\n \"resourceId\": \"ab12b0ea-85ea-4f83-b0b6-84d90209c7c4\",\r\n - \ \"callId\": \"ade1a5b4-1fed-4eb0-bece-2af" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 0-99/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:39 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=100-199 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:40 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "03a20b178\",\r\n \"chunkDocumentId\": \"0-wus-d3-008713a3abdb3f3ae4904369277244c5\",\r\n - \ \"chunkIndex\": 0,\r\n" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 100-199/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:39 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=200-299 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:40 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: " \"chunkStartTime\": \"2021-09-30T22:37:28.9321086Z\",\r\n \"chunkDuration\": - 7000.0,\r\n \"pauseResumeInter" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 200-299/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:39 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=300-399 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:40 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "vals\": [],\r\n \"recordingInfo\": {\r\n \"contentType\": \"mixed\",\r\n - \ \"channelType\": \"audioVideo\",\r\n " - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 300-399/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:40 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=400-499 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:41 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: " \"format\": \"mp4\",\r\n \"audioConfiguration\": {\r\n \"sampleRate\": - 16000,\r\n \"bitRate\": 128000," - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 400-499/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:40 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=500-599 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:41 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "\r\n \"channels\": 1\r\n },\r\n \"videoConfiguration\": - {\r\n \"longerSideLength\": 1920,\r\n \"" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 500-599/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:41 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=600-699 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:41 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "shorterSideLength\": 1080,\r\n \"framerate\": 8,\r\n \"bitRate\": - 1000000\r\n }\r\n },\r\n \"particip" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 600-699/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:41 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=700-799 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:42 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "ants\": [\r\n {\r\n \"participantId\": \"8:acs:ab12b0ea-85ea-4f83-b0b6-84d90209c7c4_0000000c-d8bc-11" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '100' - content-range: - - bytes 700-799/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:41 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=800-835 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Tue, 05 Oct 2021 01:04:42 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "76-2df4-343a0d0001bc\"\r\n }\r\n ]\r\n}" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '36' - content-range: - - bytes 800-835/836 - content-type: - - application/octet-stream - date: - - Tue, 05 Oct 2021 01:04:41 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_with_redirection.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_with_redirection.yaml deleted file mode 100644 index 9ae7dabe24ca..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_download_content.test_download_content_to_stream_with_redirection.yaml +++ /dev/null @@ -1,55 +0,0 @@ -interactions: -- request: - body: null - headers: - Accept: - - '*/*' - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Range: - - bytes=0-4194303 - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.7.9 (Windows-10-10.0.19041-SP0) - host: - - acstelephonyportaltesting.communication.azure.com - x-ms-date: - - Thu, 30 Sep 2021 22:55:41 GMT - x-ms-return-client-request-id: - - 'true' - method: GET - uri: https://storage.asm.skype.com/v1/objects/0-wus-d3-008713a3abdb3f3ae4904369277244c5/content/acsmetadata - response: - body: - string: "{\r\n \"resourceId\": \"ab12b0ea-85ea-4f83-b0b6-84d90209c7c4\",\r\n - \ \"callId\": \"ade1a5b4-1fed-4eb0-bece-2af03a20b178\",\r\n \"chunkDocumentId\": - \"0-wus-d3-008713a3abdb3f3ae4904369277244c5\",\r\n \"chunkIndex\": 0,\r\n - \ \"chunkStartTime\": \"2021-09-30T22:37:28.9321086Z\",\r\n \"chunkDuration\": - 7000.0,\r\n \"pauseResumeIntervals\": [],\r\n \"recordingInfo\": {\r\n \"contentType\": - \"mixed\",\r\n \"channelType\": \"audioVideo\",\r\n \"format\": \"mp4\",\r\n - \ \"audioConfiguration\": {\r\n \"sampleRate\": 16000,\r\n \"bitRate\": - 128000,\r\n \"channels\": 1\r\n },\r\n \"videoConfiguration\": - {\r\n \"longerSideLength\": 1920,\r\n \"shorterSideLength\": 1080,\r\n - \ \"framerate\": 8,\r\n \"bitRate\": 1000000\r\n }\r\n },\r\n - \ \"participants\": [\r\n {\r\n \"participantId\": \"8:acs:ab12b0ea-85ea-4f83-b0b6-84d90209c7c4_0000000c-d8bc-1176-2df4-343a0d0001bc\"\r\n - \ }\r\n ]\r\n}" - headers: - cache-control: - - no-cache, max-age=0, s-maxage=0, private - content-length: - - '836' - content-range: - - bytes 0-835/836 - content-type: - - application/octet-stream - date: - - Thu, 30 Sep 2021 22:55:41 GMT - server: - - Microsoft-HTTPAPI/2.0 - strict-transport-security: - - max-age=31536000; includeSubDomains - status: - code: 206 - message: Partial Content -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call.test_create_add_remove_hangup_scenario.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call.test_create_add_remove_hangup_scenario.yaml deleted file mode 100644 index 153bac50f34f..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call.test_create_add_remove_hangup_scenario.yaml +++ /dev/null @@ -1,291 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Mon, 20 Sep 2021 00:07:54 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a069-79a5-a2d9-444822001d63"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:07:54 GMT - ms-cv: - - jLteP9DdpUGLGHdusaPKxw.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 86ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Mon, 20 Sep 2021 00:07:54 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a069-7ace-a2d9-444822001d64"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:07:54 GMT - ms-cv: - - V56s+HrjdkWb+YoMnuPa8g.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 67ms - status: - code: 201 - message: Created -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/1b3806d0-3449-30e4-a5da-0c00e39fc374/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "00000b80-3ec3-402c-8e75-6a6a21d04369"}' - headers: - content-length: - - '59' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:07:55 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - dc8d600e-9834-4e5e-9bf3-6d63d3c6638c - status: - code: 202 - message: Accepted -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/1b3806d0-3449-30e4-a5da-0c00e39fc374/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "00000b80-ca45-439f-90f7-bc5b0fb419d9"}' - headers: - content-length: - - '59' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:08:06 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - d3a12425-082a-404a-b319-019ddfceb998 - status: - code: 202 - message: Accepted -- request: - body: '{"participant": {"communicationUser": {"id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f68-6fd6-e57b-254822002248"}}, - "operationContext": "77673a47-5b48-4f63-99d0-81bbcbd9621b"}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '189' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/1b3806d0-3449-30e4-a5da-0c00e39fc374/participants?api-version=2021-09-15-preview - response: - body: - string: '{"participantId": "76e20d1e-4930-4e09-b489-3f05c7e3cd10"}' - headers: - content-length: - - '56' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:08:26 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 29310a55-63f6-47fd-b57e-6af99a879993 - status: - code: 202 - message: Accepted -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: DELETE - uri: https://sanitized.communication.azure.com/calling/serverCalls/1b3806d0-3449-30e4-a5da-0c00e39fc374/participants/76e20d1e-4930-4e09-b489-3f05c7e3cd10?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 20 Sep 2021 00:08:37 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - a71762ae-963e-4a21-8b09-79b826de45db - status: - code: 202 - message: Accepted -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/00000b80-3ec3-402c-8e75-6a6a21d04369/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 20 Sep 2021 00:08:47 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 738bc188-ad55-496d-83c1-dbafc381ba39 - status: - code: 202 - message: Accepted -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/00000b80-ca45-439f-90f7-bc5b0fb419d9/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 20 Sep 2021 00:08:47 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - e3337f37-d942-4120-8426-156af6d376dd - status: - code: 202 - message: Accepted -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call.test_join_play_cancel_hangup_scenario.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call.test_join_play_cancel_hangup_scenario.yaml deleted file mode 100644 index c2236a223b48..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call.test_join_play_cancel_hangup_scenario.yaml +++ /dev/null @@ -1,333 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Mon, 20 Sep 2021 00:05:55 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a067-a98c-a4f5-343a0d00245c"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:05:54 GMT - ms-cv: - - Sc1S2WdTkE6xrx3IoV75hw.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 46ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Mon, 20 Sep 2021 00:05:55 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a067-ab2b-8e0e-4548220020e1"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:05:55 GMT - ms-cv: - - gotxQcOKokqDeioXpzaiig.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 90ms - status: - code: 201 - message: Created -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/99201345-3871-32a7-b018-f5d5b95403d2/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "421f0b00-2ac6-4fe7-a1ce-8cce728c377b"}' - headers: - content-length: - - '59' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:05:57 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 29619817-55fe-4487-af71-998fed26092d - status: - code: 202 - message: Accepted -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/99201345-3871-32a7-b018-f5d5b95403d2/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "421f0b00-cc04-4d82-a568-323868dc5a31"}' - headers: - content-length: - - '59' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:06:07 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 784a460e-7df3-49cd-8ec3-ce9b6a7698f9 - status: - code: 202 - message: Accepted -- request: - body: '{"audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", "loop": - true, "operationContext": "", "audioFileId": "8e7d6fcf-66e7-4bf0-92ee-ff39d776f2b7", - "callbackUri": "sanitized"}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '333' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/99201345-3871-32a7-b018-f5d5b95403d2/:playAudio?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "421f0b00-b900-4cfb-b726-4b31d98bc83f", "status": "running", - "operationContext": ""}' - headers: - content-length: - - '184' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:06:28 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 86c7e045-6e96-475b-b69d-420aa31baccb - status: - code: 202 - message: Accepted -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-2ac6-4fe7-a1ce-8cce728c377b/:cancelAllMediaOperations?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "53d767ab-470f-4512-a2f8-f46191032859", "status": "completed"}' - headers: - content-length: - - '75' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:06:38 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 93404091-07a1-48e6-b5a0-10ca5f60e20f - status: - code: 200 - message: OK -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-cc04-4d82-a568-323868dc5a31/:cancelAllMediaOperations?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "92f29837-41d2-44f7-b066-6e7d7d467a08", "status": "completed"}' - headers: - content-length: - - '75' - content-type: - - application/json; charset=utf-8 - date: - - Mon, 20 Sep 2021 00:06:38 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 445ad180-d40f-407a-a176-3bcc2828bc1f - status: - code: 200 - message: OK -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-2ac6-4fe7-a1ce-8cce728c377b/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 20 Sep 2021 00:06:48 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 3beb8da6-c43e-466c-aa18-b16d7661f98d - status: - code: 202 - message: Accepted -- request: - body: null - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '0' - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/421f0b00-cc04-4d82-a568-323868dc5a31/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: - - '0' - date: - - Mon, 20 Sep 2021 00:06:48 GMT - x-cache: - - CONFIG_NOCACHE - x-microsoft-skype-chain-id: - - 9ca37555-a44b-4867-b25b-7b6925911bf0 - status: - code: 202 - message: Accepted -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call_async.test_create_add_remove_hangup_scenario_async.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call_async.test_create_add_remove_hangup_scenario_async.yaml deleted file mode 100644 index 932daa86d9ea..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call_async.test_create_add_remove_hangup_scenario_async.yaml +++ /dev/null @@ -1,240 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 23:45:37 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a055-1642-ebf2-343a0d0033d2"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 23:45:37 GMT - ms-cv: - - 0TZMvIIc7kycwNMTfsBVqQ.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 43ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 23:45:38 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a055-1ae0-d90a-454822001cd2"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 23:45:38 GMT - ms-cv: - - gSgpaJgxLUu6ae8NzU1fhg.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 122ms - status: - code: 201 - message: Created -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "01000480-7bd3-47d7-915c-2529ddf0be77"}' - headers: - content-length: '59' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:45:43 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 919d4aac-dec6-4757-ac9d-fede0d191409 - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/:join?api-version=2021-09-15-preview -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "01000480-11be-411b-812a-39f84647d0e9"}' - headers: - content-length: '59' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:45:53 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 2072113c-a9d3-49fe-a9c2-def042e947e6 - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/:join?api-version=2021-09-15-preview -- request: - body: '{"participant": {"communicationUser": {"id": "8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-9f68-6fd6-e57b-254822002248"}}, - "operationContext": "963efd7b-f655-4622-899b-c34875275025"}' - headers: - Accept: - - application/json - Content-Length: - - '189' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/participants?api-version=2021-09-15-preview - response: - body: - string: '{"participantId": "3a4f0ec9-af07-4bda-af35-4a78bcda3b14"}' - headers: - content-length: '56' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:46:15 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 07971df2-bf00-4dcc-98c5-009f68fccb72 - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/participants?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: DELETE - uri: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/participants/3a4f0ec9-af07-4bda-af35-4a78bcda3b14?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 23:46:26 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 178f76f9-a60b-4563-b824-815378885bcf - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/serverCalls/b67ebfa4-c124-3cad-b4ef-08c7e67a7d37/participants/3a4f0ec9-af07-4bda-af35-4a78bcda3b14?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/01000480-7bd3-47d7-915c-2529ddf0be77/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 23:46:36 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 89c21281-7989-4718-8c04-e89b23ebda39 - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/01000480-7bd3-47d7-915c-2529ddf0be77/:hangup?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/01000480-11be-411b-812a-39f84647d0e9/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 23:46:36 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 4b85642a-42b3-4464-be63-bc906675ed21 - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/01000480-11be-411b-812a-39f84647d0e9/:hangup?api-version=2021-09-15-preview -version: 1 diff --git a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call_async.test_join_play_cancel_hangup_scenario_async.yaml b/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call_async.test_join_play_cancel_hangup_scenario_async.yaml deleted file mode 100644 index c61fff94d6ad..000000000000 --- a/sdk/communication/azure-communication-callingserver/tests/recordings/test_live_server_call_async.test_join_play_cancel_hangup_scenario_async.yaml +++ /dev/null @@ -1,275 +0,0 @@ -interactions: -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 23:30:45 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a047-7939-207c-254822006ce9"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 23:30:45 GMT - ms-cv: - - wABfLDJUa0i2IGSTeUscmA.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 152ms - status: - code: 201 - message: Created -- request: - body: '{}' - headers: - Accept: - - application/json - Accept-Encoding: - - gzip, deflate - Connection: - - keep-alive - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-identity/1.0.1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - x-ms-date: - - Sun, 19 Sep 2021 23:30:46 GMT - x-ms-return-client-request-id: - - 'true' - method: POST - uri: https://sanitized.communication.azure.com/identities?api-version=2021-03-07 - response: - body: - string: '{"identity":{"id":"8:acs:016a7064-0581-40b9-be73-6dde64d69d72_0000000c-a047-7b48-75ff-343a0d001e1a"}}' - headers: - api-supported-versions: - - 2020-07-20-preview2, 2021-02-22-preview1, 2021-03-07, 2021-03-31-preview1, - 2021-10-31-preview - content-type: - - application/json; charset=utf-8 - date: - - Sun, 19 Sep 2021 23:30:46 GMT - ms-cv: - - WKHXDJ75T0ygYCo6ZgH1hg.0 - request-context: - - appId= - strict-transport-security: - - max-age=2592000 - transfer-encoding: - - chunked - x-cache: - - CONFIG_NOCACHE - x-processing-time: - - 67ms - status: - code: 201 - message: Created -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/a63c39d3-1147-31a1-9413-d97d876e1c5a/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "411f0b00-5dfd-47db-8758-8856ef2a2b7d"}' - headers: - content-length: '59' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:30:47 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 57ddc3c3-d784-4f45-b2cd-274cdecefbc5 - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/serverCalls/a63c39d3-1147-31a1-9413-d97d876e1c5a/:join?api-version=2021-09-15-preview -- request: - body: '{"source": "sanitized", "callbackUri": "sanitized", "requestedMediaTypes": - ["audio"], "requestedCallEvents": ["participantsUpdated"]}' - headers: - Accept: - - application/json - Content-Length: - - '256' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/a63c39d3-1147-31a1-9413-d97d876e1c5a/:join?api-version=2021-09-15-preview - response: - body: - string: '{"callConnectionId": "411f0b00-170c-4460-b86c-75b8a2c53bd5"}' - headers: - content-length: '59' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:30:58 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: cae3b776-320b-4bfa-8e80-e295aeda81ce - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/serverCalls/a63c39d3-1147-31a1-9413-d97d876e1c5a/:join?api-version=2021-09-15-preview -- request: - body: '{"audioFileUri": "https://dummy.ngrok.io/audio/sample-message.wav", "loop": - true, "operationContext": "", "audioFileId": "02d0985a-4f17-426b-8826-807918876208", - "callbackUri": "sanitized"}' - headers: - Accept: - - application/json - Content-Length: - - '333' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/serverCalls/a63c39d3-1147-31a1-9413-d97d876e1c5a/:playAudio?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "04000b80-a4fa-47eb-9664-77a27b147acf", "status": "running", - "operationContext": ""}' - headers: - content-length: '184' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:31:31 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: d5c71955-b1f4-446f-8593-9d14f28134ca - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/serverCalls/a63c39d3-1147-31a1-9413-d97d876e1c5a/:playAudio?api-version=2021-09-15-preview -- request: - body: '{}' - headers: - Accept: - - application/json - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-5dfd-47db-8758-8856ef2a2b7d/:cancelAllMediaOperations?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "5ad7ae32-e4e4-4ba9-8610-67f2bdb1e0a8", "status": "completed"}' - headers: - content-length: '75' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:31:42 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 1c8f31a6-c3f8-4ca3-b716-073cb25d6417 - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-5dfd-47db-8758-8856ef2a2b7d/:cancelAllMediaOperations?api-version=2021-09-15-preview -- request: - body: '{}' - headers: - Accept: - - application/json - Content-Length: - - '2' - Content-Type: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-170c-4460-b86c-75b8a2c53bd5/:cancelAllMediaOperations?api-version=2021-09-15-preview - response: - body: - string: '{"operationId": "07004d65-f9eb-4d91-beae-70fbcd57e0b8", "status": "completed"}' - headers: - content-length: '75' - content-type: application/json; charset=utf-8 - date: Sun, 19 Sep 2021 23:31:42 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 0d8c3f78-2376-4f35-8fd4-31eff3187ec3 - status: - code: 200 - message: OK - url: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-170c-4460-b86c-75b8a2c53bd5/:cancelAllMediaOperations?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-5dfd-47db-8758-8856ef2a2b7d/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 23:31:52 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 8c6da853-31b2-453b-ba58-c85e7accbd2a - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-5dfd-47db-8758-8856ef2a2b7d/:hangup?api-version=2021-09-15-preview -- request: - body: null - headers: - Accept: - - application/json - User-Agent: - - azsdk-python-communication-callingserver/1.0.0b1 Python/3.9.7 (Windows-10-10.0.19043-SP0) - method: POST - uri: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-170c-4460-b86c-75b8a2c53bd5/:hangup?api-version=2021-09-15-preview - response: - body: - string: '' - headers: - content-length: '0' - date: Sun, 19 Sep 2021 23:31:52 GMT - x-cache: CONFIG_NOCACHE - x-microsoft-skype-chain-id: 1a9d05fd-29ca-497a-b8c4-cc5d9e04d354 - status: - code: 202 - message: Accepted - url: https://sanitized.communication.azure.com/calling/callConnections/411f0b00-170c-4460-b86c-75b8a2c53bd5/:hangup?api-version=2021-09-15-preview -version: 1 diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 2899b0469132..2191df88d68a 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -10,6 +10,8 @@ ### Bugs Fixed +- respect text encoding specified in argument (thanks to @ryohji for the contribution) #20796 + ### Other Changes ## 1.19.0 (2021-09-30) diff --git a/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py b/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py index dc03b29639f1..d8365a9a7680 100644 --- a/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py +++ b/sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py @@ -353,7 +353,9 @@ def text(self, encoding: Optional[str] = None) -> str: ctype = self.headers.get(aiohttp.hdrs.CONTENT_TYPE, "").lower() mimetype = aiohttp.helpers.parse_mimetype(ctype) - encoding = mimetype.parameters.get("charset") + if not encoding: + # extract encoding from mimetype, if caller does not specify + encoding = mimetype.parameters.get("charset") if encoding: try: codecs.lookup(encoding) @@ -372,7 +374,7 @@ def text(self, encoding: Optional[str] = None) -> str: ) else: encoding = chardet.detect(body)["encoding"] - if not encoding: + if encoding == "utf-8" or encoding is None: encoding = "utf-8-sig" return body.decode(encoding) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/__init__.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/__init__.py deleted file mode 100644 index d4be1e681b60..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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 ._form_recognizer_client import FormRecognizerClient -__all__ = ['FormRecognizerClient'] - -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_configuration.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_configuration.py deleted file mode 100644 index a8e345f24d9c..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_configuration.py +++ /dev/null @@ -1,69 +0,0 @@ -# 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 typing import TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.credentials import TokenCredential - -VERSION = "unknown" - -class FormRecognizerClientConfiguration(Configuration): - """Configuration for FormRecognizerClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). - :type endpoint: str - """ - - def __init__( - self, - credential, # type: "TokenCredential" - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - super(FormRecognizerClientConfiguration, self).__init__(**kwargs) - - self.credential = credential - self.endpoint = endpoint - self.api_version = "2021-09-30-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://cognitiveservices.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'ai-formrecognizer/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs # type: Any - ): - # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_form_recognizer_client.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_form_recognizer_client.py deleted file mode 100644 index 16ffcd292de7..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_form_recognizer_client.py +++ /dev/null @@ -1,82 +0,0 @@ -# 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 typing import TYPE_CHECKING - -from azure.core import PipelineClient -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import FormRecognizerClientConfiguration -from .operations import FormRecognizerClientOperationsMixin -from . import models - - -class FormRecognizerClient(FormRecognizerClientOperationsMixin): - """Extracts content, layout, and structured data from documents. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). - :type endpoint: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential, # type: "TokenCredential" - endpoint, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - base_url = '{endpoint}/formrecognizer' - self._config = FormRecognizerClientConfiguration(credential, endpoint, **kwargs) - self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse - """ - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - def close(self): - # type: () -> None - self._client.close() - - def __enter__(self): - # type: () -> FormRecognizerClient - self._client.__enter__() - return self - - def __exit__(self, *exc_details): - # type: (Any) -> None - self._client.__exit__(*exc_details) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_metadata.json b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_metadata.json deleted file mode 100644 index 7d82a2e4115b..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/_metadata.json +++ /dev/null @@ -1,288 +0,0 @@ -{ - "chosen_version": "2021-09-30-preview", - "total_api_version_list": ["2021-09-30-preview"], - "client": { - "name": "FormRecognizerClient", - "filename": "_form_recognizer_client", - "description": "Extracts content, layout, and structured data from documents.", - "base_url": null, - "custom_base_url": "\u0027{endpoint}/formrecognizer\u0027", - "azure_arm": false, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"PipelineClient\"]}, \"local\": {\"._configuration\": [\"FormRecognizerClientConfiguration\"], \"._operations_mixin\": [\"FormRecognizerClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.core\": [\"AsyncPipelineClient\"]}, \"local\": {\"._configuration\": [\"FormRecognizerClientConfiguration\"], \"._operations_mixin\": [\"FormRecognizerClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "endpoint": { - "signature": "endpoint, # type: str", - "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "endpoint": { - "signature": "endpoint: str,", - "description": "Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com).", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, endpoint", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://cognitiveservices.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - }, - "operation_mixins": { - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"], \"azure.core.polling\": [\"LROPoller\", \"NoPolling\", \"PollingMethod\"], \"azure.core.polling.base_polling\": [\"LROBasePolling\"], \"...._polling\": [\"DocumentModelAdministrationLROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"IO\", \"Iterable\", \"List\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"], \"azure.core.polling\": [\"AsyncLROPoller\", \"AsyncNoPolling\", \"AsyncPollingMethod\"], \"azure.core.polling.async_base_polling\": [\"AsyncLROBasePolling\"], \".....aio._async_polling\": [\"AsyncDocumentModelAdministrationLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\", \"AsyncList\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\", \"Callable\", \"Dict\", \"Generic\", \"IO\", \"List\", \"Optional\", \"TypeVar\", \"Union\"]}}}", - "operations": { - "_analyze_document_initial" : { - "sync": { - "signature": "def _analyze_document_initial(\n self,\n model_id, # type: str\n pages=None, # type: Optional[List[str]]\n locale=None, # type: Optional[str]\n string_index_type=None, # type: Optional[Union[str, \"_models.StringIndexType\"]]\n analyze_request=None, # type: Optional[Union[IO, \"_models.AnalyzeDocumentRequest\"]]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param model_id: Unique model name.\n:type model_id: str\n:param pages: List of 1-based page numbers to analyze. Ex. \"1-3,5,7-9\".\n:type pages: list[str]\n:param locale: Locale hint for text recognition and document analysis. Value may contain only\n the language code (ex. \"en\", \"fr\") or BCP 47 language tag (ex. \"en-US\").\n:type locale: str\n:param string_index_type: Method used to compute string offset and length.\n:type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType\n:param analyze_request: Analyze request parameters.\n:type analyze_request: IO or ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeDocumentRequest\n:keyword str content_type: Media type of the body sent to the API. Default value is \"application/json\".\n Allowed values are: \"application/octet-stream\", \"application/pdf\", \"image/bmp\", \"image/jpeg\", \"image/png\", \"image/tiff\", \"application/json\".\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def _analyze_document_initial(\n self,\n model_id: str,\n pages: Optional[List[str]] = None,\n locale: Optional[str] = None,\n string_index_type: Optional[Union[str, \"_models.StringIndexType\"]] = None,\n analyze_request: Optional[Union[IO, \"_models.AnalyzeDocumentRequest\"]] = None,\n **kwargs: Any\n) -\u003e None:\n", - "doc": "\"\"\"\n\n:param model_id: Unique model name.\n:type model_id: str\n:param pages: List of 1-based page numbers to analyze. Ex. \"1-3,5,7-9\".\n:type pages: list[str]\n:param locale: Locale hint for text recognition and document analysis. Value may contain only\n the language code (ex. \"en\", \"fr\") or BCP 47 language tag (ex. \"en-US\").\n:type locale: str\n:param string_index_type: Method used to compute string offset and length.\n:type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType\n:param analyze_request: Analyze request parameters.\n:type analyze_request: IO or ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeDocumentRequest\n:keyword str content_type: Media type of the body sent to the API. Default value is \"application/json\".\n Allowed values are: \"application/octet-stream\", \"application/pdf\", \"image/bmp\", \"image/jpeg\", \"image/png\", \"image/tiff\", \"application/json\".\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "model_id, pages, locale, string_index_type, analyze_request" - }, - "begin_analyze_document" : { - "sync": { - "signature": "def begin_analyze_document(\n self,\n model_id, # type: str\n pages=None, # type: Optional[List[str]]\n locale=None, # type: Optional[str]\n string_index_type=None, # type: Optional[Union[str, \"_models.StringIndexType\"]]\n analyze_request=None, # type: Optional[Union[IO, \"_models.AnalyzeDocumentRequest\"]]\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Analyze document.\n\nAnalyzes document with model.\n\n:param model_id: Unique model name.\n:type model_id: str\n:param pages: List of 1-based page numbers to analyze. Ex. \"1-3,5,7-9\".\n:type pages: list[str]\n:param locale: Locale hint for text recognition and document analysis. Value may contain only\n the language code (ex. \"en\", \"fr\") or BCP 47 language tag (ex. \"en-US\").\n:type locale: str\n:param string_index_type: Method used to compute string offset and length.\n:type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType\n:param analyze_request: Analyze request parameters.\n:type analyze_request: IO or ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeDocumentRequest\n:keyword str content_type: Media type of the body sent to the API. Default value is \"application/json\".\n Allowed values are: \"application/octet-stream\", \"application/pdf\", \"image/bmp\", \"image/jpeg\", \"image/png\", \"image/tiff\", \"application/json\".\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of LROPoller that returns either None or the result of cls(response)\n:rtype: ~azure.core.polling.LROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def begin_analyze_document(\n self,\n model_id: str,\n pages: Optional[List[str]] = None,\n locale: Optional[str] = None,\n string_index_type: Optional[Union[str, \"_models.StringIndexType\"]] = None,\n analyze_request: Optional[Union[IO, \"_models.AnalyzeDocumentRequest\"]] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[None]:\n", - "doc": "\"\"\"Analyze document.\n\nAnalyzes document with model.\n\n:param model_id: Unique model name.\n:type model_id: str\n:param pages: List of 1-based page numbers to analyze. Ex. \"1-3,5,7-9\".\n:type pages: list[str]\n:param locale: Locale hint for text recognition and document analysis. Value may contain only\n the language code (ex. \"en\", \"fr\") or BCP 47 language tag (ex. \"en-US\").\n:type locale: str\n:param string_index_type: Method used to compute string offset and length.\n:type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType\n:param analyze_request: Analyze request parameters.\n:type analyze_request: IO or ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeDocumentRequest\n:keyword str content_type: Media type of the body sent to the API. Default value is \"application/json\".\n Allowed values are: \"application/octet-stream\", \"application/pdf\", \"image/bmp\", \"image/jpeg\", \"image/png\", \"image/tiff\", \"application/json\".\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns either None or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "call": "model_id, pages, locale, string_index_type, analyze_request" - }, - "get_analyze_document_result" : { - "sync": { - "signature": "def get_analyze_document_result(\n self,\n model_id, # type: str\n result_id, # type: str\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Get analyze result.\n\nGets the result of document analysis.\n\n:param model_id: Unique model name.\n:type model_id: str\n:param result_id: Analyze operation result ID.\n:type result_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: AnalyzeResultOperation, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResultOperation\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def get_analyze_document_result(\n self,\n model_id: str,\n result_id: str,\n **kwargs: Any\n) -\u003e \"_models.AnalyzeResultOperation\":\n", - "doc": "\"\"\"Get analyze result.\n\nGets the result of document analysis.\n\n:param model_id: Unique model name.\n:type model_id: str\n:param result_id: Analyze operation result ID.\n:type result_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: AnalyzeResultOperation, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResultOperation\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "model_id, result_id" - }, - "_build_document_model_initial" : { - "sync": { - "signature": "def _build_document_model_initial(\n self,\n build_request, # type: \"_models.BuildDocumentModelRequest\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param build_request: Building request parameters.\n:type build_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.BuildDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def _build_document_model_initial(\n self,\n build_request: \"_models.BuildDocumentModelRequest\",\n **kwargs: Any\n) -\u003e None:\n", - "doc": "\"\"\"\n\n:param build_request: Building request parameters.\n:type build_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.BuildDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "build_request" - }, - "begin_build_document_model" : { - "sync": { - "signature": "def begin_build_document_model(\n self,\n build_request, # type: \"_models.BuildDocumentModelRequest\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Build model.\n\nBuilds a custom document analysis model.\n\n:param build_request: Building request parameters.\n:type build_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.BuildDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of DocumentModelAdministrationLROPoller that returns either None or the result of cls(response)\n:rtype: ~...._polling.DocumentModelAdministrationLROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def begin_build_document_model(\n self,\n build_request: \"_models.BuildDocumentModelRequest\",\n **kwargs: Any\n) -\u003e AsyncDocumentModelAdministrationLROPoller[None]:\n", - "doc": "\"\"\"Build model.\n\nBuilds a custom document analysis model.\n\n:param build_request: Building request parameters.\n:type build_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.BuildDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncDocumentModelAdministrationLROPoller that returns either None or the result of cls(response)\n:rtype: ~.....aio._async_polling.AsyncDocumentModelAdministrationLROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "call": "build_request" - }, - "_compose_document_model_initial" : { - "sync": { - "signature": "def _compose_document_model_initial(\n self,\n compose_request, # type: \"_models.ComposeDocumentModelRequest\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param compose_request:\n:type compose_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.ComposeDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def _compose_document_model_initial(\n self,\n compose_request: \"_models.ComposeDocumentModelRequest\",\n **kwargs: Any\n) -\u003e None:\n", - "doc": "\"\"\"\n\n:param compose_request:\n:type compose_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.ComposeDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "compose_request" - }, - "begin_compose_document_model" : { - "sync": { - "signature": "def begin_compose_document_model(\n self,\n compose_request, # type: \"_models.ComposeDocumentModelRequest\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Compose model.\n\nCreates a new model from document types of existing models.\n\n:param compose_request:\n:type compose_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.ComposeDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of DocumentModelAdministrationLROPoller that returns either None or the result of cls(response)\n:rtype: ~...._polling.DocumentModelAdministrationLROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def begin_compose_document_model(\n self,\n compose_request: \"_models.ComposeDocumentModelRequest\",\n **kwargs: Any\n) -\u003e AsyncDocumentModelAdministrationLROPoller[None]:\n", - "doc": "\"\"\"Compose model.\n\nCreates a new model from document types of existing models.\n\n:param compose_request:\n:type compose_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.ComposeDocumentModelRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncDocumentModelAdministrationLROPoller that returns either None or the result of cls(response)\n:rtype: ~.....aio._async_polling.AsyncDocumentModelAdministrationLROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "call": "compose_request" - }, - "authorize_copy_document_model" : { - "sync": { - "signature": "def authorize_copy_document_model(\n self,\n authorize_copy_request, # type: \"_models.AuthorizeCopyRequest\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Generate copy authorization.\n\nGenerates authorization to copy a model to this location with specified modelId and optional\ndescription.\n\n:param authorize_copy_request:\n:type authorize_copy_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.AuthorizeCopyRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CopyAuthorization, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def authorize_copy_document_model(\n self,\n authorize_copy_request: \"_models.AuthorizeCopyRequest\",\n **kwargs: Any\n) -\u003e \"_models.CopyAuthorization\":\n", - "doc": "\"\"\"Generate copy authorization.\n\nGenerates authorization to copy a model to this location with specified modelId and optional\ndescription.\n\n:param authorize_copy_request:\n:type authorize_copy_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.AuthorizeCopyRequest\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: CopyAuthorization, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "authorize_copy_request" - }, - "_copy_document_model_to_initial" : { - "sync": { - "signature": "def _copy_document_model_to_initial(\n self,\n model_id, # type: str\n copy_to_request, # type: \"_models.CopyAuthorization\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"\n\n:param model_id: Unique model name.\n:type model_id: str\n:param copy_to_request:\n:type copy_to_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def _copy_document_model_to_initial(\n self,\n model_id: str,\n copy_to_request: \"_models.CopyAuthorization\",\n **kwargs: Any\n) -\u003e None:\n", - "doc": "\"\"\"\n\n:param model_id: Unique model name.\n:type model_id: str\n:param copy_to_request:\n:type copy_to_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "model_id, copy_to_request" - }, - "begin_copy_document_model_to" : { - "sync": { - "signature": "def begin_copy_document_model_to(\n self,\n model_id, # type: str\n copy_to_request, # type: \"_models.CopyAuthorization\"\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Copy model.\n\nCopies model to the target resource, region, and modelId.\n\n:param model_id: Unique model name.\n:type model_id: str\n:param copy_to_request:\n:type copy_to_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be LROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.PollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of DocumentModelAdministrationLROPoller that returns either None or the result of cls(response)\n:rtype: ~...._polling.DocumentModelAdministrationLROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def begin_copy_document_model_to(\n self,\n model_id: str,\n copy_to_request: \"_models.CopyAuthorization\",\n **kwargs: Any\n) -\u003e AsyncDocumentModelAdministrationLROPoller[None]:\n", - "doc": "\"\"\"Copy model.\n\nCopies model to the target resource, region, and modelId.\n\n:param model_id: Unique model name.\n:type model_id: str\n:param copy_to_request:\n:type copy_to_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: By default, your polling method will be AsyncLROBasePolling.\n Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncFormTrainingLROPoller that returns either None or the result of cls(response)\n:rtype: ~.....aio._async_polling.AsyncFormTrainingLROPoller[None]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" - }, - "call": "model_id, copy_to_request" - }, - "get_operations" : { - "sync": { - "signature": "def get_operations(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"List operations.\n\nLists all operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either GetOperationsResponse or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationsResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": false, - "signature": "def get_operations(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.GetOperationsResponse\"]:\n", - "doc": "\"\"\"List operations.\n\nLists all operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either GetOperationsResponse or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationsResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" - }, - "get_operation" : { - "sync": { - "signature": "def get_operation(\n self,\n operation_id, # type: str\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Get operation.\n\nGets operation info.\n\n:param operation_id: Unique operation ID.\n:type operation_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetOperationResponse, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def get_operation(\n self,\n operation_id: str,\n **kwargs: Any\n) -\u003e \"_models.GetOperationResponse\":\n", - "doc": "\"\"\"Get operation.\n\nGets operation info.\n\n:param operation_id: Unique operation ID.\n:type operation_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetOperationResponse, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "operation_id" - }, - "get_models" : { - "sync": { - "signature": "def get_models(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"List models.\n\nList all models.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either GetModelsResponse or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetModelsResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": false, - "signature": "def get_models(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.GetModelsResponse\"]:\n", - "doc": "\"\"\"List models.\n\nList all models.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either GetModelsResponse or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetModelsResponse]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" - }, - "get_model" : { - "sync": { - "signature": "def get_model(\n self,\n model_id, # type: str\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Get model.\n\nGets detailed model information.\n\n:param model_id: Unique model name.\n:type model_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelInfo, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.ModelInfo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def get_model(\n self,\n model_id: str,\n **kwargs: Any\n) -\u003e \"_models.ModelInfo\":\n", - "doc": "\"\"\"Get model.\n\nGets detailed model information.\n\n:param model_id: Unique model name.\n:type model_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelInfo, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.ModelInfo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "model_id" - }, - "delete_model" : { - "sync": { - "signature": "def delete_model(\n self,\n model_id, # type: str\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Delete model.\n\nDeletes model.\n\n:param model_id: Unique model name.\n:type model_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def delete_model(\n self,\n model_id: str,\n **kwargs: Any\n) -\u003e None:\n", - "doc": "\"\"\"Delete model.\n\nDeletes model.\n\n:param model_id: Unique model name.\n:type model_id: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "model_id" - }, - "get_info" : { - "sync": { - "signature": "def get_info(\n self,\n **kwargs # type: Any\n):\n", - "doc": "\"\"\"Get info.\n\nReturn basic info about the current resource.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetInfoResponse, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetInfoResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def get_info(\n self,\n **kwargs: Any\n) -\u003e \"_models.GetInfoResponse\":\n", - "doc": "\"\"\"Get info.\n\nReturn basic info about the current resource.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: GetInfoResponse, or the result of cls(response)\n:rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetInfoResponse\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "" - } - } - } -} \ No newline at end of file diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/__init__.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/__init__.py deleted file mode 100644 index 69eccfa9e16e..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# 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 ._form_recognizer_client import FormRecognizerClient -__all__ = ['FormRecognizerClient'] diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/_configuration.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/_configuration.py deleted file mode 100644 index c1e30d6d780c..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/_configuration.py +++ /dev/null @@ -1,65 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.configuration import Configuration -from azure.core.pipeline import policies - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -VERSION = "unknown" - -class FormRecognizerClientConfiguration(Configuration): - """Configuration for FormRecognizerClient. - - Note that all parameters used to create this instance are saved as instance - attributes. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). - :type endpoint: str - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - endpoint: str, - **kwargs: Any - ) -> None: - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") - if endpoint is None: - raise ValueError("Parameter 'endpoint' must not be None.") - super(FormRecognizerClientConfiguration, self).__init__(**kwargs) - - self.credential = credential - self.endpoint = endpoint - self.api_version = "2021-09-30-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://cognitiveservices.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'ai-formrecognizer/{}'.format(VERSION)) - self._configure(**kwargs) - - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/_form_recognizer_client.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/_form_recognizer_client.py deleted file mode 100644 index e9cf76953fca..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/_form_recognizer_client.py +++ /dev/null @@ -1,75 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core import AsyncPipelineClient -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from msrest import Deserializer, Serializer - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - -from ._configuration import FormRecognizerClientConfiguration -from .operations import FormRecognizerClientOperationsMixin -from .. import models - - -class FormRecognizerClient(FormRecognizerClientOperationsMixin): - """Extracts content, layout, and structured data from documents. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example: https://westus2.api.cognitive.microsoft.com). - :type endpoint: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - """ - - def __init__( - self, - credential: "AsyncTokenCredential", - endpoint: str, - **kwargs: Any - ) -> None: - base_url = '{endpoint}/formrecognizer' - self._config = FormRecognizerClientConfiguration(credential, endpoint, **kwargs) - self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) - - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False - self._deserialize = Deserializer(client_models) - - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: - """Runs the network request through the client's chained policies. - - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. - :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse - """ - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> "FormRecognizerClient": - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/operations/__init__.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/operations/__init__.py deleted file mode 100644 index f2f858714054..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/operations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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 ._form_recognizer_client_operations import FormRecognizerClientOperationsMixin - -__all__ = [ - 'FormRecognizerClientOperationsMixin', -] diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/operations/_form_recognizer_client_operations.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/operations/_form_recognizer_client_operations.py deleted file mode 100644 index 3532d4004c2b..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/aio/operations/_form_recognizer_client_operations.py +++ /dev/null @@ -1,1003 +0,0 @@ -# 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 typing import Any, AsyncIterable, Callable, Dict, Generic, IO, List, Optional, TypeVar, Union -import warnings - -from .....aio._async_polling import AsyncDocumentModelAdministrationLROPoller -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.polling.async_base_polling import AsyncLROBasePolling - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class FormRecognizerClientOperationsMixin: - - async def _analyze_document_initial( - self, - model_id: str, - pages: Optional[List[str]] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, "_models.StringIndexType"]] = None, - analyze_request: Optional[Union[IO, "_models.AnalyzeDocumentRequest"]] = None, - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._analyze_document_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if pages is not None: - query_parameters['pages'] = self._serialize.query("pages", pages, '[str]', div=',') - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if string_index_type is not None: - query_parameters['stringIndexType'] = self._serialize.query("string_index_type", string_index_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/octet-stream', 'application/pdf', 'image/bmp', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = analyze_request - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: - if analyze_request is not None: - body_content = self._serialize.body(analyze_request, 'AnalyzeDocumentRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - else: - raise ValueError( - "The content_type '{}' is not one of the allowed values: " - "['application/octet-stream', 'application/pdf', 'image/bmp', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) - ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _analyze_document_initial.metadata = {'url': '/documentModels/{modelId}:analyze'} # type: ignore - - async def begin_analyze_document( - self, - model_id: str, - pages: Optional[List[str]] = None, - locale: Optional[str] = None, - string_index_type: Optional[Union[str, "_models.StringIndexType"]] = None, - analyze_request: Optional[Union[IO, "_models.AnalyzeDocumentRequest"]] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Analyze document. - - Analyzes document with model. - - :param model_id: Unique model name. - :type model_id: str - :param pages: List of 1-based page numbers to analyze. Ex. "1-3,5,7-9". - :type pages: list[str] - :param locale: Locale hint for text recognition and document analysis. Value may contain only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). - :type locale: str - :param string_index_type: Method used to compute string offset and length. - :type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType - :param analyze_request: Analyze request parameters. - :type analyze_request: IO or ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeDocumentRequest - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/octet-stream", "application/pdf", "image/bmp", "image/jpeg", "image/png", "image/tiff", "application/json". - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._analyze_document_initial( - model_id=model_id, - pages=pages, - locale=locale, - string_index_type=string_index_type, - analyze_request=analyze_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - - if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_analyze_document.metadata = {'url': '/documentModels/{modelId}:analyze'} # type: ignore - - async def get_analyze_document_result( - self, - model_id: str, - result_id: str, - **kwargs: Any - ) -> "_models.AnalyzeResultOperation": - """Get analyze result. - - Gets the result of document analysis. - - :param model_id: Unique model name. - :type model_id: str - :param result_id: Analyze operation result ID. - :type result_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AnalyzeResultOperation, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResultOperation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AnalyzeResultOperation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_analyze_document_result.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - 'resultId': self._serialize.url("result_id", result_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('AnalyzeResultOperation', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_analyze_document_result.metadata = {'url': '/documentModels/{modelId}/analyzeResults/{resultId}'} # type: ignore - - async def _build_document_model_initial( - self, - build_request: "_models.BuildDocumentModelRequest", - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._build_document_model_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(build_request, 'BuildDocumentModelRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _build_document_model_initial.metadata = {'url': '/documentModels:build'} # type: ignore - - async def begin_build_document_model( - self, - build_request: "_models.BuildDocumentModelRequest", - **kwargs: Any - ) -> AsyncDocumentModelAdministrationLROPoller[None]: - """Build model. - - Builds a custom document analysis model. - - :param build_request: Building request parameters. - :type build_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.BuildDocumentModelRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncDocumentModelAdministrationLROPoller that returns either None or the result of cls(response) - :rtype: ~.....aio._async_polling.AsyncDocumentModelAdministrationLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._build_document_model_initial( - build_request=build_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncDocumentModelAdministrationLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncDocumentModelAdministrationLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_build_document_model.metadata = {'url': '/documentModels:build'} # type: ignore - - async def _compose_document_model_initial( - self, - compose_request: "_models.ComposeDocumentModelRequest", - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._compose_document_model_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(compose_request, 'ComposeDocumentModelRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _compose_document_model_initial.metadata = {'url': '/documentModels:compose'} # type: ignore - - async def begin_compose_document_model( - self, - compose_request: "_models.ComposeDocumentModelRequest", - **kwargs: Any - ) -> AsyncDocumentModelAdministrationLROPoller[None]: - """Compose model. - - Creates a new model from document types of existing models. - - :param compose_request: - :type compose_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.ComposeDocumentModelRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncDocumentModelAdministrationLROPoller that returns either None or the result of cls(response) - :rtype: ~.....aio._async_polling.AsyncDocumentModelAdministrationLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._compose_document_model_initial( - compose_request=compose_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncDocumentModelAdministrationLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncDocumentModelAdministrationLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_compose_document_model.metadata = {'url': '/documentModels:compose'} # type: ignore - - async def authorize_copy_document_model( - self, - authorize_copy_request: "_models.AuthorizeCopyRequest", - **kwargs: Any - ) -> "_models.CopyAuthorization": - """Generate copy authorization. - - Generates authorization to copy a model to this location with specified modelId and optional - description. - - :param authorize_copy_request: - :type authorize_copy_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.AuthorizeCopyRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CopyAuthorization, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CopyAuthorization"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.authorize_copy_document_model.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(authorize_copy_request, 'AuthorizeCopyRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('CopyAuthorization', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - authorize_copy_document_model.metadata = {'url': '/documentModels:authorizeCopy'} # type: ignore - - async def _copy_document_model_to_initial( - self, - model_id: str, - copy_to_request: "_models.CopyAuthorization", - **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._copy_document_model_to_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(copy_to_request, 'CopyAuthorization') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _copy_document_model_to_initial.metadata = {'url': '/documentModels/{modelId}:copyTo'} # type: ignore - - async def begin_copy_document_model_to( - self, - model_id: str, - copy_to_request: "_models.CopyAuthorization", - **kwargs: Any - ) -> AsyncDocumentModelAdministrationLROPoller[None]: - """Copy model. - - Copies model to the target resource, region, and modelId. - - :param model_id: Unique model name. - :type model_id: str - :param copy_to_request: - :type copy_to_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncLROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncDocumentModelAdministrationLROPoller that returns either None or the result of cls(response) - :rtype: ~.....aio._async_polling.AsyncDocumentModelAdministrationLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = await self._copy_document_model_to_initial( - model_id=model_id, - copy_to_request=copy_to_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - - if polling is True: polling_method = AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling - if cont_token: - return AsyncDocumentModelAdministrationLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return AsyncDocumentModelAdministrationLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_copy_document_model_to.metadata = {'url': '/documentModels/{modelId}:copyTo'} # type: ignore - - def get_operations( - self, - **kwargs: Any - ) -> AsyncIterable["_models.GetOperationsResponse"]: - """List operations. - - Lists all operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GetOperationsResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationsResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetOperationsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_operations.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('GetOperationsResponse', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_operations.metadata = {'url': '/operations'} # type: ignore - - async def get_operation( - self, - operation_id: str, - **kwargs: Any - ) -> "_models.GetOperationResponse": - """Get operation. - - Gets operation info. - - :param operation_id: Unique operation ID. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetOperationResponse, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetOperationResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('GetOperationResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_operation.metadata = {'url': '/operations/{operationId}'} # type: ignore - - def get_models( - self, - **kwargs: Any - ) -> AsyncIterable["_models.GetModelsResponse"]: - """List models. - - List all models. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GetModelsResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetModelsResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetModelsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_models.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('GetModelsResponse', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - get_models.metadata = {'url': '/documentModels'} # type: ignore - - async def get_model( - self, - model_id: str, - **kwargs: Any - ) -> "_models.ModelInfo": - """Get model. - - Gets detailed model information. - - :param model_id: Unique model name. - :type model_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ModelInfo, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.ModelInfo - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_model.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('ModelInfo', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_model.metadata = {'url': '/documentModels/{modelId}'} # type: ignore - - async def delete_model( - self, - model_id: str, - **kwargs: Any - ) -> None: - """Delete model. - - Deletes model. - - :param model_id: Unique model name. - :type model_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.delete_model.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete_model.metadata = {'url': '/documentModels/{modelId}'} # type: ignore - - async def get_info( - self, - **kwargs: Any - ) -> "_models.GetInfoResponse": - """Get info. - - Return basic info about the current resource. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetInfoResponse, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetInfoResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetInfoResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_info.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('GetInfoResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_info.metadata = {'url': '/info'} # type: ignore diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/__init__.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/__init__.py deleted file mode 100644 index 8af2971f5221..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/__init__.py +++ /dev/null @@ -1,146 +0,0 @@ -# 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 AnalyzeDocumentRequest - from ._models_py3 import AnalyzeResult - from ._models_py3 import AnalyzeResultOperation - from ._models_py3 import AuthorizeCopyRequest - from ._models_py3 import AzureBlobContentSource - from ._models_py3 import BoundingRegion - from ._models_py3 import BuildDocumentModelRequest - from ._models_py3 import ComponentModelInfo - from ._models_py3 import ComposeDocumentModelRequest - from ._models_py3 import CopyAuthorization - from ._models_py3 import CustomDocumentModelsInfo - from ._models_py3 import DocTypeInfo - from ._models_py3 import Document - from ._models_py3 import DocumentEntity - from ._models_py3 import DocumentField - from ._models_py3 import DocumentFieldSchema - from ._models_py3 import DocumentKeyValueElement - from ._models_py3 import DocumentKeyValuePair - from ._models_py3 import DocumentLine - from ._models_py3 import DocumentPage - from ._models_py3 import DocumentSelectionMark - from ._models_py3 import DocumentSpan - from ._models_py3 import DocumentStyle - from ._models_py3 import DocumentTable - from ._models_py3 import DocumentTableCell - from ._models_py3 import DocumentWord - from ._models_py3 import Error - from ._models_py3 import ErrorResponse - from ._models_py3 import GetInfoResponse - from ._models_py3 import GetModelsResponse - from ._models_py3 import GetOperationResponse - from ._models_py3 import GetOperationsResponse - from ._models_py3 import InnerError - from ._models_py3 import ModelInfo - from ._models_py3 import ModelSummary - from ._models_py3 import OperationInfo -except (SyntaxError, ImportError): - from ._models import AnalyzeDocumentRequest # type: ignore - from ._models import AnalyzeResult # type: ignore - from ._models import AnalyzeResultOperation # type: ignore - from ._models import AuthorizeCopyRequest # type: ignore - from ._models import AzureBlobContentSource # type: ignore - from ._models import BoundingRegion # type: ignore - from ._models import BuildDocumentModelRequest # type: ignore - from ._models import ComponentModelInfo # type: ignore - from ._models import ComposeDocumentModelRequest # type: ignore - from ._models import CopyAuthorization # type: ignore - from ._models import CustomDocumentModelsInfo # type: ignore - from ._models import DocTypeInfo # type: ignore - from ._models import Document # type: ignore - from ._models import DocumentEntity # type: ignore - from ._models import DocumentField # type: ignore - from ._models import DocumentFieldSchema # type: ignore - from ._models import DocumentKeyValueElement # type: ignore - from ._models import DocumentKeyValuePair # type: ignore - from ._models import DocumentLine # type: ignore - from ._models import DocumentPage # type: ignore - from ._models import DocumentSelectionMark # type: ignore - from ._models import DocumentSpan # type: ignore - from ._models import DocumentStyle # type: ignore - from ._models import DocumentTable # type: ignore - from ._models import DocumentTableCell # type: ignore - from ._models import DocumentWord # type: ignore - from ._models import Error # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import GetInfoResponse # type: ignore - from ._models import GetModelsResponse # type: ignore - from ._models import GetOperationResponse # type: ignore - from ._models import GetOperationsResponse # type: ignore - from ._models import InnerError # type: ignore - from ._models import ModelInfo # type: ignore - from ._models import ModelSummary # type: ignore - from ._models import OperationInfo # type: ignore - -from ._form_recognizer_client_enums import ( - AnalyzeResultOperationStatus, - ApiVersion, - ContentType, - DocumentFieldType, - DocumentSignatureType, - DocumentTableCellKind, - LengthUnit, - OperationKind, - OperationStatus, - SelectionMarkState, - StringIndexType, -) - -__all__ = [ - 'AnalyzeDocumentRequest', - 'AnalyzeResult', - 'AnalyzeResultOperation', - 'AuthorizeCopyRequest', - 'AzureBlobContentSource', - 'BoundingRegion', - 'BuildDocumentModelRequest', - 'ComponentModelInfo', - 'ComposeDocumentModelRequest', - 'CopyAuthorization', - 'CustomDocumentModelsInfo', - 'DocTypeInfo', - 'Document', - 'DocumentEntity', - 'DocumentField', - 'DocumentFieldSchema', - 'DocumentKeyValueElement', - 'DocumentKeyValuePair', - 'DocumentLine', - 'DocumentPage', - 'DocumentSelectionMark', - 'DocumentSpan', - 'DocumentStyle', - 'DocumentTable', - 'DocumentTableCell', - 'DocumentWord', - 'Error', - 'ErrorResponse', - 'GetInfoResponse', - 'GetModelsResponse', - 'GetOperationResponse', - 'GetOperationsResponse', - 'InnerError', - 'ModelInfo', - 'ModelSummary', - 'OperationInfo', - 'AnalyzeResultOperationStatus', - 'ApiVersion', - 'ContentType', - 'DocumentFieldType', - 'DocumentSignatureType', - 'DocumentTableCellKind', - 'LengthUnit', - 'OperationKind', - 'OperationStatus', - 'SelectionMarkState', - 'StringIndexType', -] diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_form_recognizer_client_enums.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_form_recognizer_client_enums.py deleted file mode 100644 index 31998f7e8bda..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_form_recognizer_client_enums.py +++ /dev/null @@ -1,134 +0,0 @@ -# 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 enum import Enum, EnumMeta -from six import with_metaclass - -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AnalyzeResultOperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Operation status. - """ - - NOT_STARTED = "notStarted" - RUNNING = "running" - FAILED = "failed" - SUCCEEDED = "succeeded" - -class ApiVersion(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """API version. - """ - - TWO_THOUSAND_TWENTY_ONE09_30_PREVIEW = "2021-09-30-preview" - -class ContentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Content type for upload - """ - - #: Content Type 'application/octet-stream'. - APPLICATION_OCTET_STREAM = "application/octet-stream" - #: Content Type 'application/pdf'. - APPLICATION_PDF = "application/pdf" - #: Content Type 'image/bmp'. - IMAGE_BMP = "image/bmp" - #: Content Type 'image/jpeg'. - IMAGE_JPEG = "image/jpeg" - #: Content Type 'image/png'. - IMAGE_PNG = "image/png" - #: Content Type 'image/tiff'. - IMAGE_TIFF = "image/tiff" - -class DocumentFieldType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Semantic data type of the field value. - """ - - STRING = "string" - DATE = "date" - TIME = "time" - PHONE_NUMBER = "phoneNumber" - NUMBER = "number" - INTEGER = "integer" - SELECTION_MARK = "selectionMark" - COUNTRY_REGION = "countryRegion" - CURRENCY = "currency" - SIGNATURE = "signature" - ARRAY = "array" - OBJECT = "object" - -class DocumentSignatureType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Presence of signature. - """ - - SIGNED = "signed" - UNSIGNED = "unsigned" - -class DocumentTableCellKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Table cell kind. - """ - - CONTENT = "content" - ROW_HEADER = "rowHeader" - COLUMN_HEADER = "columnHeader" - STUB_HEAD = "stubHead" - DESCRIPTION = "description" - -class LengthUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The unit used by the width, height, and boundingBox properties. For images, the unit is - "pixel". For PDF, the unit is "inch". - """ - - PIXEL = "pixel" - INCH = "inch" - -class OperationKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Type of operation. - """ - - DOCUMENT_MODEL_BUILD = "documentModelBuild" - DOCUMENT_MODEL_COMPOSE = "documentModelCompose" - DOCUMENT_MODEL_COPY_TO = "documentModelCopyTo" - -class OperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Operation status. - """ - - NOT_STARTED = "notStarted" - RUNNING = "running" - FAILED = "failed" - SUCCEEDED = "succeeded" - CANCELED = "canceled" - -class SelectionMarkState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """State of the selection mark. - """ - - SELECTED = "selected" - UNSELECTED = "unselected" - -class StringIndexType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Method used to compute string offset and length. - """ - - TEXT_ELEMENTS = "textElements" - UNICODE_CODE_POINT = "unicodeCodePoint" - UTF16_CODE_UNIT = "utf16CodeUnit" diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_models.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_models.py deleted file mode 100644 index 407e4d3a232b..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_models.py +++ /dev/null @@ -1,1464 +0,0 @@ -# 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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AnalyzeDocumentRequest(msrest.serialization.Model): - """Document analysis parameters. - - :param url_source: Document URL to analyze. - :type url_source: str - :param base64_source: Base64 encoding of the document to analyze. - :type base64_source: bytearray - """ - - _attribute_map = { - 'url_source': {'key': 'urlSource', 'type': 'str'}, - 'base64_source': {'key': 'base64Source', 'type': 'bytearray'}, - } - - def __init__( - self, - **kwargs - ): - super(AnalyzeDocumentRequest, self).__init__(**kwargs) - self.url_source = kwargs.get('url_source', None) - self.base64_source = kwargs.get('base64_source', None) - - -class AnalyzeResult(msrest.serialization.Model): - """Document analysis result. - - All required parameters must be populated in order to send to Azure. - - :param api_version: Required. API version used to produce this result. Possible values include: - "2021-09-30-preview". - :type api_version: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.ApiVersion - :param model_id: Required. Model ID used to produce this result. - :type model_id: str - :param string_index_type: Required. Method used to compute string offset and length. Possible - values include: "textElements", "unicodeCodePoint", "utf16CodeUnit". - :type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType - :param content: Required. Concatenate string representation of all textual and visual elements - in reading order. - :type content: str - :param pages: Required. Analyzed pages. - :type pages: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentPage] - :param tables: Extracted tables. - :type tables: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentTable] - :param key_value_pairs: Extracted key-value pairs. - :type key_value_pairs: - list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentKeyValuePair] - :param entities: Extracted entities. - :type entities: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentEntity] - :param styles: Extracted font styles. - :type styles: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentStyle] - :param documents: Extracted documents. - :type documents: list[~azure.ai.formrecognizer.v3_0_preview_1.models.Document] - """ - - _validation = { - 'api_version': {'required': True}, - 'model_id': {'required': True}, - 'string_index_type': {'required': True}, - 'content': {'required': True}, - 'pages': {'required': True}, - } - - _attribute_map = { - 'api_version': {'key': 'apiVersion', 'type': 'str'}, - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'string_index_type': {'key': 'stringIndexType', 'type': 'str'}, - 'content': {'key': 'content', 'type': 'str'}, - 'pages': {'key': 'pages', 'type': '[DocumentPage]'}, - 'tables': {'key': 'tables', 'type': '[DocumentTable]'}, - 'key_value_pairs': {'key': 'keyValuePairs', 'type': '[DocumentKeyValuePair]'}, - 'entities': {'key': 'entities', 'type': '[DocumentEntity]'}, - 'styles': {'key': 'styles', 'type': '[DocumentStyle]'}, - 'documents': {'key': 'documents', 'type': '[Document]'}, - } - - def __init__( - self, - **kwargs - ): - super(AnalyzeResult, self).__init__(**kwargs) - self.api_version = kwargs['api_version'] - self.model_id = kwargs['model_id'] - self.string_index_type = kwargs['string_index_type'] - self.content = kwargs['content'] - self.pages = kwargs['pages'] - self.tables = kwargs.get('tables', None) - self.key_value_pairs = kwargs.get('key_value_pairs', None) - self.entities = kwargs.get('entities', None) - self.styles = kwargs.get('styles', None) - self.documents = kwargs.get('documents', None) - - -class AnalyzeResultOperation(msrest.serialization.Model): - """Status and result of the analyze operation. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Operation status. Possible values include: "notStarted", "running", - "failed", "succeeded". - :type status: str or - ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResultOperationStatus - :param created_date_time: Required. Date and time (UTC) when the analyze operation was - submitted. - :type created_date_time: ~datetime.datetime - :param last_updated_date_time: Required. Date and time (UTC) when the status was last updated. - :type last_updated_date_time: ~datetime.datetime - :param error: Encountered error during document analysis. - :type error: ~azure.ai.formrecognizer.v3_0_preview_1.models.Error - :param analyze_result: Document analysis result. - :type analyze_result: ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResult - """ - - _validation = { - 'status': {'required': True}, - 'created_date_time': {'required': True}, - 'last_updated_date_time': {'required': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'analyze_result': {'key': 'analyzeResult', 'type': 'AnalyzeResult'}, - } - - def __init__( - self, - **kwargs - ): - super(AnalyzeResultOperation, self).__init__(**kwargs) - self.status = kwargs['status'] - self.created_date_time = kwargs['created_date_time'] - self.last_updated_date_time = kwargs['last_updated_date_time'] - self.error = kwargs.get('error', None) - self.analyze_result = kwargs.get('analyze_result', None) - - -class AuthorizeCopyRequest(msrest.serialization.Model): - """Request body to authorize model copy. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AuthorizeCopyRequest, self).__init__(**kwargs) - self.model_id = kwargs['model_id'] - self.description = kwargs.get('description', None) - - -class AzureBlobContentSource(msrest.serialization.Model): - """Azure Blob Storage content. - - All required parameters must be populated in order to send to Azure. - - :param container_url: Required. Azure Blob Storage container URL. - :type container_url: str - :param prefix: Blob name prefix. - :type prefix: str - """ - - _validation = { - 'container_url': {'required': True}, - } - - _attribute_map = { - 'container_url': {'key': 'containerUrl', 'type': 'str'}, - 'prefix': {'key': 'prefix', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBlobContentSource, self).__init__(**kwargs) - self.container_url = kwargs['container_url'] - self.prefix = kwargs.get('prefix', None) - - -class BoundingRegion(msrest.serialization.Model): - """Bounding box on a specific page of the input. - - All required parameters must be populated in order to send to Azure. - - :param page_number: Required. 1-based page number of page containing the bounding region. - :type page_number: int - :param bounding_box: Required. Bounding box on the page, or the entire page if not specified. - :type bounding_box: list[float] - """ - - _validation = { - 'page_number': {'required': True, 'minimum': 1}, - 'bounding_box': {'required': True, 'max_items': 8, 'min_items': 8}, - } - - _attribute_map = { - 'page_number': {'key': 'pageNumber', 'type': 'int'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - } - - def __init__( - self, - **kwargs - ): - super(BoundingRegion, self).__init__(**kwargs) - self.page_number = kwargs['page_number'] - self.bounding_box = kwargs['bounding_box'] - - -class BuildDocumentModelRequest(msrest.serialization.Model): - """Request body to build a new custom model. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param azure_blob_source: Azure Blob Storage location containing the training data. - :type azure_blob_source: ~azure.ai.formrecognizer.v3_0_preview_1.models.AzureBlobContentSource - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'azure_blob_source': {'key': 'azureBlobSource', 'type': 'AzureBlobContentSource'}, - } - - def __init__( - self, - **kwargs - ): - super(BuildDocumentModelRequest, self).__init__(**kwargs) - self.model_id = kwargs['model_id'] - self.description = kwargs.get('description', None) - self.azure_blob_source = kwargs.get('azure_blob_source', None) - - -class ComponentModelInfo(msrest.serialization.Model): - """A component of a composed model. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - """ - - _validation = { - 'model_id': {'required': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ComponentModelInfo, self).__init__(**kwargs) - self.model_id = kwargs['model_id'] - - -class ComposeDocumentModelRequest(msrest.serialization.Model): - """Request body to create a composed model from component models. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param component_models: Required. List of component models to compose. - :type component_models: list[~azure.ai.formrecognizer.v3_0_preview_1.models.ComponentModelInfo] - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'component_models': {'required': True, 'unique': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'component_models': {'key': 'componentModels', 'type': '[ComponentModelInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ComposeDocumentModelRequest, self).__init__(**kwargs) - self.model_id = kwargs['model_id'] - self.description = kwargs.get('description', None) - self.component_models = kwargs['component_models'] - - -class CopyAuthorization(msrest.serialization.Model): - """Authorization to copy a model to the specified target resource and modelId. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_id: Required. ID of the target Azure resource where the model should be - copied to. - :type target_resource_id: str - :param target_resource_region: Required. Location of the target Azure resource where the model - should be copied to. - :type target_resource_region: str - :param target_model_id: Required. Identifier of the target model. - :type target_model_id: str - :param target_model_location: Required. URL of the copied model in the target account. - :type target_model_location: str - :param access_token: Required. Token used to authorize the request. - :type access_token: str - :param expiration_date_time: Required. Date/time when the access token expires. - :type expiration_date_time: ~datetime.datetime - """ - - _validation = { - 'target_resource_id': {'required': True}, - 'target_resource_region': {'required': True}, - 'target_model_id': {'required': True}, - 'target_model_location': {'required': True}, - 'access_token': {'required': True}, - 'expiration_date_time': {'required': True}, - } - - _attribute_map = { - 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, - 'target_resource_region': {'key': 'targetResourceRegion', 'type': 'str'}, - 'target_model_id': {'key': 'targetModelId', 'type': 'str'}, - 'target_model_location': {'key': 'targetModelLocation', 'type': 'str'}, - 'access_token': {'key': 'accessToken', 'type': 'str'}, - 'expiration_date_time': {'key': 'expirationDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(CopyAuthorization, self).__init__(**kwargs) - self.target_resource_id = kwargs['target_resource_id'] - self.target_resource_region = kwargs['target_resource_region'] - self.target_model_id = kwargs['target_model_id'] - self.target_model_location = kwargs['target_model_location'] - self.access_token = kwargs['access_token'] - self.expiration_date_time = kwargs['expiration_date_time'] - - -class CustomDocumentModelsInfo(msrest.serialization.Model): - """Info regarding custom document models. - - All required parameters must be populated in order to send to Azure. - - :param count: Required. Number of custom models in the current resource. - :type count: int - :param limit: Required. Maximum number of custom models supported in the current resource. - :type limit: int - """ - - _validation = { - 'count': {'required': True}, - 'limit': {'required': True}, - } - - _attribute_map = { - 'count': {'key': 'count', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomDocumentModelsInfo, self).__init__(**kwargs) - self.count = kwargs['count'] - self.limit = kwargs['limit'] - - -class DocTypeInfo(msrest.serialization.Model): - """DocTypeInfo. - - All required parameters must be populated in order to send to Azure. - - :param description: Model description. - :type description: str - :param field_schema: Required. Description of the document semantic schema using a JSON Schema - style syntax. - :type field_schema: dict[str, - ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldSchema] - :param field_confidence: Estimated confidence for each field. - :type field_confidence: dict[str, float] - """ - - _validation = { - 'description': {'max_length': 4096, 'min_length': 0}, - 'field_schema': {'required': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'field_schema': {'key': 'fieldSchema', 'type': '{DocumentFieldSchema}'}, - 'field_confidence': {'key': 'fieldConfidence', 'type': '{float}'}, - } - - def __init__( - self, - **kwargs - ): - super(DocTypeInfo, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.field_schema = kwargs['field_schema'] - self.field_confidence = kwargs.get('field_confidence', None) - - -class Document(msrest.serialization.Model): - """An object describing the location and semantic content of a document. - - All required parameters must be populated in order to send to Azure. - - :param doc_type: Required. Document type. - :type doc_type: str - :param bounding_regions: Bounding regions covering the document. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the document in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param fields: Required. Dictionary of named field values. - :type fields: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentField] - :param confidence: Required. Confidence of correctly extracting the document. - :type confidence: float - """ - - _validation = { - 'doc_type': {'required': True, 'max_length': 64, 'min_length': 2}, - 'spans': {'required': True}, - 'fields': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'doc_type': {'key': 'docType', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'fields': {'key': 'fields', 'type': '{DocumentField}'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(Document, self).__init__(**kwargs) - self.doc_type = kwargs['doc_type'] - self.bounding_regions = kwargs.get('bounding_regions', None) - self.spans = kwargs['spans'] - self.fields = kwargs['fields'] - self.confidence = kwargs['confidence'] - - -class DocumentEntity(msrest.serialization.Model): - """An object representing various categories of entities. - - All required parameters must be populated in order to send to Azure. - - :param category: Required. Entity type. - :type category: str - :param sub_category: Entity sub type. - :type sub_category: str - :param content: Required. Entity content. - :type content: str - :param bounding_regions: Bounding regions covering the entity. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the entity in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param confidence: Required. Confidence of correctly extracting the entity. - :type confidence: float - """ - - _validation = { - 'category': {'required': True}, - 'content': {'required': True}, - 'spans': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'sub_category': {'key': 'subCategory', 'type': 'str'}, - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentEntity, self).__init__(**kwargs) - self.category = kwargs['category'] - self.sub_category = kwargs.get('sub_category', None) - self.content = kwargs['content'] - self.bounding_regions = kwargs.get('bounding_regions', None) - self.spans = kwargs['spans'] - self.confidence = kwargs['confidence'] - - -class DocumentField(msrest.serialization.Model): - """An object representing the content and location of a field value. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Data type of the field value. Possible values include: "string", "date", - "time", "phoneNumber", "number", "integer", "selectionMark", "countryRegion", "currency", - "signature", "array", "object". - :type type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldType - :param value_string: String value. - :type value_string: str - :param value_date: Date value in YYYY-MM-DD format (ISO 8601). - :type value_date: ~datetime.date - :param value_time: Time value in hh:mm:ss format (ISO 8601). - :type value_time: ~datetime.time - :param value_phone_number: Phone number value in E.164 format (ex. +19876543210). - :type value_phone_number: str - :param value_number: Floating point value. - :type value_number: float - :param value_integer: Integer value. - :type value_integer: int - :param value_selection_mark: Selection mark value. Possible values include: "selected", - "unselected". - :type value_selection_mark: str or - ~azure.ai.formrecognizer.v3_0_preview_1.models.SelectionMarkState - :param value_signature: Presence of signature. Possible values include: "signed", "unsigned". - :type value_signature: str or - ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSignatureType - :param value_country_region: 3-letter country code value (ISO 3166-1 alpha-3). - :type value_country_region: str - :param value_currency: 3-letter currency code value (ISO 4217). - :type value_currency: str - :param value_array: Array of field values. - :type value_array: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentField] - :param value_object: Dictionary of named field values. - :type value_object: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentField] - :param content: Field content. - :type content: str - :param bounding_regions: Bounding regions covering the field. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Location of the field in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param confidence: Confidence of correctly extracting the field. - :type confidence: float - """ - - _validation = { - 'type': {'required': True}, - 'confidence': {'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value_string': {'key': 'valueString', 'type': 'str'}, - 'value_date': {'key': 'valueDate', 'type': 'date'}, - 'value_time': {'key': 'valueTime', 'type': 'time'}, - 'value_phone_number': {'key': 'valuePhoneNumber', 'type': 'str'}, - 'value_number': {'key': 'valueNumber', 'type': 'float'}, - 'value_integer': {'key': 'valueInteger', 'type': 'int'}, - 'value_selection_mark': {'key': 'valueSelectionMark', 'type': 'str'}, - 'value_signature': {'key': 'valueSignature', 'type': 'str'}, - 'value_country_region': {'key': 'valueCountryRegion', 'type': 'str'}, - 'value_currency': {'key': 'valueCurrency', 'type': 'str'}, - 'value_array': {'key': 'valueArray', 'type': '[DocumentField]'}, - 'value_object': {'key': 'valueObject', 'type': '{DocumentField}'}, - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentField, self).__init__(**kwargs) - self.type = kwargs['type'] - self.value_string = kwargs.get('value_string', None) - self.value_date = kwargs.get('value_date', None) - self.value_time = kwargs.get('value_time', None) - self.value_phone_number = kwargs.get('value_phone_number', None) - self.value_number = kwargs.get('value_number', None) - self.value_integer = kwargs.get('value_integer', None) - self.value_selection_mark = kwargs.get('value_selection_mark', None) - self.value_signature = kwargs.get('value_signature', None) - self.value_country_region = kwargs.get('value_country_region', None) - self.value_currency = kwargs.get('value_currency', None) - self.value_array = kwargs.get('value_array', None) - self.value_object = kwargs.get('value_object', None) - self.content = kwargs.get('content', None) - self.bounding_regions = kwargs.get('bounding_regions', None) - self.spans = kwargs.get('spans', None) - self.confidence = kwargs.get('confidence', None) - - -class DocumentFieldSchema(msrest.serialization.Model): - """Description of the field semantic schema using a JSON Schema style syntax. - - :param type: Semantic data type of the field value. Possible values include: "string", "date", - "time", "phoneNumber", "number", "integer", "selectionMark", "countryRegion", "currency", - "signature", "array", "object". - :type type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldType - :param description: Field description. - :type description: str - :param example: Example field content. - :type example: str - :param items: Field type schema of each array element. - :type items: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldSchema - :param properties: Named sub-fields of the object field. - :type properties: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldSchema] - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'example': {'key': 'example', 'type': 'str'}, - 'items': {'key': 'items', 'type': 'DocumentFieldSchema'}, - 'properties': {'key': 'properties', 'type': '{DocumentFieldSchema}'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentFieldSchema, self).__init__(**kwargs) - self.type = kwargs.get('type', None) - self.description = kwargs.get('description', None) - self.example = kwargs.get('example', None) - self.items = kwargs.get('items', None) - self.properties = kwargs.get('properties', None) - - -class DocumentKeyValueElement(msrest.serialization.Model): - """An object representing the field key or value in a key-value pair. - - All required parameters must be populated in order to send to Azure. - - :param content: Required. Concatenated content of the key-value element in reading order. - :type content: str - :param bounding_regions: Bounding regions covering the key-value element. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the key-value element in the reading order concatenated - content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'content': {'required': True}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentKeyValueElement, self).__init__(**kwargs) - self.content = kwargs['content'] - self.bounding_regions = kwargs.get('bounding_regions', None) - self.spans = kwargs['spans'] - - -class DocumentKeyValuePair(msrest.serialization.Model): - """An object representing a form field with distinct field label (key) and field value (may be empty). - - All required parameters must be populated in order to send to Azure. - - :param key: Required. Field label of the key-value pair. - :type key: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentKeyValueElement - :param value: Field value of the key-value pair. - :type value: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentKeyValueElement - :param confidence: Required. Confidence of correctly extracting the key-value pair. - :type confidence: float - """ - - _validation = { - 'key': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'key': {'key': 'key', 'type': 'DocumentKeyValueElement'}, - 'value': {'key': 'value', 'type': 'DocumentKeyValueElement'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentKeyValuePair, self).__init__(**kwargs) - self.key = kwargs['key'] - self.value = kwargs.get('value', None) - self.confidence = kwargs['confidence'] - - -class DocumentLine(msrest.serialization.Model): - """A content line object consisting of an adjacent sequence of content elements, such as words and selection marks. - - All required parameters must be populated in order to send to Azure. - - :param content: Required. Concatenated content of the contained elements in reading order. - :type content: str - :param bounding_box: Bounding box of the line. - :type bounding_box: list[float] - :param spans: Required. Location of the line in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'content': {'required': True}, - 'bounding_box': {'max_items': 8, 'min_items': 8}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentLine, self).__init__(**kwargs) - self.content = kwargs['content'] - self.bounding_box = kwargs.get('bounding_box', None) - self.spans = kwargs['spans'] - - -class DocumentPage(msrest.serialization.Model): - """Content and layout elements extracted from a page from the input. - - All required parameters must be populated in order to send to Azure. - - :param page_number: Required. 1-based page number in the input document. - :type page_number: int - :param angle: Required. The general orientation of the content in clockwise direction, measured - in degrees between (-180, 180]. - :type angle: float - :param width: Required. The width of the image/PDF in pixels/inches, respectively. - :type width: float - :param height: Required. The height of the image/PDF in pixels/inches, respectively. - :type height: float - :param unit: Required. The unit used by the width, height, and boundingBox properties. For - images, the unit is "pixel". For PDF, the unit is "inch". Possible values include: "pixel", - "inch". - :type unit: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.LengthUnit - :param spans: Required. Location of the page in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param words: Required. Extracted words from the page. - :type words: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentWord] - :param selection_marks: Extracted selection marks from the page. - :type selection_marks: - list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSelectionMark] - :param lines: Required. Extracted lines from the page, potentially containing both textual and - visual elements. - :type lines: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentLine] - """ - - _validation = { - 'page_number': {'required': True, 'minimum': 1}, - 'angle': {'required': True, 'maximum': 180, 'minimum_ex': -180}, - 'width': {'required': True, 'minimum': 0}, - 'height': {'required': True, 'minimum': 0}, - 'unit': {'required': True}, - 'spans': {'required': True}, - 'words': {'required': True}, - 'lines': {'required': True}, - } - - _attribute_map = { - 'page_number': {'key': 'pageNumber', 'type': 'int'}, - 'angle': {'key': 'angle', 'type': 'float'}, - 'width': {'key': 'width', 'type': 'float'}, - 'height': {'key': 'height', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'words': {'key': 'words', 'type': '[DocumentWord]'}, - 'selection_marks': {'key': 'selectionMarks', 'type': '[DocumentSelectionMark]'}, - 'lines': {'key': 'lines', 'type': '[DocumentLine]'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentPage, self).__init__(**kwargs) - self.page_number = kwargs['page_number'] - self.angle = kwargs['angle'] - self.width = kwargs['width'] - self.height = kwargs['height'] - self.unit = kwargs['unit'] - self.spans = kwargs['spans'] - self.words = kwargs['words'] - self.selection_marks = kwargs.get('selection_marks', None) - self.lines = kwargs['lines'] - - -class DocumentSelectionMark(msrest.serialization.Model): - """A selection mark object representing check boxes, radio buttons, and other elements indicating a selection. - - All required parameters must be populated in order to send to Azure. - - :param state: Required. State of the selection mark. Possible values include: "selected", - "unselected". - :type state: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.SelectionMarkState - :param bounding_box: Bounding box of the selection mark. - :type bounding_box: list[float] - :param span: Required. Location of the selection mark in the reading order concatenated - content. - :type span: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan - :param confidence: Required. Confidence of correctly extracting the selection mark. - :type confidence: float - """ - - _validation = { - 'state': {'required': True}, - 'bounding_box': {'max_items': 8, 'min_items': 8}, - 'span': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'span': {'key': 'span', 'type': 'DocumentSpan'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentSelectionMark, self).__init__(**kwargs) - self.state = kwargs['state'] - self.bounding_box = kwargs.get('bounding_box', None) - self.span = kwargs['span'] - self.confidence = kwargs['confidence'] - - -class DocumentSpan(msrest.serialization.Model): - """Contiguous region of the concatenated content property, specified as an offset and length. - - All required parameters must be populated in order to send to Azure. - - :param offset: Required. Zero-based index of the content represented by the span. - :type offset: int - :param length: Required. Number of characters in the content represented by the span. - :type length: int - """ - - _validation = { - 'offset': {'required': True, 'minimum': 0}, - 'length': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'offset': {'key': 'offset', 'type': 'int'}, - 'length': {'key': 'length', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentSpan, self).__init__(**kwargs) - self.offset = kwargs['offset'] - self.length = kwargs['length'] - - -class DocumentStyle(msrest.serialization.Model): - """An object representing observed text styles. - - All required parameters must be populated in order to send to Azure. - - :param is_handwritten: Is content handwritten?. - :type is_handwritten: bool - :param spans: Required. Location of the text elements in the concatenated content the style - applies to. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param confidence: Required. Confidence of correctly identifying the style. - :type confidence: float - """ - - _validation = { - 'spans': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'is_handwritten': {'key': 'isHandwritten', 'type': 'bool'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentStyle, self).__init__(**kwargs) - self.is_handwritten = kwargs.get('is_handwritten', None) - self.spans = kwargs['spans'] - self.confidence = kwargs['confidence'] - - -class DocumentTable(msrest.serialization.Model): - """A table object consisting table cells arranged in a rectangular layout. - - All required parameters must be populated in order to send to Azure. - - :param row_count: Required. Number of rows in the table. - :type row_count: int - :param column_count: Required. Number of columns in the table. - :type column_count: int - :param cells: Required. Cells contained within the table. - :type cells: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentTableCell] - :param bounding_regions: Bounding regions covering the table. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the table in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'row_count': {'required': True, 'minimum': 1}, - 'column_count': {'required': True, 'minimum': 1}, - 'cells': {'required': True}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'row_count': {'key': 'rowCount', 'type': 'int'}, - 'column_count': {'key': 'columnCount', 'type': 'int'}, - 'cells': {'key': 'cells', 'type': '[DocumentTableCell]'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentTable, self).__init__(**kwargs) - self.row_count = kwargs['row_count'] - self.column_count = kwargs['column_count'] - self.cells = kwargs['cells'] - self.bounding_regions = kwargs.get('bounding_regions', None) - self.spans = kwargs['spans'] - - -class DocumentTableCell(msrest.serialization.Model): - """An object representing the location and content of a table cell. - - All required parameters must be populated in order to send to Azure. - - :param kind: Table cell kind. Possible values include: "content", "rowHeader", "columnHeader", - "stubHead", "description". Default value: "content". - :type kind: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentTableCellKind - :param row_index: Required. Row index of the cell. - :type row_index: int - :param column_index: Required. Column index of the cell. - :type column_index: int - :param row_span: Number of rows spanned by this cell. - :type row_span: int - :param column_span: Number of columns spanned by this cell. - :type column_span: int - :param content: Required. Concatenated content of the table cell in reading order. - :type content: str - :param bounding_regions: Bounding regions covering the table cell. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the table cell in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'row_index': {'required': True}, - 'column_index': {'required': True}, - 'row_span': {'minimum': 1}, - 'column_span': {'minimum': 1}, - 'content': {'required': True}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'row_index': {'key': 'rowIndex', 'type': 'int'}, - 'column_index': {'key': 'columnIndex', 'type': 'int'}, - 'row_span': {'key': 'rowSpan', 'type': 'int'}, - 'column_span': {'key': 'columnSpan', 'type': 'int'}, - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentTableCell, self).__init__(**kwargs) - self.kind = kwargs.get('kind', "content") - self.row_index = kwargs['row_index'] - self.column_index = kwargs['column_index'] - self.row_span = kwargs.get('row_span', 1) - self.column_span = kwargs.get('column_span', 1) - self.content = kwargs['content'] - self.bounding_regions = kwargs.get('bounding_regions', None) - self.spans = kwargs['spans'] - - -class DocumentWord(msrest.serialization.Model): - """A word object consisting of a contiguous sequence of characters. For non-space delimited languages, such as Chinese, Japanese, and Korean, each character is represented as its own word. - - All required parameters must be populated in order to send to Azure. - - :param content: Required. Text content of the word. - :type content: str - :param bounding_box: Bounding box of the word. - :type bounding_box: list[float] - :param span: Required. Location of the word in the reading order concatenated content. - :type span: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan - :param confidence: Required. Confidence of correctly extracting the word. - :type confidence: float - """ - - _validation = { - 'content': {'required': True}, - 'bounding_box': {'max_items': 8, 'min_items': 8}, - 'span': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'span': {'key': 'span', 'type': 'DocumentSpan'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(DocumentWord, self).__init__(**kwargs) - self.content = kwargs['content'] - self.bounding_box = kwargs.get('bounding_box', None) - self.span = kwargs['span'] - self.confidence = kwargs['confidence'] - - -class Error(msrest.serialization.Model): - """Error info. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Error code. - :type code: str - :param message: Required. Error message. - :type message: str - :param target: Target of the error. - :type target: str - :param details: List of detailed errors. - :type details: list[~azure.ai.formrecognizer.v3_0_preview_1.models.Error] - :param innererror: Detailed error. - :type innererror: ~azure.ai.formrecognizer.v3_0_preview_1.models.InnerError - """ - - _validation = { - 'code': {'required': True}, - 'message': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[Error]'}, - 'innererror': {'key': 'innererror', 'type': 'InnerError'}, - } - - def __init__( - self, - **kwargs - ): - super(Error, self).__init__(**kwargs) - self.code = kwargs['code'] - self.message = kwargs['message'] - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - self.innererror = kwargs.get('innererror', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error response object. - - All required parameters must be populated in order to send to Azure. - - :param error: Required. Error info. - :type error: ~azure.ai.formrecognizer.v3_0_preview_1.models.Error - """ - - _validation = { - 'error': {'required': True}, - } - - _attribute_map = { - 'error': {'key': 'error', 'type': 'Error'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs['error'] - - -class GetInfoResponse(msrest.serialization.Model): - """General information regarding the current resource. - - All required parameters must be populated in order to send to Azure. - - :param custom_document_models: Required. Info regarding custom document models. - :type custom_document_models: - ~azure.ai.formrecognizer.v3_0_preview_1.models.CustomDocumentModelsInfo - """ - - _validation = { - 'custom_document_models': {'required': True}, - } - - _attribute_map = { - 'custom_document_models': {'key': 'customDocumentModels', 'type': 'CustomDocumentModelsInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(GetInfoResponse, self).__init__(**kwargs) - self.custom_document_models = kwargs['custom_document_models'] - - -class GetModelsResponse(msrest.serialization.Model): - """GetModelsResponse. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of models. - :type value: list[~azure.ai.formrecognizer.v3_0_preview_1.models.ModelSummary] - :param next_link: Link to the next page of models. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ModelSummary]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GetModelsResponse, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class OperationInfo(msrest.serialization.Model): - """Operation info. - - All required parameters must be populated in order to send to Azure. - - :param operation_id: Required. Operation ID. - :type operation_id: str - :param status: Required. Operation status. Possible values include: "notStarted", "running", - "failed", "succeeded", "canceled". - :type status: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationStatus - :param percent_completed: Operation progress (0-100). - :type percent_completed: int - :param created_date_time: Required. Date and time (UTC) when the operation was created. - :type created_date_time: ~datetime.datetime - :param last_updated_date_time: Required. Date and time (UTC) when the status was last updated. - :type last_updated_date_time: ~datetime.datetime - :param kind: Type of operation. Possible values include: "documentModelBuild", - "documentModelCompose", "documentModelCopyTo". - :type kind: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationKind - :param resource_location: Required. URL of the resource targeted by this operation. - :type resource_location: str - """ - - _validation = { - 'operation_id': {'required': True}, - 'status': {'required': True}, - 'percent_completed': {'maximum': 100, 'minimum': 0}, - 'created_date_time': {'required': True}, - 'last_updated_date_time': {'required': True}, - 'resource_location': {'required': True}, - } - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'percent_completed': {'key': 'percentCompleted', 'type': 'int'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInfo, self).__init__(**kwargs) - self.operation_id = kwargs['operation_id'] - self.status = kwargs['status'] - self.percent_completed = kwargs.get('percent_completed', None) - self.created_date_time = kwargs['created_date_time'] - self.last_updated_date_time = kwargs['last_updated_date_time'] - self.kind = kwargs.get('kind', None) - self.resource_location = kwargs['resource_location'] - - -class GetOperationResponse(OperationInfo): - """Get Operation response object. - - All required parameters must be populated in order to send to Azure. - - :param operation_id: Required. Operation ID. - :type operation_id: str - :param status: Required. Operation status. Possible values include: "notStarted", "running", - "failed", "succeeded", "canceled". - :type status: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationStatus - :param percent_completed: Operation progress (0-100). - :type percent_completed: int - :param created_date_time: Required. Date and time (UTC) when the operation was created. - :type created_date_time: ~datetime.datetime - :param last_updated_date_time: Required. Date and time (UTC) when the status was last updated. - :type last_updated_date_time: ~datetime.datetime - :param kind: Type of operation. Possible values include: "documentModelBuild", - "documentModelCompose", "documentModelCopyTo". - :type kind: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationKind - :param resource_location: Required. URL of the resource targeted by this operation. - :type resource_location: str - :param error: Encountered error. - :type error: ~azure.ai.formrecognizer.v3_0_preview_1.models.Error - :param result: Operation result upon success. - :type result: any - """ - - _validation = { - 'operation_id': {'required': True}, - 'status': {'required': True}, - 'percent_completed': {'maximum': 100, 'minimum': 0}, - 'created_date_time': {'required': True}, - 'last_updated_date_time': {'required': True}, - 'resource_location': {'required': True}, - } - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'percent_completed': {'key': 'percentCompleted', 'type': 'int'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'result': {'key': 'result', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(GetOperationResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - self.result = kwargs.get('result', None) - - -class GetOperationsResponse(msrest.serialization.Model): - """List Operations response object. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of operations. - :type value: list[~azure.ai.formrecognizer.v3_0_preview_1.models.OperationInfo] - :param next_link: Link to the next page of operations. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GetOperationsResponse, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class InnerError(msrest.serialization.Model): - """Detailed error. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Error code. - :type code: str - :param message: Error message. - :type message: str - :param innererror: Detailed error. - :type innererror: ~azure.ai.formrecognizer.v3_0_preview_1.models.InnerError - """ - - _validation = { - 'code': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'innererror': {'key': 'innererror', 'type': 'InnerError'}, - } - - def __init__( - self, - **kwargs - ): - super(InnerError, self).__init__(**kwargs) - self.code = kwargs['code'] - self.message = kwargs.get('message', None) - self.innererror = kwargs.get('innererror', None) - - -class ModelSummary(msrest.serialization.Model): - """Model summary. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param created_date_time: Required. Date and time (UTC) when the model was created. - :type created_date_time: ~datetime.datetime - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'created_date_time': {'required': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ModelSummary, self).__init__(**kwargs) - self.model_id = kwargs['model_id'] - self.description = kwargs.get('description', None) - self.created_date_time = kwargs['created_date_time'] - - -class ModelInfo(ModelSummary): - """Model info. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param created_date_time: Required. Date and time (UTC) when the model was created. - :type created_date_time: ~datetime.datetime - :param doc_types: Supported document types. - :type doc_types: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocTypeInfo] - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'created_date_time': {'required': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'doc_types': {'key': 'docTypes', 'type': '{DocTypeInfo}'}, - } - - def __init__( - self, - **kwargs - ): - super(ModelInfo, self).__init__(**kwargs) - self.doc_types = kwargs.get('doc_types', None) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_models_py3.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_models_py3.py deleted file mode 100644 index 7dbbe0b024a5..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/models/_models_py3.py +++ /dev/null @@ -1,1660 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- - -import datetime -from typing import Any, Dict, List, Optional, Union - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - -from ._form_recognizer_client_enums import * - - -class AnalyzeDocumentRequest(msrest.serialization.Model): - """Document analysis parameters. - - :param url_source: Document URL to analyze. - :type url_source: str - :param base64_source: Base64 encoding of the document to analyze. - :type base64_source: bytearray - """ - - _attribute_map = { - 'url_source': {'key': 'urlSource', 'type': 'str'}, - 'base64_source': {'key': 'base64Source', 'type': 'bytearray'}, - } - - def __init__( - self, - *, - url_source: Optional[str] = None, - base64_source: Optional[bytearray] = None, - **kwargs - ): - super(AnalyzeDocumentRequest, self).__init__(**kwargs) - self.url_source = url_source - self.base64_source = base64_source - - -class AnalyzeResult(msrest.serialization.Model): - """Document analysis result. - - All required parameters must be populated in order to send to Azure. - - :param api_version: Required. API version used to produce this result. Possible values include: - "2021-09-30-preview". - :type api_version: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.ApiVersion - :param model_id: Required. Model ID used to produce this result. - :type model_id: str - :param string_index_type: Required. Method used to compute string offset and length. Possible - values include: "textElements", "unicodeCodePoint", "utf16CodeUnit". - :type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType - :param content: Required. Concatenate string representation of all textual and visual elements - in reading order. - :type content: str - :param pages: Required. Analyzed pages. - :type pages: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentPage] - :param tables: Extracted tables. - :type tables: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentTable] - :param key_value_pairs: Extracted key-value pairs. - :type key_value_pairs: - list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentKeyValuePair] - :param entities: Extracted entities. - :type entities: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentEntity] - :param styles: Extracted font styles. - :type styles: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentStyle] - :param documents: Extracted documents. - :type documents: list[~azure.ai.formrecognizer.v3_0_preview_1.models.Document] - """ - - _validation = { - 'api_version': {'required': True}, - 'model_id': {'required': True}, - 'string_index_type': {'required': True}, - 'content': {'required': True}, - 'pages': {'required': True}, - } - - _attribute_map = { - 'api_version': {'key': 'apiVersion', 'type': 'str'}, - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'string_index_type': {'key': 'stringIndexType', 'type': 'str'}, - 'content': {'key': 'content', 'type': 'str'}, - 'pages': {'key': 'pages', 'type': '[DocumentPage]'}, - 'tables': {'key': 'tables', 'type': '[DocumentTable]'}, - 'key_value_pairs': {'key': 'keyValuePairs', 'type': '[DocumentKeyValuePair]'}, - 'entities': {'key': 'entities', 'type': '[DocumentEntity]'}, - 'styles': {'key': 'styles', 'type': '[DocumentStyle]'}, - 'documents': {'key': 'documents', 'type': '[Document]'}, - } - - def __init__( - self, - *, - api_version: Union[str, "ApiVersion"], - model_id: str, - string_index_type: Union[str, "StringIndexType"], - content: str, - pages: List["DocumentPage"], - tables: Optional[List["DocumentTable"]] = None, - key_value_pairs: Optional[List["DocumentKeyValuePair"]] = None, - entities: Optional[List["DocumentEntity"]] = None, - styles: Optional[List["DocumentStyle"]] = None, - documents: Optional[List["Document"]] = None, - **kwargs - ): - super(AnalyzeResult, self).__init__(**kwargs) - self.api_version = api_version - self.model_id = model_id - self.string_index_type = string_index_type - self.content = content - self.pages = pages - self.tables = tables - self.key_value_pairs = key_value_pairs - self.entities = entities - self.styles = styles - self.documents = documents - - -class AnalyzeResultOperation(msrest.serialization.Model): - """Status and result of the analyze operation. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. Operation status. Possible values include: "notStarted", "running", - "failed", "succeeded". - :type status: str or - ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResultOperationStatus - :param created_date_time: Required. Date and time (UTC) when the analyze operation was - submitted. - :type created_date_time: ~datetime.datetime - :param last_updated_date_time: Required. Date and time (UTC) when the status was last updated. - :type last_updated_date_time: ~datetime.datetime - :param error: Encountered error during document analysis. - :type error: ~azure.ai.formrecognizer.v3_0_preview_1.models.Error - :param analyze_result: Document analysis result. - :type analyze_result: ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResult - """ - - _validation = { - 'status': {'required': True}, - 'created_date_time': {'required': True}, - 'last_updated_date_time': {'required': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'analyze_result': {'key': 'analyzeResult', 'type': 'AnalyzeResult'}, - } - - def __init__( - self, - *, - status: Union[str, "AnalyzeResultOperationStatus"], - created_date_time: datetime.datetime, - last_updated_date_time: datetime.datetime, - error: Optional["Error"] = None, - analyze_result: Optional["AnalyzeResult"] = None, - **kwargs - ): - super(AnalyzeResultOperation, self).__init__(**kwargs) - self.status = status - self.created_date_time = created_date_time - self.last_updated_date_time = last_updated_date_time - self.error = error - self.analyze_result = analyze_result - - -class AuthorizeCopyRequest(msrest.serialization.Model): - """Request body to authorize model copy. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - *, - model_id: str, - description: Optional[str] = None, - **kwargs - ): - super(AuthorizeCopyRequest, self).__init__(**kwargs) - self.model_id = model_id - self.description = description - - -class AzureBlobContentSource(msrest.serialization.Model): - """Azure Blob Storage content. - - All required parameters must be populated in order to send to Azure. - - :param container_url: Required. Azure Blob Storage container URL. - :type container_url: str - :param prefix: Blob name prefix. - :type prefix: str - """ - - _validation = { - 'container_url': {'required': True}, - } - - _attribute_map = { - 'container_url': {'key': 'containerUrl', 'type': 'str'}, - 'prefix': {'key': 'prefix', 'type': 'str'}, - } - - def __init__( - self, - *, - container_url: str, - prefix: Optional[str] = None, - **kwargs - ): - super(AzureBlobContentSource, self).__init__(**kwargs) - self.container_url = container_url - self.prefix = prefix - - -class BoundingRegion(msrest.serialization.Model): - """Bounding box on a specific page of the input. - - All required parameters must be populated in order to send to Azure. - - :param page_number: Required. 1-based page number of page containing the bounding region. - :type page_number: int - :param bounding_box: Required. Bounding box on the page, or the entire page if not specified. - :type bounding_box: list[float] - """ - - _validation = { - 'page_number': {'required': True, 'minimum': 1}, - 'bounding_box': {'required': True, 'max_items': 8, 'min_items': 8}, - } - - _attribute_map = { - 'page_number': {'key': 'pageNumber', 'type': 'int'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - } - - def __init__( - self, - *, - page_number: int, - bounding_box: List[float], - **kwargs - ): - super(BoundingRegion, self).__init__(**kwargs) - self.page_number = page_number - self.bounding_box = bounding_box - - -class BuildDocumentModelRequest(msrest.serialization.Model): - """Request body to build a new custom model. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param azure_blob_source: Azure Blob Storage location containing the training data. - :type azure_blob_source: ~azure.ai.formrecognizer.v3_0_preview_1.models.AzureBlobContentSource - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'azure_blob_source': {'key': 'azureBlobSource', 'type': 'AzureBlobContentSource'}, - } - - def __init__( - self, - *, - model_id: str, - description: Optional[str] = None, - azure_blob_source: Optional["AzureBlobContentSource"] = None, - **kwargs - ): - super(BuildDocumentModelRequest, self).__init__(**kwargs) - self.model_id = model_id - self.description = description - self.azure_blob_source = azure_blob_source - - -class ComponentModelInfo(msrest.serialization.Model): - """A component of a composed model. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - """ - - _validation = { - 'model_id': {'required': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - } - - def __init__( - self, - *, - model_id: str, - **kwargs - ): - super(ComponentModelInfo, self).__init__(**kwargs) - self.model_id = model_id - - -class ComposeDocumentModelRequest(msrest.serialization.Model): - """Request body to create a composed model from component models. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param component_models: Required. List of component models to compose. - :type component_models: list[~azure.ai.formrecognizer.v3_0_preview_1.models.ComponentModelInfo] - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'component_models': {'required': True, 'unique': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'component_models': {'key': 'componentModels', 'type': '[ComponentModelInfo]'}, - } - - def __init__( - self, - *, - model_id: str, - component_models: List["ComponentModelInfo"], - description: Optional[str] = None, - **kwargs - ): - super(ComposeDocumentModelRequest, self).__init__(**kwargs) - self.model_id = model_id - self.description = description - self.component_models = component_models - - -class CopyAuthorization(msrest.serialization.Model): - """Authorization to copy a model to the specified target resource and modelId. - - All required parameters must be populated in order to send to Azure. - - :param target_resource_id: Required. ID of the target Azure resource where the model should be - copied to. - :type target_resource_id: str - :param target_resource_region: Required. Location of the target Azure resource where the model - should be copied to. - :type target_resource_region: str - :param target_model_id: Required. Identifier of the target model. - :type target_model_id: str - :param target_model_location: Required. URL of the copied model in the target account. - :type target_model_location: str - :param access_token: Required. Token used to authorize the request. - :type access_token: str - :param expiration_date_time: Required. Date/time when the access token expires. - :type expiration_date_time: ~datetime.datetime - """ - - _validation = { - 'target_resource_id': {'required': True}, - 'target_resource_region': {'required': True}, - 'target_model_id': {'required': True}, - 'target_model_location': {'required': True}, - 'access_token': {'required': True}, - 'expiration_date_time': {'required': True}, - } - - _attribute_map = { - 'target_resource_id': {'key': 'targetResourceId', 'type': 'str'}, - 'target_resource_region': {'key': 'targetResourceRegion', 'type': 'str'}, - 'target_model_id': {'key': 'targetModelId', 'type': 'str'}, - 'target_model_location': {'key': 'targetModelLocation', 'type': 'str'}, - 'access_token': {'key': 'accessToken', 'type': 'str'}, - 'expiration_date_time': {'key': 'expirationDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - target_resource_id: str, - target_resource_region: str, - target_model_id: str, - target_model_location: str, - access_token: str, - expiration_date_time: datetime.datetime, - **kwargs - ): - super(CopyAuthorization, self).__init__(**kwargs) - self.target_resource_id = target_resource_id - self.target_resource_region = target_resource_region - self.target_model_id = target_model_id - self.target_model_location = target_model_location - self.access_token = access_token - self.expiration_date_time = expiration_date_time - - -class CustomDocumentModelsInfo(msrest.serialization.Model): - """Info regarding custom document models. - - All required parameters must be populated in order to send to Azure. - - :param count: Required. Number of custom models in the current resource. - :type count: int - :param limit: Required. Maximum number of custom models supported in the current resource. - :type limit: int - """ - - _validation = { - 'count': {'required': True}, - 'limit': {'required': True}, - } - - _attribute_map = { - 'count': {'key': 'count', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - } - - def __init__( - self, - *, - count: int, - limit: int, - **kwargs - ): - super(CustomDocumentModelsInfo, self).__init__(**kwargs) - self.count = count - self.limit = limit - - -class DocTypeInfo(msrest.serialization.Model): - """DocTypeInfo. - - All required parameters must be populated in order to send to Azure. - - :param description: Model description. - :type description: str - :param field_schema: Required. Description of the document semantic schema using a JSON Schema - style syntax. - :type field_schema: dict[str, - ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldSchema] - :param field_confidence: Estimated confidence for each field. - :type field_confidence: dict[str, float] - """ - - _validation = { - 'description': {'max_length': 4096, 'min_length': 0}, - 'field_schema': {'required': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'field_schema': {'key': 'fieldSchema', 'type': '{DocumentFieldSchema}'}, - 'field_confidence': {'key': 'fieldConfidence', 'type': '{float}'}, - } - - def __init__( - self, - *, - field_schema: Dict[str, "DocumentFieldSchema"], - description: Optional[str] = None, - field_confidence: Optional[Dict[str, float]] = None, - **kwargs - ): - super(DocTypeInfo, self).__init__(**kwargs) - self.description = description - self.field_schema = field_schema - self.field_confidence = field_confidence - - -class Document(msrest.serialization.Model): - """An object describing the location and semantic content of a document. - - All required parameters must be populated in order to send to Azure. - - :param doc_type: Required. Document type. - :type doc_type: str - :param bounding_regions: Bounding regions covering the document. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the document in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param fields: Required. Dictionary of named field values. - :type fields: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentField] - :param confidence: Required. Confidence of correctly extracting the document. - :type confidence: float - """ - - _validation = { - 'doc_type': {'required': True, 'max_length': 64, 'min_length': 2}, - 'spans': {'required': True}, - 'fields': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'doc_type': {'key': 'docType', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'fields': {'key': 'fields', 'type': '{DocumentField}'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - *, - doc_type: str, - spans: List["DocumentSpan"], - fields: Dict[str, "DocumentField"], - confidence: float, - bounding_regions: Optional[List["BoundingRegion"]] = None, - **kwargs - ): - super(Document, self).__init__(**kwargs) - self.doc_type = doc_type - self.bounding_regions = bounding_regions - self.spans = spans - self.fields = fields - self.confidence = confidence - - -class DocumentEntity(msrest.serialization.Model): - """An object representing various categories of entities. - - All required parameters must be populated in order to send to Azure. - - :param category: Required. Entity type. - :type category: str - :param sub_category: Entity sub type. - :type sub_category: str - :param content: Required. Entity content. - :type content: str - :param bounding_regions: Bounding regions covering the entity. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the entity in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param confidence: Required. Confidence of correctly extracting the entity. - :type confidence: float - """ - - _validation = { - 'category': {'required': True}, - 'content': {'required': True}, - 'spans': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'category': {'key': 'category', 'type': 'str'}, - 'sub_category': {'key': 'subCategory', 'type': 'str'}, - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - *, - category: str, - content: str, - spans: List["DocumentSpan"], - confidence: float, - sub_category: Optional[str] = None, - bounding_regions: Optional[List["BoundingRegion"]] = None, - **kwargs - ): - super(DocumentEntity, self).__init__(**kwargs) - self.category = category - self.sub_category = sub_category - self.content = content - self.bounding_regions = bounding_regions - self.spans = spans - self.confidence = confidence - - -class DocumentField(msrest.serialization.Model): - """An object representing the content and location of a field value. - - All required parameters must be populated in order to send to Azure. - - :param type: Required. Data type of the field value. Possible values include: "string", "date", - "time", "phoneNumber", "number", "integer", "selectionMark", "countryRegion", "currency", - "signature", "array", "object". - :type type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldType - :param value_string: String value. - :type value_string: str - :param value_date: Date value in YYYY-MM-DD format (ISO 8601). - :type value_date: ~datetime.date - :param value_time: Time value in hh:mm:ss format (ISO 8601). - :type value_time: ~datetime.time - :param value_phone_number: Phone number value in E.164 format (ex. +19876543210). - :type value_phone_number: str - :param value_number: Floating point value. - :type value_number: float - :param value_integer: Integer value. - :type value_integer: int - :param value_selection_mark: Selection mark value. Possible values include: "selected", - "unselected". - :type value_selection_mark: str or - ~azure.ai.formrecognizer.v3_0_preview_1.models.SelectionMarkState - :param value_signature: Presence of signature. Possible values include: "signed", "unsigned". - :type value_signature: str or - ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSignatureType - :param value_country_region: 3-letter country code value (ISO 3166-1 alpha-3). - :type value_country_region: str - :param value_currency: 3-letter currency code value (ISO 4217). - :type value_currency: str - :param value_array: Array of field values. - :type value_array: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentField] - :param value_object: Dictionary of named field values. - :type value_object: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentField] - :param content: Field content. - :type content: str - :param bounding_regions: Bounding regions covering the field. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Location of the field in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param confidence: Confidence of correctly extracting the field. - :type confidence: float - """ - - _validation = { - 'type': {'required': True}, - 'confidence': {'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'value_string': {'key': 'valueString', 'type': 'str'}, - 'value_date': {'key': 'valueDate', 'type': 'date'}, - 'value_time': {'key': 'valueTime', 'type': 'time'}, - 'value_phone_number': {'key': 'valuePhoneNumber', 'type': 'str'}, - 'value_number': {'key': 'valueNumber', 'type': 'float'}, - 'value_integer': {'key': 'valueInteger', 'type': 'int'}, - 'value_selection_mark': {'key': 'valueSelectionMark', 'type': 'str'}, - 'value_signature': {'key': 'valueSignature', 'type': 'str'}, - 'value_country_region': {'key': 'valueCountryRegion', 'type': 'str'}, - 'value_currency': {'key': 'valueCurrency', 'type': 'str'}, - 'value_array': {'key': 'valueArray', 'type': '[DocumentField]'}, - 'value_object': {'key': 'valueObject', 'type': '{DocumentField}'}, - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - *, - type: Union[str, "DocumentFieldType"], - value_string: Optional[str] = None, - value_date: Optional[datetime.date] = None, - value_time: Optional[datetime.time] = None, - value_phone_number: Optional[str] = None, - value_number: Optional[float] = None, - value_integer: Optional[int] = None, - value_selection_mark: Optional[Union[str, "SelectionMarkState"]] = None, - value_signature: Optional[Union[str, "DocumentSignatureType"]] = None, - value_country_region: Optional[str] = None, - value_currency: Optional[str] = None, - value_array: Optional[List["DocumentField"]] = None, - value_object: Optional[Dict[str, "DocumentField"]] = None, - content: Optional[str] = None, - bounding_regions: Optional[List["BoundingRegion"]] = None, - spans: Optional[List["DocumentSpan"]] = None, - confidence: Optional[float] = None, - **kwargs - ): - super(DocumentField, self).__init__(**kwargs) - self.type = type - self.value_string = value_string - self.value_date = value_date - self.value_time = value_time - self.value_phone_number = value_phone_number - self.value_number = value_number - self.value_integer = value_integer - self.value_selection_mark = value_selection_mark - self.value_signature = value_signature - self.value_country_region = value_country_region - self.value_currency = value_currency - self.value_array = value_array - self.value_object = value_object - self.content = content - self.bounding_regions = bounding_regions - self.spans = spans - self.confidence = confidence - - -class DocumentFieldSchema(msrest.serialization.Model): - """Description of the field semantic schema using a JSON Schema style syntax. - - :param type: Semantic data type of the field value. Possible values include: "string", "date", - "time", "phoneNumber", "number", "integer", "selectionMark", "countryRegion", "currency", - "signature", "array", "object". - :type type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldType - :param description: Field description. - :type description: str - :param example: Example field content. - :type example: str - :param items: Field type schema of each array element. - :type items: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldSchema - :param properties: Named sub-fields of the object field. - :type properties: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentFieldSchema] - """ - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'example': {'key': 'example', 'type': 'str'}, - 'items': {'key': 'items', 'type': 'DocumentFieldSchema'}, - 'properties': {'key': 'properties', 'type': '{DocumentFieldSchema}'}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "DocumentFieldType"]] = None, - description: Optional[str] = None, - example: Optional[str] = None, - items: Optional["DocumentFieldSchema"] = None, - properties: Optional[Dict[str, "DocumentFieldSchema"]] = None, - **kwargs - ): - super(DocumentFieldSchema, self).__init__(**kwargs) - self.type = type - self.description = description - self.example = example - self.items = items - self.properties = properties - - -class DocumentKeyValueElement(msrest.serialization.Model): - """An object representing the field key or value in a key-value pair. - - All required parameters must be populated in order to send to Azure. - - :param content: Required. Concatenated content of the key-value element in reading order. - :type content: str - :param bounding_regions: Bounding regions covering the key-value element. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the key-value element in the reading order concatenated - content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'content': {'required': True}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - *, - content: str, - spans: List["DocumentSpan"], - bounding_regions: Optional[List["BoundingRegion"]] = None, - **kwargs - ): - super(DocumentKeyValueElement, self).__init__(**kwargs) - self.content = content - self.bounding_regions = bounding_regions - self.spans = spans - - -class DocumentKeyValuePair(msrest.serialization.Model): - """An object representing a form field with distinct field label (key) and field value (may be empty). - - All required parameters must be populated in order to send to Azure. - - :param key: Required. Field label of the key-value pair. - :type key: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentKeyValueElement - :param value: Field value of the key-value pair. - :type value: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentKeyValueElement - :param confidence: Required. Confidence of correctly extracting the key-value pair. - :type confidence: float - """ - - _validation = { - 'key': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'key': {'key': 'key', 'type': 'DocumentKeyValueElement'}, - 'value': {'key': 'value', 'type': 'DocumentKeyValueElement'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - *, - key: "DocumentKeyValueElement", - confidence: float, - value: Optional["DocumentKeyValueElement"] = None, - **kwargs - ): - super(DocumentKeyValuePair, self).__init__(**kwargs) - self.key = key - self.value = value - self.confidence = confidence - - -class DocumentLine(msrest.serialization.Model): - """A content line object consisting of an adjacent sequence of content elements, such as words and selection marks. - - All required parameters must be populated in order to send to Azure. - - :param content: Required. Concatenated content of the contained elements in reading order. - :type content: str - :param bounding_box: Bounding box of the line. - :type bounding_box: list[float] - :param spans: Required. Location of the line in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'content': {'required': True}, - 'bounding_box': {'max_items': 8, 'min_items': 8}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - *, - content: str, - spans: List["DocumentSpan"], - bounding_box: Optional[List[float]] = None, - **kwargs - ): - super(DocumentLine, self).__init__(**kwargs) - self.content = content - self.bounding_box = bounding_box - self.spans = spans - - -class DocumentPage(msrest.serialization.Model): - """Content and layout elements extracted from a page from the input. - - All required parameters must be populated in order to send to Azure. - - :param page_number: Required. 1-based page number in the input document. - :type page_number: int - :param angle: Required. The general orientation of the content in clockwise direction, measured - in degrees between (-180, 180]. - :type angle: float - :param width: Required. The width of the image/PDF in pixels/inches, respectively. - :type width: float - :param height: Required. The height of the image/PDF in pixels/inches, respectively. - :type height: float - :param unit: Required. The unit used by the width, height, and boundingBox properties. For - images, the unit is "pixel". For PDF, the unit is "inch". Possible values include: "pixel", - "inch". - :type unit: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.LengthUnit - :param spans: Required. Location of the page in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param words: Required. Extracted words from the page. - :type words: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentWord] - :param selection_marks: Extracted selection marks from the page. - :type selection_marks: - list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSelectionMark] - :param lines: Required. Extracted lines from the page, potentially containing both textual and - visual elements. - :type lines: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentLine] - """ - - _validation = { - 'page_number': {'required': True, 'minimum': 1}, - 'angle': {'required': True, 'maximum': 180, 'minimum_ex': -180}, - 'width': {'required': True, 'minimum': 0}, - 'height': {'required': True, 'minimum': 0}, - 'unit': {'required': True}, - 'spans': {'required': True}, - 'words': {'required': True}, - 'lines': {'required': True}, - } - - _attribute_map = { - 'page_number': {'key': 'pageNumber', 'type': 'int'}, - 'angle': {'key': 'angle', 'type': 'float'}, - 'width': {'key': 'width', 'type': 'float'}, - 'height': {'key': 'height', 'type': 'float'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'words': {'key': 'words', 'type': '[DocumentWord]'}, - 'selection_marks': {'key': 'selectionMarks', 'type': '[DocumentSelectionMark]'}, - 'lines': {'key': 'lines', 'type': '[DocumentLine]'}, - } - - def __init__( - self, - *, - page_number: int, - angle: float, - width: float, - height: float, - unit: Union[str, "LengthUnit"], - spans: List["DocumentSpan"], - words: List["DocumentWord"], - lines: List["DocumentLine"], - selection_marks: Optional[List["DocumentSelectionMark"]] = None, - **kwargs - ): - super(DocumentPage, self).__init__(**kwargs) - self.page_number = page_number - self.angle = angle - self.width = width - self.height = height - self.unit = unit - self.spans = spans - self.words = words - self.selection_marks = selection_marks - self.lines = lines - - -class DocumentSelectionMark(msrest.serialization.Model): - """A selection mark object representing check boxes, radio buttons, and other elements indicating a selection. - - All required parameters must be populated in order to send to Azure. - - :param state: Required. State of the selection mark. Possible values include: "selected", - "unselected". - :type state: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.SelectionMarkState - :param bounding_box: Bounding box of the selection mark. - :type bounding_box: list[float] - :param span: Required. Location of the selection mark in the reading order concatenated - content. - :type span: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan - :param confidence: Required. Confidence of correctly extracting the selection mark. - :type confidence: float - """ - - _validation = { - 'state': {'required': True}, - 'bounding_box': {'max_items': 8, 'min_items': 8}, - 'span': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'span': {'key': 'span', 'type': 'DocumentSpan'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - *, - state: Union[str, "SelectionMarkState"], - span: "DocumentSpan", - confidence: float, - bounding_box: Optional[List[float]] = None, - **kwargs - ): - super(DocumentSelectionMark, self).__init__(**kwargs) - self.state = state - self.bounding_box = bounding_box - self.span = span - self.confidence = confidence - - -class DocumentSpan(msrest.serialization.Model): - """Contiguous region of the concatenated content property, specified as an offset and length. - - All required parameters must be populated in order to send to Azure. - - :param offset: Required. Zero-based index of the content represented by the span. - :type offset: int - :param length: Required. Number of characters in the content represented by the span. - :type length: int - """ - - _validation = { - 'offset': {'required': True, 'minimum': 0}, - 'length': {'required': True, 'minimum': 0}, - } - - _attribute_map = { - 'offset': {'key': 'offset', 'type': 'int'}, - 'length': {'key': 'length', 'type': 'int'}, - } - - def __init__( - self, - *, - offset: int, - length: int, - **kwargs - ): - super(DocumentSpan, self).__init__(**kwargs) - self.offset = offset - self.length = length - - -class DocumentStyle(msrest.serialization.Model): - """An object representing observed text styles. - - All required parameters must be populated in order to send to Azure. - - :param is_handwritten: Is content handwritten?. - :type is_handwritten: bool - :param spans: Required. Location of the text elements in the concatenated content the style - applies to. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - :param confidence: Required. Confidence of correctly identifying the style. - :type confidence: float - """ - - _validation = { - 'spans': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'is_handwritten': {'key': 'isHandwritten', 'type': 'bool'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - *, - spans: List["DocumentSpan"], - confidence: float, - is_handwritten: Optional[bool] = None, - **kwargs - ): - super(DocumentStyle, self).__init__(**kwargs) - self.is_handwritten = is_handwritten - self.spans = spans - self.confidence = confidence - - -class DocumentTable(msrest.serialization.Model): - """A table object consisting table cells arranged in a rectangular layout. - - All required parameters must be populated in order to send to Azure. - - :param row_count: Required. Number of rows in the table. - :type row_count: int - :param column_count: Required. Number of columns in the table. - :type column_count: int - :param cells: Required. Cells contained within the table. - :type cells: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentTableCell] - :param bounding_regions: Bounding regions covering the table. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the table in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'row_count': {'required': True, 'minimum': 1}, - 'column_count': {'required': True, 'minimum': 1}, - 'cells': {'required': True}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'row_count': {'key': 'rowCount', 'type': 'int'}, - 'column_count': {'key': 'columnCount', 'type': 'int'}, - 'cells': {'key': 'cells', 'type': '[DocumentTableCell]'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - *, - row_count: int, - column_count: int, - cells: List["DocumentTableCell"], - spans: List["DocumentSpan"], - bounding_regions: Optional[List["BoundingRegion"]] = None, - **kwargs - ): - super(DocumentTable, self).__init__(**kwargs) - self.row_count = row_count - self.column_count = column_count - self.cells = cells - self.bounding_regions = bounding_regions - self.spans = spans - - -class DocumentTableCell(msrest.serialization.Model): - """An object representing the location and content of a table cell. - - All required parameters must be populated in order to send to Azure. - - :param kind: Table cell kind. Possible values include: "content", "rowHeader", "columnHeader", - "stubHead", "description". Default value: "content". - :type kind: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentTableCellKind - :param row_index: Required. Row index of the cell. - :type row_index: int - :param column_index: Required. Column index of the cell. - :type column_index: int - :param row_span: Number of rows spanned by this cell. - :type row_span: int - :param column_span: Number of columns spanned by this cell. - :type column_span: int - :param content: Required. Concatenated content of the table cell in reading order. - :type content: str - :param bounding_regions: Bounding regions covering the table cell. - :type bounding_regions: list[~azure.ai.formrecognizer.v3_0_preview_1.models.BoundingRegion] - :param spans: Required. Location of the table cell in the reading order concatenated content. - :type spans: list[~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan] - """ - - _validation = { - 'row_index': {'required': True}, - 'column_index': {'required': True}, - 'row_span': {'minimum': 1}, - 'column_span': {'minimum': 1}, - 'content': {'required': True}, - 'spans': {'required': True}, - } - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'row_index': {'key': 'rowIndex', 'type': 'int'}, - 'column_index': {'key': 'columnIndex', 'type': 'int'}, - 'row_span': {'key': 'rowSpan', 'type': 'int'}, - 'column_span': {'key': 'columnSpan', 'type': 'int'}, - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_regions': {'key': 'boundingRegions', 'type': '[BoundingRegion]'}, - 'spans': {'key': 'spans', 'type': '[DocumentSpan]'}, - } - - def __init__( - self, - *, - row_index: int, - column_index: int, - content: str, - spans: List["DocumentSpan"], - kind: Optional[Union[str, "DocumentTableCellKind"]] = "content", - row_span: Optional[int] = 1, - column_span: Optional[int] = 1, - bounding_regions: Optional[List["BoundingRegion"]] = None, - **kwargs - ): - super(DocumentTableCell, self).__init__(**kwargs) - self.kind = kind - self.row_index = row_index - self.column_index = column_index - self.row_span = row_span - self.column_span = column_span - self.content = content - self.bounding_regions = bounding_regions - self.spans = spans - - -class DocumentWord(msrest.serialization.Model): - """A word object consisting of a contiguous sequence of characters. For non-space delimited languages, such as Chinese, Japanese, and Korean, each character is represented as its own word. - - All required parameters must be populated in order to send to Azure. - - :param content: Required. Text content of the word. - :type content: str - :param bounding_box: Bounding box of the word. - :type bounding_box: list[float] - :param span: Required. Location of the word in the reading order concatenated content. - :type span: ~azure.ai.formrecognizer.v3_0_preview_1.models.DocumentSpan - :param confidence: Required. Confidence of correctly extracting the word. - :type confidence: float - """ - - _validation = { - 'content': {'required': True}, - 'bounding_box': {'max_items': 8, 'min_items': 8}, - 'span': {'required': True}, - 'confidence': {'required': True, 'maximum': 1, 'minimum': 0}, - } - - _attribute_map = { - 'content': {'key': 'content', 'type': 'str'}, - 'bounding_box': {'key': 'boundingBox', 'type': '[float]'}, - 'span': {'key': 'span', 'type': 'DocumentSpan'}, - 'confidence': {'key': 'confidence', 'type': 'float'}, - } - - def __init__( - self, - *, - content: str, - span: "DocumentSpan", - confidence: float, - bounding_box: Optional[List[float]] = None, - **kwargs - ): - super(DocumentWord, self).__init__(**kwargs) - self.content = content - self.bounding_box = bounding_box - self.span = span - self.confidence = confidence - - -class Error(msrest.serialization.Model): - """Error info. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Error code. - :type code: str - :param message: Required. Error message. - :type message: str - :param target: Target of the error. - :type target: str - :param details: List of detailed errors. - :type details: list[~azure.ai.formrecognizer.v3_0_preview_1.models.Error] - :param innererror: Detailed error. - :type innererror: ~azure.ai.formrecognizer.v3_0_preview_1.models.InnerError - """ - - _validation = { - 'code': {'required': True}, - 'message': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[Error]'}, - 'innererror': {'key': 'innererror', 'type': 'InnerError'}, - } - - def __init__( - self, - *, - code: str, - message: str, - target: Optional[str] = None, - details: Optional[List["Error"]] = None, - innererror: Optional["InnerError"] = None, - **kwargs - ): - super(Error, self).__init__(**kwargs) - self.code = code - self.message = message - self.target = target - self.details = details - self.innererror = innererror - - -class ErrorResponse(msrest.serialization.Model): - """Error response object. - - All required parameters must be populated in order to send to Azure. - - :param error: Required. Error info. - :type error: ~azure.ai.formrecognizer.v3_0_preview_1.models.Error - """ - - _validation = { - 'error': {'required': True}, - } - - _attribute_map = { - 'error': {'key': 'error', 'type': 'Error'}, - } - - def __init__( - self, - *, - error: "Error", - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = error - - -class GetInfoResponse(msrest.serialization.Model): - """General information regarding the current resource. - - All required parameters must be populated in order to send to Azure. - - :param custom_document_models: Required. Info regarding custom document models. - :type custom_document_models: - ~azure.ai.formrecognizer.v3_0_preview_1.models.CustomDocumentModelsInfo - """ - - _validation = { - 'custom_document_models': {'required': True}, - } - - _attribute_map = { - 'custom_document_models': {'key': 'customDocumentModels', 'type': 'CustomDocumentModelsInfo'}, - } - - def __init__( - self, - *, - custom_document_models: "CustomDocumentModelsInfo", - **kwargs - ): - super(GetInfoResponse, self).__init__(**kwargs) - self.custom_document_models = custom_document_models - - -class GetModelsResponse(msrest.serialization.Model): - """GetModelsResponse. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of models. - :type value: list[~azure.ai.formrecognizer.v3_0_preview_1.models.ModelSummary] - :param next_link: Link to the next page of models. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ModelSummary]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: List["ModelSummary"], - next_link: Optional[str] = None, - **kwargs - ): - super(GetModelsResponse, self).__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class OperationInfo(msrest.serialization.Model): - """Operation info. - - All required parameters must be populated in order to send to Azure. - - :param operation_id: Required. Operation ID. - :type operation_id: str - :param status: Required. Operation status. Possible values include: "notStarted", "running", - "failed", "succeeded", "canceled". - :type status: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationStatus - :param percent_completed: Operation progress (0-100). - :type percent_completed: int - :param created_date_time: Required. Date and time (UTC) when the operation was created. - :type created_date_time: ~datetime.datetime - :param last_updated_date_time: Required. Date and time (UTC) when the status was last updated. - :type last_updated_date_time: ~datetime.datetime - :param kind: Type of operation. Possible values include: "documentModelBuild", - "documentModelCompose", "documentModelCopyTo". - :type kind: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationKind - :param resource_location: Required. URL of the resource targeted by this operation. - :type resource_location: str - """ - - _validation = { - 'operation_id': {'required': True}, - 'status': {'required': True}, - 'percent_completed': {'maximum': 100, 'minimum': 0}, - 'created_date_time': {'required': True}, - 'last_updated_date_time': {'required': True}, - 'resource_location': {'required': True}, - } - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'percent_completed': {'key': 'percentCompleted', 'type': 'int'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - } - - def __init__( - self, - *, - operation_id: str, - status: Union[str, "OperationStatus"], - created_date_time: datetime.datetime, - last_updated_date_time: datetime.datetime, - resource_location: str, - percent_completed: Optional[int] = None, - kind: Optional[Union[str, "OperationKind"]] = None, - **kwargs - ): - super(OperationInfo, self).__init__(**kwargs) - self.operation_id = operation_id - self.status = status - self.percent_completed = percent_completed - self.created_date_time = created_date_time - self.last_updated_date_time = last_updated_date_time - self.kind = kind - self.resource_location = resource_location - - -class GetOperationResponse(OperationInfo): - """Get Operation response object. - - All required parameters must be populated in order to send to Azure. - - :param operation_id: Required. Operation ID. - :type operation_id: str - :param status: Required. Operation status. Possible values include: "notStarted", "running", - "failed", "succeeded", "canceled". - :type status: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationStatus - :param percent_completed: Operation progress (0-100). - :type percent_completed: int - :param created_date_time: Required. Date and time (UTC) when the operation was created. - :type created_date_time: ~datetime.datetime - :param last_updated_date_time: Required. Date and time (UTC) when the status was last updated. - :type last_updated_date_time: ~datetime.datetime - :param kind: Type of operation. Possible values include: "documentModelBuild", - "documentModelCompose", "documentModelCopyTo". - :type kind: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.OperationKind - :param resource_location: Required. URL of the resource targeted by this operation. - :type resource_location: str - :param error: Encountered error. - :type error: ~azure.ai.formrecognizer.v3_0_preview_1.models.Error - :param result: Operation result upon success. - :type result: any - """ - - _validation = { - 'operation_id': {'required': True}, - 'status': {'required': True}, - 'percent_completed': {'maximum': 100, 'minimum': 0}, - 'created_date_time': {'required': True}, - 'last_updated_date_time': {'required': True}, - 'resource_location': {'required': True}, - } - - _attribute_map = { - 'operation_id': {'key': 'operationId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'percent_completed': {'key': 'percentCompleted', 'type': 'int'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'resource_location': {'key': 'resourceLocation', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'Error'}, - 'result': {'key': 'result', 'type': 'object'}, - } - - def __init__( - self, - *, - operation_id: str, - status: Union[str, "OperationStatus"], - created_date_time: datetime.datetime, - last_updated_date_time: datetime.datetime, - resource_location: str, - percent_completed: Optional[int] = None, - kind: Optional[Union[str, "OperationKind"]] = None, - error: Optional["Error"] = None, - result: Optional[Any] = None, - **kwargs - ): - super(GetOperationResponse, self).__init__(operation_id=operation_id, status=status, percent_completed=percent_completed, created_date_time=created_date_time, last_updated_date_time=last_updated_date_time, kind=kind, resource_location=resource_location, **kwargs) - self.error = error - self.result = result - - -class GetOperationsResponse(msrest.serialization.Model): - """List Operations response object. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of operations. - :type value: list[~azure.ai.formrecognizer.v3_0_preview_1.models.OperationInfo] - :param next_link: Link to the next page of operations. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationInfo]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - *, - value: List["OperationInfo"], - next_link: Optional[str] = None, - **kwargs - ): - super(GetOperationsResponse, self).__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class InnerError(msrest.serialization.Model): - """Detailed error. - - All required parameters must be populated in order to send to Azure. - - :param code: Required. Error code. - :type code: str - :param message: Error message. - :type message: str - :param innererror: Detailed error. - :type innererror: ~azure.ai.formrecognizer.v3_0_preview_1.models.InnerError - """ - - _validation = { - 'code': {'required': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'innererror': {'key': 'innererror', 'type': 'InnerError'}, - } - - def __init__( - self, - *, - code: str, - message: Optional[str] = None, - innererror: Optional["InnerError"] = None, - **kwargs - ): - super(InnerError, self).__init__(**kwargs) - self.code = code - self.message = message - self.innererror = innererror - - -class ModelSummary(msrest.serialization.Model): - """Model summary. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param created_date_time: Required. Date and time (UTC) when the model was created. - :type created_date_time: ~datetime.datetime - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'created_date_time': {'required': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - *, - model_id: str, - created_date_time: datetime.datetime, - description: Optional[str] = None, - **kwargs - ): - super(ModelSummary, self).__init__(**kwargs) - self.model_id = model_id - self.description = description - self.created_date_time = created_date_time - - -class ModelInfo(ModelSummary): - """Model info. - - All required parameters must be populated in order to send to Azure. - - :param model_id: Required. Unique model name. - :type model_id: str - :param description: Model description. - :type description: str - :param created_date_time: Required. Date and time (UTC) when the model was created. - :type created_date_time: ~datetime.datetime - :param doc_types: Supported document types. - :type doc_types: dict[str, ~azure.ai.formrecognizer.v3_0_preview_1.models.DocTypeInfo] - """ - - _validation = { - 'model_id': {'required': True}, - 'description': {'max_length': 4096, 'min_length': 0}, - 'created_date_time': {'required': True}, - } - - _attribute_map = { - 'model_id': {'key': 'modelId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_date_time': {'key': 'createdDateTime', 'type': 'iso-8601'}, - 'doc_types': {'key': 'docTypes', 'type': '{DocTypeInfo}'}, - } - - def __init__( - self, - *, - model_id: str, - created_date_time: datetime.datetime, - description: Optional[str] = None, - doc_types: Optional[Dict[str, "DocTypeInfo"]] = None, - **kwargs - ): - super(ModelInfo, self).__init__(model_id=model_id, description=description, created_date_time=created_date_time, **kwargs) - self.doc_types = doc_types diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/operations/__init__.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/operations/__init__.py deleted file mode 100644 index f2f858714054..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/operations/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -# 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 ._form_recognizer_client_operations import FormRecognizerClientOperationsMixin - -__all__ = [ - 'FormRecognizerClientOperationsMixin', -] diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/operations/_form_recognizer_client_operations.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/operations/_form_recognizer_client_operations.py deleted file mode 100644 index 39752f891b1a..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/operations/_form_recognizer_client_operations.py +++ /dev/null @@ -1,1023 +0,0 @@ -# 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 typing import TYPE_CHECKING -import warnings - -from ...._polling import DocumentModelAdministrationLROPoller -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.polling.base_polling import LROBasePolling - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, IO, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class FormRecognizerClientOperationsMixin(object): - - def _analyze_document_initial( - self, - model_id, # type: str - pages=None, # type: Optional[List[str]] - locale=None, # type: Optional[str] - string_index_type=None, # type: Optional[Union[str, "_models.StringIndexType"]] - analyze_request=None, # type: Optional[Union[IO, "_models.AnalyzeDocumentRequest"]] - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._analyze_document_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if pages is not None: - query_parameters['pages'] = self._serialize.query("pages", pages, '[str]', div=',') - if locale is not None: - query_parameters['locale'] = self._serialize.query("locale", locale, 'str') - if string_index_type is not None: - query_parameters['stringIndexType'] = self._serialize.query("string_index_type", string_index_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - if header_parameters['Content-Type'].split(";")[0] in ['application/octet-stream', 'application/pdf', 'image/bmp', 'image/jpeg', 'image/png', 'image/tiff']: - body_content_kwargs['stream_content'] = analyze_request - elif header_parameters['Content-Type'].split(";")[0] in ['application/json']: - if analyze_request is not None: - body_content = self._serialize.body(analyze_request, 'AnalyzeDocumentRequest') - else: - body_content = None - body_content_kwargs['content'] = body_content - else: - raise ValueError( - "The content_type '{}' is not one of the allowed values: " - "['application/octet-stream', 'application/pdf', 'image/bmp', 'image/jpeg', 'image/png', 'image/tiff', 'application/json']".format(header_parameters['Content-Type']) - ) - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _analyze_document_initial.metadata = {'url': '/documentModels/{modelId}:analyze'} # type: ignore - - def begin_analyze_document( - self, - model_id, # type: str - pages=None, # type: Optional[List[str]] - locale=None, # type: Optional[str] - string_index_type=None, # type: Optional[Union[str, "_models.StringIndexType"]] - analyze_request=None, # type: Optional[Union[IO, "_models.AnalyzeDocumentRequest"]] - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] - """Analyze document. - - Analyzes document with model. - - :param model_id: Unique model name. - :type model_id: str - :param pages: List of 1-based page numbers to analyze. Ex. "1-3,5,7-9". - :type pages: list[str] - :param locale: Locale hint for text recognition and document analysis. Value may contain only - the language code (ex. "en", "fr") or BCP 47 language tag (ex. "en-US"). - :type locale: str - :param string_index_type: Method used to compute string offset and length. - :type string_index_type: str or ~azure.ai.formrecognizer.v3_0_preview_1.models.StringIndexType - :param analyze_request: Analyze request parameters. - :type analyze_request: IO or ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeDocumentRequest - :keyword str content_type: Media type of the body sent to the API. Default value is "application/json". - Allowed values are: "application/octet-stream", "application/pdf", "image/bmp", "image/jpeg", "image/png", "image/tiff", "application/json". - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._analyze_document_initial( - model_id=model_id, - pages=pages, - locale=locale, - string_index_type=string_index_type, - analyze_request=analyze_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - - if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_analyze_document.metadata = {'url': '/documentModels/{modelId}:analyze'} # type: ignore - - def get_analyze_document_result( - self, - model_id, # type: str - result_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AnalyzeResultOperation" - """Get analyze result. - - Gets the result of document analysis. - - :param model_id: Unique model name. - :type model_id: str - :param result_id: Analyze operation result ID. - :type result_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: AnalyzeResultOperation, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.AnalyzeResultOperation - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AnalyzeResultOperation"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_analyze_document_result.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - 'resultId': self._serialize.url("result_id", result_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('AnalyzeResultOperation', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_analyze_document_result.metadata = {'url': '/documentModels/{modelId}/analyzeResults/{resultId}'} # type: ignore - - def _build_document_model_initial( - self, - build_request, # type: "_models.BuildDocumentModelRequest" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._build_document_model_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(build_request, 'BuildDocumentModelRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _build_document_model_initial.metadata = {'url': '/documentModels:build'} # type: ignore - - def begin_build_document_model( - self, - build_request, # type: "_models.BuildDocumentModelRequest" - **kwargs # type: Any - ): - # type: (...) -> DocumentModelAdministrationLROPoller[None] - """Build model. - - Builds a custom document analysis model. - - :param build_request: Building request parameters. - :type build_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.BuildDocumentModelRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of DocumentModelAdministrationLROPoller that returns either None or the result of cls(response) - :rtype: ~...._polling.DocumentModelAdministrationLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._build_document_model_initial( - build_request=build_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return DocumentModelAdministrationLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return DocumentModelAdministrationLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_build_document_model.metadata = {'url': '/documentModels:build'} # type: ignore - - def _compose_document_model_initial( - self, - compose_request, # type: "_models.ComposeDocumentModelRequest" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._compose_document_model_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(compose_request, 'ComposeDocumentModelRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _compose_document_model_initial.metadata = {'url': '/documentModels:compose'} # type: ignore - - def begin_compose_document_model( - self, - compose_request, # type: "_models.ComposeDocumentModelRequest" - **kwargs # type: Any - ): - # type: (...) -> DocumentModelAdministrationLROPoller[None] - """Compose model. - - Creates a new model from document types of existing models. - - :param compose_request: - :type compose_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.ComposeDocumentModelRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of DocumentModelAdministrationLROPoller that returns either None or the result of cls(response) - :rtype: ~...._polling.DocumentModelAdministrationLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._compose_document_model_initial( - compose_request=compose_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - - if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return DocumentModelAdministrationLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return DocumentModelAdministrationLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_compose_document_model.metadata = {'url': '/documentModels:compose'} # type: ignore - - def authorize_copy_document_model( - self, - authorize_copy_request, # type: "_models.AuthorizeCopyRequest" - **kwargs # type: Any - ): - # type: (...) -> "_models.CopyAuthorization" - """Generate copy authorization. - - Generates authorization to copy a model to this location with specified modelId and optional - description. - - :param authorize_copy_request: - :type authorize_copy_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.AuthorizeCopyRequest - :keyword callable cls: A custom type or function that will be passed the direct response - :return: CopyAuthorization, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CopyAuthorization"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.authorize_copy_document_model.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(authorize_copy_request, 'AuthorizeCopyRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('CopyAuthorization', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - authorize_copy_document_model.metadata = {'url': '/documentModels:authorizeCopy'} # type: ignore - - def _copy_document_model_to_initial( - self, - model_id, # type: str - copy_to_request, # type: "_models.CopyAuthorization" - **kwargs # type: Any - ): - # type: (...) -> None - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._copy_document_model_to_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(copy_to_request, 'CopyAuthorization') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers['Operation-Location']=self._deserialize('str', response.headers.get('Operation-Location')) - - if cls: - return cls(pipeline_response, None, response_headers) - - _copy_document_model_to_initial.metadata = {'url': '/documentModels/{modelId}:copyTo'} # type: ignore - - def begin_copy_document_model_to( - self, - model_id, # type: str - copy_to_request, # type: "_models.CopyAuthorization" - **kwargs # type: Any - ): - # type: (...) -> DocumentModelAdministrationLROPoller[None] - """Copy model. - - Copies model to the target resource, region, and modelId. - - :param model_id: Unique model name. - :type model_id: str - :param copy_to_request: - :type copy_to_request: ~azure.ai.formrecognizer.v3_0_preview_1.models.CopyAuthorization - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be LROBasePolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of DocumentModelAdministrationLROPoller that returns either None or the result of cls(response) - :rtype: ~...._polling.DocumentModelAdministrationLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: - """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] - if cont_token is None: - raw_result = self._copy_document_model_to_initial( - model_id=model_id, - copy_to_request=copy_to_request, - cls=lambda x,y,z: x, - **kwargs - ) - - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - - if polling is True: polling_method = LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling - if cont_token: - return DocumentModelAdministrationLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - else: - return DocumentModelAdministrationLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_copy_document_model_to.metadata = {'url': '/documentModels/{modelId}:copyTo'} # type: ignore - - def get_operations( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GetOperationsResponse"] - """List operations. - - Lists all operations. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GetOperationsResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationsResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetOperationsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_operations.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('GetOperationsResponse', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_operations.metadata = {'url': '/operations'} # type: ignore - - def get_operation( - self, - operation_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GetOperationResponse" - """Get operation. - - Gets operation info. - - :param operation_id: Unique operation ID. - :type operation_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetOperationResponse, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetOperationResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetOperationResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_operation.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'operationId': self._serialize.url("operation_id", operation_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('GetOperationResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_operation.metadata = {'url': '/operations/{operationId}'} # type: ignore - - def get_models( - self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.GetModelsResponse"] - """List models. - - List all models. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GetModelsResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.formrecognizer.v3_0_preview_1.models.GetModelsResponse] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetModelsResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.get_models.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('GetModelsResponse', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - get_models.metadata = {'url': '/documentModels'} # type: ignore - - def get_model( - self, - model_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ModelInfo" - """Get model. - - Gets detailed model information. - - :param model_id: Unique model name. - :type model_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ModelInfo, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.ModelInfo - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ModelInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_model.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('ModelInfo', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_model.metadata = {'url': '/documentModels/{modelId}'} # type: ignore - - def delete_model( - self, - model_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete model. - - Deletes model. - - :param model_id: Unique model name. - :type model_id: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[None] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.delete_model.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - 'modelId': self._serialize.url("model_id", model_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) - - delete_model.metadata = {'url': '/documentModels/{modelId}'} # type: ignore - - def get_info( - self, - **kwargs # type: Any - ): - # type: (...) -> "_models.GetInfoResponse" - """Get info. - - Return basic info about the current resource. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GetInfoResponse, or the result of cls(response) - :rtype: ~azure.ai.formrecognizer.v3_0_preview_1.models.GetInfoResponse - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GetInfoResponse"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-30-preview" - accept = "application/json" - - # Construct URL - url = self.get_info.metadata['url'] # type: ignore - path_format_arguments = { - 'endpoint': self._serialize.url("self._config.endpoint", self._config.endpoint, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error) - - deserialized = self._deserialize('GetInfoResponse', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get_info.metadata = {'url': '/info'} # type: ignore diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/py.typed b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_generated/v3_0_preview_1/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/monitor/azure-monitor-query/samples/README.md b/sdk/monitor/azure-monitor-query/samples/README.md index 423fce93f453..6b514406aaf3 100644 --- a/sdk/monitor/azure-monitor-query/samples/README.md +++ b/sdk/monitor/azure-monitor-query/samples/README.md @@ -8,28 +8,30 @@ products: urlFragment: query-azuremonitor-samples --- -# Azure Monitor Query Client Library Python Samples +# Azure Monitor Query client library Python samples ## Samples -These code samples show common champion scenario operations with the Azure Monitor Query client library. -* Send a single query with LogsQueryClient and handle the response as a table: [sample_logs_single_query.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py) ([async_sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py)) +The following code samples show common scenarios with the Azure Monitor Query client library. -* Send a single query with LogsQueryClient and handle the response in key value form: [sample_logs_query_key_value_form.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py) +### Logs query samples -* Send a single query with LogsQueryClient without pandas: [sample_single_log_query_without_pandas.py.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py) +- [Send a single query with LogsQueryClient and handle the response as a table](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_single_query.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_log_query_async.py)) +- [Send a single query with LogsQueryClient and handle the response in key-value form](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_logs_query_key_value_form.py) +- [Send a single query with LogsQueryClient without pandas](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_single_log_query_without_pandas.py) +- [Send a single query with LogsQueryClient across multiple workspaces](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py) +- [Send multiple queries with LogsQueryClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py) +- [Send a single query with LogsQueryClient using server timeout](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py) -* Send a single query with LogsQueryClient across multiple workspaces: [sample_logs_query_multiple_workspaces.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_log_query_multiple_workspaces.py) +### Metrics query samples -* Send multiple queries with LogsQueryClient: [sample_batch_query.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_batch_query.py) +- [Send a query using MetricsQueryClient](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py)) +- [Get a list of metric namespaces](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py)) +- [Get a list of metric definitions](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py) ([async sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py)) -* Send a single query with LogsQueryClient using server timeout: [sample_server_timeout.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_server_timeout.py) +## _Disclaimer_ -* Send a query using MetricsQueryClient: [sample_metrics_query.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metrics_query.py) ([async_sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metrics_query_async.py)) - -* Get a list of metric namespaces: [sample_metric_namespaces.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_namespaces.py) ([async_sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_namespaces_async.py)) - -* Get a list of metric definitions: [sample_metric_definitions.py](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/sample_metric_definitions.py) ([async_sample](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/monitor/azure-monitor-query/samples/async_samples/sample_metric_definitions_async.py)) +_Azure SDK Python packages support for Python 2.7 is ending 01 January 2022. For more information and questions, refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_. ## Prerequisites @@ -40,32 +42,37 @@ These code samples show common champion scenario operations with the Azure Monit ## Setup -1. Install the latest beta version of Azure monitor query that the samples use: +1. Install the latest version of the Azure Monitor Query library: -```bash -pip install azure-monitor-query -``` + ```bash + pip install azure-monitor-query + ``` 2. Clone or download this sample repository. -3. Open the sample folder in Visual Studio Code or your IDE of choice. -4. To run most of this samples, you need azure-identity and pandas although they are optional can be replaced. +3. Open the *samples* folder in Visual Studio Code or your IDE of choice. +4. To run most of this samples, you need `azure-identity` and `pandas`. Although, those dependencies are optional and can be replaced. -```bash -pip install azure-identity pandas -``` + ```bash + pip install azure-identity pandas + ``` -5. Finally, to run the async samples, you would need an async http framework like aiohttp +5. To run the async samples, you need an asynchronous HTTP framework like `aiohttp`: -```bash -pip install aiohttp -``` + ```bash + pip install aiohttp + ``` -## Running the samples +## Run the samples 1. Open a terminal window and `cd` to the directory that the samples are saved in. 2. Set the environment variables specified in the sample file you wish to run. -3. Follow the usage described in the file, e.g. `python sample_logs_single_query.py` +3. Follow the usage described in the file. For example, `python sample_logs_single_query.py`. ## Next steps -To learn more about Azure Monitor, see the [Azure Monitor service documentation](https://docs.microsoft.com/azure/azure-monitor/). \ No newline at end of file +To learn more about Azure Monitor, see the [Azure Monitor service documentation](https://docs.microsoft.com/azure/azure-monitor/). + + + +[azure_monitor_create_using_portal]: https://docs.microsoft.com/azure/azure-monitor/logs/quick-create-workspace +[azure_subscription]: https://azure.microsoft.com/free/python/ diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md b/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md index 40839e33cad9..f362e9afa9d4 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/CHANGELOG.md @@ -1,10 +1,10 @@ # Release History -## 1.0.0b3 (Unreleased) +## 1.0.0b3 (2021-10-05) ### Features Added -- `auto_register_schemas` keyword argument has been added to `AvroSerializer`, which will allow for automatically registering schemas passed in to the `serialize`. +- `auto_register_schemas` keyword argument has been added to `AvroSerializer`, which will allow for automatically registering schemas passed in to the `serialize`, when set to `True`, otherwise `False` by default. - `value` parameter in `serialize` on `AvroSerializer` takes type `Mapping` rather than `Dict`. ### Breaking Changes diff --git a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md index 4b35666b43d8..f4d7942ef9ef 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md +++ b/sdk/schemaregistry/azure-schemaregistry-avroserializer/README.md @@ -27,25 +27,25 @@ To use this package, you must have: * Python 2.7, 3.6 or later - [Install Python][python] ### Authenticate the client -Interaction with Schema Registry Avro Serializer starts with an instance of SchemaRegistryAvroSerializer class. You need the endpoint, AAD credential and schema group name to instantiate the client object. +Interaction with Schema Registry Avro Serializer starts with an instance of AvroSerializer class. You need the endpoint, AAD credential and schema group name to instantiate the client object. **Create client using the azure-identity library:** ```python from azure.schemaregistry import SchemaRegistryClient -from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.schemaregistry.serializer.avroserializer import AvroSerializer from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() endpoint = '<< ENDPOINT OF THE SCHEMA REGISTRY >>' schema_group = '<< GROUP NAME OF THE SCHEMA >>' schema_registry_client = SchemaRegistryClient(endpoint, credential) -serializer = SchemaRegistryAvroSerializer(schema_registry_client, schema_group) +serializer = AvroSerializer(schema_registry_client, schema_group) ``` ## Key concepts -### SchemaRegistryAvroSerializer +### AvroSerializer Provides API to serialize to and deserialize from Avro Binary Encoding plus a header with schema ID. Uses [SchemaRegistryClient][schemaregistry_client] to get schema IDs from schema content or vice versa. @@ -85,21 +85,21 @@ The following sections provide several code snippets covering some of the most c ### Serialization -Use `SchemaRegistryAvroSerializer.serialize` method to serialize dict data with the given avro schema. +Use `AvroSerializer.serialize` method to serialize dict data with the given avro schema. The method would automatically register the schema to the Schema Registry Service and keep the schema cached for future serialization usage. ```python import os from azure.schemaregistry import SchemaRegistryClient -from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.schemaregistry.serializer.avroserializer import AvroSerializer from azure.identity import DefaultAzureCredential token_credential = DefaultAzureCredential() endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] -schema_group = "" +group_name = "" schema_registry_client = SchemaRegistryClient(endpoint, token_credential) -serializer = SchemaRegistryAvroSerializer(schema_registry_client, schema_group) +serializer = AvroSerializer(client=schema_registry_client, group_name=group_name) schema_string = """ {"namespace": "example.avro", @@ -114,26 +114,26 @@ schema_string = """ with serializer: dict_data = {"name": "Ben", "favorite_number": 7, "favorite_color": "red"} - encoded_bytes = serializer.serialize(dict_data, schema_string) + encoded_bytes = serializer.serialize(dict_data, schema=schema_string) ``` ### Deserialization -Use `SchemaRegistryAvroSerializer.deserialize` method to deserialize raw bytes into dict data. +Use `AvroSerializer.deserialize` method to deserialize raw bytes into dict data. The method would automatically retrieve the schema from the Schema Registry Service and keep the schema cached for future deserialization usage. ```python import os from azure.schemaregistry import SchemaRegistryClient -from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.schemaregistry.serializer.avroserializer import AvroSerializer from azure.identity import DefaultAzureCredential token_credential = DefaultAzureCredential() endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] -schema_group = "" +group_name = "" schema_registry_client = SchemaRegistryClient(endpoint, token_credential) -serializer = SchemaRegistryAvroSerializer(schema_registry_client, schema_group) +serializer = AvroSerializer(client=schema_registry_client, group_name=group_name) with serializer: encoded_bytes = b'' @@ -148,12 +148,12 @@ Integration with [Event Hubs][eventhubs_repo] to send serialized avro dict data import os from azure.eventhub import EventHubProducerClient, EventData from azure.schemaregistry import SchemaRegistryClient -from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.schemaregistry.serializer.avroserializer import AvroSerializer from azure.identity import DefaultAzureCredential token_credential = DefaultAzureCredential() endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] -schema_group = "" +group_name = "" eventhub_connection_str = os.environ['EVENT_HUB_CONN_STR'] eventhub_name = os.environ['EVENT_HUB_NAME'] @@ -169,7 +169,7 @@ schema_string = """ }""" schema_registry_client = SchemaRegistryClient(endpoint, token_credential) -avro_serializer = SchemaRegistryAvroSerializer(schema_registry_client, schema_group) +avro_serializer = AvroSerializer(client=schema_registry_client, group_name=group_name) eventhub_producer = EventHubProducerClient.from_connection_string( conn_str=eventhub_connection_str, @@ -179,7 +179,7 @@ eventhub_producer = EventHubProducerClient.from_connection_string( with eventhub_producer, avro_serializer: event_data_batch = eventhub_producer.create_batch() dict_data = {"name": "Bob", "favorite_number": 7, "favorite_color": "red"} - payload_bytes = avro_serializer.serialize(data=dict_data, schema=schema_string) + payload_bytes = avro_serializer.serialize(dict_data, schema=schema_string) event_data_batch.add(EventData(body=payload_bytes)) eventhub_producer.send_batch(event_data_batch) ``` @@ -192,17 +192,17 @@ Integration with [Event Hubs][eventhubs_repo] to receive `EventData` and deseria import os from azure.eventhub import EventHubConsumerClient from azure.schemaregistry import SchemaRegistryClient -from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.schemaregistry.serializer.avroserializer import AvroSerializer from azure.identity import DefaultAzureCredential token_credential = DefaultAzureCredential() endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] -schema_group = "" +group_name = "" eventhub_connection_str = os.environ['EVENT_HUB_CONN_STR'] eventhub_name = os.environ['EVENT_HUB_NAME'] schema_registry_client = SchemaRegistryClient(endpoint, token_credential) -avro_serializer = SchemaRegistryAvroSerializer(schema_registry_client, schema_group) +avro_serializer = AvroSerializer(client=schema_registry_client, group_name=group_name) eventhub_consumer = EventHubConsumerClient.from_connection_string( conn_str=eventhub_connection_str, @@ -236,7 +236,7 @@ headers, can be enabled on a client with the `logging_enable` argument: import sys import logging from azure.schemaregistry import SchemaRegistryClient -from azure.schemaregistry.serializer.avroserializer import SchemaRegistryAvroSerializer +from azure.schemaregistry.serializer.avroserializer import AvroSerializer from azure.identity import DefaultAzureCredential # Create a logger for the SDK @@ -250,13 +250,13 @@ logger.addHandler(handler) credential = DefaultAzureCredential() schema_registry_client = SchemaRegistryClient("", credential) # This client will log detailed information about its HTTP sessions, at DEBUG level -serializer = SchemaRegistryAvroSerializer(schema_registry_client, "", logging_enable=True) +serializer = AvroSerializer(client=schema_registry_client, group_name="", logging_enable=True) ``` Similarly, `logging_enable` can enable detailed logging for a single operation, even when it isn't enabled for the client: ```py -serializer.serialie(dict_data, schema_content, logging_enable=True) +serializer.serialize(dict_data, schema=schema_definition, logging_enable=True) ``` ## Next steps diff --git a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md index d6d2624e2d88..5a6b03b5612e 100644 --- a/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md +++ b/sdk/schemaregistry/azure-schemaregistry/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.0b3 (Unreleased) +## 1.0.0b3 (2021-10-05) ### Breaking Changes diff --git a/sdk/schemaregistry/azure-schemaregistry/README.md b/sdk/schemaregistry/azure-schemaregistry/README.md index b1042dd95fae..3369dc50d9a6 100644 --- a/sdk/schemaregistry/azure-schemaregistry/README.md +++ b/sdk/schemaregistry/azure-schemaregistry/README.md @@ -27,7 +27,7 @@ To use this package, you must have: * Python 2.7, 3.6 or later - [Install Python][python] ### Authenticate the client -Interaction with Schema Registry starts with an instance of SchemaRegistryClient class. You need the endpoint and AAD credential to instantiate the client object. +Interaction with Schema Registry starts with an instance of SchemaRegistryClient class. You need the fully qualified namespace and AAD credential to instantiate the client object. **Create client using the azure-identity library:** @@ -36,8 +36,9 @@ from azure.schemaregistry import SchemaRegistryClient from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() -endpoint = '<< ENDPOINT OF THE SCHEMA REGISTRY >>' -schema_registry_client = SchemaRegistryClient(endpoint, credential) +# Namespace should be similar to: '.servicebus.windows.net/' +fully_qualified_namespace = '<< FULLY QUALIFIED NAMESPACE OF THE SCHEMA REGISTRY >>' +schema_registry_client = SchemaRegistryClient(fully_qualified_namespace, credential) ``` ## Key concepts @@ -57,7 +58,6 @@ The following sections provide several code snippets covering some of the most c ### Register a schema Use `SchemaRegistryClient.register_schema` method to register a schema. -When registering a schema, the `Schema` and `SchemaProperties` will be cached in the `SchemaRegistryClient` instance, so that any subsequent calls to `get_schema_id` and `get_schema` corresponding to the same schema can use the cached value rather than going to the service. ```python import os @@ -66,11 +66,11 @@ from azure.identity import DefaultAzureCredential from azure.schemaregistry import SchemaRegistryClient token_credential = DefaultAzureCredential() -endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] -schema_group = "" -schema_name = "" -serialization_type = "Avro" -schema_content = """ +fully_qualified_namespace = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] +group_name = "" +name = "" +format = "Avro" +schema_definition = """ {"namespace": "example.avro", "type": "record", "name": "User", @@ -82,16 +82,15 @@ schema_content = """ } """ -schema_registry_client = SchemaRegistryClient(endpoint=endpoint, credential=token_credential) +schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=fully_qualified_namespace, credential=token_credential) with schema_registry_client: - schema_properties = schema_registry_client.register_schema(schema_group, schema_name, serialization_type, schema_content) - schema_id = schema_properties.schema_id + schema_properties = schema_registry_client.register_schema(group_name, name, schema_definition, format) + id = schema_properties.id ``` ### Get the schema by id Get the schema content and its properties by schema id. -When looking up the schema content by schema id, the `Schema` will be cached in the `SchemaRegistryClient` instance so that subsequent requests for this schema id do not need to go the service. ```python import os @@ -100,19 +99,18 @@ from azure.identity import DefaultAzureCredential from azure.schemaregistry import SchemaRegistryClient token_credential = DefaultAzureCredential() -endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] -schema_id = '' +fully_qualified_namespace = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] +id = '' -schema_registry_client = SchemaRegistryClient(endpoint=endpoint, credential=token_credential) +schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=fully_qualified_namespace, credential=token_credential) with schema_registry_client: - schema = schema_registry_client.get_schema(schema_id) - schema_content = schema.schema_content + schema = schema_registry_client.get_schema(id) + schema_definition = schema.schema_definition ``` ### Get the id of a schema Get the schema id of a schema by schema content and its properties. -When looking up the schema id, the `Schema` and `SchemaProperties` will be cached in the `SchemaRegistryClient` instance, so that subsequent requests for this schema do not need to go the service. ```python import os @@ -121,11 +119,11 @@ from azure.identity import DefaultAzureCredential from azure.schemaregistry import SchemaRegistryClient token_credential = DefaultAzureCredential() -endpoint = os.environ['SCHEMA_REGISTRY_ENDPOINT'] -schema_group = "" -schema_name = "" -serialization_type = "Avro" -schema_content = """ +fully_qualified_namespace = os.environ['SCHEMA_REGISTRY_FULLY_QUALIFIED_NAMESPACE'] +group_name = "" +name = "" +format = "Avro" +schema_definition = """ {"namespace": "example.avro", "type": "record", "name": "User", @@ -137,10 +135,10 @@ schema_content = """ } """ -schema_registry_client = SchemaRegistryClient(endpoint=endpoint, credential=token_credential) +schema_registry_client = SchemaRegistryClient(fully_qualified_namespace=fully_qualified_namespace, credential=token_credential) with schema_registry_client: - schema_properties = schema_registry_client.get_schema_id(schema_group, schema_name, serialization_type, schema_content) - schema_id = schema_properties.schema_id + schema_properties = schema_registry_client.register_schema(group_name, name, schema_definition, format) + id = schema_properties.id ``` ## Troubleshooting @@ -173,13 +171,13 @@ logger.addHandler(handler) credential = DefaultAzureCredential() # This client will log detailed information about its HTTP sessions, at DEBUG level -schema_registry_client = SchemaRegistryClient("you_end_point", credential, logging_enable=True) +schema_registry_client = SchemaRegistryClient("your_fully_qualified_namespace", credential, logging_enable=True) ``` Similarly, `logging_enable` can enable detailed logging for a single operation, even when it isn't enabled for the client: ```py -schema_registry_client.get_schema(schema_id, logging_enable=True) +schema_registry_client.get_schema(id, logging_enable=True) ``` ## Next steps diff --git a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py index 87531c43b14b..9aec37ca8954 100644 --- a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py +++ b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py @@ -6,6 +6,7 @@ import os import aiohttp +from urllib.parse import urljoin from ._policies import PerfTestProxyPolicy @@ -67,7 +68,7 @@ async def stop_playback(self): "x-recording-id": self._recording_id, "x-purge-inmemory-recording": "true" } - url = self.args.test_proxy + "/playback/stop" + url = urljoin(self.args.test_proxy, "/playback/stop") async with self._session.post(url, headers=headers) as resp: assert resp.status == 200 @@ -91,20 +92,20 @@ async def run_async(self): raise Exception("run_async must be implemented for {}".format(self.__class__.__name__)) async def _start_recording(self): - url = self.args.test_proxy + "/record/start" + url = urljoin(self.args.test_proxy, "/record/start") async with self._session.post(url) as resp: assert resp.status == 200 self._recording_id = resp.headers["x-recording-id"] async def _stop_recording(self): headers = {"x-recording-id": self._recording_id} - url = self.args.test_proxy + "/record/stop" + url = urljoin(self.args.test_proxy, "/record/stop") async with self._session.post(url, headers=headers) as resp: assert resp.status == 200 async def _start_playback(self): headers = {"x-recording-id": self._recording_id} - url = self.args.test_proxy + "/playback/start" + url = urljoin(self.args.test_proxy, "/playback/start") async with self._session.post(url, headers=headers) as resp: assert resp.status == 200 self._recording_id = resp.headers["x-recording-id"] diff --git a/tools/azure-sdk-tools/devtools_testutils/__init__.py b/tools/azure-sdk-tools/devtools_testutils/__init__.py index c58ea74788c2..b5303641ae36 100644 --- a/tools/azure-sdk-tools/devtools_testutils/__init__.py +++ b/tools/azure-sdk-tools/devtools_testutils/__init__.py @@ -1,5 +1,5 @@ from .mgmt_testcase import AzureMgmtTestCase, AzureMgmtPreparer -from .azure_recorded_testcase import add_sanitizer, AzureRecordedTestCase +from .azure_recorded_testcase import AzureRecordedTestCase from .azure_testcase import AzureTestCase, is_live, get_region_override from .resource_testcase import ( FakeResource, @@ -16,12 +16,30 @@ from .keyvault_preparer import KeyVaultPreparer from .powershell_preparer import PowerShellPreparer from .proxy_testcase import RecordedByProxy -from .enums import ProxyRecordingSanitizer +from .sanitizers import ( + add_body_key_sanitizer, + add_body_regex_sanitizer, + add_continuation_sanitizer, + add_general_regex_sanitizer, + add_header_regex_sanitizer, + add_oauth_response_sanitizer, + add_remove_header_sanitizer, + add_request_subscription_id_sanitizer, + add_uri_regex_sanitizer, +) from .helpers import ResponseCallback, RetryCounter from .fake_credential import FakeTokenCredential __all__ = [ - "add_sanitizer", + "add_body_key_sanitizer", + "add_body_regex_sanitizer", + "add_continuation_sanitizer", + "add_general_regex_sanitizer", + "add_header_regex_sanitizer", + "add_oauth_response_sanitizer", + "add_remove_header_sanitizer", + "add_request_subscription_id_sanitizer", + "add_uri_regex_sanitizer", "AzureMgmtTestCase", "AzureMgmtPreparer", "AzureRecordedTestCase", @@ -38,7 +56,6 @@ "RandomNameResourceGroupPreparer", "CachedResourceGroupPreparer", "PowerShellPreparer", - "ProxyRecordingSanitizer", "RecordedByProxy", "ResponseCallback", "RetryCounter", diff --git a/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py b/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py index 969d80fe57fe..c2a709d0dc91 100644 --- a/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py +++ b/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py @@ -7,7 +7,6 @@ import logging import os import os.path -import requests import six import sys import time @@ -21,8 +20,6 @@ from . import mgmt_settings_fake as fake_settings from .azure_testcase import _is_autorest_v3, get_resource_name, get_qualified_method_name -from .config import PROXY_URL -from .enums import ProxyRecordingSanitizer try: # Try to import the AsyncFakeCredential, if we cannot assume it is Python 2 @@ -37,38 +34,6 @@ load_dotenv(find_dotenv()) -def add_sanitizer(sanitizer, **kwargs): - # type: (ProxyRecordingSanitizer, **Any) -> None - """Registers a sanitizer, matcher, or transform with the test proxy. - - :param sanitizer: The name of the sanitizer, matcher, or transform you want to add. - :type sanitizer: ProxyRecordingSanitizer or str - - :keyword str value: The substitution value. - :keyword str regex: A regex for a sanitizer. Can be defined as a simple regex, or if a ``group_for_replace`` is - provided, a substitution operation. - :keyword str group_for_replace: The capture group that needs to be operated upon. Do not provide if you're invoking - a simple replacement operation. - """ - request_args = {} - request_args["value"] = kwargs.get("value") or "fakevalue" - request_args["regex"] = ( - kwargs.get("regex") or "(?<=\\/\\/)[a-z]+(?=(?:|-secondary)\\.(?:table|blob|queue)\\.core\\.windows\\.net)" - ) - request_args["group_for_replace"] = kwargs.get("group_for_replace") - - if sanitizer == ProxyRecordingSanitizer.URI: - requests.post( - "{}/Admin/AddSanitizer".format(PROXY_URL), - headers={"x-abstraction-identifier": ProxyRecordingSanitizer.URI.value}, - json={ - "regex": request_args["regex"], - "value": request_args["value"], - "groupForReplace": request_args["group_for_replace"], - }, - ) - - def is_live(): """A module version of is_live, that could be used in pytest marker.""" if not hasattr(is_live, "_cache"): diff --git a/tools/azure-sdk-tools/devtools_testutils/enums.py b/tools/azure-sdk-tools/devtools_testutils/enums.py deleted file mode 100644 index f1456dbc8a1f..000000000000 --- a/tools/azure-sdk-tools/devtools_testutils/enums.py +++ /dev/null @@ -1,11 +0,0 @@ -# ------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -# -------------------------------------------------------------------------- -from enum import Enum - -class ProxyRecordingSanitizer(str, Enum): - """General-purpose sanitizers for sanitizing test proxy recordings""" - - URI = "UriRegexSanitizer" diff --git a/tools/azure-sdk-tools/devtools_testutils/sanitizers.py b/tools/azure-sdk-tools/devtools_testutils/sanitizers.py new file mode 100644 index 000000000000..0922828fea31 --- /dev/null +++ b/tools/azure-sdk-tools/devtools_testutils/sanitizers.py @@ -0,0 +1,183 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import requests +from typing import TYPE_CHECKING + +from .config import PROXY_URL + +if TYPE_CHECKING: + from typing import Any, Dict + + +def add_body_key_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer that offers regex update of a specific JTokenPath within a returned body. + + For example, "TableName" within a json response body having its value replaced by whatever substitution is offered. + + :keyword str json_path: The SelectToken path (which could possibly match multiple entries) that will be used to + select JTokens for value replacement. + :keyword str value: The substitution value. + :keyword str regex: A regex. Can be defined as a simple regex replace OR if groupForReplace is set, a subsitution + operation. Defaults to replacing the entire string. + :keyword str group_for_replace: The capture group that needs to be operated upon. Do not provide if you're invoking + a simple replacement operation. + """ + + request_args = _get_request_args(**kwargs) + _send_request("BodyKeySanitizer", request_args) + + +def add_body_regex_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer that offers regex replace within a returned body. + + Specifically, this means regex applying to the raw JSON. If you are attempting to simply replace a specific key, the + BodyKeySanitizer is probably the way to go. + + :keyword str value: The substitution value. + :keyword str regex: A regex. Can be defined as a simple regex, or if a ``group_for_replace`` is provided, a + substitution operation. + :keyword str group_for_replace: The capture group that needs to be operated upon. Do not provide if you're invoking + a simple replacement operation. + """ + + request_args = _get_request_args(**kwargs) + _send_request("BodyRegexSanitizer", request_args) + + +def add_continuation_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer that's used to anonymize private keys in response/request pairs. + + For instance, a request hands back a "sessionId" that needs to be present in the next request. Supports "all further + requests get this key" as well as "single response/request pair". Defaults to maintaining same key for rest of + recording. + + :keyword str key: The name of the header whos value will be replaced from response -> next request. + :keyword str method: The method by which the value of the targeted key will be replaced. Defaults to guid + replacement. + :keyword str reset_after_first: Do we need multiple pairs replaced? Or do we want to replace each value with the + same value? + """ + + request_args = _get_request_args(**kwargs) + _send_request("ContinuationSanitizer", request_args) + + +def add_general_regex_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer that offers a general regex replace across request/response Body, Headers, and URI. + + For the body, this means regex applying to the raw JSON. + + :keyword str value: The substitution value. + :keyword str regex: A regex. Can be defined as a simple regex, or if a ``group_for_replace`` is provided, a + substitution operation. + :keyword str group_for_replace: The capture group that needs to be operated upon. Do not provide if you're invoking + a simple replacement operation. + """ + + request_args = _get_request_args(**kwargs) + _send_request("GeneralRegexSanitizer", request_args) + + +def add_header_regex_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer that offers regex replace on returned headers. + + Can be used for multiple purposes: 1) To replace a key with a specific value, do not set "regex" value. 2) To do a + simple regex replace operation, define arguments "key", "value", and "regex". 3) To do a targeted substitution of a + specific group, define all arguments "key", "value", and "regex". + + :keyword str key: The name of the header we're operating against. + :keyword str value: The substitution or whole new header value, depending on "regex" setting. + :keyword str regex: A regex. Can be defined as a simple regex, or if a ``group_for_replace`` is provided, a + substitution operation. + :keyword str group_for_replace: The capture group that needs to be operated upon. Do not provide if you're invoking + a simple replacement operation. + """ + + request_args = _get_request_args(**kwargs) + _send_request("HeaderRegexSanitizer", request_args) + + +def add_oauth_response_sanitizer(): + # type: () -> None + """Registers a sanitizer that cleans out all request/response pairs that match an oauth regex in their URI.""" + + _send_request("OAuthResponseSanitizer", {}) + + +def add_remove_header_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer that removes specified headers before saving a recording. + + :keyword str headers: A comma separated list. Should look like "Location, Transfer-Encoding" or something along + those lines. Don't worry about whitespace between the commas separating each key. They will be ignored. + """ + + request_args = _get_request_args(**kwargs) + _send_request("RemoveHeaderSanitizer", request_args) + + +def add_request_subscription_id_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer that replaces subscription IDs in requests. + + Subscription IDs are replaced with "00000000-0000-0000-0000-000000000000" by default. + + :keyword str value: The fake subscriptionId that will be placed where the real one is in the real request. + """ + + request_args = _get_request_args(**kwargs) + _send_request("ReplaceRequestSubscriptionId", request_args) + + +def add_uri_regex_sanitizer(**kwargs): + # type: (**Any) -> None + """Registers a sanitizer for cleaning URIs via regex. + + :keyword str value: The substitution value. + :keyword str regex: A regex. Can be defined as a simple regex, or if a ``group_for_replace`` is provided, a + substitution operation. + :keyword str group_for_replace: The capture group that needs to be operated upon. Do not provide if you're invoking + a simple replacement operation. + """ + + request_args = _get_request_args(**kwargs) + _send_request("UriRegexSanitizer", request_args) + + +def _get_request_args(**kwargs): + # type: (**Any) -> Dict + """Returns a dictionary of sanitizer constructor headers""" + + request_args = {} + request_args["groupForReplace"] = kwargs.get("group_for_replace") + request_args["headersForRemoval"] = kwargs.get("headers") + request_args["jsonPath"] = kwargs.get("json_path") + request_args["key"] = kwargs.get("key") + request_args["method"] = kwargs.get("method") + request_args["regex"] = kwargs.get("regex") + request_args["resetAfterFirst"] = kwargs.get("reset_after_first") + request_args["value"] = kwargs.get("value") + return request_args + + +def _send_request(sanitizer, parameters): + # type: (str, Dict) -> None + """Send a POST request to the test proxy endpoint to register the specified sanitizer. + + :param str sanitizer: The name of the sanitizer to add. + :param dict parameters: The sanitizer constructor parameters, as a dictionary. + """ + + requests.post( + "{}/Admin/AddSanitizer".format(PROXY_URL), + headers={"x-abstraction-identifier": sanitizer}, + json=parameters + ) diff --git a/tools/vcrpy/setup.py b/tools/vcrpy/setup.py index 67ba3899b550..a04a21b9a9f8 100644 --- a/tools/vcrpy/setup.py +++ b/tools/vcrpy/setup.py @@ -24,7 +24,7 @@ def run_tests(self): install_requires = [ "PyYAML", - "wrapt", + "wrapt<=1.12.1", "six>=1.5", 'contextlib2; python_version=="2.7"', 'mock; python_version=="2.7"',