diff --git a/sdk/textanalytics/ai-text-analytics/recordings/browsers/aad_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.json b/sdk/textanalytics/ai-text-analytics/recordings/browsers/aad_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.json new file mode 100644 index 000000000000..c1dea21a9c26 --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/browsers/aad_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.json @@ -0,0 +1,49 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token", + "query": {}, + "requestBody": "response_type=token&grant_type=client_credentials&client_id=azure_client_id&client_secret=e6tr%7E1TUr68KL37-09TCkkqa.40G73WOq%7E&scope=https%3A%2F%2Fsanitized%2F", + "status": 200, + "response": "{\"token_type\":\"Bearer\",\"expires_in\":86399,\"ext_expires_in\":86399,\"access_token\":\"access_token\"}", + "responseHeaders": { + "cache-control": "no-store, no-cache", + "content-length": "1331", + "content-type": "application/json; charset=utf-8", + "date": "Wed, 27 Oct 2021 02:56:30 GMT", + "expires": "-1", + "nel": "{\"report_to\":\"network-errors\",\"max_age\":86400,\"success_fraction\":0.001,\"failure_fraction\":1.0}", + "p3p": "CP=\"DSP CUR OTPi IND OTRi ONL FIN\"", + "pragma": "no-cache", + "referrer-policy": "strict-origin-when-cross-origin", + "report-to": "{\"group\":\"network-errors\",\"max_age\":86400,\"endpoints\":[{\"url\":\"https://identity.nel.measure.office.net/api/report?catId=GW+estsfd+est\"}]}", + "strict-transport-security": "max-age=31536000; includeSubDomains", + "x-content-type-options": "nosniff", + "x-ms-ests-server": "2.1.12171.14 - NCUS ProdSlices", + "x-ms-request-id": "67070905-de0c-4e4f-9158-b5e10db19a00" + } + }, + { + "method": "POST", + "url": "https://endpoint/text/analytics/v3.2-preview.2/analyze", + "query": {}, + "requestBody": "{\"analysisInput\":{\"documents\":[{\"id\":\"1\",\"text\":\"I will go to the park.\"}]},\"tasks\":{\"entityRecognitionPiiTasks\":[{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}},{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}}]}}", + "status": 400, + "response": "{\"error\":{\"code\":\"InvalidRequest\",\"message\":\"InvalidTask in AnalyzeInput\",\"innererror\":{\"code\":\"InvalidRequestBodyFormat\",\"message\":\"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name\"}}}", + "responseHeaders": { + "apim-request-id": "d2e142ab-d5e7-4b71-bad9-6403227d7d8f", + "content-type": "application/json; charset=utf-8", + "date": "Wed, 27 Oct 2021 02:56:30 GMT", + "strict-transport-security": "max-age=31536000; includeSubDomains; preload", + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "6" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "b622bb90bc1506f299109d6581856a55" +} \ No newline at end of file diff --git a/sdk/textanalytics/ai-text-analytics/recordings/browsers/apikey_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.json b/sdk/textanalytics/ai-text-analytics/recordings/browsers/apikey_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.json new file mode 100644 index 000000000000..59c644ff4d78 --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/browsers/apikey_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.json @@ -0,0 +1,25 @@ +{ + "recordings": [ + { + "method": "POST", + "url": "https://endpoint/text/analytics/v3.2-preview.2/analyze", + "query": {}, + "requestBody": "{\"analysisInput\":{\"documents\":[{\"id\":\"1\",\"text\":\"I will go to the park.\"}]},\"tasks\":{\"entityRecognitionPiiTasks\":[{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}},{\"parameters\":{\"model-version\":\"latest\",\"stringIndexType\":\"Utf16CodeUnit\"}}]}}", + "status": 400, + "response": "{\"error\":{\"code\":\"InvalidRequest\",\"message\":\"InvalidTask in AnalyzeInput\",\"innererror\":{\"code\":\"InvalidRequestBodyFormat\",\"message\":\"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name\"}}}", + "responseHeaders": { + "apim-request-id": "a690ef99-d493-4c60-bbe4-d709c2470e77", + "content-type": "application/json; charset=utf-8", + "date": "Wed, 27 Oct 2021 02:56:29 GMT", + "strict-transport-security": "max-age=31536000; includeSubDomains; preload", + "x-content-type-options": "nosniff", + "x-envoy-upstream-service-time": "5" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "b622bb90bc1506f299109d6581856a55" +} \ No newline at end of file diff --git a/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.js b/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.js new file mode 100644 index 000000000000..56cc6b879fd0 --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.js @@ -0,0 +1,130 @@ +let nock = require('nock'); + +module.exports.hash = "24c8a2a5a8e45f8e91b3a40ae590296d"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .get('/common/discovery/instance') + .query(true) + .reply(200, {"tenant_discovery_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}, [ + 'Cache-Control', + 'max-age=86400, private', + 'Content-Type', + 'application/json; charset=utf-8', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'Access-Control-Allow-Origin', + '*', + 'Access-Control-Allow-Methods', + 'GET, OPTIONS', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '820efad7-c6d0-4634-ad25-867df5015001', + 'x-ms-ests-server', + '2.1.12171.14 - WUS2 ProdSlices', + 'Set-Cookie', + 'fpc=AoqcdnNtUZJCofFWOReLxa4; expires=Fri, 26-Nov-2021 02:56:20 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrRL2j78nH6Zlme1h9iNfAaQYC_ygNCvSS1VtnPWtKd3VK2YskbPJ1ExY6C_bXj_SIi48lVyF1bh6meG9qRoEHShNOuAYhNzd247mOoh1CT_-6tTbw6JIQ1OMPWX8YLRBk3f0kDRM71BqQfaVLG_c_TWi34kj5pA2HNawvgRd12BsgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 02:56:19 GMT', + 'Content-Length', + '980' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .get('/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration') + .reply(200, {"token_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/kerberos","tenant_region_scope":"WW","cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}, [ + 'Cache-Control', + 'max-age=86400, private', + 'Content-Type', + 'application/json; charset=utf-8', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'Access-Control-Allow-Origin', + '*', + 'Access-Control-Allow-Methods', + 'GET, OPTIONS', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '412f489e-4103-4077-bbeb-9b489eb84f00', + 'x-ms-ests-server', + '2.1.12171.14 - EUS ProdSlices', + 'Set-Cookie', + 'fpc=AqMyUgOy8jJLlj-DWPWmulQ; expires=Fri, 26-Nov-2021 02:56:20 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevraJsuPFltdW-fkBD5egmNrbjGC47e3tWacuzu8HKVIDj6JWWVnWCewNUd5h2sVbSPrGZeTDWalUU_uyQQe9w_QY22nyVTT-rrDKtqqBF2olUr2VD5Io6-cwmggPNTZoK7sgA9095DfbGPSkODTS2zRPHvWW2Mf7TRE-Q1Wbm5W_EgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 02:56:19 GMT', + 'Content-Length', + '1753' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "client_id=azure_client_id&scope=https%3A%2F%2Fsanitized%2F&grant_type=client_credentials&x-client-SKU=msal.js.node&x-client-VER=1.3.2&x-client-OS=linux&x-client-CPU=x64&x-ms-lib-capability=retry-after, h429&x-client-current-telemetry=5|771,2,,,|,&x-client-last-telemetry=5|0|||0,0&client-request-id=9a532c22-ea25-430f-8629-7697781856c3&client_secret=azure_client_secret&claims=%7B%22access_token%22%3A%7B%22xms_cc%22%3A%7B%22values%22%3A%5B%22CP1%22%5D%7D%7D%7D") + .reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '6abbd419-15a4-439e-bfd3-2f9d10949f00', + 'x-ms-ests-server', + '2.1.12171.14 - WUS2 ProdSlices', + 'x-ms-clitelem', + '1,0,0,,', + 'Set-Cookie', + 'fpc=AuCKzs04wE9GkJRk1XhrKqZz_bg1AQAAANO2CtkOAAAA; expires=Fri, 26-Nov-2021 02:56:20 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 02:56:20 GMT', + 'Content-Length', + '1331' +]); + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}}]}}) + .reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/json; charset=utf-8', + 'x-envoy-upstream-service-time', + '5', + 'apim-request-id', + '2f65907e-9d9b-4112-ae2c-4a50f8237ecb', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains; preload', + 'x-content-type-options', + 'nosniff', + 'Date', + 'Wed, 27 Oct 2021 02:56:19 GMT' +]); diff --git a/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_multiple_actions_per_type_are_allowed.js b/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_multiple_actions_per_type_are_allowed.js new file mode 100644 index 000000000000..ce24d6e1a9a0 --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_multiple_actions_per_type_are_allowed.js @@ -0,0 +1,130 @@ +let nock = require('nock'); + +module.exports.hash = "6ff577dd9fdb3d9869fb300f0ecc6d42"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .get('/common/discovery/instance') + .query(true) + .reply(200, {"tenant_discovery_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}, [ + 'Cache-Control', + 'max-age=86400, private', + 'Content-Type', + 'application/json; charset=utf-8', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'Access-Control-Allow-Origin', + '*', + 'Access-Control-Allow-Methods', + 'GET, OPTIONS', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '358549b5-bf62-4540-8274-39a3292cfd00', + 'x-ms-ests-server', + '2.1.12158.6 - NCUS ProdSlices', + 'Set-Cookie', + 'fpc=AhFOVuRXFWNOgiVnKmSE7mo; expires=Fri, 26-Nov-2021 02:49:00 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrB0miYSWkR3HH4P15eMHaJwcFHUE-wRMl98Do3IjhnUeWb7mGtmSK80jJ5oQvelevnM9pVzP709ndRZ0-mmeu99LtkXXLuKa4qi_2lmcxenk1xakvqdPxKECaJY1Wl8Fjt69LF-5teDH_f08gFHPpqmHGcaZjo-zWxDHHs_5zXP8gAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 02:49:00 GMT', + 'Content-Length', + '980' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .get('/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration') + .reply(200, {"token_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/kerberos","tenant_region_scope":"WW","cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}, [ + 'Cache-Control', + 'max-age=86400, private', + 'Content-Type', + 'application/json; charset=utf-8', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'Access-Control-Allow-Origin', + '*', + 'Access-Control-Allow-Methods', + 'GET, OPTIONS', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'e35a5e16-42aa-4d26-8aa0-4ddbfa47ca00', + 'x-ms-ests-server', + '2.1.12171.14 - SCUS ProdSlices', + 'Set-Cookie', + 'fpc=Ar8TjVHJwuNIgDx_J3dskng; expires=Fri, 26-Nov-2021 02:49:00 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrKEBydCxkHMbscI261nMRDkUHgHVXLcTgXHBo19qRrDFvlpsn19vlHmqZSbn8GahVVxzguKc270rmm0OgKY1DSK0iP1jI8kDvrLHATPXeqAaOzk4NhNkFEa6nAdy4B9QfCrKFf0mhp_xJVpm9Zfo-9b5gtBN5BUhnHi_Y_zq0zpAgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 02:49:00 GMT', + 'Content-Length', + '1753' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "client_id=azure_client_id&scope=https%3A%2F%2Fsanitized%2F&grant_type=client_credentials&x-client-SKU=msal.js.node&x-client-VER=1.3.2&x-client-OS=linux&x-client-CPU=x64&x-ms-lib-capability=retry-after, h429&x-client-current-telemetry=5|771,2,,,|,&x-client-last-telemetry=5|0|||0,0&client-request-id=aba45ac6-7bc2-4d0a-8f9c-7d916342a66b&client_secret=azure_client_secret&claims=%7B%22access_token%22%3A%7B%22xms_cc%22%3A%7B%22values%22%3A%5B%22CP1%22%5D%7D%7D%7D") + .reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '6167ad4b-a5ca-4f45-853f-be7ceb79c300', + 'x-ms-ests-server', + '2.1.12171.14 - EUS ProdSlices', + 'x-ms-clitelem', + '1,0,0,,', + 'Set-Cookie', + 'fpc=Asr2JKDYPv1Mr1wZP6O4JkRz_bg1AQAAABy1CtkOAAAA; expires=Fri, 26-Nov-2021 02:49:00 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 02:49:00 GMT', + 'Content-Length', + '1331' +]); + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","stringIndexType":"TextElement_v8"}}]}}) + .reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/json; charset=utf-8', + 'x-envoy-upstream-service-time', + '7', + 'apim-request-id', + '787ba36a-6ca6-4ac3-8dca-1a8e5b4c3f48', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains; preload', + 'x-content-type-options', + 'nosniff', + 'Date', + 'Wed, 27 Oct 2021 02:49:00 GMT' +]); diff --git a/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_unique_multiple_actions_per_type_are_allowed.js b/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_unique_multiple_actions_per_type_are_allowed.js new file mode 100644 index 000000000000..5b733e86d249 --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/node/aad_textanalyticsclient_lros_analyze/recording_unique_multiple_actions_per_type_are_allowed.js @@ -0,0 +1,130 @@ +let nock = require('nock'); + +module.exports.hash = "b79ca2dc44c72b32e7a28d9f404d63dc"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .get('/common/discovery/instance') + .query(true) + .reply(200, {"tenant_discovery_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration","api-version":"1.1","metadata":[{"preferred_network":"login.microsoftonline.com","preferred_cache":"login.windows.net","aliases":["login.microsoftonline.com","login.windows.net","login.microsoft.com","sts.windows.net"]},{"preferred_network":"login.partner.microsoftonline.cn","preferred_cache":"login.partner.microsoftonline.cn","aliases":["login.partner.microsoftonline.cn","login.chinacloudapi.cn"]},{"preferred_network":"login.microsoftonline.de","preferred_cache":"login.microsoftonline.de","aliases":["login.microsoftonline.de"]},{"preferred_network":"login.microsoftonline.us","preferred_cache":"login.microsoftonline.us","aliases":["login.microsoftonline.us","login.usgovcloudapi.net"]},{"preferred_network":"login-us.microsoftonline.com","preferred_cache":"login-us.microsoftonline.com","aliases":["login-us.microsoftonline.com"]}]}, [ + 'Cache-Control', + 'max-age=86400, private', + 'Content-Type', + 'application/json; charset=utf-8', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'Access-Control-Allow-Origin', + '*', + 'Access-Control-Allow-Methods', + 'GET, OPTIONS', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '67296d04-a8ac-496a-9d02-40d02e73c601', + 'x-ms-ests-server', + '2.1.12158.6 - SCUS ProdSlices', + 'Set-Cookie', + 'fpc=Atx5kEDpJ2VFnbtcL7-fyOs; expires=Fri, 26-Nov-2021 03:00:15 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrOqQo6YCH6I5pvxgxfvTKfAZHxKdn3QeE8JHYgAuYMKRgxw_OzQO6jxrE6ZtfN6BK-dPuYeBXzTETC80CQyFKGRl38JGTtG0NVsc1arBccWEtaFTkiv4RPugpDG3RmxrGgvho9osAXQtbL9krh5gWwZbRHCFyK65GjbHsZpLmjgggAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 03:00:14 GMT', + 'Content-Length', + '980' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .get('/88888888-8888-8888-8888-888888888888/v2.0/.well-known/openid-configuration') + .reply(200, {"token_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt","client_secret_basic"],"jwks_uri":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/discovery/v2.0/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","id_token token"],"scopes_supported":["openid","profile","email","offline_access"],"issuer":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/v2.0","request_uri_parameter_supported":false,"userinfo_endpoint":"https://graph.microsoft.com/oidc/userinfo","authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/authorize","device_authorization_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/devicecode","http_logout_supported":true,"frontchannel_logout_supported":true,"end_session_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/oauth2/v2.0/logout","claims_supported":["sub","iss","cloud_instance_name","cloud_instance_host_name","cloud_graph_host_name","msgraph_host","aud","exp","iat","auth_time","acr","nonce","preferred_username","name","tid","ver","at_hash","c_hash","email"],"kerberos_endpoint":"https://login.microsoftonline.com/88888888-8888-8888-8888-888888888888/kerberos","tenant_region_scope":"WW","cloud_instance_name":"microsoftonline.com","cloud_graph_host_name":"graph.windows.net","msgraph_host":"graph.microsoft.com","rbac_url":"https://pas.windows.net"}, [ + 'Cache-Control', + 'max-age=86400, private', + 'Content-Type', + 'application/json; charset=utf-8', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'Access-Control-Allow-Origin', + '*', + 'Access-Control-Allow-Methods', + 'GET, OPTIONS', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + 'b3c5a7a8-a9fa-4221-b210-9e881679b400', + 'x-ms-ests-server', + '2.1.12171.14 - WUS2 ProdSlices', + 'Set-Cookie', + 'fpc=AqZZ6c4eQpJKumuQEw6mQdg; expires=Fri, 26-Nov-2021 03:00:15 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'esctx=AQABAAAAAAD--DLA3VO7QrddgJg7WevrTu8MvUu4HFMzek9x0O70qRoY1H8IiSIxKkI3eu8o7AubA69xZwTI3Dxem155o-MvjFY8laR1Z_eScOtp3GlfyBYhUEElwjgJP_2WqvbFkIBAD1hLp5UIPlqH1HPvGHCl95o-OCI-9VPEXbQKz9NzzEzjNXs2pMh8DTKFxMxvS1wgAA; domain=.login.microsoftonline.com; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 03:00:14 GMT', + 'Content-Length', + '1753' +]); + +nock('https://login.microsoftonline.com:443', {"encodedQueryParams":true}) + .post('/88888888-8888-8888-8888-888888888888/oauth2/v2.0/token', "client_id=azure_client_id&scope=https%3A%2F%2Fsanitized%2F&grant_type=client_credentials&x-client-SKU=msal.js.node&x-client-VER=1.3.2&x-client-OS=linux&x-client-CPU=x64&x-ms-lib-capability=retry-after, h429&x-client-current-telemetry=5|771,2,,,|,&x-client-last-telemetry=5|0|||0,0&client-request-id=483a8ff5-a1b2-47ad-b733-32fd0891e540&client_secret=azure_client_secret&claims=%7B%22access_token%22%3A%7B%22xms_cc%22%3A%7B%22values%22%3A%5B%22CP1%22%5D%7D%7D%7D") + .reply(200, {"token_type":"Bearer","expires_in":86399,"ext_expires_in":86399,"access_token":"access_token"}, [ + 'Cache-Control', + 'no-store, no-cache', + 'Pragma', + 'no-cache', + 'Content-Type', + 'application/json; charset=utf-8', + 'Expires', + '-1', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains', + 'X-Content-Type-Options', + 'nosniff', + 'P3P', + 'CP="DSP CUR OTPi IND OTRi ONL FIN"', + 'x-ms-request-id', + '9dceffc0-e933-4a73-b587-8267f3059000', + 'x-ms-ests-server', + '2.1.12171.14 - NCUS ProdSlices', + 'x-ms-clitelem', + '1,0,0,,', + 'Set-Cookie', + 'fpc=Avm5dl-K5-pIlL6YLmX1buJz_bg1AQAAAL63CtkOAAAA; expires=Fri, 26-Nov-2021 03:00:15 GMT; path=/; secure; HttpOnly; SameSite=None', + 'Set-Cookie', + 'x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly', + 'Set-Cookie', + 'stsservicecookie=estsfd; path=/; secure; samesite=none; httponly', + 'Date', + 'Wed, 27 Oct 2021 03:00:14 GMT', + 'Content-Length', + '1331' +]); + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","piiCategories":["USSocialSecurityNumber"],"stringIndexType":"TextElement_v8"}}]}}) + .reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/json; charset=utf-8', + 'x-envoy-upstream-service-time', + '5', + 'apim-request-id', + '0f59cbe0-d1fc-4303-ac16-9f2c327ea60e', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains; preload', + 'x-content-type-options', + 'nosniff', + 'Date', + 'Wed, 27 Oct 2021 03:00:15 GMT' +]); diff --git a/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.js b/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.js new file mode 100644 index 000000000000..f919e8e99b6f --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_duplicate_multiple_actions_per_type_are_disallowed.js @@ -0,0 +1,24 @@ +let nock = require('nock'); + +module.exports.hash = "24c8a2a5a8e45f8e91b3a40ae590296d"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}}]}}) + .reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/json; charset=utf-8', + 'x-envoy-upstream-service-time', + '5', + 'apim-request-id', + 'd6e53f6b-cecf-42b6-a06d-fb7e0a93d22f', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains; preload', + 'x-content-type-options', + 'nosniff', + 'Date', + 'Wed, 27 Oct 2021 02:56:18 GMT' +]); diff --git a/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_multiple_actions_per_type_are_allowed.js b/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_multiple_actions_per_type_are_allowed.js new file mode 100644 index 000000000000..08456a38d646 --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_multiple_actions_per_type_are_allowed.js @@ -0,0 +1,24 @@ +let nock = require('nock'); + +module.exports.hash = "6ff577dd9fdb3d9869fb300f0ecc6d42"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","stringIndexType":"TextElement_v8"}}]}}) + .reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/json; charset=utf-8', + 'x-envoy-upstream-service-time', + '5', + 'apim-request-id', + 'fda147dc-0498-4108-bec0-4cdc08a83644', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains; preload', + 'x-content-type-options', + 'nosniff', + 'Date', + 'Wed, 27 Oct 2021 02:48:59 GMT' +]); diff --git a/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_unique_multiple_actions_per_type_are_allowed.js b/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_unique_multiple_actions_per_type_are_allowed.js new file mode 100644 index 000000000000..0031fc368a64 --- /dev/null +++ b/sdk/textanalytics/ai-text-analytics/recordings/node/apikey_textanalyticsclient_lros_analyze/recording_unique_multiple_actions_per_type_are_allowed.js @@ -0,0 +1,24 @@ +let nock = require('nock'); + +module.exports.hash = "b79ca2dc44c72b32e7a28d9f404d63dc"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .post('/text/analytics/v3.2-preview.2/analyze', {"analysisInput":{"documents":[{"id":"1","text":"I will go to the park."}]},"tasks":{"entityRecognitionPiiTasks":[{"parameters":{"model-version":"latest","stringIndexType":"Utf16CodeUnit"}},{"parameters":{"model-version":"latest","piiCategories":["USSocialSecurityNumber"],"stringIndexType":"TextElement_v8"}}]}}) + .reply(400, {"error":{"code":"InvalidRequest","message":"InvalidTask in AnalyzeInput","innererror":{"code":"InvalidRequestBodyFormat","message":"Duplicate task name for task type PersonallyIdentifiableInformation. Make sure each task under a task type has a unique name"}}}, [ + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/json; charset=utf-8', + 'x-envoy-upstream-service-time', + '11', + 'apim-request-id', + '9a99fca7-7f1e-44bf-aeca-ec0efce33836', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains; preload', + 'x-content-type-options', + 'nosniff', + 'Date', + 'Wed, 27 Oct 2021 03:00:14 GMT' +]); diff --git a/sdk/textanalytics/ai-text-analytics/src/analyzeLro.ts b/sdk/textanalytics/ai-text-analytics/src/analyzeLro.ts index 7dd60f7aa0bf..816cd640c29f 100644 --- a/sdk/textanalytics/ai-text-analytics/src/analyzeLro.ts +++ b/sdk/textanalytics/ai-text-analytics/src/analyzeLro.ts @@ -12,7 +12,7 @@ import { TextDocumentInput } from "./generated"; import { createSpan } from "./tracing"; -import { getRawResponse, handleInvalidDocumentBatch, sendGetRequest } from "./util"; +import { compileError, getRawResponse, sendGetRequest } from "./util"; import * as Mappers from "./generated/models/mappers"; import { accept, @@ -150,7 +150,7 @@ export class AnalyzeLro implements LongRunningOperation 1) { - throw new Error( - `beginAnalyzeActions: Currently, the service can accept up to one action only for ${actionType} actions.` - ); - } - } - validateActionType(actions.analyzeSentimentActions, `analyzeSentiment`); - validateActionType(actions.extractKeyPhrasesActions, `extractKeyPhrases`); - validateActionType(actions.recognizeEntitiesActions, `recognizeEntities`); - validateActionType(actions.recognizeLinkedEntitiesActions, `recognizeLinkedEntities`); - validateActionType(actions.recognizePiiEntitiesActions, `recognizePiiEntities`); - validateActionType(actions.extractSummaryActions, `extractSummary`); -} - /** * @internal */ diff --git a/sdk/textanalytics/ai-text-analytics/src/util.ts b/sdk/textanalytics/ai-text-analytics/src/util.ts index ba3377e66db8..bea9ca83ecbb 100644 --- a/sdk/textanalytics/ai-text-analytics/src/util.ts +++ b/sdk/textanalytics/ai-text-analytics/src/util.ts @@ -5,7 +5,7 @@ import { RestError } from "@azure/core-rest-pipeline"; import { FullOperationResponse, OperationOptions, OperationSpec } from "@azure/core-client"; import { SpanStatusCode } from "@azure/core-tracing"; import { logger } from "./logger"; -import { GeneratedClient, StringIndexType as GeneratedStringIndexType } from "./generated"; +import { ErrorResponse, GeneratedClient, InnerError, StringIndexType as GeneratedStringIndexType, TextAnalyticsError } from "./generated"; import { TextAnalyticsAction } from "./textAnalyticsAction"; import { createSpan } from "./tracing"; import { LroResponse } from "@azure/core-lro"; @@ -199,38 +199,29 @@ export function getOperationId(operationLocation: string): string { * InvalidDocumentBatch, it exposes that as the statusCode instead. * @param error - the incoming error */ -export function handleInvalidDocumentBatch(error: unknown): any { - const castError = error as { +export function compileError(errorResponse: unknown): any { + const castErrorResponse = (errorResponse as { response: { - parsedBody?: { - error?: { - innererror?: { - code: string; - message: string; - }; - }; - }; + parsedBody?: ErrorResponse }; statusCode: number; - }; - const innerCode = castError.response?.parsedBody?.error?.innererror?.code; - const innerMessage = castError.response?.parsedBody?.error?.innererror?.message; - if (innerMessage) { - return innerCode === "InvalidDocumentBatch" - ? new RestError(innerMessage, { code: innerCode, statusCode: castError.statusCode }) - : error; - } else { - // unfortunately, the service currently does not follow the swagger definition - // for errors in some cases. - // Issue: https://msazure.visualstudio.com/Cognitive%20Services/_workitems/edit/8775003/?workitem=8972164 - // throw new Error( - // `The error coming from the service does not follow the expected structure: ${error}` - // ); - logger.warning( - `The error coming from the service does not follow the expected structure: ${error}` - ); - return error; + }) + const topLevelError = castErrorResponse.response.parsedBody?.error; + if (!topLevelError) return errorResponse; + let errorMessage = topLevelError.message || ""; + let invalidDocumentBatchCode = false; + function unwrap(error: TextAnalyticsError | InnerError): TextAnalyticsError { + if (error?.innererror !== undefined && error.innererror.message !== undefined) { + if (error.innererror.code === "InvalidDocumentBatch") { + invalidDocumentBatchCode = true; + } + errorMessage = errorMessage + ". " + error.innererror.message; + return unwrap(error.innererror); + } + return error as TextAnalyticsError; } + unwrap(topLevelError); + return new RestError(errorMessage, { code: invalidDocumentBatchCode ? "InvalidDocumentBatch" : topLevelError.code, statusCode: castErrorResponse.statusCode }); } /** diff --git a/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts b/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts index ac97a00537d6..8d05647d77aa 100644 --- a/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts +++ b/sdk/textanalytics/ai-text-analytics/test/public/textAnalyticsClient.spec.ts @@ -2222,30 +2222,46 @@ matrix([["APIKey", "AAD"]] as const, async (authMethod: AuthMethod) => { } }); - it("multiple actions per type are disallowed", async function() { + it("duplicate multiple actions per type are disallowed", async function() { const docs = [{ id: "1", text: "I will go to the park." }]; try { - await client.beginAnalyzeActions( + const response = await client.beginAnalyzeActions( docs, { recognizePiiEntitiesActions: [ { modelVersion: "latest" }, - { modelVersion: "latest", stringIndexType: "TextElement_v8" } + { modelVersion: "latest" } ] }, { updateIntervalInMs: pollingInterval } ); - throw new Error("Expected an error to occur"); + assert.fail(`expected a failure but received the following intead: ${JSON.stringify(response, null, 2)}`) } catch (e) { - assert.equal( - e.message, - "beginAnalyzeActions: Currently, the service can accept up to one action only for recognizePiiEntities actions." - ); + assert.equal(e.code, "InvalidRequest"); + assert.include(e.message, "Duplicate task name"); } }); + + it.skip("unique multiple actions per type are allowed", async function() { + const docs = [{ id: "1", text: "I will go to the park." }]; + + const response = await client.beginAnalyzeActions( + docs, + { + recognizePiiEntitiesActions: [ + { modelVersion: "latest", actionName: "action1" }, + { modelVersion: "latest", stringIndexType: "TextElement_v8", categoriesFilter: ["USSocialSecurityNumber"], actionName: "action2" } + ] + }, + { + updateIntervalInMs: pollingInterval + } + ); + assert.isDefined(response); + }); }); describe("#health", function() {